Thanks for your responses.
I have already found that "merge" function performs what I am looking for.
On Fri, Jun 14, 2013 at 12:51 AM, Yasin Gocgun wrote:
> Hi,
>
> I have been struggling with the issue of merging data frames that have
> common columns and have different dimensions. Although I
?merge
Sent from my iPad
On Jun 14, 2013, at 0:51, Yasin Gocgun wrote:
> Hi,
>
> I have been struggling with the issue of merging data frames that have
> common columns and have different dimensions. Although I made alot of
> search about it on internet, I could not find any function that woul
type ?merge in R
-
Yasir Kaheil
--
View this message in context:
http://r.789695.n4.nabble.com/Merging-Data-Frames-in-R-tp4636781p4636962.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://st
Thanks a lot, Phil.
I decided to do it via the list - as you suggested, but had to do some
gymnastics, which Reduce will greatly help me to avoid now!
Dimitri
On Tue, Nov 9, 2010 at 12:36 PM, Phil Spector wrote:
> Dimitri -
> Usually the easiest way to solve problems like this
> is to put all t
Dimitri -
Usually the easiest way to solve problems like this
is to put all the dataframes in a list, and then use
the Reduce() function to merge them all together at the
end. You don't give many details about how the data frames
are constructed, so it's hard to be specific about the
best way
Thanks a lot, Joshua.
You might be right.
I am thinking of creating a list (as a placeholder) and then merging
the elements of the list.
Dimitri
On Tue, Nov 9, 2010 at 12:11 PM, Joshua Wiley wrote:
> Hi Dimitri,
>
> I have some doubts whether storing the results of a loop in a data
> frame and me
Hi Dimitri,
I have some doubts whether storing the results of a loop in a data
frame and merging it with every run is the most efficient way of doing
things, but I do not know your situation. This does what you want, I
believe, but I suspect it could be quite slow. I worked around the
placeholde
If you want to keep only the rows that are unique in the first column
then do the following:
workComb1 <- subset(workComb, !duplicated(ProbeID))
On Mon, Jun 14, 2010 at 11:20 AM, Assa Yeroslaviz wrote:
> well, the problem is basically elsewhere. I have a data frame with
> expression data and dou
Put the rownames as another column in your dataframe so that it
remains with the data. After merging, you can then use it as the
"rownames"
On Mon, Jun 14, 2010 at 9:25 AM, Assa Yeroslaviz wrote:
> Hi,
>
> is it possible to merge two data frames while preserving the row names of
> the bigger dat
Yes, indexing will typically make a large difference.
On Tue, Apr 6, 2010 at 3:54 PM, Abhishek Pratap wrote:
> Hi Guys
>
> I have two data frames which I would like to merge on two conditions.
>
> I am doing the following (abstract form)
>
> new.data.frame <- merge(df1,df2, by=c("Col1","Col2"))
You got the error. It is different naming convention of chr. I should be
able to fix that pretty easily.
In case the problem persists, I will contact the list.
Thanks!
-Abhi
On Tue, Apr 6, 2010 at 5:01 PM, David Winsemius wrote:
> OK, not the SNP's. So look at the "chr"'s. I will bet that you g
OK, not the SNP's. So look at the "chr"'s. I will bet that you get 0
when you try :
length(intersect(data_lane6_snps$chr, data_lane6_snps_rsid$chr))
... since one is using a format of "chrNN" and the other is using just
"NN". You need to get the chromosome naming convention straightened out
Just so you know
length(intersect(data_lane6_snps$SNP, data_lane6_snps_rsid$SNP))
796120
I just need to include the chr condition now where I am stuck.
-Abhi
On Tue, Apr 6, 2010 at 4:51 PM, Abhishek Pratap wrote:
> Hi David
>
> I can understand looking the SNP data values it can be felt that t
Hi David
I can understand looking the SNP data values it can be felt that they are
different values and hence no result in merge. However the columns still
have ~700K SNPs common. What I am looking for is a merge where the SNP and
Chr matches. If I match only the SNP column I get partially correct
On Apr 6, 2010, at 4:03 PM, Abhishek Pratap wrote:
Hi David
Here it is. You can ignore the bio jargon if it sounds confusing.
Sometimes it is essential to have domain details.
The corresponding data type of column (SNP, chr) on which I am
applying merge is same.
merge(data_lane6_snps, d
And I should also add that if I merge only on one column it works fine but
the result is not what I want.
merge(data_lane6_snps, data_lane6_snps_rsid , by = c("SNP") : works as
expected.
Is the "chr" column being a factor creating probs here ?
-A
On Tue, Apr 6, 2010 at 4:03 PM, Abhishek Pratap
Hi David
Here it is. You can ignore the bio jargon if it sounds confusing. The
corresponding data type of column (SNP, chr) on which I am applying merge is
same.
merge(data_lane6_snps, data_lane6_snps_rsid , by = c("SNP,"chr"))
str(data_lane6_snps)
'data.frame': 7724462 obs. of 10 variables:
On Apr 6, 2010, at 3:54 PM, Abhishek Pratap wrote:
Hi Guys
I have two data frames which I would like to merge on two conditions.
I am doing the following (abstract form)
new.data.frame <- merge(df1,df2, by=c("Col1","Col2"))
What does
str(df1) ; str(df2)
... show?
It is giving me a
Yeah, sometimes the vocabulary we bring to a task does not match up
(or "merge" properly) with the vocabulary that the developers use. In
this case the merge operation is one that has a precise meaning in
database lingo, which apparently you do not have background in. My
experience in tryi
I agree. I have a foot of books on R now, for example the R Book by
Michael Crowly. But so far, Googling the archives of this list has been
the most help. Nonetheless, if I cannot understand the documentation of
a function, then the documentation needs to be updated. For example,
there needs to be
James Rome wrote:
On 2/1/2010 5:51 PM, David Winsemius wrote:
I figured this out finally. I really believe that the R help write-ups
are sorely lacking.
The help docs are probably not the best way to learn R, but they are
great for users of the functions. I have found that after going thro
On 2/1/2010 5:51 PM, David Winsemius wrote:
I figured this out finally. I really believe that the R help write-ups
are sorely lacking. As soon as I looked at
http://www.statmethods.net/management/merging.html, it was obvious:
Adding Columns
To merge two dataframes (datasets) horizontally, us
David,
Now the code is:
for (j in seq_along(rwy)) { # subset the data and merge them
ar4rw = ar4rw <- subset(arrgnd, arrgnd$Runway==rwy[j])
if(j == 1) {
arrw = ar4rw
}
else {
arrw = merge(arrw, ar4rw)
}
}
I attach the data. I needed 500 rows to get both runways in rwy.
The suggestions did not h
On Feb 1, 2010, at 5:16 PM, James Rome wrote:
Dear kind R helpers,
I have a vector of runway names in rwy ("31R", "31L",... the
number is user selectable)
arrgnd is a data frame with data for all flights and all runways,
with a Runway column.
I am trying to subset arrgnd into a dat frame
Yes, that was the original question: when a variable in a data frame is
a matrix instead of an ordinary variable merge() handles the missing
cases so that only the first column of the matrix gets NA and the rest
are recycled. If the matrix is broken to several variables everything
works fine.
Why
This has something to do with your data.frame structure
see
> str(df1)
'data.frame': 3 obs. of 2 variables:
$ a : int 1 2 3
$ X1: 'AsIs' int [1:3, 1:2] 1 2 3 4 5 6
> str(df2)
'data.frame': 2 obs. of 2 variables:
$ a : int 1 2
$ X2: 'AsIs' int [1:2, 1:2] 11 12 13 14
This seems to work
You are exceeding your max memory here, so R will not be able to do that.
dump both tables into a db such as mysql and then run the query either from
RMySQL or from mysql directly. then output the result and import back in R.
that will take care of the merge, but not sure what will happen when y
Hi,
How about this:
> SNP5 <- merge(SNP4, SNP1[,2:3], all.x=TRUE)
> SNP5
MarkerAnimal Y x
1 P1001 194073197 0.021088 2
2 P1002 194073197 0.021088 1
3 P1004 194073197 0.021088 2
4 P1005 194073197 0.021088 0
5 P1006 194073197 0.021088 2
6 P1007 194073197 0.021088 0
Thi
On Apr 22, 2009, at 5:22 AM, Johannes G. Madsen wrote:
Hello
I have two data frames, SNP4 and SNP1:
head(SNP4)
Animal MarkerY
3213 194073197 P1001 0.021088
1295 194073197 P1002 0.021088
915 194073197 P1004 0.021088
2833 194073197 P1005 0.021088
1487 194073197 P10
Try this (where SNP1x is same as SNP1 from your post
but without the last line). If the merge below does not work
on real data set due to size then try the sqldf alternative
as it
> SNP1x <-
+ structure(list(Animal = c(194073197L, 194073197L, 194073197L,
+ 194073197L, 194073197L), Marker = struct
Thanks a lot, Gabor - it's perfect!
Dimitri
On Fri, Dec 19, 2008 at 6:24 PM, Gabor Grothendieck
wrote:
> Try this:
>
>> L <- list(data.frame(A=2, B=3, C=4),
> + data.frame(A=2, B=1, C=3, D=2, E=4, F=5),
> + data.frame(A=1, B=2, C=4, D=3, E=2, F=4, G=5, H=4, I=2))
>
>> library(plyr)
>> do.call(rbi
Try this:
> L <- list(data.frame(A=2, B=3, C=4),
+ data.frame(A=2, B=1, C=3, D=2, E=4, F=5),
+ data.frame(A=1, B=2, C=4, D=3, E=2, F=4, G=5, H=4, I=2))
> library(plyr)
> do.call(rbind.fill, L)
A B C D E F G H I
1 2 3 4 NA NA NA NA NA NA
2 2 1 3 2 4 5 NA NA NA
3 1 2 4 3 2 4 5 4 2
Hi Dimitri,
Not exceptionally elegant, but this should do it:
alldata <- as.data.frame(matrix(as.numeric(NA),nrow=99,ncol=9))
colnames(alldata) <- colnames(L[[?]])
( where ? is a 9-column data frame with the correct names )
foreach (i in 1:99) {
alldata[i,colnames(L[[i]])] <- L[[i]]
}
> DF1<- data.frame(Name=as.factor(c("A","B","C")), Age= c(21,45,30))
> DF2<- data.frame(Name=as.factor(c("A","B","X")), Age= c(50,20,10))
> DF3<- data.frame(Name=as.factor(c("B","Y","K")), Age= c(40,21,30))
>
> merge(merge(DF1,DF2, by.x= "Name", by.y="Name",
> all=TRUE),DF3,by.x="Name",by.y="Name
34 matches
Mail list logo