Try this:

## Dataset
mydata <- data.frame(x=sample(1:8,10,replace=T),y=sample(1:9,10,replace=T),
var1=rnorm(10),var2=rnorm(10))
## Put x and y in bins
xcut <- cut(mydata$x,seq(0,8,2))
ycut <- cut(mydata$y,seq(0,9,3))
## Create table
tapply(mydata$var1,list(ycut,xcut),mean)

- Norma


On 5/16/07, Norbert <[EMAIL PROTECTED]> wrote:

> hi dear R users,
> I'm a newbie with R and excuse me if my question is stupid ...  but i've
> read lot of documentation and I don't know how to do.
>
> I have a dataset like
>
> x    y    var1    var2
> 2    4    10    50
> 3   3    20    70
> 3    2    50    68
> 4    5   34    42
> 5    3    10    23
> 7    8    23    42
> 7   3    23    34
> [...]
>
> And I need to produce grids like :
> y\x    ]0-2]    ]2-4]    ]4-6]    ]6-8]
> ]0-3]
> ]3-6]            means of corresponding values for var1 (or var2)
> ]6-9]
>
>
> but I don't find any example ....
>
>
> in advance, lot of thanks for your help
>
> js
>
>
>
>
> _____________________________________________________________________________
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to