[R] count - help

Dieter Menne dieter.menne at menne-biomed.de
Wed Jul 14 20:06:19 CEST 2010



barbara horta e costa wrote:
> 
> 
> Sample     Season  Area     Gear  Depth
>        1           W           1          5       1
>        2           Sp          1          3       1
>        2           Sp          1          5       1
>        2           Sp          1         11      1
>        2           Sp          1         11      1
> 
> Sample: 1:28
> Season: I, P, V, O
> Area: 1:3
> Fishing gear: 1:12
> Depth: 1:8
> 
> each variable level is coded with numbers. e.g I have 3 areas and 12 gears
> 
> 

Here is an example how to create a data frame. If you post again, it is
polite and you will get faster answers when you supply sample data in this
form.

Dieter

n = 100
set.seed(123)
d = data.frame(Sample = sample(1:28,n,TRUE),          
           Season=sample(c("I","P","V","O"),n,TRUE),
           Area = sample(c(1:3,NA),n,TRUE),
           Gear = sample(c(1:12,NA),n,TRUE),
           Depth = sample(1:8,n,TRUE))

# The real job is rather simple in your case (package reshape is for the
hard work)
xt = xtabs(d,exclude=NULL,na.action=na.pass)
xt
ftable(xt, exclude=NULL,na.action=na.pass)


-- 
View this message in context: http://r.789695.n4.nabble.com/count-help-tp2288571p2289161.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list