I wanted to split a column in R into two new columns. I came across the following code on the internet which worked quite well:
as.numeric(lapply(strsplit(data$Coord, split=","), "[", 1))
My question is, how exactly does this work, in particular the latter part of the function where we have the "[" and the 1. Would someone be able to explain to me what lapply is doing here exactly, would really like to understand.
The above result gives back the first portion of the split before the comma in the data$Coord vector.
Thanks