Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Eric Berger
For what it's worth, for larger vectors, and following on from your observation that the do.call() approach is faster, the following provides some modest additional speedup: cbind(x,t(do.call(cbind, lapply(x, function(y) vec Rgds, Eric On Tue, Jul 3, 2018 at 8:12 PM, Viechtbauer, Wolfgang

Re: [R] R maintains old values

2018-07-03 Thread Berry, Charles
> On Jul 3, 2018, at 6:25 AM, J C Nash wrote: > > Now, to add to the controversy, how do you set a computer on fire? >From the bash prompt: stuxnet --overload=cpu,disk,network,gpu --fan=off --no-warnings HTH, Chuck __ R-help@r-project.org maili

[R] ASExtras library

2018-07-03 Thread Mehrshad Barary
Hi Everyone, Does anybody know how I can get ASExtras library? Thanks Mehrshad -- Mehrshad Barary Senior Lecturer in Crop Ecophysiology Department of Agronomy and Plant Breeding Faculty of Agriculture Ilam University Tel: (+98)8412227019-21 Fax: (+98)8412227015 [[alternative HTML vers

Re: [R] ggplot2 version 3

2018-07-03 Thread Roy Mendelssohn - NOAA Federal via R-help
Thanks! -Roy > On Jul 3, 2018, at 2:40 PM, William Dunlap wrote: > > One way to test the new ggplot2 is to make a new directory to use as an R > library and to install the new ggplot2 there. >newLibrary <- "C:/tmp/newRLibrary" >dir.create(newLibrary) >install.packages("ggplot2", l

Re: [R] ggplot2 version 3

2018-07-03 Thread William Dunlap via R-help
One way to test the new ggplot2 is to make a new directory to use as an R library and to install the new ggplot2 there. newLibrary <- "C:/tmp/newRLibrary" dir.create(newLibrary) install.packages("ggplot2", lib=newLibrary) Then you can run two R sessions at once, starting one with .libPa

Re: [R] prod(NaN, NA) vs. prod(NA, NaN)

2018-07-03 Thread Rolf Turner
On 04/07/18 00:24, Martin Møller Skarbiniks Pedersen wrote: Hi, I am currently using R v3.4.4 and I just discovered this: prod(NA, NaN) ; prod(NaN, NA) [1] NA [1] NaN ?prod says: If ‘na.rm’ is ‘FALSE’ an ‘NA’ value in any of the arguments will cause a value of ‘NA’ to be retu

[R] ggplot2 version 3

2018-07-03 Thread Roy Mendelssohn - NOAA Federal via R-help
Hi All: When I ask about updating packages in my R distribution, it lists ggplot2 version 3.0.0 as being available. I know that ggplot2 version 3.0.0 has made some significant changes that will break certain things. I would like to install the new version, to see if it breaks anything that I

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Viechtbauer, Wolfgang (SP)
Thanks for all of the suggestions. I did some benchmarking: library(microbenchmark) x <- 1:5 vec <- c(2,4,3) fastWolfgang <- function(v, vec) matrix(c(v, rep(vec, each = length(v))), nrow = length(v)) microbenchmark(cbind(x, t(replicate(length(x), vec))), t(sapply(x, function(

[R] FW: Structure to ts Error in attributes(.Data) <- c(attributes(.Data), attrib) :

2018-07-03 Thread Bill Poling
Hi, I have my solution. It should be .Tsp=c(2016,2018.417,12) (off by one error) Thank you. WHP From: Bill Poling Sent: Tuesday, July 03, 2018 11:24 AM To: r-help (r-help@r-project.org) Cc: Bill Poling Subject: Structure to ts Error in attributes(.Data) <- c(attributes(.Data), attrib) :

Re: [R] Structure to ts Error in attributes(.Data) <- c(attributes(.Data), attrib) :

2018-07-03 Thread Eric Berger
Hi WHP, It should be .Tsp=c(2016,2018.417,12) (off by one error) HTH, Eric On Tue, Jul 3, 2018 at 6:23 PM, Bill Poling wrote: > Hi, obviously missing something here? Getting error: Error in > attributes(.Data) <- c(attributes(.Data), attrib) : invalid time series > parameters specified >

Re: [R] R maintains old values

2018-07-03 Thread Ted Harding
On Tue, Jul 3, 2018 at 9:25 AM, J C Nash wrote: > > > . . . Now, to add to the controversy, how do you set a computer on fire? > > > > JN Perhaps by exploring the context of this thread, where new values strike a match with old values??? Ted __ R-hel

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Jeff Newmiller
Sorry trying again... fastWolfgang <- function( v, vec ) { matrix( c( v, rep( vec, each = length( v ) ) ) , nrow = length( v ) ) } On July 3, 2018 8:21:47 AM PDT, Jeff Newmiller wrote: >Gabor's solution seems to optimize 'simpler'. > >More efficient is to learn that in R a vector is n

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Gabor Grothendieck
or this variation if you don't want the first column to be named init: Reduce(cbind2, vec, 1:5) On Tue, Jul 3, 2018 at 10:46 AM, Gabor Grothendieck wrote: > Try Reduce: > > Reduce(cbind, vec, 1:5) > > On Tue, Jul 3, 2018 at 9:28 AM, Viechtbauer, Wolfgang (SP) > wrote: >> Hi All, >> >> I have

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Jeff Newmiller
Gabor's solution seems to optimize 'simpler'. More efficient is to learn that in R a vector is not a matrix, but a matrix is just an ornamented vector. fastWolfgang <- function( v, vec ) { matrix( c( v, rep( vec, length( v ) ) ) , now = length( v ) ) } On July 3, 2018 6:28:45 AM PDT,

[R] Structure to ts Error in attributes(.Data) <- c(attributes(.Data), attrib) :

2018-07-03 Thread Bill Poling
Hi, obviously missing something here? Getting error: Error in attributes(.Data) <- c(attributes(.Data), attrib) : invalid time series parameters specified dat3 <- structure(c(1439713.32, 1265962.79, 1491834.9, 1276180.74, 1702077.51, 1420186.1, 1469240.11, 1415855.34, 1592933.06, #9

[R] limit windows() rescale/resize options

2018-07-03 Thread Derek Ogle
I am developing an application that opens an image in a new window using, at times, windows(). I don't want the user to be able to resize the window (and distort the image). The new window contains a menu item called "resize" that contains three options - "R mode", "Fit to window", and "Fixed si

Re: [R] R-help Digest, Vol 185, Issue 1

2018-07-03 Thread Nina Schönfelder
Dear Luke, it true that the number is not immediately displayed in the GMM-regression output using the plm package. To get the number of instruments (incl. exogenous variables and time dummies) you have to type:   k <- model    # so that k is the pgmm-estimation output (an object of class

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Gabor Grothendieck
Try Reduce: Reduce(cbind, vec, 1:5) On Tue, Jul 3, 2018 at 9:28 AM, Viechtbauer, Wolfgang (SP) wrote: > Hi All, > > I have one vector that I want to combine with another vector and that other > vector should be the same for every row in the combined matrix. This > obviously does not work: >

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread PIKAL Petr
Hi If you put 1:5 vector to x you could do cbind(x,t(replicate(length(x), vec))) Cheers Petr Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processin

Re: [R] R maintains old values

2018-07-03 Thread Christopher W Ryan
This TV series might have some advice on that. https://www.imdb.com/title/tt2543312/ --Chris Ryan On Tue, Jul 3, 2018 at 9:25 AM, J C Nash wrote: > . . . Now, to add to the controversy, how do you set a computer on fire? > > JN > > [[alternative HTML version deleted]] ___

Re: [R] R maintains old values

2018-07-03 Thread peter dalgaard
> On 3 Jul 2018, at 15:25 , J C Nash wrote: > > For the sake of those who didn't see the link, Jenny objects strongly to > startup > lines that either set a personal path or clear the workspace. > > While I agree both of these are anti-social to the point of pathology for > scripts > that a

Re: [R] R maintains old values

2018-07-03 Thread JRG
On 07/03/2018 09:25 AM, J C Nash wrote: > For the sake of those who didn't see the link, Jenny objects strongly to > startup > lines that either set a personal path or clear the workspace. > > While I agree both of these are anti-social to the point of pathology for > scripts > that are distri

[R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Viechtbauer, Wolfgang (SP)
Hi All, I have one vector that I want to combine with another vector and that other vector should be the same for every row in the combined matrix. This obviously does not work: vec <- c(2,4,3) cbind(1:5, vec) This does, but requires me to specify the correct value for 'n' in replicate(): cbi

Re: [R] R maintains old values

2018-07-03 Thread J C Nash
For the sake of those who didn't see the link, Jenny objects strongly to startup lines that either set a personal path or clear the workspace. While I agree both of these are anti-social to the point of pathology for scripts that are distributed, I have found it VERY important when testing things

[R] prod(NaN, NA) vs. prod(NA, NaN)

2018-07-03 Thread Martin Møller Skarbiniks Pedersen
Hi, I am currently using R v3.4.4 and I just discovered this: > prod(NA, NaN) ; prod(NaN, NA) [1] NA [1] NaN ?prod says: If ‘na.rm’ is ‘FALSE’ an ‘NA’ value in any of the arguments will cause a value of ‘NA’ to be returned, otherwise ‘NA’ values are ignored. So according to the m

Re: [R] R maintains old values

2018-07-03 Thread peter dalgaard
Also beware the traveling arsonist, Jenny Bryan: https://www.tidyverse.org/articles/2017/12/workflow-vs-script/ -pd > On 2 Jul 2018, at 17:11 , Bert Gunter wrote: > > ... or perhaps > > rm( list = ls(all = TRUE)) > ## see ?ls for details. > > However, see ?Startup for how to start a R in a

Re: [R] doMPI: script hangs on closeCluster

2018-07-03 Thread Loris Bennett
Loris Bennett writes: > Hi, > > On Linux with R 3.5.1 and OpenMPI 2.1.0 I have built Rmpi and can run a > simple example just using Rmpi and printing out the rank of each worker. > > However, when I try to use doMPI by running the following > > library(Rmpi) > library(doMPI) > cl <- startMP