Loading Dataset into R continual issue

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

Loading Dataset into R continual issue

bobo
Hi, this is related to academic research I am trying to conduct. Please pardon my lack of socialization for this forum.

For my project, I had to combine two different datasets, Democracy dataset from Pippa Norris and World Bank Patents dataset.

My issue arrises from just loading the file into R. My colleagues proficient in R have been stumped as well.  Often times the file would seem to load fine using read.table command, however when I tried to run summary statistics of variables, it would say "object not found".

I have tried different formats and commands. Formats .xlsx, .csv, . txt. Commands read.table, read.csv, read.delim. I have tried to run summary statistics of Pat2006, Pat2005, Pat 2004 all the way to Pat 2001.

Could anyone PLEASE help me solve this issue? I cannot even begin to say how thankful I will be.

I have uploaded the .txt file onto mediafire website for easy access. I posted .txt so people aren't worried about viruses or anything of the sort. I can also post other versions of the file, or direct to the 2 original datasets.

Good Democracy Dataset http://www.mediafire.com/?ytg7a76s7ox05se  (141 kb)
Reply | Threaded
Open this post in threaded view
|

Re: Loading Dataset into R continual issue

Michael Weylandt
Seems to work for me:

x <- read.table("read.table("~/Downloads/gooddemocracy.txt", sep =
"\t", header = TRUE)
str(x)

summary(x)[,1:10]

Michael



On Mon, Mar 19, 2012 at 5:52 PM, bobo <[hidden email]> wrote:

> Hi, this is related to academic research I am trying to conduct. Please
> pardon my lack of socialization for this forum.
>
> For my project, I had to combine two different datasets, Democracy dataset
> from Pippa Norris and World Bank Patents dataset.
>
> My issue arrises from just loading the file into R. My colleagues proficient
> in R have been stumped as well.  Often times the file would seem to load
> fine using read.table command, however when I tried to run summary
> statistics of variables, it would say "object not found".
>
> I have tried different formats and commands. Formats .xlsx, .csv, . txt.
> Commands read.table, read.csv, read.delim. I have tried to run summary
> statistics of Pat2006, Pat2005, Pat 2004 all the way to Pat 2001.
>
> Could anyone PLEASE help me solve this issue? I cannot even begin to say how
> thankful I will be.
>
> I have uploaded the .txt file onto mediafire website for easy access. I
> posted .txt so people aren't worried about viruses or anything of the sort.
> I can also post other versions of the file, or direct to the 2 original
> datasets.
>
> Good Democracy Dataset http://www.mediafire.com/?ytg7a76s7ox05se  (141 kb)
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Loading-Dataset-into-R-continual-issue-tp4486619p4486619.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.

______________________________________________
[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: Loading Dataset into R continual issue

bobo
In reply to this post by bobo
Thank you. I was able to get it loaded however when I tried to run

mod1<-lm(Pat2006~FHouse)
I got
Error in eval(expr, envir, enclos) : object 'Pat2006' not found

What exactly is occurring here?
Reply | Threaded
Open this post in threaded view
|

Re: Loading Dataset into R continual issue

gradstudent
just a guess but does it know where to look for the variable?  has the data been specified?  i am not seeing any of the previous messages in this thread so forgive me if this has been mentioned.

that error means it has no idea where to find the dependent variable 'Pat2006'.



~nicole

----- Original Message -----
From: "bobo" <[hidden email]>
To: [hidden email]
Sent: Wednesday, March 21, 2012 1:35:36 AM
Subject: Re: [R] Loading Dataset into R continual issue

Thank you. I was able to get it loaded however when I tried to run

mod1<-lm(Pat2006~FHouse)
I got
Error in eval(expr, envir, enclos) : object 'Pat2006' not found

What exactly is occurring here?

--
View this message in context: http://r.789695.n4.nabble.com/Loading-Dataset-into-R-continual-issue-tp4486619p4491424.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[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.

______________________________________________
[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.
Ph.D. Candidate
Reply | Threaded
Open this post in threaded view
|

Re: Loading Dataset into R continual issue

Jeff Newmiller
In reply to this post by bobo
How do you expect us to give you an exact description of what is going on in your R session if you don't provide an exact sequence of commands and data?

Learn to use ?str for understanding your own data, and ?head and ?dput for giving us a sample of data, and provide a succinct set of commands that produces your error. One part of the beauty of R is that it is possible to ask a precise question, and get a precise answer.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

bobo <[hidden email]> wrote:

>Thank you. I was able to get it loaded however when I tried to run
>
>mod1<-lm(Pat2006~FHouse)
>I got
>Error in eval(expr, envir, enclos) : object 'Pat2006' not found
>
>What exactly is occurring here?
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Loading-Dataset-into-R-continual-issue-tp4486619p4491424.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>[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.

______________________________________________
[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: Loading Dataset into R continual issue

christiaan pauw-2
In reply to this post by gradstudent
Hi Bobo

Give us the output of ls() before you run mod1<-lm(Pat2006~FHouse)

regards
Christiaan

On 21 March 2012 09:04, Nicole Marie Ford <[hidden email]> wrote:
> just a guess but does it know where to look for the variable?  has the data been specified?  i am not seeing any of the previous messages in this thread so forgive me if this has been mentioned.
>
> that error means it has no idea where to find the dependent variable 'Pat2006'.
>
> ~nicole
>
> ----- Original Message -----

> Thank you. I was able to get it loaded however when I tried to run
>
> mod1<-lm(Pat2006~FHouse)
> I got
> Error in eval(expr, envir, enclos) : object 'Pat2006' not found

--
Christiaan Pauw
Nova Institute
www.nova.org.za

______________________________________________
[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: Loading Dataset into R continual issue

Paul Hiemstra-2
In reply to this post by bobo
On 03/21/2012 06:35 AM, bobo wrote:

> Thank you. I was able to get it loaded however when I tried to run
>
> mod1<-lm(Pat2006~FHouse)
> I got
> Error in eval(expr, envir, enclos) : object 'Pat2006' not found
>
> What exactly is occurring here?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Loading-Dataset-into-R-continual-issue-tp4486619p4491424.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.
What is probably going wrong is that Pat2006 and FHouse are part of a
data.frame, as columns. If the columns are in the same data.frame, say
one called df:

mod1 <- lm(Path2006 ~ FHouse, data = df)

an alternative is to use assign to dump the columns as variables in your
workspace:

> speed
Error: object 'speed' not found
> attach(cars)
> speed
 [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14
14 15 15
[26] 15 16 16 17 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24
24 24 25

but I am very much in favor of the first solution using "data =". Using
attach fills up your workspace with a great deal of objects. Keeping the
columns in a data.frame is also better from a design point of view:
having them in one data.frame already groups together variables
(columns) that share a common background.

In addition:

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, *reproducible code*.

good luck,
Paul

--
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

______________________________________________
[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.