An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20061203/c8359e46/attachment-0004.pl
creating column based on another variable
3 messages · Jeff Miller, Uwe Ligges, John Kane
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.
--- Jeff Miller <jeffmiller at adsam.com> 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 want to add a variable that is based on the previous one US US Europe Europe Europe US US Europe Europe How do that?
?cbind
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
?write.table ?write.csv It might be a good idea to read a bit about how R works. A handy tutorial is http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html and you should have a look at the FAQ and the Intro to R both available the main R site http://www.r-project.org/