Re: [R] For Loop

2018-09-22 Thread Jeff Newmiller
I do use for loops a few times per month, but only wrapped around large chunks of vectorized calculations, not for this kind of use case. In those cases I also pre-allocate output vectors/lists (e.g. vector( "list", len )) to avoid memory thrashing as you grow lists or other vectors one element

Re: [R] For Loop

2018-09-22 Thread Wensui Liu
or this one: (Vectorize(function(i) log(c1[i + 1] / c1[i])) (1:len)) On Sat, Sep 22, 2018 at 4:16 PM rsherry8 wrote: > > > It is my impression that good R programmers make very little use of the > for statement. Please consider the following > R statement: > for( i in 1:(len-1) ) s[i]

Re: [R] For Loop

2018-09-22 Thread Wensui Liu
another version just for fun s <- parallel::pvec(1:len, function(i) log(c1[i + 1] / c1[i])) On Sat, Sep 22, 2018 at 4:16 PM rsherry8 wrote: > > > It is my impression that good R programmers make very little use of the > for statement. Please consider the following > R statement: > for(

Re: [R] error "The system cannot find the file specified..."

2018-09-22 Thread Bert Gunter
You probably want pattern = "\\.PDF" , as "." has a special meaning for regex's. However, that really shouldn't make any difference. Obvious questions: 1. dir() returns a vector of file names. Are they pdf's "PDF" or "pdf" (case matters!) ? 2. extract.tables() almost certainly wants the full path

[R] error "The system cannot find the file specified..."

2018-09-22 Thread Ek Esawi
Hi All, I am using the R Tabulizer package to extract tables from a set of pdf files. Tabulizer creates a list of data frames; each corresponds to a table in a file. My aim is to create a list of lists, one for each file.i have 8 files The code below kept giving me the error "Error in normalizePat

Re: [R] For Loop

2018-09-22 Thread Richard M. Heiberger
c1 <- 1:100 len <- 100 system.time( s1 <- log(c1[-1]/c1[-len]) ) s <- c1[-len] system.time( for (i in 1:(len-1)) s[i] <- log(c1[i+1]/c1[i]) ) all.equal(s,s1) > > c1 <- 1:100 > len <- 100 > system.time( + s1 <- log(c1[-1]/c1[-len]) + ) user system elapsed 0.032 0.005 0.03

Re: [R] For Loop

2018-09-22 Thread Bert Gunter
Bob: Please, please spend some time with an R tutorial or two before you post here. This list can help, but I think we assume that you have already made an effort to learn basic R on your own. Your question is about as basic as it gets, so it appears to me that you have not done this. There are ma

[R] For Loop

2018-09-22 Thread rsherry8
It is my impression that good R programmers make very little use of the for statement. Please consider the following R statement: for( i in 1:(len-1) ) s[i] = log(c1[i+1]/c1[i], base = exp(1) ) One problem I have found with this statement is that s must exist before the statement is

Re: [R] as.Date and ylim in empty plot: RESOLVED

2018-09-22 Thread David Winsemius
> On Sep 19, 2018, at 10:48 PM, Ogbos Okike wrote: > > Hi David, > That's it!!! The outcome is attached. The explanation for this is that columns that have digits separated by dashes will not be interpreted by R's read.table() as numeric or dates, but rather as the default for text entries:

Re: [R] Link from vignette to package documentation

2018-09-22 Thread Duncan Murdoch
On 22/09/2018 4:14 AM, Martin Maechler wrote: Duncan Murdoch on Fri, 21 Sep 2018 05:02:32 -0400 writes: > On 21/09/2018 4:54 AM, Sigbert Klinke wrote: >> Hi, >> >> is it possible to make a link from a vignette to a (Rd) >> help files in my own or other packages?

Re: [R] Smallest Space Analysis (SSA) in R

2018-09-22 Thread Andrew
Hi Michael This looks like it could be really helpful in moving my project forwards thank you. I remember many years ago using (proprietary) software from the University of Liverpool which did a nice job of allowing regions to be defined, and then for the space to be rotated to obtain visual

Re: [R] Link from vignette to package documentation

2018-09-22 Thread Martin Maechler
> Duncan Murdoch > on Fri, 21 Sep 2018 05:02:32 -0400 writes: > On 21/09/2018 4:54 AM, Sigbert Klinke wrote: >> Hi, >> >> is it possible to make a link from a vignette to a (Rd) >> help files in my own or other packages? > Only with some significant compromis