[R] Creating a new variable from existing ones
dwinsemius at comcast.net
Wed Jan 26 20:55:20 CET 2011
On Jan 26, 2011, at 2:06 PM, Melanie Zoelck wrote:
> I am relatively new to R and have a question regarding code. I have
> a data set which has data organised by location (site names, which
> are factors). I now want to add a new variable Region (this will be
> non numerical, as it will be names). Each region will contain
> locations. So for example:
> Region: WestCoast
> Locations in Region WestCoast: Tralee, Carradale and so on...
Presumably you have some sort of table with "location" and "region"
and another table with perhaps "persons" and "location". You would
merge these two tables with ... wait for it .... "merge":
In the future it is considered more helpful to offer a tiny data
example constructed with R code to allow more complete illustrations
to be offered. Please read the Posting Guide.
> So each Region will contain different Locations, so that location
> can be nested within Region if needed.
> I have found info on how to create different Age categories for
> example but my input is not numeric, but it is names or rather
> factors with a number of levels (which are place names).
> I would be grateful for any assistance you may be able to provide.
> Thank you!
> Melanie Zoelck
> 86 Gleann Na Ri
David Winsemius, MD
West Hartford, CT
More information about the R-help