[R] Inf and lazy evaluation
Bert Gunter
gunter.berton at gene.com
Mon May 14 21:45:32 CEST 2012
?list.files
-- Bert
On Mon, May 14, 2012 at 12:34 PM, J Toll <jctoll at gmail.com> wrote:
> Hi,
>
> I have a question involving Inf, lazy evaluation, and maybe argument
> recycling. I have a directory where I am trying to check for the
> existence of files of a certain pattern, basically something like
> "filename-#", where # is an integer. I can do something like this,
> which works.
>
> file.exists(paste(filename, "-", 1:100, sep = ""))
>
> But I don't like the fact that I am only checking the first 100
> possibilities. What I would prefer is this:
>
> file.exists(paste(filename, "-", 1:Inf, sep = ""))
>
> But that doesn't work, I get the error:
>
> Error in 1:Inf : result would be too long a vector
>
> On one hand, with lazy evaluation, you would think that 1:Inf should
> work. On the other hand, I'm not quite sure what the output would be
> if it was working, especially if there were large gaps in the
> integers. Is there a way to get the behavior I seek (i.e. the lazy
> evaluation of 1:Inf).
>
> Thanks,
>
>
> James
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Bert Gunter
Genentech Nonclinical Biostatistics
Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
More information about the R-help
mailing list