Re: [R] strsplit with dataframes

From: Jacques VESLOT <jacques.veslot_at_cirad.fr>
Date: Thu 22 Dec 2005 - 22:36:27 EST

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
>h.andersson@nioo.knaw.nl
>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 Received on Thu Dec 22 22:44:14 2005

This archive was generated by hypermail 2.1.8 : Thu 22 Dec 2005 - 23:42:41 EST