D0407 D0409 D0410 D0462 D0463 D0473 D0475 D0488 D0489 D0492
#Conti_Australia 0 0 1 0 0 0 0 0 0 0
#Conti_Korea 0 0 0 0 0 0 0 0 0 0
#Conti_Malay 0 0 0 1 0 0 0 0 0 0
#
0 1 0 0 0 0
#Conti_Malay 0 0 0 0 0 1 0 0 0 0
#Island_Sumatra 0 0 0 0 0 0 0 0 0 1
# D0493 D0504 D0536
#Conti_Australia 0 0 1
#Conti_Malay 1 0 1
#Island_Sumatra
10 D0462 D0463 D0473 D0475 D0488 D0489 D0492 D0493 D0504
#IslandA 0 0 0 0 0 0 0 0 0 0 0 0
#IslandB 0 0 0 0 0 1 0 0 0 0 1 0
# D0536
#IslandA 0
#IslandB 1
A.K.
__
ot;",header=TRUE))
>> >
>> >row.names(mat1)<- gsub(".*\\_","",row.names(mat1)) #to replace the
>> "GID_" from the row.names()
>> > mat1
>> >
>> ># D0989 D9820 D5629 D4327 D2134
>> >
>> >#1 1 0 0 1 0
>&
dA","IslandB"),function(x) {x1<-
mat1[match(gsub(".*\\s+","",get(x)),mat1[,1]),-1];(!!colSums(x1))*1}))
# D0989 D9820 D5629 D4327 D2134
#IslandA 1 1 0 1 0
#IslandB 0 1 1 0 1
A.K.
__________
10 0 0
> 7 010 0 1
> ",sep="",header=TRUE))
> IslandA<-c("GID 1", "GID 5")
> IslandB<- c("GID 2", "GID 4", "GID
> 7")t(sapply(c("IslandA","
Sums(x1)}))
> #D0989 D9820 D5629 D4327 D2134
> #IslandA FALSE FALSE TRUE FALSE TRUE
> #IslandB TRUE FALSE FALSE TRUE FALSE
>
> t(sapply(c("IslandA","IslandB"),function(x) {x1<-
> mat1[match(gsub(".*\\s+","",get(x)),row.names(m
uot;IslandB"),function(x) {x1<-
mat1[match(gsub(".*\\s+","",get(x)),row.names(mat1)),];!!colSums(x1)}))
# D0989 D9820 D5629 D4327 D2134
#IslandA TRUE TRUE FALSE TRUE FALSE
#IslandB FALSE TRUE TRUE FALSE TRUE
# "*1" will replace TRUE with 1 and FA
es(mat1)),];(!!colSums(x1))*1} ))
>>
>> res
>> #D0989 D9820 D5629 D4327 D2134
>> #IslandA 1 1 0 1 0
>> #IslandB 0 1 1 0 1
>> A.K.
>>
>>
>>
>>
>> - Original Message -
>>
D0989 D9820 D5629 D4327 D2134
> #IslandA 1 1 0 1 0
> #IslandB 0 1 1 0 1
> A.K.
>
>
>
>
> - Original Message -
> From: Elaine Kuo
> To: "r-h...@stat.math.ethz.ch"
> Cc:
> Sent: Wednesday, July 31, 2013 9:03
;IslandB"),function(x)
{x1<-mat1[match(get(x),row.names(mat1)),];(!!colSums(x1))*1} ))
res
# D0989 D9820 D5629 D4327 D2134
#IslandA 1 1 0 1 0
#IslandB 0 1 1 0 1
A.K.
- Original Message -----
From: Elaine Kuo
To: "r-h...@stat.mat
Dear list,
I have a matrix showing the species presence-absence on a map.
Its rows are map locations, represented by GridCellID, such as GID1 and GID
5.
Its columns are species ID, such as D0989, D9820, and D5629.
The matrix is as followed.
Now I want to merge the GridCellID according to t
12 matches
Mail list logo