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:> On 06/09/2021 10:16 a.m., John Tully wrote:
>> Dear colleagues
>>>
>>> in conducting a meta-analysis (of MRI data) I am running into the
repeated issue:
>>>
>>> Error: Assigned data `single_study_df` must be compatible with
existing data. ? Error occurred for column `accumbens_sd`. x Can't convert
from <double> to <logical> due to loss of precision. * Locations: 1,
2. Run `rlang::last_error()` to see where the error occurred.
>
> That certainly looks like a tidyverse error, specifically from the
> tibble package.
>
> Duncan Murdoch
>
>>>
>>> This follows the commands
>>>
>>> for (region in regions){
>>> for (study in unique(df$studyid)){
>>> single_study_df <- df %>% filter(studyid==study)
>>> if (is.na(single_study_df[sprintf('%s_mn',
region)][[1]]) & !is.na(single_study_df[sprintf('%s_mn_l',
region)])){
>>> df <- calc_bilat(study, region, r, df)
>>> }
>>> }
>>> }
>>>
>>>
>>> My colleague (cc'd) believed it may be an issue with tidyverse
version, however using an older version (1.2.1), the issue persists. note
'accumbens' is the first of many columns so I suspect this is why it
flags this up.
>>>
>>> I would greatly value your input on this matter
>>>
>>> Kind regards
>>>
>>> John Tully
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>> This message and any attachment are intended solely for the addressee
>> and may contain confidential information. If you have received this
>> message in error, please contact the sender and delete the email and
>> attachment.
>>
>> Any views or opinions expressed by the author of this email do not
>> necessarily reflect the views of the University of Nottingham. Email
>> communications with the University of Nottingham may be monitored
>> where permitted by law.
>>
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>