Try n <- 1 f <- if (n == 1) sin else cos f(pi)
On 10/7/06, Alberto Vieira Ferreira Monteiro <[EMAIL PROTECTED]> wrote: > Why this kind of assignment does not work? > > n <- 1 > f <- ifelse(n == 1, sin, cos) > f(pi) > > this must be rewritten as: > > n <- 1 > f <- cos > if (n == 1) f <- sin > f(pi) > > [oops. 1.224606e-16 instead of zero. Damn floating point errors :-/] > > Alberto Monteiro > > ______________________________________________ > [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. > ______________________________________________ [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.
