Re: [R] rbind of multiple data frames by column name, when each data frames can contain different columns

2022-06-03 Thread Avi Gross via R-help
Message- From: CALUM POLWART To: Bert Gunter Cc: r-help@R-project.org ; Stefano Sofia Sent: Fri, Jun 3, 2022 3:48 am Subject: Re: [R] rbind of multiple data frames by column name, when each data frames can contain different columns Bert! It sounds like you are warming to the the tidyverse

Re: [R] rbind of multiple data frames by column name, when each data frames can contain different columns

2022-06-03 Thread John Fox
arche Region - Italy Meteo Section Snow Section Via del Colle Ameno 5 60126 Torrette di Ancona, Ancona (AN) Uff: +39 071 806 7743 E-mail: stefano.so...@regione.marche.it ---Oo-oO ________ Da: Andrew Simmons Inviato: venerd� 3

[R] rbind of multiple data frames by column name, when each data frames can contain different columns

2022-06-01 Thread Stefano Sofia
Dear R-list users, for each winter season from 2000 to 2022 I have a data frame collecting for different weather stations snowpack height (Hs), snowfall in the last 24h (Hn) and a validation flag. Suppose I have these three following data frames df1 <- data.frame(data_POSIX=seq(as.POSIXct("20

Re: [R] rbind common header to file list

2021-01-21 Thread Miluji Sb
Thank you, that was it. Best, Milu On Wed, Jan 20, 2021 at 1:33 PM Eric Berger wrote: > for ( file in filelist ) > > > > On Wed, Jan 20, 2021 at 2:21 PM Miluji Sb wrote: > >> Thank you for your reply and the solution. Yes, I would like the date to >> be >> the column header for all the files

Re: [R] rbind common header to file list

2021-01-20 Thread Eric Berger
for ( file in filelist ) On Wed, Jan 20, 2021 at 2:21 PM Miluji Sb wrote: > Thank you for your reply and the solution. Yes, I would like the date to be > the column header for all the files in the list. > > This is what tried following your suggestion; > > filelist = list.files(pattern = ".*.t

Re: [R] rbind common header to file list

2021-01-20 Thread Miluji Sb
Thank you for your reply and the solution. Yes, I would like the date to be the column header for all the files in the list. This is what tried following your suggestion; filelist = list.files(pattern = ".*.txt") date <- 2101 for (file %in% filelist){ datalist <- read.table(file) write.t

Re: [R] rbind common header to file list

2021-01-19 Thread Jeff Newmiller
a) I recommend _not_ overwriting the input files. Very difficult to debug/recover if anything goes wrong. b) I recommend making a function that takes the file name, source directory, and destination directory, and reads the file, makes the change, and writes it to the output directory. c) Your

[R] rbind common header to file list

2021-01-19 Thread Miluji Sb
Dear all, I have more than 200 text files in a folder without header - example below. I would like to read, add a common date header to all the files, and write (replace) the files. ## Read files filelist = list.files(pattern = ".*.txt") datalist = lapply(filelist, function(x)read.table(x, header

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread Dagmar
Hello Rui and Gerrit and Sarah, Thank you very much for your help. I finally got it to work! Have a great day! Dagmar Am 29.10.2015 um 08:38 schrieb ruipbarra...@sapo.pt: > > Hello, > > Try the following. > > > newframe <- myframe > newframe$Hungertype <- with(myframe, ifelse(Hunger <= 1, NA, >

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread Gerrit Eichner
Hello, Sarah, take a look at the online help page of the function cut() (and apply the function to the Hunger-column). Hth -- Gerrit On Thu, 29 Oct 2015, Dagmar wrote: Dear Sarah, (dear All), Thank you for trying to help! You are right, that I want to add a column to my dataframe with a

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread ruipbarradas
Hello, Try the following. newframe <- myframe newframe$Hungertype <- with(myframe, ifelse(Hunger <= 1, NA,                             ifelse(1 < Hunger & Hunger <= 2, "Hunger",                             ifelse(Hunger < 3, "bigHUnger", "verybigHunger") ))) Note that the new column is of type c

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread Dagmar
Dear Sarah, (dear All), Thank you for trying to help! You are right, that I want to add a column to my dataframe with a corresponding value to the Hunger column. Your solution is basically correct in the result but my data are a little more complicated. Maybe that example describes it better:

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Sarah Goslee
If I'm reading this correctly, you want to add a column to your dataframe with a name corresponding to the value in the Hunger column. myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) ) myframe$Hungertype <- c("none", "bighunger", "ver

[R] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Dagmar Cimiotti
Hello, It must be very easy. I have data like this: myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) ) myframe bighunger <- subset (myframe, myframe$Hunger>=2 &myframe$Hunger <3 ) bighunger verybighunger <- subset(myframe,myframe$Hun

Re: [R] rbind in array of lists

2014-10-12 Thread Rui Barradas
Hello, Em 12-10-2014 18:26, David Winsemius escreveu: On Oct 12, 2014, at 8:45 AM, Rui Barradas wrote: Hello, Try the following. do.call(rbind, lapply(a, '[[', "var1")) do.call(rbind, lapply(a, '[[', "var2")) Could perhaps (untested) make it more general with: do.call(rbind, lapply(a, '[

Re: [R] rbind in array of lists

2014-10-12 Thread David Winsemius
On Oct 12, 2014, at 8:45 AM, Rui Barradas wrote: > Hello, > > Try the following. > > do.call(rbind, lapply(a, '[[', "var1")) > do.call(rbind, lapply(a, '[[', "var2")) Could perhaps (untested) make it more general with: do.call(rbind, lapply(a, '[[', names(a[[1]])[1])) do.call(rbind, lapply(a,

Re: [R] rbind in array of lists

2014-10-12 Thread Rui Barradas
Hello, Try the following. do.call(rbind, lapply(a, '[[', "var1")) do.call(rbind, lapply(a, '[[', "var2")) Hope this helps, Rui Barradas Em 12-10-2014 07:14, Cesar Caballero escreveu: Hi all, I have an array of lists. All lists have the same names and the vectors inside each name have the

[R] rbind in array of lists

2014-10-11 Thread Cesar Caballero
Hi all, I have an array of lists. All lists have the same names and the vectors inside each name have the same dimension. For instance, a[1:4] [[1]] [[1]]$var1 [1] 1 2 3 4 5 [[1]]$var2 [1] 6 7 [[2]] [[2]]$var1 [1] 2 4 6 8 10 [[2]]$var2 [1] 12 14 [[3]] [[3]]$var1 [1] 3 6 9 12 15 [[3

Re: [R] rbind multiple data sets (.csv)

2014-06-11 Thread arun
Hi, If your working directory is "data 3" which has only two folders C1 and C2. May be this helps: lsF1 <- list.files(recursive=TRUE) lst1 <- lapply(split(lsF1,gsub(".*\\_(\\d+)\\..*","\\1",lsF1)),function(x) do.call(rbind,lapply(x,function(y) read.csv(y, header=TRUE A.K. Hello, I am tryi

Re: [R] rbind/timestamp problem

2013-12-10 Thread Georg Hörmann
Thank you, now it works. I would never have never found the source of the problem. I am trying to build a data frame with results from a sensitivity analysis for a model. I use rbind because the number of rows is unkown and i use the timestamp as a hint for the students that they do not analyse

Re: [R] rbind/timestamp problem

2013-12-10 Thread jim holtman
try this: > sensitivity=rbind(sensitivity,data.frame(mtype=2,cdate=as.POSIXct(Sys.time(), > origin="1970-01-01"))) > sensitivity mtype cdate 1 1 2013-12-10 09:35:53 2 2 2013-12-10 09:37:02 The 'c' function is coercing to numeric. If you want to 'rbind' rows to a datafram

[R] rbind/timestamp problem

2013-12-10 Thread Georg Hörmann
Hello world, I am stuck somehow... I am trying to add a timestamp to a sensitivity matrix: #this code works: sensitivity=data.frame(mtype=1,cdate=2) sensitivity=rbind(sensitivity,c(mtype=2,cdate=2)) # this code does not work - no idea why sensitivity=data.frame(mtype=1,cdate=as.POSIXct(Sys.ti

Re: [R] rbind a list of matrices

2013-03-07 Thread Berend Hasselman
On 07-03-2013, at 17:52, Heath Blackmon wrote: > I have a large list of matrices and a vector that identifies the desired > matrices that I would like to rbind. However, I am stuck on how to get > this to work. I have written some code below to illustrate my problem: > > # 3 simple matrices >

Re: [R] rbind a list of matrices

2013-03-07 Thread Bert Gunter
?do.call ## as in do.call(rbind, list_of_matrices) ## Note that list_of_matrices must be a **list**. -- Bert On Thu, Mar 7, 2013 at 8:52 AM, Heath Blackmon wrote: > I have a large list of matrices and a vector that identifies the desired > matrices that I would like to rbind. However, I am

Re: [R] rbind a list of matrices

2013-03-07 Thread arun
-help@r-project.org Sent: Thursday, March 7, 2013 11:52 AM Subject: [R] rbind a list of matrices I have a large list of matrices and a vector that identifies the desired matrices that I would like to rbind.  However, I am stuck on how to get this to work.  I have written some code below to

[R] rbind a list of matrices

2013-03-07 Thread Heath Blackmon
I have a large list of matrices and a vector that identifies the desired matrices that I would like to rbind. However, I am stuck on how to get this to work. I have written some code below to illustrate my problem: # 3 simple matrices a<-matrix(1:9,3,3) b<-matrix(10:18,3,3) c<-matrix(19:27,3,3)

Re: [R] rbind Missing Something: Need New Eyes

2013-01-31 Thread Peter Langfelder
On Thu, Jan 31, 2013 at 3:55 PM, Rich Shepard wrote: > I don't see what's missing in my statements to add rows to a data frame > and someone else will probably see what needs to be added to the statements. > > The data frame has this structure (without any data): > > $ PHYLUM : chr > $

Re: [R] rbind Missing Something: Need New Eyes [RESOLVED]

2013-01-31 Thread Rich Shepard
On Thu, 31 Jan 2013, Rich Shepard wrote: I don't see what's missing in my statements to add rows to a data frame and someone else will probably see what needs to be added to the statements. Found the problem: a FUBAR'd R session. Rich __ R-hel

[R] rbind Missing Something: Need New Eyes

2013-01-31 Thread Rich Shepard
I don't see what's missing in my statements to add rows to a data frame and someone else will probably see what needs to be added to the statements. The data frame has this structure (without any data): $ PHYLUM : chr $ SUBPHYLUM : chr $ SUPERCLASS : chr $ CLASS : chr $ SUBC

Re: [R] rbind: inconsistent behaviour with empty data frames?

2013-01-03 Thread Dmitrii Izgurskii
L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Dmitrii I. Sent: Wednesday, January 02, 2013 2:09 PM To: r-help@r-project.org Subject: [R

Re: [R] rbind: inconsistent behaviour with empty data frames?

2013-01-02 Thread David L Carlson
ilto:r-help-bounces@r- > project.org] On Behalf Of Dmitrii I. > Sent: Wednesday, January 02, 2013 2:09 PM > To: r-help@r-project.org > Subject: [R] rbind: inconsistent behaviour with empty data frames? > > The rbind on empty and nonempty data frames behaves inconsistently. I > a

[R] rbind: inconsistent behaviour with empty data frames?

2013-01-02 Thread Dmitrii I.
The rbind on empty and nonempty data frames behaves inconsistently. I am not sure if by design. In the first example, first row is deleted, which may or may not be on purpose: df1 <- data.frame() df2 <- data.frame(foo=c(1, 2), bar=c("a", "b")) rbind(df1, df2) foo bar 2 2 b Now if we co

Re: [R] rbind in a loop with " : " elements

2012-08-22 Thread bilelsan
You are a GENIUS !! I don't know how to thank you !! Thank you so much ! I really need to improve my R language (I take any advice) If i can do something for you about MGARCH models, let me know Thx again Bilel Le Aug 22, 2012 à 8:55 PM, Rui Barradas [via R] a écrit : > Hello, > > I'm being

Re: [R] rbind in a loop with " : " elements

2012-08-22 Thread Rui Barradas
Hello, I'm being lazy, but the following works. r = 3 ; set.seed(1) v <- matrix(c(rnorm(40)),10,4) result <- vector("list", r*ncol(v)) ires <- 0 for (j in 1:4){ for (i in 1:r){ x <- t(v[,j]^(i)*v[,1:4]^((r-(4-1)):r)) #print(x) ires <- ires + 1 result[[ ires

[R] rbind in a loop with " : " elements

2012-08-22 Thread bilelsan
Dear Ruser, Below, the deal (you can copy paste): r=3 ; set.seed(1) v <- matrix(c(rnorm(40)),10,4) for (j in 1:4){ for (i in 1:r){ x <- t(v[,j]^(i)*v[,1:4]^((r-(4-1)):r)) print(x) } } How to reach to " x " " row bind " inside or outside (preferred) of the loop. T

Re: [R] rbind-ing numeric matrices

2012-05-01 Thread Sarah Goslee
te: >> >> > Good morning, >> >> > >> >> > I'm running into trouble rbind-ing numeric matrices with differing >> >> numbers >> >> > of rows. In particular, there seem to be issues whenever a one-row >> >> numeric

Re: [R] rbind-ing numeric matrices

2012-05-01 Thread Nick Switanek
whenever a one-row > >> numeric > >> > matrix is involved. > >> > > >> > Assume A is a numeric matrix with 1 row and Y columns and B is a > numeric > >> > matrix with X rows and Y columns. Let C be the result of rbinding A > and > &g

Re: [R] rbind-ing numeric matrices

2012-05-01 Thread Sarah Goslee
1 row and Y columns and B is a numeric >> > matrix with X rows and Y columns. Let C be the result of rbinding A and >> B. >> > Then C is a numeric matrix with X + 1 rows and Y columns, only instead of >> > the rows of B being "stacked" beneath the row of A

Re: [R] rbind-ing numeric matrices

2012-05-01 Thread Nick Switanek
B. > > Then C is a numeric matrix with X + 1 rows and Y columns, only instead of > > the rows of B being "stacked" beneath the row of A as expected, the > first Y > > elements of the 1st column of B are placed in the 2nd row of C, the > > remaining values of B

Re: [R] rbind-ing numeric matrices

2012-05-01 Thread Steve Lianoglou
else going on with your data. Consider: R> m1 <- matrix(-(1:5), nrow=1) R> m2 <- matrix(1:20, ncol=5) R> rbind(m1, m2) [,1] [,2] [,3] [,4] [,5] [1,] -1 -2 -3 -4 -5 [2,]159 13 17 [3,]26 10 14 18 [4,]37 11 15 19 [5,]48

Re: [R] rbind-ing numeric matrices

2012-05-01 Thread Sarah Goslee
Hi Nick, We absolutely need a reproducible example, with code and data, to be able to help you. Because otherwise I can't replicate your problem: > A <- matrix(1:5, nrow=1, ncol=5) > B <- matrix(6:20, nrow=3, ncol=5) > C <- rbind(A, B) > A [,1] [,2] [,3] [,4] [,5] [1,]1234

[R] rbind-ing numeric matrices

2012-05-01 Thread Nick Switanek
Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C

Re: [R] rbind()

2012-01-20 Thread MacQueen, Don
As Sarah said, you have a path problem. Are you saying that RawData is a sub-folder (sub-directory) of SampleProject? And you are running the script with the working directory set to SampleProject? [check using getwd() as Sarah suggested] If so, it looks like it would work if you use './RawData/F

Re: [R] rbind()

2012-01-20 Thread Sarah Goslee
Hi Fred, It seems you don't have an rbind() problem, but a path problem. The error you're getting means R can't find your file. When specifying a relative path, as you do with "../RawData/File1.csv" it's relative to your current working directory, not necessarily the directory where your script i

[R] rbind()

2012-01-20 Thread Fred G
Hello there, Much thanks in advance for any help. I have a few questions: 1) Why do I keep getting the following error: File1 <- read.csv("../RawData/File1.csv",as.is=TRUE,row.names=1) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : c

Re: [R] rbind/cbind

2011-08-10 Thread ONKELINX, Thierry
50 > Aan: Anthony Ching Ho Ng > CC: r-help@r-project.org > Onderwerp: Re: [R] rbind/cbind > > > On Aug 10, 2011, at 9:08 AM, Anthony Ching Ho Ng wrote: > > > Dear list, > > > > I wonder if there a better way to have rbind/cbind/append to create > > the firs

Re: [R] rbind/cbind

2011-08-10 Thread David Winsemius
On Aug 10, 2011, at 9:08 AM, Anthony Ching Ho Ng wrote: Dear list, I wonder if there a better way to have rbind/cbind/append to create the first element (if it is empty) instead of doing the following in a loop? for (i in 1:10) { if (i == 1) { aRow = SomeExpression(i) } else { aRow =

[R] rbind/cbind

2011-08-10 Thread Anthony Ching Ho Ng
Dear list, I wonder if there a better way to have rbind/cbind/append to create the first element (if it is empty) instead of doing the following in a loop? for (i in 1:10) { if (i == 1) { aRow = SomeExpression(i) } else { aRow = rbind(aRow,SomeExpression(i)) } } Thanks Anthony _

Re: [R] rbind with partially overlapping column names

2011-05-16 Thread Jonathan Flowers
quot; wrote: > > > > >> -Original Message- > >> From: r-help-boun...@r-project.org > >> [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flowers > >> Sent: Sunday, May 15, 2011 5:41 PM > >> To: r-help@r-project.org > &

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread Ian Gow
;c")) > merge(df1,df2,all=TRUE) b a c 1 B A c 2 B A c 3 B A c 4 B A c On 5/15/11 11:19 PM, "William Dunlap" wrote: > >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flo

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flowers > Sent: Sunday, May 15, 2011 5:41 PM > To: r-help@r-project.org > Subject: [R] rbind with partially overlapping column names > > Hel

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread Dennis Murphy
Hi: Another way, with a little less typing but using the same principle, is df1$c <- df2$a <- NA rbind(df1, df2) Dennis On Sun, May 15, 2011 at 5:50 PM, Ian Gow wrote: > Hi: > > This is a bit of a kluge, but works for your test case: > >> df2[,setdiff(names(df1),names(df2))] <- NA >> df1[,setd

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread Ian Gow
Hi: This is a bit of a kluge, but works for your test case: > df2[,setdiff(names(df1),names(df2))] <- NA > df1[,setdiff(names(df2),names(df1))] <- NA > df3 <- rbind(df1,df2) > df3 a b c 1 A B 2 A B 3 b c 4 b c -Ian On 5/15/11 7:41 PM, "Jonathan Flowers" wrote: >Hello, > >I would like to

[R] rbind with partially overlapping column names

2011-05-15 Thread Jonathan Flowers
Hello, I would like to merge two data frames with partially overlapping column names with an rbind-like operation. For the follow data frames, df1 <- data.frame(a=c("A","A"),b=c("B","B")) df2 <- data.frame(b=c("b","b"),c=c("c","c")) I would like the output frame to be (with NAs where the frames

Re: [R] rbind a heterogeneous row

2011-03-22 Thread Henrique Dallazuanna
You need a list object indeed of a vector, try this: rbind(df, dreps = c(rep(list(TRUE), 7), 5, 0)) On Tue, Mar 22, 2011 at 10:12 PM, Alexy Khrabrov wrote: > I have a dataframe with many rows like this: > >> df >                 X1   X2   X3   X4   X5   X6   X7 week         d > sim1 FALSE TRUE T

[R] rbind a heterogeneous row

2011-03-22 Thread Alexy Khrabrov
I have a dataframe with many rows like this: > df X1 X2 X3 X4 X5 X6 X7 week d sim1 FALSE TRUE TRUE TRUE TRUE TRUE TRUE1 0.3064985 sim1 is the rowname, X1..X7,week,d are the column names. X1..X7 are factors, booleans in this case. I need to add another r

[R] rbind error (maybe a problem with chron package?)

2010-11-24 Thread Timothy W. Hilton
Hello, I have a list of data frames that I would like to combine to a single data frame. I typically do this with: do.call(rbind, list.of.dataframes) This time, I get Error in class(x) <- cl : cannot set class to "array" unless the dimension attribute has length > 0 I'm not sure what's hap

Re: [R] rbind ing matrices and resetting column numbers

2010-10-14 Thread David Winsemius
On Oct 14, 2010, at 10:40 AM, David Winsemius wrote: On Oct 14, 2010, at 10:31 AM, Maas James Dr (MED) wrote: Sorry for the verbose example. I want to row bind two matrices, and all works except I want the column labelled "row" to be sequential in the new matrix, shown as "mat3" here, i.

Re: [R] rbind ing matrices and resetting column numbers

2010-10-14 Thread David Winsemius
On Oct 14, 2010, at 10:31 AM, Maas James Dr (MED) wrote: Sorry for the verbose example. I want to row bind two matrices, and all works except I want the column labelled "row" to be sequential in the new matrix, shown as "mat3" here, i.e. needs to be 1:6 and not 1:3 repeated twice. Any su

[R] rbind ing matrices and resetting column numbers

2010-10-14 Thread Maas James Dr (MED)
Sorry for the verbose example. I want to row bind two matrices, and all works except I want the column labelled "row" to be sequential in the new matrix, shown as "mat3" here, i.e. needs to be 1:6 and not 1:3 repeated twice. Any suggestions? Thanks J > colnm1 <- c("row","ti","counti") > col

Re: [R] rbind() overwriting data.frame()

2010-09-06 Thread rajesh j
> say what the experiment died of. >> ~ Sir Ronald Aylmer Fisher >> >> The plural of anecdote is not data. >> ~ Roger Brinner >> >> The combination of some data and an aching desire for an answer does not >> ensure that a reasonable answer can be ex

Re: [R] rbind() overwriting data.frame()

2010-09-06 Thread rajesh j
of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of > data. > ~ John Tukey > > > > -Oorspronkelijk bericht- > > Van: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-

Re: [R] rbind() overwriting data.frame()

2010-09-06 Thread ONKELINX, Thierry
data. ~ John Tukey > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] Namens rajesh j > Verzonden: maandag 6 september 2010 16:57 > Aan: r-help@r-project.org > Onderwerp: [R] rbind() overwriting data.frame() > >

Re: [R] rbind() overwriting data.frame()

2010-09-06 Thread Ivan Calandra
Hi again! I'm trying to follow your general goal from your questions today but it's not easy. First, declaring a data.frame of 0 rows is a bad idea. It is much faster to define the length and number of rows from the beginning and to fill it then. Second, I don't know how to do it! What I kn

[R] rbind() overwriting data.frame()

2010-09-06 Thread rajesh j
Hi, first off, I wanna ask how do I declare a data.frame of 0 rows and n columns? Coming to my problem, I have a data.frame of 22 columns by dynamic rows which I insert using rbind. The total number of rows could go upto 2,00,000. The problem is that after about 800 or 900 get inserted rbind sta

Re: [R] rbind with different columns

2010-06-21 Thread Daniel Malter
Works wonderfully. I am very happy that I eventually found this post :) Daniel. -- View this message in context: http://r.789695.n4.nabble.com/rbind-with-different-columns-tp907370p2263588.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] rbind, data.frame, classes

2010-03-15 Thread Rob Forler
a hah, that works :) simple but sweet, thanks, Rob On Mon, Mar 15, 2010 at 1:59 PM, Henrique Dallazuanna wrote: > Try this: > > do.call(rbind, lapply(list(list1, list2), as.data.frame)) > > On Mon, Mar 15, 2010 at 3:42 PM, Rob Forler wrote: > > Hi, > > > > This has bugged me for a bit. First

Re: [R] rbind, data.frame, classes

2010-03-15 Thread Henrique Dallazuanna
Try this: do.call(rbind, lapply(list(list1, list2), as.data.frame)) On Mon, Mar 15, 2010 at 3:42 PM, Rob Forler wrote: > Hi, > > This has bugged me for a bit. First question is how to keep classes with > rbind, and second question is how to properly return vecotrs instead of > lists after turnin

[R] rbind, data.frame, classes

2010-03-15 Thread Rob Forler
Hi, This has bugged me for a bit. First question is how to keep classes with rbind, and second question is how to properly return vecotrs instead of lists after turning an rbind of lists into a data.frame list1=list(a=2, b=as.Date("20090102", format="%Y%m%d")) list2=list(a=2, b=as.Date("20090102"

Re: [R] rbind with different columns

2009-10-20 Thread Antje
Karl Ove Hufthammer wrote: In article <4addc1d0.2040...@yahoo.de>, niederlein-rs...@yahoo.de says... In every list entry is a data.frame but the columns are only partially the same. If I have exactly the same columns, I could do the following command to combine my data: do.call("rbind", myLis

Re: [R] rbind with different columns

2009-10-20 Thread Ista Zahn
Nice! I was going to recommend merge(merge(myList[[1]], myList[[2]], all=TRUE, sort=FALSE), myList[[3]], all=TRUE, sort=FALSE) but rbind.fill is better. -Ista On Tue, Oct 20, 2009 at 10:05 AM, Karl Ove Hufthammer wrote: > In article <4addc1d0.2040...@yahoo.de>, niederlein-rs...@yahoo.de > says

Re: [R] rbind with different columns

2009-10-20 Thread Karl Ove Hufthammer
In article <4addc1d0.2040...@yahoo.de>, niederlein-rs...@yahoo.de says... > In every list entry is a data.frame but the columns are only partially > the same. If I have exactly the same columns, I could do the following > command to combine my data: > > do.call("rbind", myList) > > but of cour

[R] rbind with different columns

2009-10-20 Thread Antje
Hello there, with the following dummy code I'd like to give you an idea how my data looks like: df1 <- data.frame(a = rnorm(10), b = rnorm(10)) df2 <- data.frame(a = rnorm(10), c = rnorm(10)) df3 <- data.frame(a = rnorm(10), b = rnorm(10), c = rnorm(10)) myList <- list(df1, df2, df3) # (myLis

Re: [R] rbind to array members‏

2009-10-19 Thread RICHARD M. HEIBERGER
>        z <- abind(x[,,1], c(4,5,6),along=0) z is probably not what you want because you aren't using the drop=FALSE argument. See the FAQ 7.5 abind, and arrays in general, are rectangular solids. They are not ragged. For that you need lists. To get something like your request > x > , , 1 >

Re: [R] rbind to array members‏

2009-10-19 Thread Another Oneforyou
(resent as hotmail really cannot format plaintext, but I've just read Tony Plate's message that what I'd like to do might not be possible) > > library(abind) ## array binding I've looked into using abind() but it seems I might not understand it properly. I can build my 2 table array and insert a

Re: [R] rbind to array members

2009-10-19 Thread Tony Plate
Unfortunately, I can't read your examples. Can you repost without the formatting characters which are confusing when rendered in plain text? One thing to keep in mind is that a R array is a regular object -- e.g., if you have a 2 x 3 x 4 array, then if you want to add a row to a slice, you mus

Re: [R] rbind to array members

2009-10-19 Thread Another Oneforyou
<4adbca02.8020...@temple.edu> Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 >=20 > library(abind) ## array binding I've looked into using abind()=2C but it seems I might not understand it pr= operly. I can build my 2 table arra

Re: [R] rbind to array members

2009-10-18 Thread Richard M. Heiberger
library(abind) ## array binding __ 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-guide.html and provide commented, minimal, self-contained, reproducible

[R] rbind to array members

2009-10-18 Thread Another Oneforyou
Hi, I would like to add rows to arbitrary tables within a 3dimensional array. I can directly add data to an existing row of a table: > x <- array(0,c(1,3,2))> x[,,1] <- c(1,2,3) And I can even add a row to the table and assign to another object. > y <- rbind(x[,,1], c(4,5,6)) and 'y' is what I wan

Re: [R] rbind for a list

2009-09-29 Thread Carlos Hernandez
On Tue, Sep 29, 2009 at 8:05 PM, David Winsemius wrote: > > On Sep 29, 2009, at 1:43 PM, Carlos Hernandez wrote: > > Dear All, >> I´m using the following code: >> >> all1<-gg2[[1]][[1]]; for(i in 1:48){ all1 <- rbind(all1,gg2[[i]][[1]]) } >> > > Looks to me that you would be getting a duplicate c

Re: [R] rbind for a list

2009-09-29 Thread David Winsemius
On Sep 29, 2009, at 1:43 PM, Carlos Hernandez wrote: Dear All, I´m using the following code: all1<-gg2[[1]][[1]]; for(i in 1:48){ all1 <- rbind(all1,gg2[[i]] [[1]]) } Looks to me that you would be getting a duplicate copy of the first matrix, but aside from that what problems are you expe

Re: [R] rbind for a list

2009-09-29 Thread Carlos Hernandez
Thank you for your quick reply! It works perfectly! On Tue, Sep 29, 2009 at 7:51 PM, Henrique Dallazuanna wrote: > Try this; > > do.call(rbind, sapply(gg2, '[', 1)) > > On Tue, Sep 29, 2009 at 2:43 PM, Carlos Hernandez > wrote: > > Dear All, > > I´m using the following code: > > > > all1<-gg2[[1

[R] rbind for a list

2009-09-29 Thread Carlos Hernandez
Dear All, I´m using the following code: all1<-gg2[[1]][[1]]; for(i in 1:48){ all1 <- rbind(all1,gg2[[i]][[1]]) } to create a new matrix that contains all the matrices in a list called gg2. gg2 is a list that looks like >> gg2 [[1]] [[1]][[1]] [[2]] [[2]][[1]] . . . [[48]] [[48]][[1]] Is the

Re: [R] rbind for a list

2009-09-29 Thread Henrique Dallazuanna
Try this; do.call(rbind, sapply(gg2, '[', 1)) On Tue, Sep 29, 2009 at 2:43 PM, Carlos Hernandez wrote: > Dear All, > I´m using the following code: > > all1<-gg2[[1]][[1]]; for(i in 1:48){ all1 <- rbind(all1,gg2[[i]][[1]]) } > > to create a new matrix that contains all the matrices in a list call

Re: [R] rbind

2009-06-22 Thread Patrick Burns
Now that I've actually read the question, I'm in a better position to answer it. I have no idea how you are getting the results that you show, but you can use 'rownames' to set whatever row names you like. As in: rownames(result) <- 1:6 Pat Patrick Burns wrote: I'm guessing that your 'data'

Re: [R] rbind

2009-06-22 Thread Patrick Burns
I'm guessing that your 'data' and 'data1' are just vectors so your 'rbind' command returns a 2 by 3 matrix. Jim showed you already that: rbind(as.matrix(data), as.matrix(data1)) will probably get you what you are looking for. However, I'm suspicious that just: c(data, data1) will serve you j

Re: [R] rbind

2009-06-21 Thread jim holtman
You need to provide a reproducible example. At least provide an 'str' of your data and preferably the output of 'dput'. I am not sure what you data looks like. works fine for me when using matrices: > data [,1] [1,]5 [2,] 2342 [3,] 33 > data1 [,1] [1,]6 [2,]5 [3,]7 >

[R] rbind

2009-06-21 Thread Xiaogang Yang
Hi, I have a array like this data: 1 5 2 2342 3 33 and another data1: 1 6 2 5 3 7 when I do rbind(data,data1) I get not what I want they become 1 5 2 2342 3 33 101 6 102 5 103 7 but I want to make the index as increasing one by one. like 1 .. 2 .. 3 .. 4 .. 5 .. 6 .. So what command I shou

Re: [R] rbind help

2009-05-12 Thread James W. MacDonald
Hi Mike, MikSmith wrote: Hi I have a dataset of orientation and elevation in a dataframe which I am plotting in circular. Orientation is on the range 0-360, however I need to reduce this to 0-180 as the values over 180 are not necessarily correct. I can do striae$orientation[striae$orientation

[R] rbind help

2009-05-12 Thread MikSmith
Hi I have a dataset of orientation and elevation in a dataframe which I am plotting in circular. Orientation is on the range 0-360, however I need to reduce this to 0-180 as the values over 180 are not necessarily correct. I can do striae$orientation[striae$orientation>180]-180) to extract thes

Re: [R] rbind on a list

2009-04-23 Thread David Hajage
Thank you, it is working. David 2009/4/23 Henrique Dallazuanna > Try this: > > lapply(names(col.prop), function(idx)rbind(col.prop[[idx]], n[[idx]])) > > On Thu, Apr 23, 2009 at 7:33 AM, David Hajage wrote: > >> I have two lists (and possibly more): >> >> col.prop <- >> structure(list(B = stru

Re: [R] rbind on a list

2009-04-23 Thread Henrique Dallazuanna
Try this: lapply(names(col.prop), function(idx)rbind(col.prop[[idx]], n[[idx]])) On Thu, Apr 23, 2009 at 7:33 AM, David Hajage wrote: > I have two lists (and possibly more): > > col.prop <- > structure(list(B = structure(c(0.5, 0.5, 0.6, 0.4, 0.556, > 0.444), class = c("

[R] rbind on a list

2009-04-23 Thread David Hajage
I have two lists (and possibly more): col.prop <- structure(list(B = structure(c(0.5, 0.5, 0.6, 0.4, 0.556, 0.444), class = c("cast_matrix", "matrix"), .Dim = 2:3, .Dimnames = list( NULL, NULL)), D = structure(c(1, 0, 0.667, 0.333, 0.8, 0.2), cla

Re: [R] rbind data frames stored in a list

2009-04-22 Thread Dimitri Liakhovitski
Thank you very much, do.call is, of course, much more elegant! Dimitri On Wed, Apr 22, 2009 at 9:58 PM, jim holtman wrote: > 'do.call' is your friend:: > >> a<-data.frame(a=1,b=2,c=3) >> b<-data.frame(a=c(4,7),b=c(5,8),c=c(6,9)) >> c<-data.frame(a=c(10,13,16),b=c(11,14,17),c=c(12,15,18)) >> X<-li

Re: [R] rbind data frames stored in a list

2009-04-22 Thread Dimitri Liakhovitski
Replying to my own post. I found the following solution: full.frame<-as.data.frame(matrix(nrow=0,ncol=3)) names(full.frame)<-c("a","b","c") for(j in 1:length(X)) {full.frame<-rbind(full.frame,X[[j]])} (full.frame) Is there a more elegant solution? Thank you! Dimitri On Wed, Apr 22, 2009 at 9:36

Re: [R] rbind data frames stored in a list

2009-04-22 Thread jim holtman
'do.call' is your friend:: > a<-data.frame(a=1,b=2,c=3) > b<-data.frame(a=c(4,7),b=c(5,8),c=c(6,9)) > c<-data.frame(a=c(10,13,16),b=c(11,14,17),c=c(12,15,18)) > X<-list() > X[[1]]<-a > X[[2]]<-b > X[[3]]<-c > do.call(rbind, X) a b c 1 1 2 3 2 4 5 6 3 7 8 9 4 10 11 12 5 13 14 15 6 16

Re: [R] rbind data frames stored in a list

2009-04-22 Thread Bert Gunter
oject.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Wednesday, April 22, 2009 6:36 PM To: R-Help List Subject: [R] rbind data frames stored in a list Hello everyone! I have a list X with 3 elements, each of which is a data frame, for example: a<-dat

Re: [R] rbind data frames stored in a list

2009-04-22 Thread Marc Schwartz
On Apr 22, 2009, at 8:36 PM, Dimitri Liakhovitski wrote: Hello everyone! I have a list X with 3 elements, each of which is a data frame, for example: a<-data.frame(a=1,b=2,c=3) b<-data.frame(a=c(4,7),b=c(5,8),c=c(6,9)) c<-data.frame(a=c(10,13,16),b=c(11,14,17),c=c(12,15,18)) X<-list() X[[1

[R] rbind data frames stored in a list

2009-04-22 Thread Dimitri Liakhovitski
Hello everyone! I have a list X with 3 elements, each of which is a data frame, for example: a<-data.frame(a=1,b=2,c=3) b<-data.frame(a=c(4,7),b=c(5,8),c=c(6,9)) c<-data.frame(a=c(10,13,16),b=c(11,14,17),c=c(12,15,18)) X<-list() X[[1]]<-a X[[2]]<-b X[[3]]<-c (X) How can I most effectively transf

Re: [R] rbind: number of columns of result is not a multiple of vector length (arg 1)

2009-02-17 Thread jim holtman
You could 'split' the dataframe and then write out each element: something like x <- split(data.info, data.info$station.id) for (i in names(x)) write.csv(x[[i]], file=paste(i, ".csv", sep="")) On Tue, Feb 17, 2009 at 10:11 PM, CJ Rubio wrote: > > it works perfectly thank you for your help...

  1   2   >