Thanks a lot!
Cc: R help
Sent: Tuesday, March 19, 2013 8:39 PM
Subject: Re: [R] How to subsetting data based on factor levels
levels(group)
#[1] "A" "C"
levels(group)=="A"
#[1] TRUE FALSE
a[,group=="A"]
# A
evels(group))==1]
# A AB
#[1,] 1 6
#[2,] 2 7
#[3,] 3 8
#[4,] 4 9
#[5,] 5 10
A.K.
- Original Message -
From: capricy gao
To: r-help
Cc:
Sent: Tuesday, March 19, 2013 9:19 PM
Subject: [R] How to subsetting data based on factor levels
Here are the code and results
=
Here are the code and results
> a=matrix(1:20,5)
> a
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
> colnames(a)=c("A","AB","C","CD")
> a
A AB C CD
[1,] 1 6 11 16
[2,] 2 7
3 matches
Mail list logo