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
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
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
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
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
5 matches
Mail list logo