Hi,

I have a data frame x, and a vector y which limits x by rows
so that no element of x in that row is smaller than y.

For example,

> x <- as.data.frame( t( array( 1:9, dim=c(3,3))))
> y <- c( 2, 8, 0 )
> x
  V1 V2 V3
1  1  2  3
2  4  5  6
3  7  8  9
> y
[1] 2 8 0

=============================================
I want to get this:

  V1 V2 V3
1  2  2  3
2  8  8  8
3  7  8  9

=============================================

I tried:

x[ x<=y ] <- y

but R wasn't happy.

I know I can do this with a loop, but there has to be a way which I can avoid 
it...

Thanks in advance.

- Ken

______________________________________________
[email protected] 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