[R] how to replace a text in a table by another text in R?

arun smartpink111 at yahoo.com
Wed Dec 4 05:38:32 CET 2013


Hi,
Use ?paste()
dat1<- read.table(text="name      value
central    -10.91699497
western    -10.16521404
upper    -6.915860837
lower    -6.546794281
southern -6.382722608",sep="",header=TRUE,stringsAsFactors=FALSE)

 number1 <- c(1,3,2,4,5) 

dat1[,1] <- paste0(number1,dat1[,1])
A.K.


On Tuesday, December 3, 2013 11:31 PM, Kristi Glover <kristi.glover at hotmail.com> wrote:
Hi R user, 
I have been struggling to add number in front of text. It mus t be easy. but I could not figure it out.
example
I have this data:
name      value
central     -10.91699497
western     -10.16521404
upper     -6.915860837
lower     -6.546794281
southern -6.382722608

I want to following. I want to add number in front of text. The number are not in sequence. 
name        value
1central    -10.91699497
3western    -10.16521404
2upper        -6.915860837
4lower        -6.546794281
5southern    -6.382722608
How can we find something in a table and replace by something in R? It could be easy in R but my data is so big so that Excel does not open the file. 
I would really appreciate your help. 



                          
    [[alternative HTML version deleted]]

______________________________________________
R-help at 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.




More information about the R-help mailing list