Skip to content
Prev 389090 / 398506 Next

'Double to logical' error

You get this error from this kind of operation on tibbles:

library(tibble)
t1 <- tibble(x = c(TRUE, FALSE))
t2 <- tibble(x = c(1.2, 1.3))
t1[1,] <- t2[1,]
#> Error: Assigned data `t2[1, ]` must be compatible with existing data.
#> ? Error occurred for column `x`.
#> x Can't convert from <double> to <logical> due to loss of precision.
#> * Locations: 1.

If t1 had been a data.frame instead of a tibble, this would convert t1$x 
to type double.  So it is possible some code you are using assumes 
things inheriting from class "data.frame" act like dataframes.  Or maybe 
they were just sloppy.  In any case, you might be able to fix it by 
changing single_study_df to a dataframe using

   single_study_df <- as.data.frame(single_study_df)

Duncan Murdoch
On 06/09/2021 12:34 p.m., Duncan Murdoch wrote: