[R] merge counts from table()

2012-08-13 Thread Francois Pepin
Hi everyone, Is there an easy way to combine the counts from table()? Let's say that I have: x<-1:4 y<-2:5 I want to replicate: table(c(x,y)) using only table(x) and table(y) as input. The reason is that it's cumbersome to carry all the values around when all I care about are the counts. The

Re: [R] merge many files together using R

2012-06-14 Thread Rui Barradas
Hello, Suppose your files list is called 'flist'. And that your files have blanks as separators. dflist <- lapply(flist, read.table, header=TRUE, stringsAsFactors=FALSE) big <- do.call(rbind, dflist) You can get a list of all files you want with list.files(). See ?list.files Hope this hel

[R] merge many files together using R

2012-06-14 Thread sathya7priya
I have hundreds of text files which has data like a data frame with three columns.The column names are same in all the files.I need to merge all files into a single big file. My files are like this file1 "new.col" "ppm.p." "freq.p." "1_3_diaminopropane" 3.13859 5.67516 "1_3_diaminopropane" 3.137 6.

Re: [R] Merge function - Return NON matches

2012-04-27 Thread RHelpPlease
Hi again, Petr, your solution worked! Thanks everyone for your input. I'll look more into "setdiff." Cheers! -- View this message in context: http://r.789695.n4.nabble.com/Merge-function-Return-NON-matches-tp4590755p4593101.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] Merge function - Return NON matches

2012-04-27 Thread Petr PIKAL
Hi If you used shorter names for your objects you will get probably more readable advice Is this what you wanted? truncated_dataframe[truncated_dataframe$CLAIM_NO %in% setdiff(truncated_dataframe$CLAIM_NO, truncated_list$CLAIM_NO),] Regards Petr > Hi there, > I've tried the noted solutions

Re: [R] Merge function - Return NON matches

2012-04-27 Thread RHelpPlease
Hi there, I've tried the noted solutions: "If you do `no <- unlist(hrc_78_clm_no`, do you get a character vector of claim numbers you want to exclude? If so, then `subset(whatever, !CLAIM_NO %in% no)` should work." I converted the CLAIM_NO list to a character, with > hrc78_clmno_char <- format

Re: [R] Merge function - Return NON matches

2012-04-26 Thread chuck.01
# dput() example # lets say you have data called y, like this: > y sp1 sp2 sp3 sp4 d 0 0 0 0 e 0 0 0 0 f 0 0 0 0 # ok, so do this: > dput(y) structure(list(sp1 = c(0, 0, 0), sp2 = c(0, 0, 0), sp3 = c(0, 0, 0), sp4 = c(0, 0, 0)), .Names = c("sp1", "sp2", "sp3", "sp4" )

Re: [R] Merge function - Return NON matches

2012-04-26 Thread MacQueen, Don
Assuming everything else is good, the "all" or "all.x" or "all.y" arguments to merge() should do what I think you're asking for. You did read the help page for merge, right? -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 O

Re: [R] Merge function - Return NON matches

2012-04-26 Thread RHelpPlease
Hi there, Thanks for your responses. I haven't used/heard of dput() before. I'm looking it up & understanding how it works. Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Merge-function-Return-NON-matches-tp4590755p4591003.html Sent from the R help mailing list archive

Re: [R] Merge function - Return NON matches

2012-04-26 Thread Steve Lianoglou
Hi, As Sarah reiterated -- it'd *really* be helpful if you give us data we can actually work with. That having been said: On Thu, Apr 26, 2012 at 4:12 PM, RHelpPlease wrote: > Hi again, > I tried the sample code like this: > >> merged_clmno <- subset(bestPartAreadmin, !CLAIM_NO %in% hrc78_clm_n

Re: [R] Merge function - Return NON matches

2012-04-26 Thread Sarah Goslee
You'd get better help if you actually did as Steve requested and provided sample data (a reproducible example!) using dput(). But since you didn't: > fakedata <- data.frame(a = 1:5, b=11:15, c=c(1,1,1,2,2)) > fakedata a b c 1 1 11 1 2 2 12 1 3 3 13 1 4 4 14 2 5 5 15 2 > notb <- c(12, 14, 15) >

Re: [R] Merge function - Return NON matches

2012-04-26 Thread RHelpPlease
Hi again, I tried the sample code like this: > merged_clmno <- subset(bestPartAreadmin, !CLAIM_NO %in% hrc78_clm_no) > dim(merged_clmno) [1] 1306893 Note that: > dim(bestPartAreadmin) [1] 1306893 So, no change between the original data.frame (bestPartAreadmin) & the (should be) less-row

Re: [R] Merge function - Return NON matches

