Re: [R] iterators : checkFunc with ireadLines

2020-06-03 Thread Laurent Rhelp
Ok, thank you for the advice I will take some time to see in details these packages. Le 19/05/2020 à 05:44, Jeff Newmiller a écrit : Laurent... Bill is suggesting building your own indexed database... but this has been done before, so re-inventing the wheel seems inefficient and risky. It

Re: [R] iterators : checkFunc with ireadLines

2020-06-03 Thread Jeff Newmiller
Laurent... Bill is suggesting building your own indexed database... but this has been done before, so re-inventing the wheel seems inefficient and risky. It is actually impossible to create such a beast without reading the entire file into memory at least temporarily anyway, so you are better

Re: [R] iterators : checkFunc with ireadLines

2020-05-27 Thread William Michels via R-help
Hi Laurent, Off the bat I would have guessed that the problem you're seeing has to do with 'command line quoting' differences between the Windows system and the Linux/Mac systems. I've noticed people using Windows having better command line success with "exterior double-quotes / interior

Re: [R] iterators : checkFunc with ireadLines

2020-05-27 Thread Ivan Krylov
On Wed, 27 May 2020 10:56:42 +0200 Laurent Rhelp wrote: > May be it is because I work with MS windows ? That is probably the case. On Windows, pipe() invokes "%COMSPEC% /c ", and the rules of command line quoting are different between POSIX shell and cmd.exe + runtimes of Windows applications

Re: [R] iterators : checkFunc with ireadLines

2020-05-27 Thread Laurent Rhelp
I installed raku on my PC to test your solution: The command raku -e '.put for lines.grep( / ^^N053 | ^^N163 /, :p );'  Laurents.txt works fine when I write it in the bash command but when I use the pipe command in R as you say there is nothing in lines with lines <- read.table(i) There is

Re: [R] iterators : checkFunc with ireadLines

2020-05-24 Thread William Michels via R-help
Strike that one sentence in brackets: "[In point of fact, the R Data Import/Export Manual suggests using perl]", to pre-process data before loading into R. The manual's recommendation only pertains to large fixed width formatted files [see #1], whereas Laurent's data is whitespace-delimited: >

Re: [R] iterators : checkFunc with ireadLines

2020-05-23 Thread William Michels via R-help
Hi Laurent, Seeking to give you an "R-only" solution, I thought the read.fwf() function might be useful (to read-in your first column of data, only). However Jeff is correct that this is a poor strategy, since read.fwf() reads the entire file into R (documented in "Fixed-width-format files",

Re: [R] iterators : checkFunc with ireadLines

2020-05-22 Thread Laurent Rhelp
Hi Ivan,   Endeed, it is a good idea. I am under MSwindows but I can use the bash command I use with git. I will see how to do that with the unix command lines. Le 20/05/2020 à 09:46, Ivan Krylov a écrit : Hi Laurent, I am not saying this will work every time and I do recognise that this

Re: [R] iterators : checkFunc with ireadLines

2020-05-20 Thread Jeff Newmiller
There is also apparently a package called disk.frame that you might consider. On May 19, 2020 12:07:38 AM PDT, Laurent Rhelp wrote: >Ok, thank you for the advice I will take some time to see in details >these packages. > > >Le 19/05/2020 à 05:44, Jeff Newmiller a écrit : >> Laurent... Bill is

Re: [R] iterators : checkFunc with ireadLines

2020-05-20 Thread Ivan Krylov
Hi Laurent, I am not saying this will work every time and I do recognise that this is very different from a more general solution that you had envisioned, but if you are on an UNIX-like system or have the relevant utilities installed and on the %PATH% on Windows, you can filter the input file

Re: [R] iterators : checkFunc with ireadLines

2020-05-19 Thread Jeff Newmiller
Laurent... Bill is suggesting building your own indexed database... but this has been done before, so re-inventing the wheel seems inefficient and risky. It is actually impossible to create such a beast without reading the entire file into memory at least temporarily anyway, so you are better

Re: [R] iterators : checkFunc with ireadLines

2020-05-19 Thread Laurent Rhelp
Ok, thank you for the advice I will take some time to see in details these packages. Le 19/05/2020 à 05:44, Jeff Newmiller a écrit : Laurent... Bill is suggesting building your own indexed database... but this has been done before, so re-inventing the wheel seems inefficient and risky. It

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread Laurent Rhelp
GREAT ! It is exactly in the idea of my request ! I like the nextElem call in the skip argument. Thank you very much William Best Regards Laurent Le 18/05/2020 à 20:37, William Michels a écrit : Hi Laurent, Thank you for explaining your size limitations. Below is an example using the

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread Laurent Rhelp
Dear William,  Thank you for your answer My file is very large so I cannot read it in my memory (I cannot use read.table). So I want to put in memory only the line I need to process. With readLines, as I did, it works but I would like to use an iterator and a foreach loop to understand this

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread William Michels via R-help
Dear Laurent, I'm going through your code quickly, and the first question I have is whether you loaded the "gmp" library? > library(gmp) Attaching package: ‘gmp’ The following objects are masked from ‘package:base’: %*%, apply, crossprod, matrix, tcrossprod > library(iterators) >

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread William Michels via R-help
Apologies, Laurent, for this two-part answer. I misunderstood your post where you stated you wanted to "filter(ing) some selected lines according to the line name... ." I thought that meant you had a separate index (like a series of primes) that you wanted to use to only read-in selected line

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread William Michels via R-help
Hi Laurent, Thank you for explaining your size limitations. Below is an example using the read.fwf() function to grab the first column of your input file (in 2000 row chunks). This column is converted to an index, and the index is used to create an iterator useful for skipping lines when

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread Laurent Rhelp
Dear William,  Thank you for your answer My file is very large so I cannot read it in my memory (I cannot use read.table). So I want to put in memory only the line I need to process. With readLines, as I did, it works but I would like to use an iterator and a foreach loop to understand this

[R] iterators : checkFunc with ireadLines

2020-05-17 Thread Laurent Rhelp
Dear R-Help List,    I would like to use an iterator to read a file filtering some selected lines according to the line name in order to use after a foreach loop. I wanted to use the checkFunc argument as the following example found on internet to select only prime numbers : |