[R] How to repeat the names?

2010-02-10 Thread Madhavi Bhave
Dear R helpers   I have a city.csv file as given below.   'city.csv' city_name1    city_name2 New York City    Buffallo     So I define   city_name = read.csv('city.csv') city1 = city_name$city_name1 city2 = city_name$city_name2   My problem is how do I repeat the names one after other

Re: [R] How to repeat the names?

2010-02-10 Thread Paul Hiemstra
Hi, Take a look at rep(), specifically the each = parameter. cheers, Paul Madhavi Bhave wrote: Dear R helpers I have a city.csv file as given below. 'city.csv' city_name1city_name2 New York CityBuffallo So I define city_name = read.csv('city.csv') city1 =

Re: [R] How to repeat the names?

2010-02-10 Thread Ivan Calandra
Hi! I'm kind of a newboe here, but I think it is because read.csv transforms the character variables to factors. Maybe try setting the argument as.is in read.csv(). Or try: rep(as.character(c(city1, city2)),5) That should work. HTH Ivan Le 2/10/2010 10:44, Madhavi Bhave a écrit : Dear R

Re: [R] How to repeat the names?

2010-02-10 Thread Romain Francois
Hello, That's not the problem here. The variables are read as factors. You can use the stringAsFactors argument of read.csv to turn this off: read.csv( 'city.csv', stringsAsFactors = FALSE ) and then you can proceed as you did. Romain On 02/10/2010 10:44 AM, Paul Hiemstra wrote: Hi,

Re: [R] How to repeat the names?

2010-02-10 Thread Madhavi Bhave
Dear Sirs,   Thanks a lot for your guidance. It worked wonderfully.   Regards   Madhavi --- On Wed, 10/2/10, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: From: Ivan Calandra ivan.calan...@uni-hamburg.de Subject: Re: [R] How to repeat the names? To: r-help@r-project.org Date: Wednesday, 10