Re: [R] Replacing text with a carriage return

2012-06-25 Thread Rui Barradas
Hello, Instead of replacing "record_start" with newlines, you can split the string by it. And use 'gsub' to make it prettier. x <- readLines("test.txt") x y <- gsub("\"", "", x) # remove the double quotes y <- unlist(strsplit(y, "record_start,")) # do the split, with comma # remove leading

[R] Replacing text with a carriage return

2012-06-25 Thread Thomas
I have a comma separated data file with no carriage returns and what I'd like to do is 1. read the data as a block text 2. search for the string that starts each record "record_start", and replace this with a carriage return. Replace will do, or just add a carriage return before it. The str

Re: [R] Replacing text

2008-03-11 Thread Henrique Dallazuanna
If the column is factor: levels(DATA$x)[levels(DATA$x) == "Toyota2"] <- "Scion" or character: DATA$x[DATA$x == "Toyota2"] <- "Scion" On 11/03/2008, Suran, Luciana @ Torto Wheaton Research <[EMAIL PROTECTED]> wrote: > Sorry, another newbie question :-( > > > > > > I loaded a data set with 10

[R] Replacing text

2008-03-11 Thread Jorge Velez
Hi Luciana, Try this: yourData[,1] <- sapply(yourData[,1], function(x){ x=as.character(x) x[which(x=="Toyota2")]<-"Scion" x } ) # Example set.seed(123) x=c("Jeep","Nissan", "Toyota1", "Toyota2") y=rnorm(4) DATA=data.frame(x,y) DATA x y 1Jeep -0.56047565 2 Nissan

[R] Replacing text

2008-03-11 Thread Suran, Luciana @ Torto Wheaton Research
Sorry, another newbie question :-( I loaded a data set with 10 rows and 30 columns. The first column is characters for names of car manufacturers: Jeep Nissan Toyota1 Toyota2 Etc. How can I replace "Toyota2" with "Scion"? Thanks again [[alternative HTML