I've got a section of code, let's assume it's
x <- c("10/05/1997 00:00:00", "11/05/1997 00:00:00", "12/05/1997 00:00:00")
x <- strsplit(as.character(x), " ", fixed=TRUE)[1]
The issue I'm running into is this: I want to take the first index of the split string ("10/05/1997") while discarding the second index of the split string ("00:00:00"). However, rather than indexing through the split string, I'm currently telling R to only perform this operation on the first index of x. I would have thought in order to only perform this on the first index of x, my code would have to look like this:
x <- strsplit(as.character(x)[1], " ", fixed=TRUE)[1]
Is there a way to pull just the first element of the split string for each index in the vector?
Thanks for the help, all. I'm very much an R newbie. I couldn't find any similar issues.