[R] Regex - subsetting parts of a file name.

arnaud gaboury arnaud.gaboury at gmail.com
Thu Jul 31 17:39:59 CEST 2014


>
> R> as.vector(sapply(my.cache.list, function(x)strsplit(x, "\\.")[[1]][2]))
> [1] "subject_test"  "subject_train" "y_test"        "y_train"
>
>
> R> gsub("df\\.(.*)\\.RData", "\\1", my.cache.list)
> [1] "subject_test"  "subject_train" "y_test"        "y_train"
>
>
> Note that "." will match any character, while "\\." matches a period.



Thank you for your various suggestions.



More information about the R-help mailing list