[R] adding column and pulling data from table

Peter Alspach PAlspach at hortresearch.co.nz
Tue Jun 3 22:13:23 CEST 2008


Paul

It is not entirely clear to me what you want to do.  However, if you are
wanting to add row names then try

row.names(dat) <- paste('g', 1:nrow(dat), sep='')

First twenty rows of columns 1:3 are obtained by

dat[1:20,1:3]

Regarding putting all the points in a column onto a scatterplot.  One
usually has two variates for a scatterplot.  Thus to make a scatter plot
of column 2 against column 1

plot(dat[,1], dat[,2])

Incidentally, subsetting is covered in the introductory manual and some
online texts.

HTH ......

Peter Alspach


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Paul Adams
> Sent: Wednesday, 4 June 2008 7:08 a.m.
> To: r-help at r-project.org
> Subject: [R] adding column and pulling data from table
> 
> Hello to everyone,
> I have a general question about how to add a column to a 
> table.I have a table that has 62 columns and 2000 rows.I am 
> wanting to add a column on the left most row.I am wanting to 
> label the rows g1 to g2000 I have the code of 
> ("g",c(1:nrow(dat)),sep="") for the right side of the 
> assignment but do not know what function to use for the left 
> side of the equation.I also have a similiar question as to 
> how to select a particular portion of the table and to plot 
> this. For example to select column 1 and 3 and to take the 
> data from the first twenty rows from those columns and put 
> this data onto a plot which I have allready coded.Lastly I 
> would like to take all the points in a column (2000) and put 
> them into a scatter plot.What is the command or function I 
> would use to do this?
> Thank You
> Paul
> 
> 
>       
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.



More information about the R-help mailing list