[R] Files with Missing Data
Setlhare Lekgatlhamang
SetlhareL at bob.bw
Fri Jul 2 10:21:39 CEST 2010
Hi Norman,
If you still have not managed, google for "Econometrics in R" pdf paper
by Farnsworth; it as helped me a lot. You will only need to replace
Farnsworth's read function with the read.csv function suggested below by
Erik.
Lexi
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Erik Iverson
Sent: Friday, July 02, 2010 3:44 AM
To: Norman Jessup
Cc: r-help at r-project.org
Subject: Re: [R] Files with Missing Data
Norman Jessup wrote:
> I'm a new R user so this is possibly a naive question. I'm trying to
> load an external CSV file into a dataframe using:
>
> df_name<-read.table("myfile.csv")
>
> myfile.csv should have 5 elements per row, though a percentage are
> missing the last two elements (the commas are present as
placemarkers).
> However, R does not create the dataset but returns the message:
>
> line 1 did not have 2 elements
>
> but examining the file shows that it does. These are the first 5
rows:
>
> DARWIN,NT,800,-12.461334,130.841904
> ALAWA,NT,810,-12.37896,130.874226
> BRINKIN,NT,810,-12.364533,130.869394
> CASUARINA,NT,810,-12.373112,130.883619
> COCONUT GROVE,NT,810,-12.397685,130.852324
>
> Is R complaining because the first two elements of each row are not
> numeric, or am I doing something else wrong?
> Thanks for your suggestions
You can use Peter's advice; also note there is a read.csv function. A
thorough
reading of the ?read.table help page is very useful I've found.
There is also an R data import/export manual on CRAN.
______________________________________________
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.
DISCLAIMER:\ Sample Disclaimer added in a VBScript.\ ...{{dropped:3}}
More information about the R-help
mailing list