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
1    Jeep -0.56047565
2  Nissan -0.23017749
3 Toyota1  1.55870831
4 Toyota2  0.07050839


DATA[,1] <- sapply(DATA[,1], function(x){
     x=as.character(x)
    x[which(x=="Toyota2")]<-"Scion"
    x
    }
)

DATA
        x           y
1    Jeep -0.56047565
2  Nissan -0.23017749
3 Toyota1  1.55870831
4   Scion  0.07050839


HTH,

Jorge



On Tue, Mar 11, 2008 at 2:01 PM, Suran, Luciana @ Torto Wheaton Research <
[EMAIL PROTECTED]> wrote:

> 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 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]]

______________________________________________
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