As R notes, the problem is that you are trying to fit 9 rows into two:
specifically, note that on the left hand side you select only those rows
such that X[,"c"]==1 (which is 2 for your data) while on the right hand you
select all 9rows of column "d" so they simply don't fit. If you change the
code to

X[X[,"c"]==1,"b"]<-X[X[,"c"]==1,"d"]

it will move the column "d" rows corresponding to the ones you've selected
on the LHS. Hopefully that makes sense.

Michael Weylandt

On Wed, Aug 3, 2011 at 8:09 AM, zcatav <zcatav@gmail.com> wrote:

> Your suggestion works perfect as i pointed previous message. Now have
> another
> question about data editing. I try this code:
> X[X[,"c"]==1,"b"]<-X[,"d"]
> and results with error: `[<-.data.frame`(`*tmp*`, X[, "c"] == 1, "b", value
> = c(NA,  :
>  replacement has 9 rows, data has 2
>
> Logically i selected 2 rows with X[,"c"]==1. Than i want to replace in that
> rows its own data from "d" to "b" with X[,"b"]<-X[,"d"]. What is wrong?
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/conditional-data-replace-recode-change-or-whatsoever-tp3714715p3715218.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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]]

