Skip to content
Prev 324786 / 398503 Next

split and common variables

Your request is still vague. Arun has given you one approach. This
will tell you which names are found in pairs of places:
+ for (j in (i+1):ndf) {
+ pair <- paste(names(dta.df.sp)[i], names(dta.df.sp)[j])
+ results[[pair]] <- intersect(dta.df.sp[[i]]$name,
dta.df.sp[[j]]$name)
+ k <- k+1
+ }
+ }
$`GCKT IKLI`
character(0)

$`GCKT KLOI`
[1] "P_CK24" "P_CK29" "P_CK32"

$`GCKT PLRT`
[1] "P_CK33" "P_CK30"

$`GCKT POIV`
[1] "P_CK24" "P_CK33" "P_CK26"

$`IKLI KLOI`
[1] "P_CK25"

$`IKLI PLRT`
[1] "P_CK23" "P_CK25"

$`IKLI POIV`
[1] "P_CK23" "P_CK28" "P_CK31"

$`KLOI PLRT`
[1] "P_CK27" "P_CK25"

$`KLOI POIV`
[1] "P_CK24"

$`PLRT POIV`
[1] "P_CK23" "P_CK33"

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: arun [mailto:smartpink111 at yahoo.com] 
Sent: Wednesday, June 5, 2013 10:37 AM
To: Nico Met
Cc: dcarlson at tamu.edu; R help
Subject: Re: [R] split and common variables

Hello,
May be this helps:
dta1<-do.call(data.frame,dta)
dta2<-dta1[complete.cases(dta1),]
dta2[,-3]<-lapply(dta2[,-3],as.character)
lstdta2<-split(dta2,dta2$place)
library(plyr)
#Some names are common in a few, but not in all the places. If you
are looking for names common in 2 places, 3, places, etc...
lstNew<-lapply(2:5,function(i){x1<-
combn(names(lstdta2),i);lapply(split(x1,col(x1)),function(x){x2<-pas
te(x,collapse="_");lst1<-lapply(lstdta2[x],`[`,-1);lst2<-join_all(ls
t1,by="name",type="inner");names(lst2)<-x2;
colnames(lst2)[-1]<-paste("value",1:(ncol(lst2)-1),sep="");lst2}) })

?lstNew1<-lapply(lstNew,function(x) x[lapply(x,nrow)!=0])
?lstNew2<-lstNew1[lapply(lstNew1,length)!=0]
?lstNew2[[1]][1:2]
#$`2`
#? GCKT_KLOI? value1?? value2
#1??? P_CK24? 6.0786? -1.2738
#2??? P_CK29? 1.2757 -13.7960
#3??? P_CK29? 1.2757 -34.8020
#4??? P_CK32 -8.1963 -11.1280
#5??? P_CK32 -8.1963 -35.9044
#
#$`3`
#? GCKT_PLRT? value1?? value2
#1??? P_CK33? 6.2826 -14.4522
#2??? P_CK33? 6.2826? -9.4303
#3??? P_CK30 15.3869 -23.9914
#4??? P_CK30 15.3869 -11.1103
A.K.






----- Original Message -----
From: Nico Met <nicomet80 at gmail.com>
To: dcarlson at tamu.edu
Cc: R help <r-help at r-project.org>
Sent: Wednesday, June 5, 2013 10:30 AM
Subject: Re: [R] split and common variables

Dear Dr. David,

Many thanks for your answer.

Now, if I want to see if there are common "name"in those "places" ,
how can
I do it? So, by common I mean, it might be compared with 2, 3, 4
.... all
of them. All possible combinations

Many thanks

regards

Nico


On Mon, Jun 3, 2013 at 5:20 PM, David Carlson <dcarlson at tamu.edu>
wrote:
that
"value"
-13.796,
class
??? [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org 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.