Re: [R] adding column and pulling data from table

From: Peter Alspach <PAlspach_at_hortresearch.co.nz>
Date: Wed, 04 Jun 2008 08:13:23 +1200

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.



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. Received on Tue 03 Jun 2008 - 21:32:21 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 Tue 03 Jun 2008 - 22:30:40 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.

list of date sections of archive