parsing a structured object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

parsing a structured object

BenM
Hi All,
     Thanks in advance for your help.  I take this to be a very basic question, but I'm very new to R.
     I'm trying to figure out how to parse an object.  I have the following:

          > fileLocation
               location
          1 foo.csv

          > fileLocation$location
          [1] foo.csv
          Levels: foo.csv

What I want to get back is "foo.csv", as a string.  What is the best way to do this?

Thanks,

Ben
Reply | Threaded
Open this post in threaded view
|

Re: parsing a structured object

David Winsemius

On Oct 23, 2012, at 4:43 PM, BenM wrote:

> Hi All,
>     Thanks in advance for your help.  I take this to be a very basic
> question, but I'm very new to R.
>     I'm trying to figure out how to parse an object.  I have the following:
>
>> fileLocation
>               location
>          1 foo.csv
>
>> fileLocation$location
>          [1] foo.csv
>          Levels: foo.csv
>
> What I want to get back is "foo.csv", as a string.  What is the best way to
> do this?

It appears to be a factor. Therefore try:

as.character(fileLocation$location)

And read both  ?factor and R-FAQ 7.10
--

David Winsemius, MD
Alameda, CA, USA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: parsing a structured object

BenM
That's simple and appears to work.  Thanks for the prompt response.

Ben