try:
cbind.data.frame(do.call("rbind", strsplit(as.character(yourdf$ID), 
"-")), yourdf$data)



Henrik Andersson a écrit :

>Hello fellow R people,
>
>I can not figure out a pretty way to use strplit with vectors
>
>Imagine that I got the following data from someone with ID's 
>representing several factors
>
>ID             data
>A1-B1-t1       0
>A1-B1-t2       1
>A1-B2-t1       5
>A1-B2-t2       10
>A1-B10-t1      0
>A1-B10-t2      1
>A1-B20-t1      5
>A1-B20-t2      10
>
>...
>
>I would like to turn this dataframe to
>
>station substation time data
>A1     B1      t1      0
>A1     B1      t2      1
>A1     B2      t1      5
>A1     B2      t2      10
>A1     B10     t1      0
>A1     B10     t2      1
>A1     B20     t1      5
>A1     B20     t2      10
>...
>
>This must surely be done easily, but there are not an example like this 
>in ?strsplit
>
>Cheers,
>---------------------------------------------
>Henrik Andersson
>Netherlands Institute of Ecology -
>Centre for Estuarine and Marine Ecology
>P.O. Box 140
>4400 AC Yerseke
>Phone: +31 113 577472
>[EMAIL PROTECTED]
>http://www.nioo.knaw.nl/ppages/handersson
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>  
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to