On May 22, 2012, at 10:01 PM, arun wrote:

HI David,

My intention was to get the output in the format:

 Price Floor Area Rooms Age Cent.heat
    52   111  830     5 5.2        no
    54   128  710     5 6.2        no
    57   101 1000     5 3.8        no
    57   138  690     5 4.5        no
    59    93  780     5 6.8       yes


which was accomplished from Peter's code:

print(HousePriceT1,row.names=FALSE).
In the output given below by you, it is still having the rownumbers (1,2,3,4,5) which I wanted to eliminate.

My point was ... you have NOT "eliminated" them. There are still row.names in that dataframe. You have been told by an experienced useR how to `print` that object in a manner that lets you not see them. They are still there.

--
David.



----- Original Message -----
From: David Winsemius <dwinsem...@comcast.net>
To: Peter Ehlers <ehl...@ucalgary.ca>
Cc: arun <smartpink...@yahoo.com>; R help <r-help@r-project.org>
Sent: Tuesday, May 22, 2012 9:48 PM
Subject: Re: [R] Deleting row labels in dataframe


On May 22, 2012, at 6:30 PM, Peter Ehlers wrote:

On 2012-05-22 13:55, arun wrote:
Dear R group,

I was working on an example dataset to see if the row labels can be deleted. I know that header=TRUE could be used when we use read.table. In the data.frame, I tried to delete row labels 1,2,..5, but so far not successful. Is there a neat way to do it.


What are you trying to accomplish? Save the dataframe without
rownames?
Use write.table(..., row.names=FALSE)

Print it in the console without rownames?
Use print(..., row.names=FALSE)

Notice that Peter Ehlers, an accomplished useR, has _not_ told you how to remove row.names from dataframes.

attr(HousePriceT1, "rownames") <- NULL
HousePriceT1
  Price Floor Area Rooms Age Cent.heat
1    52   111  830     5 5.2        no
2    54   128  710     5 6.2        no
3    57   101 1000     5 3.8        no
4    57   138  690     5 4.5        no
5    59    93  780     5 6.8       yes


--David.

Peter Ehlers

Thanks.
A.K.


HousePriceT1<-structure(list(Price = c(52, 54, 57, 57, 59), Floor = c(111,
128, 101, 138, 93), Area = c(830, 710, 1000, 690, 780), Rooms = c(5,
5, 5, 5, 5), Age = c(5.2, 6.2, 3.8, 4.5, 6.8), Cent.heat = structure(c(1L, 1L, 1L, 1L, 2L), .Label = c("no", "yes"), class = "factor")), .Names = c("Price",
"Floor", "Area", "Rooms", "Age", "Cent.heat"), row.names = c(NA,
-5L), class = "data.frame")


______________________________________________
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.

David Winsemius, MD
West Hartford, CT

David Winsemius, MD
West Hartford, CT

______________________________________________
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