Re: [R] Interweaving of two datasets

2012-05-12 Thread John Kane
riaal...@yahoo.it > Sent: Fri, 11 May 2012 07:29:22 -0700 (PDT) > To: r-help@r-project.org > Subject: Re: [R] Interweaving of two datasets > > Ok, merging in this way the total number of rows of the new dataset is > the > number of rows of the dataset "request". >

Re: [R] Interweaving of two datasets

2012-05-11 Thread lunarossa
Ok, merging in this way the total number of rows of the new dataset is the number of rows of the dataset "request". Is it possible to obtain a new dataset with the number of rows of the dataset "phone"? -- View this message in context: http://r.789695.n4.nabble.com/Interweaving-of-two-datasets-t

Re: [R] Interweaving of two datasets

2012-05-10 Thread Rui Barradas
Hello, > > I'm very frightened to lose datas or make mistakes > You wont lose rows, don't worry. Two notes: merge uses the common columns in both data.frames, so by.x and by.y aren't really needed but they wont hurt. And second, from the help page for 'attach', "attach can lead to confusion. " Th

Re: [R] Interweaving of two datasets

2012-05-10 Thread lunarossa
I tried to do using merge, I think now it works (anyway it is your worth), I wrote: df1<-read.csv("df1.csv",head=T) attach(df1) df2<-read.csv("df2.csv",head=T) attach(df2) join<-merge(df1,df2,by.x="name",by.y="name") Is it correct? Coz I'm very frightened to lose datas or make mistakes -- View

Re: [R] Interweaving of two datasets

2012-05-10 Thread Rui Barradas
With the sample data and the merge as above, table(res2$phone) 454 2123 2342 9876 56775 87678 2 2 3 3 4 1 with(res2, table(name, request)) request name book cigarettes drink food paper Andy 0 1 00

Re: [R] Interweaving of two datasets

2012-05-10 Thread John Kane
t;drink", "food", "paper"), class = "factor")), .Names = c("name", "request"), class = "data.frame", row.names = c(NA, -15L)) mydata <- merge(dat1, dat2) mydata =============== #I

Re: [R] Interweaving of two datasets

2012-05-10 Thread lunarossa
Hi Ruri, sorry for my vagueness. The problem is not the order. I tried to merge the datasets as you wrote. The result is that when I input: table(phone) The output is: 0 And this happens for all the variables. -- View this message in context: http://r.789695.n4.nabble.com/Interweaving-of-two

Re: [R] Interweaving of two datasets

2012-05-10 Thread Rui Barradas
Hello, What doesn't work, exactly? I can only see two things: 1. The order of the columns is different, first data.frame in merge instruction comes first. Solution: reverse the order of data.frames in merge. 2. The order of the rows is different, the merge function orders it's output by the c

Re: [R] Interweaving of two datasets

2012-05-10 Thread lunarossa
it doesn't work. Find attached what I need explained in xls. Thank you very very much! http://r.789695.n4.nabble.com/file/n4622912/interweaving_of_2_datasets.xls interweaving_of_2_datasets.xls -- View this message in context: http://r.789695.n4.nabble.com/Interweaving-of-two-datasets-tp4608505p4

Re: [R] Interweaving of two datasets

2012-05-04 Thread Rui Barradas
Hello, lunarossa wrote > > I have two datasets, the first has this shape (each word is a column) > Name address phone .. .. > > The second one has the following shape > Name request > > I need a contingency table with for example phone and request. > > > The people registered in these datase

[R] Interweaving of two datasets

2012-05-04 Thread lunarossa
I have two datasets, the first has this shape (each word is a column) Name address phone .. .. The second one has the following shape Name request I need a contingency table with for example phone and request. The people registered in these datasets are present in both datasets, BUT in the fi