2012-04-26 Thread RHelpPlease
Hi Steve, Thanks for replying. Here's a small piece of the data.frame: > bestPartAreadmin[1:5,1:6] DESY_SORT_KEY PRVDR_NUM CLM_THRU_DT CLAIM_NO NCH_NEAR_LINE_REC_IDEN_CD NCH_CLM_TYPE_CD 1 10193 290003 20090323 20

Re: [R] Merge function - Return NON matches

2012-04-26 Thread Steve Lianoglou
Hi, To increase the chances of you getting help on this one, please give example data (a small data.frame, a small list) that you are trying to do this on, and also show the desired output. Whip these variables up in your R workspace and paste the output of `dput` for each into your follow up emai

[R] Merge function - Return NON matches

2012-04-26 Thread RHelpPlease
Hi there, I wish to merge a common variable between a list and a data.frame & return rows via the data.frame where there is NO match. Here are some details: The list, where the variable/col.name = CLAIM_NO CLAIM_NO 20 83 1440 4439 7002 ... > dim(hrc78_clm_no) [1] 66781 The data.frame, where

[R] merge - preserve value labels

2012-04-24 Thread Marion Wenty
Hello, I am having trouble with the merge function. I am trying to merge two dataframes. Before I merge them I can get the value labels by using the command attr(Dataframe_1$MyVariable,"value.labels") attr(Dataframe_2$MyVariable,"value.lables") Personen unter 15 Jahren Präsenz- und Zivildiener

Re: [R] merge multiple data frames

2012-04-10 Thread David M. Schruth
to study for a while thank you for your help max - Original Message - From: "MacQueen, Don" To: "Massimo Bressan" ; Sent: Monday, January 30, 2012 4:47 PM Subject: Re: [R] merge multiple data frames Does this example help? It doesn't handle the problem of

Re: [R] R merge two dataframes with different row?

2012-03-16 Thread David Winsemius
On Mar 16, 2012, at 5:51 AM, zhu free wrote: Hi everyone, I have a question for R code to merge. Say I have two dataframes: File1 is: V1V2V3V4 1100101name1 2200201name2 2300301name3 3400401name4 3500501name5 4600601

[R] R merge two dataframes with different row?

2012-03-16 Thread zhu free
Hi everyone, I have a question for R code to merge. Say I have two dataframes: File1 is: V1V2V3V4 1100101name1 2200201name2 2300301name3 3400401name4 3500501name5 4600601name6 4700701name7 File2 is: V1

Re: [R] merge multiple data frames

2012-01-31 Thread Massimo Bressan
thanks don I have here enough to study for a while thank you for your help max - Original Message - From: "MacQueen, Don" To: "Massimo Bressan" ; Sent: Monday, January 30, 2012 4:47 PM Subject: Re: [R] merge multiple data frames Does this example help? I

Re: [R] merge multiple data frames

2012-01-30 Thread MacQueen, Don
t;-sqldf("select a_b.*, c.* from a_b left join c on a_b.date=c.date") > >bye > >max > > > > > >- Original Message - >From: "MacQueen, Don" >To: "maxbre" ; >Sent: Saturday, January 28, 2012 12:24 AM >Subject: Re

Re: [R] merge multiple data frames

2012-01-30 Thread Massimo Bressan
thanks michael it's working like a charm: that's exaclty what I was looking for bye max - Original Message - From: "R. Michael Weylandt" To: "Massimo Bressan" Cc: Sent: Friday, January 27, 2012 4:16 PM Subject: Re: [R] merge multiple data frames O

Re: [R] merge multiple data frames

2012-01-30 Thread Massimo Bressan
t a_b.*, c.* from a_b left join c on a_b.date=c.date") bye max - Original Message - From: "MacQueen, Don" To: "maxbre" ; Sent: Saturday, January 28, 2012 12:24 AM Subject: Re: [R] merge multiple data frames Not tested, but this might be a case for the s

Re: [R] merge multiple data frames

2012-01-27 Thread MacQueen, Don
Not tested, but this might be a case for the sqldf package. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/26/12 9:29 AM, "maxbre" wrote: >This is my reproducible example (three data frames: a, b, c) > >a<-structure

Re: [R] merge multiple data frames

2012-01-27 Thread R. Michael Weylandt
Massimo Bressan wrote: > I tested your code: it's OK but there is still the problem of the suffixes > for the last dataframe > thank you for the support > > > - Original Message - From: "R. Michael Weylandt" > > To: "maxbre" > Cc:

Re: [R] merge multiple data frames

2012-01-27 Thread Massimo Bressan
I tested your code: it's OK but there is still the problem of the suffixes for the last dataframe thank you for the support - Original Message - From: "R. Michael Weylandt" To: "maxbre" Cc: Sent: Thursday, January 26, 2012 8:19 PM Subject: Re: [R] m

