similar to: merging dataframes with an unequal number of variables

Displaying 20 results from an estimated 5000 matches similar to: "merging dataframes with an unequal number of variables"

2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
Dear All Sorry for this simple question, I could not solve it by spending days. My data looks like this: # data set.seed(1234) clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100 level for this factor var; yvar <- rnorm(40, 10,6); var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2); var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15,
2009 Feb 19
3
Multiple merge, better solution?
Hello, My problem is that I would like to merge multiple files with a common column but merge accepts only two data.frames to merge. In the real situation, I have 26 different data.frames with a common column. I can of course use merge many times (see below) but what would be more sophisticated solution? For loop? Any ideas? DF1 <- data.frame(var1 = letters[1:5], a = rnorm(5)) DF2 <-
2010 Dec 16
2
Compare two dataframes
Hello, I have two dataframes DF1 and DF2 that should be identical but are not (DF1 has some rows that aren't in DF2, and vice versa). I would like to produce a new dataframe DF3 containing rows in DF1 that aren't in DF2 (and similarly DF4 would contain rows in DF2 that aren't in DF1). I have a solution for this problem (see self contained example below) but it's awkward and
2010 Jan 20
1
Reshaping data with xtabs giving me 'extra' data
Dear all, Lets say I have several data frames as follows: > set.seed(42) > dates <- as.Date(c("2010-01-19", "2010-01-20")) > times <- c("09:30:00", "11:30:00", "13:30:00", "15:30:00") > shows <- c("Red Dwarf", "Being Human", "Doctor Who") > > df1 <- data.frame(Date = dates[1],
2010 Nov 11
4
How to get a specific named element in a nested list
Hello, I have a nested named list structure, like the following: x <- list( list( list(df1,df2) list(df3, list(df4,df5)) list(df6,df7))) with df1...d7 as data frames. Every data frame is named. Is there a way to get a specific named element in x? so, for example, x[[c("df5")]] gives me the data frame 5? Thank you in advance! Best, Friedericksen
2005 Oct 20
1
Windows 2000 crash while using rbind (PR#8225)
Windows 2000 reports that "Rgui.exe has generated errors and will be = closed by Windows. You will need to restart the program." when using = rbind.=20 df1 <- data.frame(cbind(x=3D1, y=3D1:1000), fac=3Dsample(LETTERS[1:3], = 1000, repl=3DTRUE)) df2 <- data.frame(cbind(x=3D1, y=3D1:10), fac=3Dsample(LETTERS[4:6], = 10, repl=3DTRUE)) df3 <- data.frame(cbind(x=3D1,
2007 Sep 27
2
create data frame(s) from a list with different numbers of rows
# Hello, # I have a list with 6 categories and with different numbers of rows. # I would like to change each of them into a unique data frame in order to match # values with other data frames and perform some calculations. # Or I could make each category or list element have the same number of rows and create one large data.frame. # below is a creation of a sample list # I apologize for the
2010 Sep 04
4
Please explain "do.call" in this context, or critique to "stack this list faster"
I've been doing some consulting with students who seem to come to R from SAS. They are usually pre-occupied with do loops and it is tough to persuade them to trust R lists rather than keeping 100s of named matrices floating around. Often it happens that there is a list with lots of matrices or data frames in it and we need to "stack those together". I thought it would be a simple
2012 Jun 03
2
merging single column from different dataframe
Hi all, probably really simple to solve, but having no background in programming I haven't been able to figure this out: I have two dataframes like df1 <- data.frame(names1=c('aa','ab', 'ac', 'ad'), var1=c(1,5,7,12)) df2 <- data.frame(names2=c('aa', 'ab', 'ac', 'ad', 'ae'), var2=c(3,6,9,12,15)) Now I want merge
2013 Jun 11
1
mapply on multiple data frames
Hi all- I am wondering about using the mapply function to multiple data frames. Specifically, I would like to do a t-test on a subset of multiple data frames. All data frames have the same structure. Here is my code so far: f<-function(x,y) { test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=="num",],paired=T,alternative="greater") out<-test$p.value
2009 Jan 21
3
merging several dataframes from a list
Hi there, I have a list of dataframes (generated by reading multiple files) and all dataframes are comparable in dimension and column names. They also have a common column, which, I'd like to use for merging. To give a simple example of what I have: df1 <- data.frame(c(LETTERS[1:5]), c(2,6,3,1,9)) names(df1) <- c("pos", "data") df3 <- df2 <- df1 df2$data
2004 Mar 09
5
Adding data.frames together
I have a series of data frames that are identical structurally, i.e. - made with the same code, but I need to add them together so that they become one, longer, data frame, i.e. - each of the slot vectors are increased in length by the length of the added data frame vectors. So if I have df1 with a slot A so that length(df1$A) = 100 and I have df2 with a slot A so that length(df2$A)=200 then I
2004 Mar 15
1
gzfile & read.table on Win32
Hello ... Are there any known problems or even gotchas to look out for when using a gzfile connection in read.csv/read.table in Windows? In the package PROcess, available at www.bioconductor.org/repository/devel/package/html/PROcess.html there are two files in the PROcess/inst/Test directory which are of the extension *.csv.gz. With both files, if I open up a gzfile connection, say: vv <-
2011 Aug 18
2
Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
Dear expeRts, What is the best approach to create a third data frame from two given ones, when the new/third data frame has last column computed from the last columns of the two given data frames? ## Okay, sounds complicated, so here is an example. Assume we have the two data frames: df1 <- data.frame(Year=rep(2001:2010, each=2), Group=c("Group 1","Group 2"), Value=1:20)
2007 Oct 22
3
median value dataframe coming from multiple dataframes
Hi all, I am not a skillful R programmer and has I am handling with large dataframes (about 30000 x 300) I am in need of an efficient function. I have 4 dataframes with the same dimension. I need to generate other dataframe with the some dimension than the others where in each position it has the median value of the 4 values in the same position coming from the 4 dataframes. Grateful by your
2011 Dec 07
2
Dividing rows when time is overlapping
Hi all, I have dataframe that was created from the fusion of two dataframes. Both spanned over the same time intervall but contained different information. When I put them together, the info overlapped since there is no holes in the time interval of one of the dataframe. Here is an example where the rows "sp=A and B" are part of a first df and the rows "sp=C" come from a
2008 Feb 19
2
Looping through a list of objects & do something...
Hey Folks, Could somebody show me how to loop through a list of dataframes? I want to be able to generically access their elements and do something with them. For instance, instead of this: df1<- data.frame(x=(1:5),y=(1:5)); df2<- data.frame(x=(1:5),y=(1:5)); df3<- data.frame(x=(1:5),y=(1:5)); plot(df1$x,df1$y); plot(df2$x,df2$y); plot(df3$x,df3$y); I would like to do something like:
2012 Jul 11
1
sapply question
Why does this sapply code change df3 but not df1? Thanks df1 <- read.table(text=" cola colb colc cold cole 1 NA 5 9 NA 17 2 NA 6 NA 14 NA 3 3 NA 11 15 19 4 4 8 12 NA 20 ", header=TRUE) df2 <-df1*2 df1 df2 df3 <-sapply(names(df1),function(x) {df1[[x]]<- df2[[x]]}) df1 df3 [[alternative HTML version deleted]]
2003 Sep 04
1
error in lm.fit
Hello R user, I have several data frames with >100 columns and I did a linear regression over time of each column df1.lm <- lapply(df1, function(x) lm(x~year)$coeff[2]) that worked fine and I get slope of each column oder time - until I divided df1 by df2 df3 <- df1/df2 > df3.lm <- lapply(df3, function(x) lm(x~year)$coeff[2]) Error in lm.fit(x, y, offset = offset, ...) :
2011 Jun 06
1
Merge two columns of a data frame
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