Re : help to replace variable value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re : help to replace variable value

mohan L
Dear All,

I have a data frame "data"  with Jan , Feb as column. I using  like this
data$Jan to take Jan column. I have the Jan in another variable

var1 <- "Jan"

data$var1

I need to replace the variable value there . Any help will be greatly
appreciated.

Thanks & Rg
Mohan L

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Re : help to replace variable value

Ivan Calandra
Hi!

Not sure to understand what you mean...
Would
data[[var1]]
do what you're looking for?

HTH,
Ivan

Le 5/28/2010 11:13, Mohan L a écrit :

> Dear All,
>
> I have a data frame "data"  with Jan , Feb as column. I using  like this
> data$Jan to take Jan column. I have the Jan in another variable
>
> var1<- "Jan"
>
> data$var1
>
> I need to replace the variable value there . Any help will be greatly
> appreciated.
>
> Thanks&  Rg
> Mohan L
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
>    

--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
[hidden email]

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Re : help to replace variable value

Wu Gong
In reply to this post by mohan L
Do you mean replace values of a column?
> df <- data.frame("Jan" = 1:3,"Feb" = 11:13)
> df
  Jan Feb
1   1  11
2   2  12
3   3  13
> df$Jan <- 21:23
> df
  Jan Feb
1  21  11
2  22  12
3  23  13