[R] change value in one cell

jim holtman jholtman at gmail.com
Sat Jun 11 03:33:35 CEST 2011


you probably need to read the Introduction to R to understand indexing:

> x
  Obs X Y Z
1   1 1 0 1
2   2 0 0 1
3   3 1 1 1
4   4 0 1 1
5   5 1 1 0
6   6 0 0 0
> x[4, "Y"] <- 0
> x
  Obs X Y Z
1   1 1 0 1
2   2 0 0 1
3   3 1 1 1
4   4 0 0 1
5   5 1 1 0
6   6 0 0 0


On Fri, Jun 10, 2011 at 5:42 PM, jour4life <jour4life at gmail.com> wrote:
> Hello all,
>
> I am wondering if there is a way to change the value of one cell in R. For
> instance let's say I have a hypothetical data frame that looks like this:
>
> Obs X Y Z
> 1    1 0 1
> 2    0 0 1
> 3    1 1 1
> 4    0 1 1
> 5    1 1 0
> 6    0 0 0
>
> I would like to change the value of the 4th observation in the Y column from
> 1 to 0. It should look like this:
>
> Obs X Y Z
> 1    1 0 1
> 2    0 0 1
> 3    1 1 1
> 4    0 0 1
> 5    1 1 0
> 6    0 0 0
>
> Is it possible to change the value in one command?
>
> Thanks,
>
> Carlos
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/change-value-in-one-cell-tp3589456p3589456.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list