Displaying 1 result from an estimated 1 matches for "change_y".
2008 Oct 20
3
Trying to pass arrays as arguments to a function
...e value of "y" according to values in
"x". Wherever "x" holds the value 3, the corresponding value in "y"
should be set to 1.
So I tried the following giving an error message:
#################
x <- c(1,2,3,2,2,3,1,1,3,3)
y <- c(0,0,1,1,0,0,1,0,0,1)
Change_y <- function() {
if (x == 3) {y <- 1}
}
do.call("Change_y", as.list(x,y))
Error in Change_y(1, 2, 3, 2, 2, 3, 1, 1, 3, 3) :
unused argument(s) ( ...)
##################
How should it be done?
Cheers,
Kare
[[alternative HTML version deleted]]