Re: [R] Using map with filled.contour doesn't display map

2016-11-04 Thread Jeff Charlton
Hi David, Thank you for the response. I apologize that I didn't give a more complete example. Here's code that recreates the issue I'm having on my system. You'll have to enter the path to your packages and where you want to store the downloaded file. library("maps", lib.loc="")

Re: [R] Using map with filled.contour doesn't display map

2016-11-04 Thread David Winsemius
> On Nov 4, 2016, at 11:26 AM, Jeff Charlton wrote: > > Hello, > > I'm trying to overlay a map on top of data showing temperatures across the > world. The code I'm using is: > > filledContour(tempdata, plot.axes={axis(1); axis(2); map("world2", > add=TRUE)}) > >

Re: [R] loop with variable names

2016-11-04 Thread Ista Zahn
It's hard to imagine a situation where this makes sense, but of course you can do it if you want. Perhaps rhs <- unlist(sapply(1:(ncol(df)-1), function(x) apply(combn(names(df)[-1], x), 2, paste, collapse = " + "))) lapply(rhs, function(x) lm(as.formula(paste("y ~", x)), data = df)) --Ista On

[R] Using map with filled.contour doesn't display map

2016-11-04 Thread Jeff Charlton
Hello, I'm trying to overlay a map on top of data showing temperatures across the world. The code I'm using is: filledContour(tempdata, plot.axes={axis(1); axis(2); map("world2", add=TRUE)}) where tempdata is a raster file made from a netcdf file downloaded from the NOAA website. The

[R] loop with variable names

2016-11-04 Thread paolo brunori
Suppose I have the following data: y<-rnorm(10) age<-rnorm(10) sex<-rbinom(10,1, 0.5) edu<-round(runif(10, 1, 20)) edu2<-edu^2 df<-data.frame(y,age,sex,edu,edu2) I want to run a large number of models, for example: lm(y~age) lm(y~age+sex) lm(y~age+sex+edu) lm(y~age+sex+edu+edu2)

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread David Winsemius
> On Nov 4, 2016, at 1:39 PM, C W wrote: > > Dear R list, > > Every time I start R, the following error message come up: > > *** caught segfault *** > address 0x0, cause 'unknown' > > Possible actions: > 1: abort (with core dump, if enabled) > 2: normal R exit > 3: exit R

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Bert Gunter
OK, just for fun, I added a couple of *obvious* (or should have been) approaches and got results that exactly agreed with Peter D's comments: all O(n^2) results were essentially the same, and my matrix multiplication O(n^3) solution was **far** worse. So I'm not sure quite where Jeff's result

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Stefan Evert
> On 4 Nov 2016, at 17:35, peter dalgaard wrote: > > Notice though, that Bert loses (or _should_ lose) for larger values of N, > since that method involves O(N^3) operations whereas the other two are > O(N^2). I am a bit surprised that sweep() is so inefficient even at

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread C W
Here's the sessionInfo() > sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: macOS Sierra 10.12.1 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread C W
I just got the following error instead of the previous one, 2016-11-04 16:50:08.446 R[23372:326103] -[NSDrawerWindow setRuleThickness:]: unrecognized selector sent to instance 0x7fabc94a74b0 2016-11-04 16:50:08.454 R[23372:326103] *** RController: caught ObjC exception while processing system

[R] R segfault at startup, causing R crash

