There is nothing weird about it if you look at the structure of the CSV file:

IQ Scores,
145,
101,
123,
106,
117,
102,
139,
142,
94,

Notice that there is an extra comma that EXCEL is inserting and
therefore when you are reading it in to R, it assumes there is an
unnamed column that it calls "X":

> x <- read.csv('clipboard')
> str(x)
'data.frame':   60 obs. of  2 variables:
 $ IQ.Scores: int  145 101 123 106 117 102 139 142 94 124 ...
 $ X        : logi  NA NA NA NA NA NA ...

So file a bug report with Microsoft on the way Excel writes CSV files;
R is interpreting them correctly.


On Wed, Aug 15, 2012 at 1:27 PM, darnold <dwarnol...@suddenlink.net> wrote:
> My friend sent an Excel file:
>
> http://msemac.redwoods.edu/~darnold/temp/cyu01_iqscores.xls
> http://msemac.redwoods.edu/~darnold/temp/cyu01_iqscores.xls
>
> I opened it in Excel, saved is as cyu01_iqscores.csv, then imported it into
> R with:
>
> iqscores=read.csv('cyu01_iqscores.csv',header=TRUE)
>
> The result was:
>
>> head(iqscores)
>   IQ.Scores  X
> 1       145 NA
> 2       101 NA
> 3       123 NA
> 4       106 NA
> 5       117 NA
> 6       102 NA
>
> Now, I know I can cure this with:
>
> iqscores=iqscores[,1]
>
> But I am wondering about this weird behavior.
>
> Suggestions?
>
> David
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Reading-one-column-csv-file-tp4640396.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

______________________________________________
R-help@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.

Reply via email to