On 10/24/2010 04:57 PM, Jason Kwok wrote:
I'm trying to import a CSV file into R and when it gets imported, the
entries get numbered down the left side. How do I get rid of that?
When you imported the CSV file into R, an object of class data.frame
was created, and since you did not assign it to a variable name,
(e.g., df1 <- read.csv(...) ), the object got printed.
A data.frame object is going to have a row.names attribute by definition,
which is what you're seeing.
In ?data.frame, we see documentation for the "row.names" argument:
If ‘row.names’ was supplied as ‘NULL’
or no suitable component was found the row names are the integer
sequence starting at one (and such row names are considered to be
‘automatic’, and not preserved by ‘as.matrix’).
The method that prints out a data.frame is called print.data.frame,
and it does have an argument to suppress printing of the row.names.
The question is, why do you not want row.names? Are they just
distracting you when printed, or is there some reason not to
carry them along in the object?
--Erik
Thanks,
Jason
*> read.csv(file="C:\\Program Files\\R\\Test Data\\sales.csv",head=TRUE)
Month Sales
1 January 422
2 February 151
3 March 451
4 April 175
5 May 131
6 June 307
7 July 47
8 August 12
9 September 488
10 October 122
11 November 54
12 December 244
*
[[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.
______________________________________________
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.