[R-sig-Geo] NOT easy ID selection and split data.frame

bart bart at njn.nl
Wed Nov 10 12:39:25 CET 2010


This will do:
 > split(mydata,substr( as.character(mydata$ID),1,8))
It will return a list of dataframes

Bart

On 11/10/2010 12:31 PM, gianni lavaredo wrote:
> Dear Researcher,
>
> I have a problem and I don't know is possible to resolve with R
>
>
> mydata<-
> data.frame(ID=c(1015344101,1015344102,1015344103,1015344104,1015344105,1015344106,1015344107,1015344108,1015344109,1015344110,
>
> 1015344201,1015344202,1015344203,1015344204,1015344205,1015344206,1015344207,1015344208,1015344209,1015344210,1015353001,
>
> 1015353002,1015353003,1015353004,1015353005,1015353006,1015353007,1015353008,1015353009,1015353010),
> value=c(146.5,87.1,211.5,152.0,183.0,104.7,92.2,157.2,116.0,168.0,158.7,78.2,89.3,77.7,108.7,108.5,104.4,101.1,
>
>    91.7,124.0,143.4,158.7,223.4,174.0,243.0,274.6,133.8,147.5,218.3,210.8))
>
>
>
>
> i wish to split in htis way:
>
> data.frame A
>
>             ID value
> 1  1015344101 146.5
> 2  1015344102  87.1
> 3  1015344103 211.5
> 4  1015344104 152.0
> 5  1015344105 183.0
> 6  1015344106 104.7
> 7  1015344107  92.2
> 8  1015344108 157.2
> 9  1015344109 116.0
> 10 1015344110 168.0
>
> data.farme B
> 11 1015344201 158.7
> 12 1015344202  78.2
> 13 1015344203  89.3
> 14 1015344204  77.7
> 15 1015344205 108.7
> 16 1015344206 108.5
> 17 1015344207 104.4
> 18 1015344208 101.1
> 19 1015344209  91.7
> 20 1015344210 124.0
>
>
> data.frame C
> 21 1015353001 143.4
> 22 1015353002 158.7
> 23 1015353003 223.4
> 24 1015353004 174.0
> 25 1015353005 243.0
> 26 1015353006 274.6
> 27 1015353007 133.8
> 28 1015353008 147.5
> 29 1015353009 218.3
> 30 1015353010 210.8
>
>
>
> the first 8 numers (ex: 10153441) give the location of plot and the last the
> ID number of plot (ex: 01)
>
> thanks
> Gianni
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list