Consider the following exerpt from a list called matches:
[[9997]]
[1] "20070125" "11"
[[9998]]
[1] "20070129" "01"
[[9999]]
[1] "20070129" "02"
[[10000]]
[1] "20070129" "03"
The class
of this list is obviously list
. I know that strsplit
requires a vector input.
I want to use strsplit
to try to get only the date, not the second number.
strsplit(as.character(matches)," ")[10000]
This returns:
[[1]]
[1] "c(\"20070129\"," "\"03\")"
Instead of
[[1]]
[1] "20070129"
[2] "03"
As I had hoped. I am not sure what the problem is as I tried to coerce the list into a character vector.
Here is code you can use to generate the example above:
matches<-vector("list", 10000)
matches[[10000]] <- paste(c("20070129","03"))
perhaps there are alternatives to strsplit that can be used on a list?