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 February, 2010, 1:54 AM


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 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 say 10 times i.e. my 
> output should be like
>   
> New York
> City Buffallo
> New York
> City Buffallo
> New York
> City Buffallo
> New York City
> ...................
> ...................
> ...................
> ...................
>   
> I have tried the following commands
>   
> rep(c(city1,city2), 5)
>   
> and I got the output something like this
>   
> [1] 1 1 1 1 1 1 .......
>   
> If I try
>   
> rep((city1,city2), 5)
>   
> Error: unexpected ',' in "rep((city1,"
>   
> Please guide
>   
> Regards
>   
> MAdhavi
>
>
>        Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
>http://downloads.yahoo.com/in/internetexplorer/
>     [[alternative HTML version deleted]]
>
>    
>
>
> ______________________________________________
> R-help@r-project.org 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.
>    

    [[alternative HTML version deleted]]


-----Inline Attachment Follows-----


______________________________________________
R-help@r-project.org 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.



[[elided Yahoo spam]]

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to