[R] title line

Michael Kubovy kubovy at virginia.edu
Mon May 21 15:15:04 CEST 2007


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/



More information about the R-help mailing list