[R] Where did lost variables go, with example
PIKAL Petr
petr.pikal at precheza.cz
Thu Jan 2 11:34:34 CET 2014
Hi
you are confusing yourself and maybe other audience.
With ls() you list objects in your environment (usually stored in .RData file) and loaded with starting R.
Let me guess. You probably have 2 data frames All8 and All8Sites. They have some variables inside and you can see structure of any object by str
str(All8)
you can see names of these variables by names
names(All8)
you can use those variables by e.g.
All8Sites$X
You probably managed somehow to save variables from data.frame to independent objects in your environment, which can be confusing.
Maybe it is time to read R-intro which is located in doc folder of your R installation.
Regards
Petr
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of David Parkhurst
> Sent: Tuesday, December 31, 2013 5:39 PM
> To: Duncan Murdoch; r-help at r-project.org
> Subject: Re: [R] Where did lost variables go, with example
>
> Thank you. I've tried what you're suggesting, at an earlier suggestion
> from another respondent, and I don't find my variable in any of lists
> ls() through ls(7).
>
> I'm just going back to using R after being away from statistics for
> several years. I'm thinking I might uninstall R, then reinstall it,
> and redo my work so far (I've kept the commands elsewhere), and avoid
> using "attach," as someone else has suggested.
>
> David
> On 12/31/2013 11:32 AM, Duncan Murdoch wrote:
> > On 13-12-31 9:48 AM, David Parkhurst wrote:
> >> Two or three respondents asked for an example of my problem. Here's
> >> what's happening to me now. I can't reproduce how I got to this
> >> point,
> >> though:
> >>
> >> > ls()
> >> [1] "All8" "All8Sites" "A" "B" "C" "i" "n" "D" "F"
> >> > X
> >> Error: object 'X' not found
> >> > attach(All8Sites)
> >> > ls()
> >> [1] "All8" "All8Sites" "A" "B" "C" "i" "n" "D" "F"
> >>
> >>
> >> "X" is one of the variables in the data frame I attached in the
> third
> >> command above, but it's not listed by >ls(). If I enter > X now,
> its
> >> values ARE listed, but it's hiding somewhere. What is happening
> here?
> >> How can I get the variables in that data frame listed when I attach
> it?
> >
> > Use search() to see the search list. Your dataframe will likely be
> in
> > position 2. Use ls(2) to see the variables there.
> >
> > Duncan Murdoch
> >
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list