[R] using imported tables
Mulholland, Tom
Tom.Mulholland at dpi.wa.gov.au
Wed Apr 20 02:59:52 CEST 2005
While you may want to jump in at the deep end I would suggest that you need to take the time to fully digest some of the basics. This is one of them. There are a number of ways that can be used. You tell me you have a table, but I asume that you have a data.frame. I normally associate table with "an object of 'class' '"table"', an array of integer values." which is produced by the table command. in other words an array. However the read.table command returns a data.frame (see ?read.table, in particular Value: which tells you exactly what is returned by the function.)
To help you understand what you really have use str(name.of.object)
Data.frames and arrays can be subset by row or column using indexing that is
df[1,] is row 1 of df
df[,1] is column 1 of df
df[1:2,] are the first two rows of df etc (but you do need to read about indexing arrays)
If however you have a data.frame with named columns you can refer to them directly. So if column 1 is called Age then df$Age is the vector relating to that column. If you had a data.frame with named columns of income and persons which were both numeric than you could calculate gross income as df$GrossIncome <- df$income * df$persons.
As a minimum* you need to read "An introduction to R." If you are using windows then in all probability it is one of the documents in your help system. There are also a number of excellent texts that take you through the basics of R. If you wish to gain proficiency you will find it easier to do this first. The list does not generally go out of its way to help people who have apparently not read the basic documentation. The list will not penalize you for not understanding so if you don't understand some component it helps when you indicate where you have gleaned your information from and what attempts you have made to solve your problem.
Tom
* The posting guide explains all of this much better than I do.
> -----Original Message-----
> From: Owen Buchner [mailto:OBUCHNER at DAL.CA]
> Sent: Tuesday, 19 April 2005 7:51 PM
> To: Mulholland, Tom
> Subject: RE: [R] using imported tables
>
>
> The table I uploaded has two columns and I've been able to
> assign both a name.
> The main problem is that i want to work with the data I had R
> import using
> read.table. I want to use one column at a time or have two
> of the columns
> multiplied together to yeild a new column but I'm not sure of
> the commands I
> can use to have R take one column from the table and use it
> like a vector.
>
More information about the R-help
mailing list