With a function f
f <- function(x) { data.frame(a=c(x, 2*x), b=c(2*x, 4*x)) }
we can construct two data frames
df1 <- f(5)
df2 <- f(5)
and want to confirm that they they are equal. Because we ultimately want to obtain a Boolean, we use identical
, and indeed
identical(df1, df2)
evaluates to TRUE.
Now we compute three terms
terms <- lapply(rep(5, 3), f)
and want to determine whether the three data frames are equal. We choose to compare with the first term
first.term <- terms[1]
and evaluate
lapply(terms,
function(x) identical(x, first.term))
but we get three FALSEs, not three TRUEs. What am I missing?