[R] read dataset in R language.

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Wed Dec 16 00:18:54 CET 2009


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Nancy Adam
> Sent: Tuesday, December 15, 2009 1:24 PM
> To: r-help at r-project.org
> Subject: Re: [R] read dataset in R language.
> 
> 
> 
> Hi all,Thanks for your reply. Sorry I did not send sufficient information about my
> problem…I attach the two datasets that I’m trying to read and these are my
> attempts to read them:1)#train <- read.table("trainingset.txt", header=TRUE, sep=";"
> ,fill=TRUE) #test <- read.table("testset.txt", header=TRUE, sep=";" , fill=TRUE)its
> error message is:
>  “ undefined columns selected”2)train <- scan("trainingset.txt",  sep=";" ,fill=TRUE)
> test <- scan("testset.txt", sep=";" , fill=TRUE)
> 
> its error message is:
> “  'names' attribute [172] must be the same length as the vector [152]”
> 
> many thanks,
> Nancy

Nancy, 

I took a quick look at your training set data file and I see a couple of problems.
1.  You have some name fields that aren't legal names in the header.
2.  It appears that you have more variable names in your header than you have data fields on each line.

These issues will  need to be cleaned up before you can read the file.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204




More information about the R-help mailing list