[R] importing multiple file form folder

jim holtman jholtman at gmail.com
Tue May 29 22:31:02 CEST 2012


Here is how to get the number:

> x <- c("channel 1 20120509 153744 00001.ddf", "channel 1 20120509 154744 00001.ddf",
+ "channel 1 20120509 155744 00001.ddf", "channel 1 20120509 160744 00001.ddf",
+ "channel 1 20120509 161744 00001.ddf", "channel 1 20120509 162744 00001.ddf")
> # get the number
> xNew <- sub("^channel 1 ([0-9 ]+).*", "\\1", x)  # notice the space after the '9'
> xNew
[1] "20120509 153744 00001" "20120509 154744 00001" "20120509 155744
00001" "20120509 160744 00001"
[5] "20120509 161744 00001" "20120509 162744 00001"
>
>

On Tue, May 29, 2012 at 3:41 PM, mpavlic <matevz.pavlic at gi-zrmk.si> wrote:
> Just one more thing ...
>
> my colnames are as follows  :
> c("channel 1 20120509 153744 00001.ddf", "channel 1 20120509 154744
> 00001.ddf",
> "channel 1 20120509 155744 00001.ddf", "channel 1 20120509 160744
> 00001.ddf",
> "channel 1 20120509 161744 00001.ddf", "channel 1 20120509 162744
> 00001.ddf",...)
>
> How would i get just the numbers after channel 1 as name of the column? For
> example, 2012205009 153744 instead of channel 1 201220509 153744...
>
> Thanks, m
>
> --
> View this message in context: http://r.789695.n4.nabble.com/importing-multiple-file-form-folder-tp4631637p4631753.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



More information about the R-help mailing list