[R] help to slip a file name using "strsplit" function

Robert Baer rbaer at atsu.edu
Wed Jan 25 16:52:57 CET 2012


How about:
unlist(strsplit(as.character("Myfile_MyArea1_sample1.txt"), split = 
'[[:punct:]]'))

-----Original Message----- 
From: gianni lavaredo
Sent: Wednesday, January 25, 2012 9:26 AM
To: r-help at r-project.org
Subject: [R] help to slip a file name using "strsplit" function

Dear Researchers,

I have several files as this example: Myfile_MyArea1_sample1.txt

i wish to split in "Myfile", "MyArea1", "sample1", and "txt", becasue i
need to use "sample1" label. I try to use "strsplit" but I am able just to
split as "Myfile_MyArea1_sample1" and "txt" OR "Myfile", "MyArea1",
"sample1.txt" using


strsplit(as.character("Myfile_MyArea1_sample1.txt"), ".", fixed = TRUE)
strsplit(as.character("Myfile_MyArea1_sample1.txt"), "_", fixed = TRUE)

Thanks in advance

Gianni

[[alternative HTML version deleted]]

______________________________________________
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.


------------------------------------------
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965



More information about the R-help mailing list