ot;list" over 1 million rows. It is possible to
work with a matrix in ggplot2?
Jeff
-Original Message-
From: Duncan Murdoch
Sent: Saturday, July 24, 2021 12:03 PM
To: reichm...@sbcglobal.net; R-help@r-project.org
Subject: Re: [R] Converting a list to a data frame
Others hav
Thanks for the tips
-Original Message-
From: Rui Barradas
Sent: Saturday, July 24, 2021 11:40 AM
To: reichm...@sbcglobal.net; R-help@r-project.org
Subject: Re: [R] Converting a list to a data frame
Hello,
This should do it:
as.data.frame(weight_chains$mcmc)
The only list member
million rows. It is possible to
work with a matrix in ggplot2?
Jeff
-Original Message-
From: Duncan Murdoch
Sent: Saturday, July 24, 2021 12:03 PM
To: reichm...@sbcglobal.net; R-help@r-project.org
Subject: Re: [R] Converting a list to a data frame
Others have shown you how to e
4, 2021 12:03 PM
To: reichm...@sbcglobal.net; R-help@r-project.org
Subject: Re: [R] Converting a list to a data frame
Others have shown you how to extract the matrix and convert it to a dataframe.
My only addition is to suggest that you don't do this:
matrix methods are often much more effi
Others have shown you how to extract the matrix and convert it to a
dataframe. My only addition is to suggest that you don't do this:
matrix methods are often much more efficient than dataframe methods, so
if you can work with the matrix without conversion, you'll often find
things run a lot
Hello,
This should do it:
as.data.frame(weight_chains$mcmc)
The only list member already has a dim attribute of length 2 and
dimnames' 2nd member are the colnames, just coerce to df.
Hope this helps,
Rui Barradas
Às 14:18 de 24/07/21, Jeff Reichman escreveu:
How does one convert a list
Here is a reprex that does what I think you want:
ex <- list(mcmc = matrix(1:12, ncol = 3, byrow=TRUE),
NULL, c("a","b", "s"))
dex <- data.frame(ex$mcmc)
names(dex) <- ex[[3]]
> dex
a b s
1 1 2 3
2 4 5 6
3 7 8 9
4 10 11 12
If this is not correct, you should provide a
How does one convert a list into a data frame?
> str(weight_chains)
List of 1
$ : 'mcmc' num [1:10, 1:3] -105 -105 -105 -104 -103 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:3] "a" "b" "s"
..- attr(*, "mcpar")= num [1:3] 1001 101000 1
- attr(*,
ct.org>
Subject: Re: [R] Converting a list to a data frame
It looks like you made a copy/paste error below. Your ata.frame should
be data.frame.
Kevin
On 05/04/2018 08:18 AM, Bill Poling wrote:
> Good morning.
>
> Novice usR. Here.
>
> I am following this string, among many, lea
;ata.frame"?
William H. Poling, Ph.D.
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Huzefa Khalil
Sent: Wednesday, May 02, 2018 1:24 PM
To: Kevin E. Thorpe <kevin.tho...@utoronto.ca>
Cc: R Help Mailing List <r-help@r-project.org>
Subject: Re: [R] Converting a list
May 02, 2018 1:24 PM
*To:* Kevin E. Thorpe <kevin.tho...@utoronto.ca>
*Cc:* R Help Mailing List <r-help@r-project.org>
*Subject:* Re: [R] Converting a list to a data frame
Hi Kevin,
There is probably a better way, but it can be done in two steps like this
temp <- list(A=data.frame
If you require that the 'type' column be a factor with a level for each
element of the input list, then you need to do that after calling
dplyr::bind_rows(), just as with the base-R solutions.
> l <- list( A = data.frame(X=1:2, Y=11:12), B = data.frame(X=integer(),
Y=integer()), C =
On 05/03/2018 01:28 PM, Hadley Wickham wrote:
On Wed, May 2, 2018 at 11:53 AM, Jeff Newmiller
wrote:
Another approach:
library(tidyr)
L <- list( A = data.frame( x=1:2, y=3:4 )
, B = data.frame( x=5:6, y=7:8 )
)
D <- data.frame( Type =
On Wed, May 2, 2018 at 11:53 AM, Jeff Newmiller
wrote:
> Another approach:
>
>
> library(tidyr)
> L <- list( A = data.frame( x=1:2, y=3:4 )
> , B = data.frame( x=5:6, y=7:8 )
> )
> D <- data.frame( Type = names( L )
>,
A NA NA NA NA ...
--
David, the other.
>
> David C
>
> -Original Message-
> From: R-help <r-help-boun...@r-project.org> On Behalf Of David L Carlson
> Sent: Wednesday, May 2, 2018 3:51 PM
> To: William Dunlap <wdun...@tibco.com>; Kevin E. Thorpe
vin.tho...@utoronto.ca>
Cc: r-help mailing list <r-help@r-project.org>
Subject: Re: [R] Converting a list to a data frame
Or add the type column first and then rbind:
x <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
x2 <- do.call(rbind, lapply(names
Carlson
> Sent: Wednesday, May 2, 2018 3:51 PM
> To: William Dunlap <wdun...@tibco.com>; Kevin E. Thorpe
> <kevin.tho...@utoronto.ca>
> Cc: r-help mailing list <r-help@r-project.org>
> Subject: Re: [R] Converting a list to a data frame
>
> Or add the type c
On 05/03/2018 07:58 AM, Jeff Newmiller wrote:
This is very nice to learn about, Denis, but it seems only fair to point out
that the result of rbindlist is not a data frame. You can convert it to a data
frame easily, but the copy and indexing semantics of data tables are quite
different than
This is very nice to learn about, Denis, but it seems only fair to point out
that the result of rbindlist is not a data frame. You can convert it to a data
frame easily, but the copy and indexing semantics of data tables are quite
different than data tables, which could be a real headache for
lson
Sent: Wednesday, May 2, 2018 3:51 PM
To: William Dunlap <wdun...@tibco.com>; Kevin E. Thorpe
<kevin.tho...@utoronto.ca>
Cc: r-help mailing list <r-help@r-project.org>
Subject: Re: [R] Converting a list to a data frame
Or add the type column first and then rbind:
x <- lis
.org>
Subject: Re: [R] Converting a list to a data frame
> x1 <- do.call(rbind, c(x, list(make.row.names=FALSE)))
> x2 <- cbind(type=rep(names(x), vapply(x, nrow, 0)), x1)
> str(x2)
'data.frame': 4 obs. of 3 variables:
$ type: Factor w/ 2 levels "A","B": 1 1 2
On 05/02/2018 07:11 PM, Kevin E. Thorpe wrote:
I suspect this is pretty easy, but I'm having trouble figuring it out.
Basically, I have a list of data frames such as the following example:
list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
I would like to turn this into data frame
Another approach:
library(tidyr)
L <- list( A = data.frame( x=1:2, y=3:4 )
, B = data.frame( x=5:6, y=7:8 )
)
D <- data.frame( Type = names( L )
, stringsAsFactors = FALSE
)
D$data <- L
unnest(D, data)
#> Type x y
#> 1A 1 3
#> 2A
On Wed, 2 May 2018, Kevin E. Thorpe wrote:
I suspect this is pretty easy, but I'm having trouble figuring it out.
Basically, I have a list of data frames such as the following example:
list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
I would like to turn this into data frame where
> x1 <- do.call(rbind, c(x, list(make.row.names=FALSE)))
> x2 <- cbind(type=rep(names(x), vapply(x, nrow, 0)), x1)
> str(x2)
'data.frame': 4 obs. of 3 variables:
$ type: Factor w/ 2 levels "A","B": 1 1 2 2
$ x : int 1 2 5 6
$ y : int 3 4 7 8
Bill Dunlap
TIBCO Software
wdunlap
Hi Kevin,
There is probably a better way, but it can be done in two steps like this
temp <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
temp <- lapply(names(temp), function(n, temp) {
temp[[n]]$type <- n
return(temp[[n]])
}, temp = temp)
do.call(rbind, temp)
On Wed, May
I suspect this is pretty easy, but I'm having trouble figuring it out.
Basically, I have a list of data frames such as the following example:
list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
I would like to turn this into data frame where the list elements are
essentially rbind'ed
I believe that a slightly more efficient way of doing this without
leaving base R is:
cbind(do.call(rbind,x), set = rep(seq_along(x), vapply(x,nrow,1)) )
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka
Hi,
You have also "rbindlist()" function in package "data.table" that does
exactly what you need.
Kind Regards,
Carlos Ortega
www.qualityexcellence.es
2016-11-04 13:37 GMT+01:00 Kevin E. Thorpe :
> There is probably a very simple elegant way to do this, but I have
Hi Kevin,
There may be a more elegant way but the following do.call and lapply should
solve your problem.
do.call(rbind, lapply(seq(length(x)), function(i) data.frame(set=i,
x[[i]])))
Regards,
Charles
On Fri, Nov 4, 2016 at 7:37 AM, Kevin E. Thorpe
wrote:
> There is
There is probably a very simple elegant way to do this, but I have been
unable to find it. Here is a toy example. Suppose I have a list of data
frames like this.
print(x <-
list('1'=data.frame(id=1:4,expand.grid(x1=0:1,x2=0:1)),'2'=data.frame(id=5:8,expand.grid(x1=2:3,x2=2:3
$`1`
id
I have a column in which dates and times are specified thus
m/d/ HH:MM:SS
Alas, some entries do not include the time and therefore are only
m/d/
so I used read.csv and specified that the relevant column should be read as
is and it remained as a character variable.
I then split the value on
32 matches
Mail list logo