Re: [R] merge multiple data frames

2012-01-26 Thread maxbre
thank you for your reply I'll study and test your code (which is a bit obscure to me up to now); by the way do you think that "merge_all" is a wrong way to hit? thanks again m -- View this message in context: http://r.789695.n4.nabble.com/merge-multiple-data-frames-tp4331089p4331830.html Sent fr

Re: [R] merge multiple data frames

2012-01-26 Thread R. Michael Weylandt
I might do something like this: mergeAll <- function(..., by = "date", all = TRUE) { dotArgs <- list(...) Reduce(function(x, y) merge(x, y, by = by, all = all, suffixes=paste(".", names(dotArgs), sep = "")), dotArgs)} mergeAll(a = a, b = b, c = c) str(.Last.value) You also might be able

[R] merge multiple data frames

2012-01-26 Thread maxbre
This is my reproducible example (three data frames: a, b, c) a<-structure(list(date = structure(1:6, .Label = c("2012-01-03", "2012-01-04", "2012-01-05", "2012-01-06", "2012-01-07", "2012-01-08", "2012-01-09", "2012-01-10", "2012-01-11", "2012-01-12", "2012-01-13", "2012-01-14", "2012-01-15", "

Re: [R] Merge Data by time stamps

2011-10-10 Thread David Winsemius
On Oct 10, 2011, at 1:28 PM, Alaios wrote: Dear all, I have some device measurements and the time stamps I get from it have the below format: MyStruct$TimeStamps[1,] [1] 2011.000 10.0006.000 16.000 23.000 30.539 I can convert them easily with ISOdate() to a number and do the

[R] Merge Data by time stamps

2011-10-10 Thread Alaios
Dear all, I have some device measurements and the time stamps I get from it have the below format: MyStruct$TimeStamps[1,] > [1] 2011.000   10.000    6.000   16.000   23.000   30.539 I can convert them easily with ISOdate() to a number and do the calculations I need. One of my problems is that

Re: [R] Merge dataframes

2011-10-08 Thread jdanielnd
Hi everybody, I got a solution for my problem with Eric Paniagua (many thanks!)! Thank you a lot everybody! Paniagua said explained that I was losing row.names when I merged a data.frame with a factor object (data2$color), because a factor objects don't have row.names. Instead of merging data1 to

Re: [R] Merge dataframes

2011-10-07 Thread David Winsemius
On Oct 7, 2011, at 9:34 AM, jdanielnd wrote: Hello, I am having some problems to use the 'merge' function. I'm not sure if I got its working right. What I want to do is: 1) Suppose I have a dataframe like: height width 11.12.3 22.1

Re: [R] Merge dataframes

2011-10-07 Thread jdanielnd
I'm not sure if this solves the problem. The NA cases are spread into de cases. This solution always returns the NA cases for the last variables as the last cases. It's not keeping the same row.names they have in data1. What I want to do it return exactly the same data1 (cases in the same order)

Re: [R] Merge dataframes

2011-10-07 Thread Uwe Ligges
On 07.10.2011 15:34, jdanielnd wrote: Hello, I am having some problems to use the 'merge' function. I'm not sure if I got its working right. What I want to do is: 1) Suppose I have a dataframe like: height width 11.12.3 22.1

[R] Merge dataframes

2011-10-07 Thread jdanielnd
Hello, I am having some problems to use the 'merge' function. I'm not sure if I got its working right. What I want to do is: 1) Suppose I have a dataframe like: height width 11.12.3 22.12.5 31.81.9 4

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-04 Thread francesca casalino
Sorry---I thought it worked but I think I am actually definitely doing something wrong... The problem might be that there are NA's and there are also duplicated values...My fault. I can't figure out what is going wrong... I'll be more thorough and modify the two df to mirror more what I have to ex

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-04 Thread francesca casalino
Yes, your code did exactly what I needed. Thank you!! -f [[alternative HTML version deleted]] __ R-help@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-gu

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread Sarah Goslee
Hi, On Mon, Oct 3, 2011 at 1:54 PM, francy wrote: > Hi, > > I am trying to find a function to match two data frames of different lengths > for one field only. > So, for example, > df1 is: > > Name Position location > francesca A 75 > cristina B 36 > > And df2 is: > > location Country > 75 UK > 5

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread William Dunlap
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of francy > Sent: Monday, October 03, 2011 10:55 AM > To: r-help@r-project.org > Subject: [R] Merge two data frames and find common values and non-matching > values > > Hi, > > I am tryin

[R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread francy
Hi, I am trying to find a function to match two data frames of different lengths for one field only. So, for example, df1 is: Name Position location francesca A 75 cristina B 36 And df2 is: location Country 75 UK 56 Austria And I would like to match on "Location" and the output to be something

Re: [R] merge some columns

2011-09-02 Thread David Winsemius
On Sep 2, 2011, at 9:30 AM, David Winsemius wrote: On Sep 2, 2011, at 8:34 AM, Joao Fadista wrote: Dear all, I would like to know how to merge columns like: Input file: V1 V2 V3 V4 V5 V6 1 G A G G G G 2 A A G A A G Looked like an mapply-type problem: > with(dat, mapply

Re: [R] merge some columns

2011-09-02 Thread David Winsemius
On Sep 2, 2011, at 8:34 AM, Joao Fadista wrote: Dear all, I would like to know how to merge columns like: Input file: V1 V2 V3 V4 V5 V6 1 G A G G G G 2 A A G A A G Looked like an mapply-type problem: > with(dat, mapply(paste, list(V1, V3, V5),

Re: [R] merge some columns

2011-09-02 Thread Dennis Murphy
Hi: Here's one approach: d <- read.table(textConnection(" V1 V2 V3 V4 V5 V6 1 G A G G G G 2 A A G A A G"), header = TRUE, stringsAsFactors = FALSE) closeAllConnections() # Create two vectors of variable names, one for odd numbered, # one for even numbered vars1 <- names(d)[seq_along(

[R] merge some columns

2011-09-02 Thread Joao Fadista
Dear all, I would like to know how to merge columns like: Input file: V1 V2 V3 V4 V5 V6 1 G A G G G G 2 A A G A A G Desired output file: V1 V2 V3 1 G/A G/G G/G 2 A/A G/A A/G So for every 2 consecutive columns merge their content into one. Thanks in advance. [[al

Re: [R] merge(join) problem

2011-08-16 Thread Ista Zahn
On Tue, Aug 16, 2011 at 6:40 PM, Sam Steingold wrote: >> * Ista Zahn [2011-08-16 18:31:00 -0400]: >> On Tue, Aug 16, 2011 at 6:29 PM, Ista Zahn wrote: >>> Hi Tia, > > "tia" == "thanks in advance" :-) *facepalm* Thanks Sam, one day I'll learn internet acronyms... > >> AB3 <- AB2[order(AB$Time,

Re: [R] merge(join) problem

2011-08-16 Thread Sam Steingold
> * Ista Zahn [2011-08-16 18:31:00 -0400]: > On Tue, Aug 16, 2011 at 6:29 PM, Ista Zahn wrote: >> Hi Tia, "tia" == "thanks in advance" :-) > AB3 <- AB2[order(AB$Time, decreasing=TRUE), ] > AB4 <- AB3[!duplicated(AB3[c("Name", "Open")]), ] thanks! -- Sam Steingold (http://sds.podval.org/) on

Re: [R] merge(join) problem

2011-08-16 Thread Ista Zahn
On Tue, Aug 16, 2011 at 6:29 PM, Ista Zahn wrote: > Hi Tia, > > On Tue, Aug 16, 2011 at 6:00 PM, Sam Steingold wrote: >> I have two datasets: >> A with columns Open and Name (and many others, irrelevant to the merge) >> B with columns Time and Name (and many others, irrelevant to the merge) >> >>

Re: [R] merge(join) problem

2011-08-16 Thread Ista Zahn
Hi Tia, On Tue, Aug 16, 2011 at 6:00 PM, Sam Steingold wrote: > I have two datasets: > A with columns Open and Name (and many others, irrelevant to the merge) > B with columns Time and Name (and many others, irrelevant to the merge) > > I want the dataset AB with all these columns > Open from A -

[R] merge(join) problem

2011-08-16 Thread Sam Steingold
I have two datasets: A with columns Open and Name (and many others, irrelevant to the merge) B with columns Time and Name (and many others, irrelevant to the merge) I want the dataset AB with all these columns Open from A - a difftime (time of day) Time from B - a difftime (time of day) Name (same

Re: [R] merge function

2011-07-01 Thread peter dalgaard
to have a well-defined problem from the outset. -pd > > "Downey, Patrick" wrote: > > Hello, > > I'm clearly confused about the merge function. In the following > > r <- merge(x,y,all.x=T,all.y=F) > > my y vector has only unique values (no dupl

Re: [R] merge function

2011-06-30 Thread Jeff Newmiller
uot;Downey, Patrick" wrote: Hello, I'm clearly confused about the merge function. In the following r <- merge(x,y,all.x=T,all.y=F) my y vector has only unique values (no duplicates). So I don't understand how this can ever generate an r which is of greater length than x. I thou

Re: [R] merge function

2011-06-30 Thread Downey, Patrick
n the following r <- merge(x,y,all.x=T,all.y=F) my y vector has only unique values (no duplicates). So I don't understand how this can ever generate an r which is of greater length than x. I thought the default behavior was only matching rows are included, but that using all.x=T included rows w

[R] merge function

2011-06-30 Thread Downey, Patrick
Hello, I'm clearly confused about the merge function. In the following r <- merge(x,y,all.x=T,all.y=F) my y vector has only unique values (no duplicates). So I don't understand how this can ever generate an r which is of greater length than x. I thought the default behavior was

Re: [R] merge large number of raster objects

2011-06-10 Thread Ben Zaitchik
Thank you Henrik and Rolf. My migraine just disappeared. : ) myobjects = ls(pattern='^RH') dataobj = mget(myTemp,.GlobalEnv) map = Reduce(merge,dataobj) did the trick. do.call() didn't cut it for some reason . . . it returned an " 'x' is missing " error. But Reduce works quite nicely for

Re: [R] merge large number of raster objects

2011-06-10 Thread Rolf Turner
On 10/06/11 14:57, Ben Zaitchik wrote: Hello, I have a large number of raster objects in memory, with names RH100, RH101, RH102, etc. (myobjects <- ls(pattern='^RH')). These rasters are sections of a continuous map, and I would like to combine them using the RasterObject merge tool in package

Re: [R] merge large number of raster objects

2011-06-09 Thread Henrik Bengtsson
...and ?mget for retrieving multiple objects as a list. /Henrik On Thu, Jun 9, 2011 at 10:32 PM, Henrik Bengtsson wrote: > See ?get and ?do.call.  That should be enough. > > ?Reduce may be an alternative for do.call(), but could also be less > memory efficient. > > My $.02 > > /Henrik > > On Thu

Re: [R] merge large number of raster objects

2011-06-09 Thread Henrik Bengtsson
See ?get and ?do.call. That should be enough. ?Reduce may be an alternative for do.call(), but could also be less memory efficient. My $.02 /Henrik On Thu, Jun 9, 2011 at 7:57 PM, Ben Zaitchik wrote: > Hello, > > I have a large number of raster objects in memory, with names RH100, RH101, > RH

[R] merge large number of raster objects

2011-06-09 Thread Ben Zaitchik
Hello, I have a large number of raster objects in memory, with names RH100, RH101, RH102, etc. (myobjects <- ls(pattern='^RH')). These rasters are sections of a continuous map, and I would like to combine them using the RasterObject merge tool in package 'raster.' Merge expects an input list

Re: [R] Merge two columns of a data frame

2011-06-06 Thread Ethan Brown
Another possibility: dfs <- list(df1, df2, df3) df.1.2.3 <- as.data.frame(unlist(sapply(dfs, function(x) do.call(paste, x On Mon, Jun 6, 2011 at 2:37 PM, Ista Zahn wrote: > Hi Abraham, > Just take it step by step. Paste the values together, combine them, > and assign them to a data.frame col

Re: [R] Merge two columns of a data frame

2011-06-06 Thread Ista Zahn
Hi Abraham, Just take it step by step. Paste the values together, combine them, and assign them to a data.frame column. Like this perhaps: df.1.2.3 <- data.frame(Var1 = c(with(df1, paste(Var1, Var2, Var3)), with(df2, paste(Var1, Var2)), with(df3, paste(Var1, Var2 B

[R] Merge two columns of a data frame

2011-06-06 Thread Abraham Mathew
I have the following data: prefix <- c("cheap", "budget") roots <- c("car insurance", "auto insurance") suffix <- c("quote", "quotes") prefix2 <- c("cheap", "budget") roots2 <- c("car insurance", "auto insurance") roots3 <- c("car insurance", "auto insurance") suffix3 <- c("quote", "quotes") df

Re: [R] merge with origin information in new variable names

2011-04-25 Thread Phil Spector
Eric - As others have said, you should change the names of the variables in the data frames before you merge them. Here's one implementation of that idea: DF.wave.1 <- data.frame(id=1:10,var.A=sample(letters[1:4],10,TRUE)) DF.wave.2 <- data.frame(id=1:10,var.M=sample(letters[5:8],10,TR

Re: [R] merge with origin information in new variable names

2011-04-25 Thread Eric Fail
Is there anyone out there who can suggest a way to solve this problem? Thanks, Esben On Sun, Apr 24, 2011 at 8:53 PM, Jeff Newmiller wrote: > Merge only lets you combine two tables at a time, but it does have a > "suffix" argument that is intended to address your concern, but only for > variable

Re: [R] merge with origin information in new variable names

2011-04-24 Thread Jeff Newmiller
Merge only lets you combine two tables at a time, but it does have a "suffix" argument that is intended to address your concern, but only for variable names that would conflict. In your example, the id variables are all sequenced exactly the same, so you could actually use cbind rather than mer

[R] merge with origin information in new variable names

2011-04-24 Thread Eric Fail
Dear R-list, Here is my simple question, I have n data frames that I would like to merge, but I can't figure out how to add information about the origin of the variable(s). Here is my problem, DF.wave.1 <- data.frame(id=1:10,var.A=sample(letters[1:4],10,TRUE)) DF.wave.2 <- data.frame(id=1:10,va

Re: [R] Merge matrix

2011-04-13 Thread Pankaj Barah
Hi Kevin, Sorry.it is not Bt ? A and B are two independent Matrices with equal number rows and different number of columns. dim (A) [1] 30380 104 dim(B) [1] 3038063 I want to combine both A and B to matrix C wheredim(C) [1] 30380 167 So I got the answer C<-cbind(A,B) Thanks and reg

Re: [R] Merge matrix

2011-04-12 Thread Kevin E. Thorpe
On 04/12/2011 10:54 AM, pankaj borah wrote: I have two matrices A and B dim (A) [1] 30380 104 dim(Bt) [1] 3038063 I want to combine both A and B to matrix C where dim(C) [1] 30380 167 How do I do that ? Assuming that Bt is the transpose of B and you want C = [A|Bt] you coul

Re: [R] Merge matrix

2011-04-12 Thread Kehl Dániel
?cbind should solve your problem 2011-04-12 07:54 keltezéssel, pankaj borah írta: > I have two matrices A and B > >> dim (A) > [1] 30380 104 > >> dim(Bt) > [1] 3038063 > > I want to combine both A and B to matrix C where >> dim(C) > [1] 30380 167 > > How do I do that ? > > > Regards, >

[R] Merge matrix

2011-04-12 Thread pankaj borah
I have two matrices A and B > dim (A) [1] 30380   104 > dim(Bt) [1] 30380    63 I want to  combine both A and B to matrix C where >dim(C) [1] 30380   167 How do I do that ? Regards, Pankaj Barah Department of Biology, Norwegian University of Science & Technology (NTNU) Realfagbygget, N-

Re: [R] Merge data under conditions

2011-03-13 Thread flymer
Thanks to both of you for your help! Jim, my problem is to match some observations of a time serie (vector 'a' in my example) with theoretical predictions of this process (vector 'b' in my example), with a small time lag between them. -- View this message in context: http://r.789695.n4.nabble

Re: [R] Merge data under conditions

2011-03-12 Thread jim holtman
use the sqldf package: > require(sqldf) > a time x 1 1.0 4 2 2.2 5 3 5.2 6 > b time y 10 1 21 3 32 5 44 7 55 9 > sqldf(" + select a.time, a.x, b.y + from a, b + where abs(a.time - b.time) < 0.5 + ") time x y 1 1.0 4 3 2 2.2 5 5 3 5.2 6 9 >

Re: [R] Merge data under conditions

2011-03-12 Thread David Winsemius
On Mar 12, 2011, at 4:14 PM, flymer wrote: Dear All, Debuting in R, I'm facing a problem. I have 2 vectors, say 'a' et 'b', and I'd like to merge them according to the proximity of their variable 'time'. How to do to keep elements which satisfy (for example) 'a$time-b $time<0.5'? For exa

[R] Merge data under conditions

2011-03-12 Thread flymer
Dear All, Debuting in R, I'm facing a problem. I have 2 vectors, say 'a' et 'b', and I'd like to merge them according to the proximity of their variable 'time'. How to do to keep elements which satisfy (for example) 'a$time-b$time<0.5'? For example : > a time x 1 1.0 4 2 2.2 5 3 5.2 6 >

[R] 'merge' function creating duplicate columns names in the output

2011-03-03 Thread jim holtman
The "merge" command is creating duplicate column names in a dataframe that is the result of the merge. The following is the 'merge' command: x <- merge(invType , allocSlots , by.x = 'index' , by.y = 'indx' , all.x = TRUE ) The 'invType' dataframe was the result of a previous

Re: [R] merge( , by='row.names') slowness

2011-03-02 Thread rex.dwyer
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dms Sent: Wednesday, March 02, 2011 3:16 PM To: r-help@r-project.org Subject: [R] merge( , by='row.names') slowness I noticed that joining two data.frames in R using

[R] merge( , by='row.names') slowness

2011-03-02 Thread dms
I noticed that joining two data.frames in R using the "merge" function that using by='row.names' slows things down substantially when compared to just joining on a common index column. Using a dataframe size of ~10,000 rows: it's as slow as 10 minutes in the by='row.names' case versus merely 1 s

Re: [R] merge in data.tables -- "non-visible"

2011-03-02 Thread Ted Rosenbaum
Thanks for the help -- merge.data.table was being used! On Wed, Mar 2, 2011 at 12:25 AM, Steve Lianoglou < mailinglist.honey...@gmail.com> wrote: > Hi Ted, > > On Tue, Mar 1, 2011 at 9:45 PM, Ted Rosenbaum > wrote: > > Hi, > > I am trying to use the merge command in the data.tables package. > >

Re: [R] merge in data.tables -- "non-visible"

2011-03-01 Thread Steve Lianoglou
Hi Ted, On Tue, Mar 1, 2011 at 9:45 PM, Ted Rosenbaum wrote: > Hi, > I am trying to use the merge command in the data.tables package. > However, when I run the command I am not sure if it is running the merge > command from the base package or the merge command from data.tables. > When I run "met

[R] merge in data.tables -- "non-visible"

2011-03-01 Thread Ted Rosenbaum
Hi, I am trying to use the merge command in the data.tables package. However, when I run the command I am not sure if it is running the merge command from the base package or the merge command from data.tables. When I run "methods(generic.function="merge")' it informs me that 'merge.data.table" is

Re: [R] merge multiple .csv files

2011-02-09 Thread Benjamin Caldwell
ilto:r-help-boun...@r-project.org] > On Behalf Of Benjamin Caldwell > Sent: Thursday, 10 February 2011 1:22 PM > To: r-help > Subject: [R] merge multiple .csv files > > Am trying to merge about 15 .csv tables - tried a test run but came up with > 0 rows (no data for each variable/co

Re: [R] merge multiple .csv files

2011-02-09 Thread Bill.Venables
same class, and some values in common? You do not give us very much to go on. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Benjamin Caldwell Sent: Thursday, 10 February 2011 1:22 PM To: r-help Subject: [R] merge multiple .csv

Re: [R] merge multiple .csv files

2011-02-09 Thread Erik Iverson
On 02/09/2011 09:21 PM, Benjamin Caldwell wrote: Am trying to merge about 15 .csv tables - tried a test run but came up with 0 rows (no data for each variable/column head) CAHSEE.EA.feb.2009<-read.csv("2009 CAHSEE EA feb 2009.csv", header=TRUE) CAHSEE.IM.MATH.2009<-read.csv("2009 CAHSEE Impact

[R] merge multiple .csv files

2011-02-09 Thread Benjamin Caldwell
Am trying to merge about 15 .csv tables - tried a test run but came up with 0 rows (no data for each variable/column head) > CAHSEE.EA.feb.2009<-read.csv("2009 CAHSEE EA feb 2009.csv", header=TRUE) > CAHSEE.IM.MATH.2009<-read.csv("2009 CAHSEE Impact Math.csv", header=TRUE) > testmerge<-merge(CAHSE

Re: [R] merge, rbind, merge.zoo? adding new rows to existing data.frame

2011-02-09 Thread Gabor Grothendieck
On Wed, Feb 9, 2011 at 1:10 AM, Ad Flan wrote: > Hi all, > I'm trying to add updated data to an existing time series where an > overlap exists. I need to give priority to the update data. > My script runs every morning to collect data the updated data. There > are quite often varied lengths, so on

[R] merge, rbind, merge.zoo? adding new rows to existing data.frame

2011-02-08 Thread Ad Flan
Hi all, I'm trying to add updated data to an existing time series where an overlap exists. I need to give priority to the update data. My script runs every morning to collect data the updated data. There are quite often varied lengths, so once off solutions identifying rows to solve this example wo

Re: [R] merge tables in a loop

2011-01-26 Thread MacQueen, Don
Not sure exactly what you mean by, “ writing a table with several rows per file”. If what you want to do is write output to an external file, adding to it as your loop progresses, then look at the functions sink() cat() And their ‘file’ and ‘append’ arguments. If what you want to do is appe

[R] merge tables in a loop

2011-01-26 Thread clemens karwautz
I’m running a loop opening one file after another. >setwd("D:/Documents and Settings/trflp") >a<-list.files() >results.diversity<-data.frame(matrix(0,ncol=7,nrow=length(a))) >names(results.diversity)<-c("file","simpson","shannon","eveness") >x<-length(a) >for (i in 1:x){ > trflp<-read.table(a[i

[R] Merge() error

2010-12-13 Thread Jeremy Miles
Hi All, I'm getting some weird problems with merge(), which give me the Error in match.names(clabs, names(xi)) : names do not match previous names Error. I've found other people discussing this error, but they don't seem to match my situation, and the strange thing is that changing the order

[R] Merge two ggplots

2010-11-21 Thread Alaios
et as an error message this: plot_shad_CR(CRX,CRY,1,CRagent,f) Error in eval(expr, envir, enclos) : object 'z' not found Calls: print ... lapply -> is.vector -> lapply -> FUN -> eval -> eval From: Dennis Murphy Cc: Rhelp Sent: Sat, No

Re: [R] Merge two ggplots

2010-11-21 Thread Dennis Murphy
Dennis > > and I get as an error message this: > > plot_shad_CR(CRX,CRY,1,CRagent,f) > Error in eval(expr, envir, enclos) : object 'z' not found > Calls: print ... lapply -> is.vector -> lapply -> FUN -> eval -> eval > > > -

Re: [R] Merge two ggplots

2010-11-20 Thread Dennis Murphy
Hi: Perhaps a plus sign at the end of the line before geom_tile() would help. Dennis On Sat, Nov 20, 2010 at 6:30 AM, Alaios wrote: > Hello everyone. > I am using ggplot and I need some help to merge these two plots into one. > > plot_CR<-function(x,y,agentid,CRagent){ > library(ggplot2) > >

[R] Merge two ggplots

2010-11-20 Thread Alaios
Hello everyone. I am using ggplot and I need some help to merge these two plots into one. plot_CR<-function(x,y,agentid,CRagent){   library(ggplot2)     agent<-CRagent[[agentid]] # To make following expression shorter   ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+   geom_point(aes(x,y,colour=cu

Re: [R] Merge postscript files into ps/pdf

2010-11-15 Thread Patrick Connolly
lto:r-help-boun...@r- |> >> project.org] On Behalf Of Ralf B |> >> Sent: Friday, November 12, 2010 12:07 AM |> >> To: r-help Mailing List |> >> Subject: [R] Merge postscript files into ps/pdf |> >> |> >> I created multiple pos

Re: [R] merge two dataset and replace missing by 0

2010-11-15 Thread Kate Hsu
Thanks for all of your help. It works to me. Kate On Mon, Nov 15, 2010 at 10:06 AM, David Winsemius wrote: > > On Nov 15, 2010, at 10:42 AM, Kate Hsu wrote: > > Hi r users, >> >> I have two data sets (X1, X2). For example, >> time1<-c( 0, 8, 15, 22, 43, 64, 85, 106, 127, 148, 169, 190 ,21

Re: [R] merge two dataset and replace missing by 0

2010-11-15 Thread Gabor Grothendieck
On Mon, Nov 15, 2010 at 10:42 AM, Kate Hsu wrote: > Hi r users, > > I have two data sets (X1, X2). For example, > time1<-c( 0,   8,  15,  22,  43,  64,  85, 106, 127, 148, 169, 190 ,211 ) > outpue1<-c(171 ,164 ,150 ,141 ,109 , 73 , 47  ,26  ,15  ,12   ,6   ,2   ,1 ) > X1<-cbind(time1,outpue1) > >

Re: [R] merge two dataset and replace missing by 0

2010-11-15 Thread David Winsemius
On Nov 15, 2010, at 10:42 AM, Kate Hsu wrote: Hi r users, I have two data sets (X1, X2). For example, time1<-c( 0, 8, 15, 22, 43, 64, 85, 106, 127, 148, 169, 190 , 211 ) outpue1<-c(171 ,164 ,150 ,141 ,109 , 73 , 47 ,26 ,15 ,12 ,6 , 2 ,1 ) X1<-cbind(time1,outpue1) time2<-c(

Re: [R] merge two dataset and replace missing by 0

2010-11-15 Thread Uwe Ligges
See ?merge with argument all=TRUE and replace by 0 afterwards. Uwe Ligges On 15.11.2010 16:42, Kate Hsu wrote: Hi r users, I have two data sets (X1, X2). For example, time1<-c( 0, 8, 15, 22, 43, 64, 85, 106, 127, 148, 169, 190 ,211 ) outpue1<-c(171 ,164 ,150 ,141 ,109 , 73 , 47 ,26

[R] merge two dataset and replace missing by 0

2010-11-15 Thread Kate Hsu
Hi r users, I have two data sets (X1, X2). For example, time1<-c( 0, 8, 15, 22, 43, 64, 85, 106, 127, 148, 169, 190 ,211 ) outpue1<-c(171 ,164 ,150 ,141 ,109 , 73 , 47 ,26 ,15 ,12 ,6 ,2 ,1 ) X1<-cbind(time1,outpue1) time2<-c( 0 ,8 ,15 , 22 ,43 , 64 ,85 ,106 ,148) output2<-c(

Re: [R] Merge postscript files into ps/pdf

2010-11-12 Thread Joshua Wiley
On Fri, Nov 12, 2010 at 1:27 PM, Ralf B wrote: > Assuming I would go into the trouble of messing with the existing R > scripts that create mentioned postscripts/pdfs, how can I achieve that > an array of scripts append to a single ps/pdf? I would want the first > script to create the file if it do

<    1   2   3   4   5   >