[R] creating column based on another variable
Uwe Ligges
ligges at statistik.uni-dortmund.de
Mon Dec 4 09:06:21 CET 2006
Jeff Miller wrote:
> Hi all,
>
>
>
> I hope someone can help me with this.
>
>
>
> Suppose I import a text file and one of the columns looks like this:
>
>
>
> New York
>
> New York
>
> England
>
> Spain
>
> Spain
>
> Orlando
>
> New York
>
> England
>
> France
I don't understand the semantics here. You are mixing cities and countries.
> I want to add a variable that is based on the previous one
>
>
>
> US
>
> US
>
> Europe
>
> Europe
>
> Europe
>
> US
>
> US
>
> Europe
>
> Europe
Now you are mixing a single country and a whole continent.
Is this some homework?
You should consider to tell R which cities are in the US and which
countries are in Europe and than try to match appropriately ...
As the footer of this message says:
"PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html"
which tells you to read introductory material and to specify some code
examples and details that you already have got. Then it's much easier
for us to help.
Uwe Ligges
>
>
> How do that?
>
>
>
> Also, I would like to be able to export the data as a text file that retains
> this new variable.
>
>
>
> Any suggestions are greatly appreciated,
>
>
>
> Jeff Miller
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
More information about the R-help
mailing list