NA NA 1
> #4 NA 1 NA
> #5 1 NA NA
>
>
> identical(mydf1,mygoal)
> #[1] TRUE
> A.K.
>
>
>
> - Original Message -
> From: Dimitri Liakhovitski
> To: r-help
> Cc:
> Sent: Wednesday, March 13, 2013 8:10 PM
> Subject: [R] Modifying a data frame ba
o: r-help
Cc:
Sent: Wednesday, March 13, 2013 8:10 PM
Subject: [R] Modifying a data frame based on a vector that contains column
numbers
Hello!
# I have a data frame:
mydf<-data.frame(c1=rep(NA,5),c2=rep(NA,5),c3=rep(NA,5))
# I have an index whose length is always the same as nrow(mydf)
nal Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Dimitri Liakhovitski
> Sent: Wednesday, March 13, 2013 5:11 PM
> To: r-help
> Subject: [R] Modifying a data frame based on a vector that contains column
> numbers
>
Hello!
# I have a data frame:
mydf<-data.frame(c1=rep(NA,5),c2=rep(NA,5),c3=rep(NA,5))
# I have an index whose length is always the same as nrow(mydf):
myindex<-c(1,2,3,2,1)
# I need c1 to have 1s in rows 1 and 5 (based on the information in myindex)
# I need c2 to have 1s in rows 2 and 4 (also
4 matches
Mail list logo