[R] group variables in classes

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Jan 6 18:11:24 CET 2013



On 04.01.2013 17:10, catalin roibu wrote:
> Dear R users,
> I want to group the d values in classes. If I use this script I have a
> problem.
> classes <- function(x, n){
>    s <- seq(0, ceiling(max(x)), by = n)
>    factor(n*findInterval(x, s), levels = s)
> }
> z<-sapply(tapply(t$d,t$plot,function(x) classes(t$d, 4)),table)
> z<-cbind(z)


It would be helpful to tell the list what you actually aim at.

Best,
Uwe Ligges


> Thank you!
> Initial data:
>       nr        x      y     d plot plotn xplot yplot
> 121  162 50.26989 46.230 55.00    1    NA    NA    NA
> 120  160 43.05703 41.096 12.50    2    NA    NA    NA
> 1211 162 50.26989 46.230 55.00    2    NA    NA    NA
> 143  130 48.29959 59.406 42.00    2    NA    NA    NA
> 144  131 49.56329 55.866 79.50    2    NA    NA    NA
> 145  161 55.20783 50.046 79.75    2    NA    NA    NA
> 146  163 55.51600 51.860 40.75    2    NA    NA    NA
> 147  164 58.28660 52.787 13.25    2    NA    NA    NA
> 92   200 46.71426 38.114 20.75    3    92    15    95
> 93   193 56.97232 39.945 77.75    3    93    25    95
>




More information about the R-help mailing list