[R] Benefit of Iterators (package iterator)

2016-12-08 Thread Doran, Harold
R-Help (and package author) I'm trying to understand within the context of R what the benefit of using an iterator is. My only goal in using the foreach package is to improve computational speed with some embarrassingly parallel tasks I have to compute. I took the example found at the link belo

Re: [R] Benefit of Iterators (package iterator)

2016-12-08 Thread Thierry Onkelinx
Dear Harold, I get a different story library(doParallel) library(microbenchmark) cl <- makeCluster(4) registerDoParallel(cl) x <- matrix(rnorm(100), ncol=1000) itx <- iter(x, by='row') microbenchmark( iterator = foreach(i=itx, .combine=c) %dopar% mean(i), base = foreach(i= 1:nrow(x), .com

[R] sample train and test data using dplyr

2016-12-08 Thread Partha Sinha
I want to create two files train and test using dplyr (by random sampling method). How to do the same same using lets say iris data. Regards Parth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and mo

[R] double metaphone for non-English languages

2016-12-08 Thread Dimitri Liakhovitski
Hello! I am processing some strings using package "PGRdup". I using function 'DoubleMetaphone' to generate the double metaphone codes of strings - to match words that sound alike (in case they were written differently). However, I got some French and German strings and discovered that DoubleMetap

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Bert Gunter
Usually we expect posters to do their homework by reading necessary R documentation and relevant subject matter resources (e.g. on clustering) and making a serious attempt to solve the problem by offering their code to us along as part of a reproducible example of how it failed. You have done none

[R] are R packages safe?

2016-12-08 Thread Dimitri Liakhovitski
Guys, suddenly, I am being asked for a proof that R packages that are not '"base" are safe. I've never been asked this question before. Is there some documentation on CRAN that discusses how it's ensured that all "official" R packages have been "vetted" and are safe? Thanks a lot! -- Dimitri L

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Ulrik Stervbo
In addition to 'sample', and if you insist on dplyr, you can use 'sample_n'. Best, Ulrik On Thu, 8 Dec 2016 at 18:47 Bert Gunter wrote: > Usually we expect posters to do their homework by reading necessary R > documentation and relevant subject matter resources (e.g. on > clustering) and making

Re: [R] are R packages safe?

2016-12-08 Thread Bert Gunter
1. What does "Safe" mean??? 2. From the R banner on startup: "R is free software and comes with ABSOLUTELY NO WARRANTY." Don't think it could be clearer than that! Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." --

Re: [R] are R packages safe?

2016-12-08 Thread Marc Schwartz
> On Dec 8, 2016, at 11:47 AM, Dimitri Liakhovitski > wrote: > > Guys, > > suddenly, I am being asked for a proof that R packages that are not > '"base" are safe. I've never been asked this question before. > > Is there some documentation on CRAN that discusses how it's ensured > that all "of

Re: [R] are R packages safe?

2016-12-08 Thread Dimitri Liakhovitski
I just thought maybe there is something - about the process of submitting packages or anything like that - that shows that at least some diligence is being done to ensure that a given package is not just a piece of malware from ISIS or Russia. But if you, Bert, say it's not the case, then I'll beli

Re: [R] are R packages safe?

2016-12-08 Thread Dimitri Liakhovitski
Thank you, Marc. That's helpful! I think, in this case it's mostly: That they are virus/malware free. And that they don't send out some info that they are not supposed to. Thank you! Dimitri On Thu, Dec 8, 2016 at 1:04 PM, Marc Schwartz wrote: > > On Dec 8, 2016, at 11:47 AM, Dimitri Liakhovit

Re: [R] are R packages safe?

2016-12-08 Thread Jeff Newmiller
On the plus side, all binary packages on CRAN are built from source code automatically by the CRAN team, so it would be a bit audacious to include "unsafe" code when the source code had to reviewable at any time. There is nothing in R that would prevent a user from downloading a binary package

Re: [R] are R packages safe?

2016-12-08 Thread Dimitri Liakhovitski
Great to know thanks, Bert! Do you happen to have a reference that shows that: -U. Wien checks R packages on submission for malicious code -R repository servers have filters in place. Thanks again! On Thu, Dec 8, 2016 at 1:13 PM, Bert Gunter wrote: > Dimitri: > > > > > On Thu, Dec 8, 2016 at 10

Re: [R] are R packages safe?

2016-12-08 Thread Bert Gunter
On Thu, Dec 8, 2016 at 10:16 AM, Dimitri Liakhovitski wrote: > Great to know thanks, Bert! > > Do you happen to have a reference that shows that: > -U. Wien checks R packages on submission for malicious code > -R repository servers have filters in place. No. Ask them -- Bert > > Thanks again! >

Re: [R] are R packages safe?

2016-12-08 Thread Bert Gunter
Dimitri: On Thu, Dec 8, 2016 at 10:05 AM, Dimitri Liakhovitski wrote: > I just thought maybe there is something - about the process of > submitting packages or anything like that - that shows that at least > some diligence is being done to ensure that a given package is not > just a piece of m

Re: [R] are R packages safe?

2016-12-08 Thread Marc Schwartz
Dimitri, Even if you narrowly define "safe" as being virus/malware free and even if the CRAN maintainers have extensive screening in place, the burden will still be on the end users to test/scan the downloaded packages (whether in source or binary form), according to some a priori defined stand

Re: [R] are R packages safe?

2016-12-08 Thread Spencer Graves
On 12/8/2016 12:08 PM, Dimitri Liakhovitski wrote: Thank you, Marc. That's helpful! I think, in this case it's mostly: That they are virus/malware free. And that they don't send out some info that they are not supposed to. Doing those things are absolutely against CRAN policies, but y

Re: [R] are R packages safe?

2016-12-08 Thread Dimitri Liakhovitski
Thanks a lot, guys - it's very helpful! On Thu, Dec 8, 2016 at 1:24 PM, Marc Schwartz wrote: > Dimitri, > > Even if you narrowly define "safe" as being virus/malware free and even if > the CRAN maintainers have extensive screening in place, the burden will still > be on the end users to test/sc

Re: [R] are R packages safe?

2016-12-08 Thread Spencer Graves
On 12/8/2016 12:24 PM, Marc Schwartz wrote: Dimitri, Even if you narrowly define "safe" as being virus/malware free and even if the CRAN maintainers have extensive screening in place, the burden will still be on the end users to test/scan the downloaded packages (whether in source or binary

Re: [R] are R packages safe?

2016-12-08 Thread Marc Schwartz
Inline below... > On Dec 8, 2016, at 12:27 PM, Spencer Graves > wrote: > > > > On 12/8/2016 12:24 PM, Marc Schwartz wrote: >> Dimitri, >> >> Even if you narrowly define "safe" as being virus/malware free and even if >> the CRAN maintainers have extensive screening in place, the burden will

[R] R problem

2016-12-08 Thread Grace King
Hi all, I am trying to run a macro by R in a EMME script. The R macro that we wrote is called IPFPUMS.R. The whole process has been working until someone removed R. We tried to re-install R but getting the error message: “‘R’ is not recognized as an internal or external command, operable progra

Re: [R] R problem

2016-12-08 Thread MacQueen, Don
Since you didn't say, I'm going to assume this is Linux. One option would be to put the full path to R in the call in the EMME script. This might be, for example /usr/local/bin/R --save < IPFPUMS.R Without the asterisks before and after, unless they are a requirement of EMME (which I've never he

Re: [R] R problem

2016-12-08 Thread Bert Gunter
This looks like it has nothing to do with R per se and therefore is likely OT here. Please consult your local IT resources for help. Cheers, 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 hi

Re: [R] R problem

2016-12-08 Thread Jim Lemon
Hi Grace, It is almost certainly a directory problem. The new R installation may be in a different directory from the old one. Does R run from the Start menu or a desktop icon? If so, look at "Properties" to discover where it is located and use the explicit path (e.g. C:\Users\Grace\R -save < IPFPU

Re: [R] [FORGED] help with gradient boxplot

2016-12-08 Thread Paul Murrell
Hi You could try ... grid.export(..., strict=FALSE) ... and/or install the latest gridSVG version from R-Forge ... https://r-forge.r-project.org/R/?group_id=1025 Paul On 09/12/16 11:13, Fix Ace wrote: Hi, Paul, Thank you very much for your reply. I tried your sample code, but did not get g

[R] creating possible cominations of a vector's elements

2016-12-08 Thread Dimitri Liakhovitski
Hello! I have a vector of strings 'x' that was based on a longer string 'mystring' (the actual length of x is unknown). mystring <- "this is my vector" x <- strsplit(mystr, " ")[[1]] I am looking for an elegant way of creating an object (e.g., a list) that contains the following strings: "this"

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread David L Carlson
You can use expand.grid() and mapply(): mystring <- "this is my vector" mystring.spl <- strsplit(mystring, " ")[[1]] makestrings <- function(x) { len <- length(mystring.spl) idx <- expand.grid(1:len, 1:len) idx <- idx[idx$Var2 <= idx$Var1, c("Var2", "Var1")] mapply(function(x,

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread Dimitri Liakhovitski
Thanks a lot, David - this is great! On Thu, Dec 8, 2016 at 6:51 PM, David L Carlson wrote: > You can use expand.grid() and mapply(): > > mystring <- "this is my vector" > mystring.spl <- strsplit(mystring, " ")[[1]] > > makestrings <- function(x) { > len <- length(mystring.spl) > idx <

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread William Dunlap via R-help
> ij <- combn(length(x)+1, 2) > lapply(seq_len(ncol(ij)), function(k) x[ij[1,k]:(ij[2,k]-1)]) [[1]] [1] "this" [[2]] [1] "this" "is" ... [[9]] [1] "my" "vector" [[10]] [1] "vector" Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Dec 8, 2016 at 3:02 PM, Dimitri Liakhovitski < dimitri.l

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread David L Carlson
This corrects an error in my earlier function definition: makestrings <- function(vec) { len <- length(mystring.spl) idx <- expand.grid(1:len, 1:len) idx <- idx[idx$Var2 <= idx$Var1, c("Var2", "Var1")] mapply(function(x, y) paste(vec[x:y], collapse=" "), x=idx[, 1],

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread David L Carlson
Not my day. Another correction: makestrings <- function(vec) { len <- length(vec) idx <- expand.grid(1:len, 1:len) idx <- idx[idx$Var2 <= idx$Var1, c("Var2", "Var1")] mapply(function(x, y) paste(vec[x:y], collapse=" "), x=idx[, 1], y=idx[, 2]) } David C -Origin

[R] .External2(C_savehistory, file) : no history available to save

2016-12-08 Thread Christian
Hi, I try to save my history: > if (interactive()) try(savehistory(file=paste0(dir,"/.Rhistory")) ) to get: Error in .External2(C_savehistory, file) : no history vailable to save My system: R version 3.3.2 (2016-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: macOS Sierra 10.

Re: [R] [FORGED] help with gradient boxplot

2016-12-08 Thread Fix Ace via R-help
Hi, Paul, Thank you very much for your reply. I tried your sample code, but did not get gradient filling (still empty box). And many warnings:1: In checkAttrs(attrs, eltName) :   Removing non-SVG attribute name(s): fill, fill-opacity 2: In checkAttrs(attrs, eltName) :   Removing non-SVG attribute

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Partha Sinha
How to get two sets of non overlapping data? Regards Parth On 8 December 2016 at 23:23, Ulrik Stervbo wrote: > In addition to 'sample', and if you insist on dplyr, you can use > 'sample_n'. > > Best, > Ulrik > > On Thu, 8 Dec 2016 at 18:47 Bert Gunter wrote: > >> Usually we expect posters to do

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Ulrik Stervbo
df <- data.frame(x = 1:12, y = rnorm(12)) If you use sample: RowIndex <- sample(1:nrow(df), 5) TrainSet <- df[RowIndex, ] TestSet <- df[-RowIndex, ] Or with dplyr: TrainSet <- sample_n(df, 5) TestSet <- anti_join(TestSet, df) HTH Ulrik On Fri, 9 Dec 2016, 06:56 Partha Sinha, wrote: > How to