Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you Bert for your suggestion ;). On Tue, Jun 6, 2017 at 8:19 AM, Bert Gunter wrote: > Simple matrix indexing suffices without any fancier functionality. > > ## First convert M and N to character vectors -- which they should > have been in the first place! > > M <- sort(as.character(M[,1]))

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bert Gunter
Simple matrix indexing suffices without any fancier functionality. ## First convert M and N to character vectors -- which they should have been in the first place! M <- sort(as.character(M[,1])) N <- sort(as.character(N[,1])) ## This could be a one-liner, but I'll split it up for clarity. res

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you David. Using xtabs operation simplifies the code very much, many thanks ;) On Tue, Jun 6, 2017 at 7:44 AM, David Winsemius wrote: > > > On Jun 6, 2017, at 4:01 AM, Jim Lemon wrote: > > > > Hi Bogdan, > > Kinda messy, but: > > > > N <- data.frame(N=c("n1","n2","n3","n4")) > > M <- data

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread David Winsemius
> On Jun 6, 2017, at 4:01 AM, Jim Lemon wrote: > > Hi Bogdan, > Kinda messy, but: > > N <- data.frame(N=c("n1","n2","n3","n4")) > M <- data.frame(M=c("m1","m2","m3","m4","m5")) > C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400)) > MN<-as.data.frame(matrix(NA,nrow=lengt

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
> David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon > Sent: Tuesday, June 6, 2017 6:02 AM > To: Bogdan

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread David L Carlson
-- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon Sent: Tuesday, June 6, 2017 6:02 AM To: Bogdan Tanasa ; r-help mailing list Subject:

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you Jim ! On Tue, Jun 6, 2017 at 4:01 AM, Jim Lemon wrote: > Hi Bogdan, > Kinda messy, but: > > N <- data.frame(N=c("n1","n2","n3","n4")) > M <- data.frame(M=c("m1","m2","m3","m4","m5")) > C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), > I=c(100,300,400)) > MN<-as.data.frame(mat

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Jim Lemon
Hi Bogdan, Kinda messy, but: N <- data.frame(N=c("n1","n2","n3","n4")) M <- data.frame(M=c("m1","m2","m3","m4","m5")) C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400)) MN<-as.data.frame(matrix(NA,nrow=length(N[,1]),ncol=length(M[,1]))) names(MN)<-M[,1] rownames(MN)<-N[,1]

Re: [R] integrating 2 lists and a data frame in R

2017-06-05 Thread Bogdan Tanasa
Dear Bert, thank you for your response. here it is the piece of R code : given 3 data frames below --- N <- data.frame(N=c("n1","n2","n3","n4")) M <- data.frame(M=c("m1","m2","m3","m4","m5")) C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400)) how shall I integrate N, a

Re: [R] integrating 2 lists and a data frame in R

2017-06-05 Thread Bert Gunter
Reproducible example, please. -- In particular, what exactly does C look ilike? (You should know this by now). -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip

[R] integrating 2 lists and a data frame in R

2017-06-05 Thread Bogdan Tanasa
Dear all, please could you advise on the R code I could use in order to do the following operation : a. -- I have 2 lists of "genome coordinates" : a list is composed by numbers that represent genome coordinates; let's say list N : n1 n2 n3 n4 and a list M: m1 m2 m3 m4 m5 2 -- and a