Displaying 2 results from an estimated 2 matches for "rslt_with_i".
2025 Apr 19
1
Is it odd or not? about I() function
...ion, about which
I am seeking help.? I wrote a following toy script
which can recreate the situation.
--- the script begins here ---
?? 1?? ? library(tidyverse)
?? 2?? ? library(rlist)
?? 3?? ? library(patchwork)
?? 4?? ? set.seed(42)
?? 5?? ? f <- function(x, y, z, x_axis) {
?? 6?? ??? rslt_with_I <- I(x^2 * 0.5) + I(x * y)
?? 7?? ??? rslt_without_I <- (x^2 * 0.5) + (x * y)
?? 8?? ??? out <- data.frame(rslt_without_I, rslt_with_I)
?? 9?? ??? return(out)
? 10?? ? }
? 11?? ?
? 12?? ? df <- data.frame(
? 13?? ??? x = runif(40, 0, 1),
? 14?? ??? y = runif(40, 0, 1),
? 15?? ?...
2025 Apr 19
1
Is it odd or not? about I() function
...variables:
$ x : num 0.915 0.937 0.286 0.83 0.642 ...
$ y : num 0.3796 0.4358 0.0374 0.9735 0.4318 ...
$ z : int 1 1 1 1 1 1 1 1 1 1 ...
$ x_axis : int 1 2 3 4 5 6 7 8 9 10 ...
$ rslt_without_I: num 0.7657 0.8474 0.0516 1.1533 0.483 ...
$ rslt_with_I : 'AsIs' num 0.765658.... 0.847406.... 0.051648....
1.153295.... 0.482993.... ...
you'll see that the two variables have different *classes*. Your '=='
test checks to see if the *numeric values* of the elements are the same.
Both of these, which check the characteristics...