2016-11-04 Thread C W
Dear R list, Every time I start R, the following error message come up: *** caught segfault *** address 0x0, cause 'unknown' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace > Selection: I am unable to do a

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Jeff Newmiller
If you want to get a comparable result, then run the same code. You may not want a comparable result though... your version straightens out the issue Peter was puzzled by. -- Sent from my phone. Please excuse my brevity. On November 4, 2016 11:35:02 AM PDT, Berend Hasselman

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Dimitri Liakhovitski
I love R for it: if you experiment enough with t() you can find a way to multiply almost anything by almost anything! :) On Thu, Nov 3, 2016 at 5:32 PM, Rui Barradas wrote: > Hello, > > Take advantage that in R '*' recycles its arguments (the shorter one) and > that the

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Bert Gunter
Berend, et. al.: "I don't quite understand why I get a very different ranking." Nor do I. But, as Peter noted, my matrix multiplication solution "should" be worst in terms of efficiency, and it clearly is. The other two *should* be "similar", and they are. So your results are consistent with

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Berend Hasselman
> On 4 Nov 2016, at 19:27, Berend Hasselman wrote: > >> >> On 4 Nov 2016, at 16:41, Jeff Newmiller wrote: >> >> Sara wins on memory use. >> >> Rui wins on speed. >> >> Bert wins on clarity. >> >> library(microbenchmark) >> >> N <- 1000 >> x <-

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Berend Hasselman
> On 4 Nov 2016, at 16:41, Jeff Newmiller wrote: > > Sara wins on memory use. > > Rui wins on speed. > > Bert wins on clarity. > > library(microbenchmark) > > N <- 1000 > x <- matrix( runif( N*N ), ncol=N ) > y <- seq.int( N ) > > microbenchmark( { t( y * t(x) ) }

[R] [R-pkgs] Major Update to rms package: 5.0-0

2016-11-04 Thread Frank Harrell
A major new version of the rms package is now on CRAN. The most user-visible changes are: - interactive plotly graphic methods for model fits. The best example of this is survplot for npsurv (Kaplan-Meier) estimates where the number of risk pop up as you hover over the curves, and you can click

[ESS] ESS on an odd setup

2016-11-04 Thread Gavin Kelly
Hello My work's computer facilities have only just been set up, and the sysadmin has decided to go for an easybuild module system, which means that to start R, I need to type "module load R" to get the environment set correctly - unless I do that, R doesn't appear to be installed.

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread peter dalgaard
Notice though, that Bert loses (or _should_ lose) for larger values of N, since that method involves O(N^3) operations whereas the other two are O(N^2). I am a bit surprised that sweep() is so inefficient even at N=1000. -pd On 04 Nov 2016, at 16:41 , Jeff Newmiller

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Jeff Newmiller
Sara wins on memory use. Rui wins on speed. Bert wins on clarity. library(microbenchmark) N <- 1000 x <- matrix( runif( N*N ), ncol=N ) y <- seq.int( N ) microbenchmark( { t( y * t(x) ) } , { x %*% diag( y ) } , { sweep( x, 2, y, `*` ) } ) Unit:

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Dimitri Liakhovitski
Nice! Thanks a lot, everybody! Dimitri On Fri, Nov 4, 2016 at 10:35 AM, Bert Gunter wrote: > My goodness! > >> x %*% diag(y) > > [,1] [,2] > [1,]2 12 > [2,]4 15 > [3,]6 18 > > will do. > > -- Bert > > > > Bert Gunter > > "The trouble with having an

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

2016-11-04 Thread Bert Gunter
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

[R] [R-pkgs] new package: rpostgisLT

2016-11-04 Thread David Bucklin
We're announcing the initial CRAN release of 'rpostgisLT' (v0.4.0), which is an extension to our 'rpostgis ' package. rpostgisLT is aimed at those using R and/or the PostgreSQL/PostGIS database system to manage and analyze animal

Re: [R] multiplying a matrix by a vector

2016-11-04 Thread Bert Gunter
My goodness! > x %*% diag(y) [,1] [,2] [1,]2 12 [2,]4 15 [3,]6 18 will do. -- Bert 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

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

2016-11-04 Thread Carlos Ortega
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

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

2016-11-04 Thread Charles Determan
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

[R] Converting a list to a data frame

2016-11-04 Thread Kevin E. Thorpe
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

Re: [R] When customizing last line, the code stops working

2016-11-04 Thread Frank S.
A clarification regarding my previous post for those ineterested in the issue: Looking carefully at Duncan's solution, the key point would be introducing envir = environment() as argument of lapply function (the default envir of do.call function is parent.frame() ). ) union <- do.call(

[R] Continuous Wavelet tranform in Biwavelet Package

2016-11-04 Thread FMH via R-help
Dear All, I have 15 minutes of temperature data for 3 years and would like calculate and plot the CWT using wt command in Biwavelet package. Appreciate if someone could tell me the way to define it in wt command. Thank you, [[alternative HTML version deleted]]