Re: [R] title line

From: Michael Kubovy <kubovy_at_virginia.edu>
Date: Mon, 21 May 2007 09:15:04 -0400

On May 21, 2007, at 8:21 AM, elyakhlifi mustapha wrote:

> I know how to do to write down the columns in a data frame but I
> also wanna write down the lines .
> Do you know how could I do this?

I'm not sure what you mean by "write down the lines". If you mean that you want to know what the row names are, then an answer is:

df <- data.frame(x1 = rnorm(3), x2 = rnorm(3)) names(df) # just to show that I gave the columns names while defining df rownames(df)

If you mean that you want to assign names to the rows, then

df <- data.frame(rnorm(3), rnorm(3))
names(df) <- c('y1', 'y2') # not required rownames(df) <- c('a', 'b', 'c')

In one commandt:

df <- data.frame(x1 = rnorm(3), x2 = rnorm(3), row.names = c('a', 'b', 'c'))

More detailed:

df <- data.frame(x1 = rnorm(3), x2 = rnorm(3), row.names = c('a', 'b', 'c'), check.rows = TRUE, check.names = TRUE)



More importantly you could have found all this out by typing ?data.frame

I have seen several posts from you that seem to be rather elementary questions, sometimes not using the correct terminology ('write down' and 'lines of a data frame' are not standard). Have you taken the time to go through any of the many introductions to R available on line?

Also, you're not asking your questions well (this comment is not about knowing English well):
You would have been better off asking:
"I have a data frame
df <- data.frame(x1 = rnorm(3), x2 = rnorm(3)) How do I ....? "



Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766

WWW: http://www.people.virginia.edu/~mk9y/

R-help_at_stat.math.ethz.ch 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. Received on Mon 21 May 2007 - 13:24:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 May 2007 - 13:31:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.