By default for read.table,

comment.char = "#"

so the first line was being treated as a comment line, and when you
specified row.names="#", read.table couldn't find that column.

On Tue, Sep 1, 2009 at 12:07 PM, esawdust <lan...@360vl.com> wrote:

>
>
> esawdust wrote:
> >
> > Here's the contents of a simple test2.csv CSV file:
> >
> > #,Status,Project
> > 5842,New,Test
> >
> >> snortalerts = read.table( "/Users/lcox/Documents/test2.csv",
> header=TRUE,
> >> sep=",", row.names="#")
> > Error in data[[rowvar]] : attempt to select less than one element
> >
> > Landon
> >
>
> Figured out the answer, though it wasn't obvious (to me anyway).  The
> symbol
> "#" used as the first column label was the problem.   I changed that to be
> "id" and changed the read.table to be:
>
> snortalerts <- read.table( "/Users/lcox/Documents/test2.csv", header=TRUE,
> sep=",", row.names="id")
>
> and it worked fine.
> --
> View this message in context:
> http://www.nabble.com/Simple-question-about-error-on-CSV-import-tp25242899p25243159.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.
>



-- 
Levi Waldron
post-doctoral fellow
Jurisica Lab, Ontario Cancer Institute
Division of Signaling Biology
TMDT 9-304D
101 College Street
Toronto, Ontario M5G 1L7
(416)581-7453

        [[alternative HTML version deleted]]

______________________________________________
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