Re: [R] Converting a list to a data frame

2021-07-24 Thread Duncan Murdoch
On 24/07/2021 5:40 p.m., Rui Barradas wrote: Hello, No, it's not possible to work with a matrix in ggplot2. Not even with an object of class "list". If that's the main thing Jeff is doing, then he should convert to a dataframe. But it *is* possible to work with the original matrix in

Re: [R] Converting a list to a data frame

2021-07-24 Thread Jeff Reichman
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

Re: [R] Converting a list to a data frame

2021-07-24 Thread Rui Barradas
Hello, No, it's not possible to work with a matrix in ggplot2. Not even with an object of class "list". l <- list(x=1:5, y=1:5) d <- as.data.frame(l) m <- as.matrix(d) library(ggplot2) ggplot(l, aes(x, y)) + geom_point() # Error ggplot(d, aes(x, y)) + geom_point() # OK, as expected

Re: [R] Converting a list to a data frame

2021-07-24 Thread Jeff Reichman
Duncan I need to plot the results (ggplot2) and I'm thinking I can only use a data.frame object in ggplot2. It is a rath r large "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

Re: [R] Sin curve question

2021-07-24 Thread Rui Barradas
Hello, You can use stat_function, it will take care of all the details, all you have to do is to pass xlim. library(ggplot2) library(cowplot) ggplot() + stat_function(fun = sin, xlim = c(0, pi)) + xlab("x") + ylab("sin(x)") + scale_x_continuous(breaks = seq(0, pi, pi/6), labels =

Re: [R] Sin curve question

2021-07-24 Thread Jeff Newmiller
This is not excel-help, but to the best of my knowledge Excel interpolates with splines when you select curved point interpolation. R, being primarily a science tool rather than a business tool, assumes you want to be precise about how new points are to be interpolated between original data

Re: [R] Sin curve question

2021-07-24 Thread Spencer Graves
plot(sin, to=pi) # also works but with x labeled in radians. # With x axis labeled in degrees plot(sin, to=pi, axes=FALSE) axis(2) lbls <- seq(0, 180, 30) axis(1, pi*lbls/180, lbls) This can probably be done in ggplot2, but I don't know how off the top of my head. Hope this

Re: [R] Sin curve question

2021-07-24 Thread Eric Berger
Alternatively with base graphics N <- 500 ## number of points (arbitrary) degrees <- seq(from=0,to=180,length=N) degreesToRadians <- function(d) { pi * d / 180.0} ## vectorIzed! plot(x=degrees,y=sin(degreesToRadians(degrees)),type='l', xlab="x",ylab="sin(x)",main="sin(x) vs x\nx is in

Re: [R] Sin curve question

2021-07-24 Thread Sorkin, John
Try something like the following copdat$degrees <- c(1:180) John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC

[R] Sin curve question

2021-07-24 Thread Thomas Subia via R-help
Colleagues, Here is my code which plots sin(x) vs x, for angles between 0 and 180 degrees. library(ggplot2) library(REdaS) copdat$degrees <- c(0,45,90,135,180) copdat$radians <- deg2rad(copdat$degrees) copdat$sin_x <- sin(copdat$radians) ggplot(copdat,aes(x=degrees,y=sin_x))+ geom_point(size

Re: [R] Converting a list to a data frame

2021-07-24 Thread Duncan Murdoch
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

Re: [R] Converting a list to a data frame

2021-07-24 Thread Rui Barradas
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

Re: [R] Testing for R CMD INSTALL

2021-07-24 Thread Duncan Murdoch
On 24/07/2021 11:22 a.m., Andrew Simmons wrote: Hello, I was wondering if anyone has a way to test if a package is currently being installed. My solution was to check if environment variable "R_INSTALL_PKG" was unset, something like: "R CMD INSTALL-ing" <- function ()

Re: [R] Testing for R CMD INSTALL

2021-07-24 Thread Bert Gunter
Does ?installed.packages help? Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Jul 24, 2021 at 8:30 AM Andrew Simmons wrote: > Hello, > > > I was

Re: [R] Makefile error

2021-07-24 Thread Ivan Krylov
On Sat, 24 Jul 2021 11:19:41 + (UTC) Bintao Cui via R-help wrote: > Makefile.in:87: *** missing separator.  Stop. Thanks for showing us the error message, but this isn't enough information. In order to be able to help, we also need to know what exactly you did to get the error message.

[R] Testing for R CMD INSTALL

2021-07-24 Thread Andrew Simmons
Hello, I was wondering if anyone has a way to test if a package is currently being installed. My solution was to check if environment variable "R_INSTALL_PKG" was unset, something like: "R CMD INSTALL-ing" <- function () !is.na(Sys.getenv("R_INSTALL_PKG", NA)) Unfortunately, I couldn't find

[R] Makefile error

2021-07-24 Thread Bintao Cui via R-help
Makefile.in:87: *** missing separator.  Stop. I am trying to install R-4.1.0 version to fedora, and got the error above, please help! Thanks. With regards,Bintao __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Converting a list to a data frame

2021-07-24 Thread Bert Gunter
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

[R] Converting a list to a data frame

2021-07-24 Thread Jeff Reichman
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(*,

Re: [R] How to select rows, not in sequence

2021-07-24 Thread Neha gupta
Thanks a lot Sir, indeed it resolved my issue. Warm regards On Sat, Jul 24, 2021 at 1:51 PM Rui Barradas wrote: > Hello, > > Simply by also passing a vector to the extraction function: > > > rows= df[c(1,2,5,7,12) , ] > > > Hope this helps, > > Rui Barradas > > Às 12:38 de 24/07/21, Neha gupta

Re: [R] How to select rows, not in sequence

2021-07-24 Thread Rui Barradas
Hello, Simply by also passing a vector to the extraction function: rows= df[c(1,2,5,7,12) , ] Hope this helps, Rui Barradas Às 12:38 de 24/07/21, Neha gupta escreveu: Hi If I have to select specific rows and all columns of a dataframe, I use: rows= df[1:12 , ] However, how to select

[R] How to select rows, not in sequence

2021-07-24 Thread Neha gupta
Hi If I have to select specific rows and all columns of a dataframe, I use: rows= df[1:12 , ] However, how to select rows if our required rows are not in sequence i.e. if we need to select row numbers 1,2,5,7, and 12.. Warm regards [[alternative HTML version deleted]]