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
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
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
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
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
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
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
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
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,
>
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
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
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:
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
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
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, '[
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,
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
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
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
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
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
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
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
>
?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
-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
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)
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
> $
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 =
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
_
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
> &
;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
> -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
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
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
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
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
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
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
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.
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
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
> 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
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-
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()
>
>
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
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
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.
___
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
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
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"
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
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
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
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
> 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
>
(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
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
<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
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
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
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
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
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
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
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
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'
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
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
>
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
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
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
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
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("
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
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
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
'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
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
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
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
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 - 100 of 117 matches
Mail list logo