[R] assigning a file name, or part of, to an object

Ista Zahn istazahn at gmail.com
Fri Jan 22 17:53:41 CET 2010


Hi Jim,
You might also want to see ?list.files() for a quick way to get the
filenames in the first place, and then you can manipulate them using
the functions Gabor suggested.

-Ista

On Fri, Jan 22, 2010 at 4:48 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> Check out the various help pages on string manipulation:
>
> help.search(keyword = "character", package = "base")
>
> and particularly ?sub, ?substr and ?regex
>
> On Fri, Jan 22, 2010 at 11:33 AM, Jim Bouldin <jrbouldin at ucdavis.edu> wrote:
>>
>> Is there a way to capure all, or part, of a filename and assign it to an
>> object.  Say I wanted to read in a file tiled "example.txt" and then assign
>> the character string "example" (or "exa" or any other substring of
>> "example" for that matter), to object a.  Is there a simple way to do so?
>> Thanks in advance for any help.
>>
>>
>>
>> Jim Bouldin
>> Research Ecologist
>> Department of Plant Sciences, UC Davis
>> Davis CA, 95616
>> 530-554-1740
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list