Rtools error in compileCode when using brms package

54 Views Asked by At

My supervisor told me to run the brms package to model my data using the brm() function. When I tried to do that, I had to install Rtools43. After that, when I tried to run the code the following error occured:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file14b04a5d5e69.o:file14b04a5d5e69.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file14b04a5d5e69.o:file14b04a5d5e69.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1c): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file14b04a5d5e69.o:file14b04a5d5e69.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x37): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file14b04a5d5e69.o:file14b04a5d5e69.cpp:(.text$_ZN3tbb10interface
In addition: Warning message:
Rows containing NAs were excluded from the model. 
Error in sink(type = "output") : invalid connection

This is my code:

pacman::p_load(tidyverse, readxl, janitor, emmeans, multcomp, magrittr,
               parameters, effectsize, multcompView, see, performance,
               conflicted, ggpubr, rstatix, nortest)

library(rstatix)
conflict_prefer("select", "dplyr")
conflict_prefer("filter", "dplyr")
conflict_prefer("summarise", "dplyr")
conflict_prefer("extract", "magrittr")


cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") ## Color blind friendly palette
##--------------------------------------------------------------------------------------------------------------------------
## Funktion um Excel Datei mit mehreren Sheets zu öffnen und eines davon auszuwählen
library(readxl)    
read_excel_allsheets <- function(filename) {
  sheets <- readxl::excel_sheets(filename)
  x <- lapply(sheets, function(x) readxl::read_excel(filename, sheet = x))
  return(x)
}

big_tbl <- read_excel_allsheets ("Mesocosms_R.xlsx")
big_tbl

phyto_plankton_tbl<- big_tbl[[14]]

##--------------------------------------------------------------------------------------------------------------------------
## Data transformation
phyto_plankton_tbl %>% 
  mutate( ## Mutieren hier block und trt von chr zu factor
  block = as.factor(block),
  trt = as.factor(trt))

phyto_plankton_tbl <- phyto_plankton_tbl %>% 
  gather(key = "time", value = "PelaChl", t0, t1, t2, t3, t4, t5) %>%  ## Ändert Tabelle aus width format into long format
  convert_as_factor(trt, time)
print(phyto_plankton_tbl, n = 40)

##--------------------------------------------------------------------------------------------------------------------------
## Visualization

pelaChl_bxp <- ggplot(data = phyto_plankton_tbl, aes(x= time, y = PelaChl, fill = trt)) +
  geom_boxplot() + 
  ylim(0, NA) +
  scale_fill_manual(values=cbPalette) + ## Adds color blind firendly palette
  labs(x = "Week", y = "Pelagic Chlorophyll [µg/L]",
       fill = "Treatment") +
  ##  geom_jitter() +
  theme_bw() 
pelaChl_bxp

pelaChl_point <- ggplot(data = phyto_plankton_tbl, aes(x= time, y = PelaChl, color = trt, group = trt)) +
  ## geom_line() 
  ## geom_jitter() +
  scale_color_manual(values=cbPalette) + ## Adds color blind firendly palette
  labs(x = "Week", y = "Total pelagic chlorophyll [µg/L]",
       color = "Treatment") +
  geom_smooth(method='loess', se = FALSE) + ## Method loess nutzt eine polynomiale regression
  theme_bw()
pelaChl_point

##--------------------------------------------------------------------------------------------------------------------------
## Test ANOVA Model assumptions

phyto_plankton_tbl %>% 
  group_by(time, trt) %>% 
  identify_outliers(PelaChl) ## is.extreme checks outliers assumption. Must be FALSE for everyone
## ==> Zeigt extreme outliers 

ggqqplot(phyto_plankton_tbl, "PelaChl", facet.by = "time")
## ==> sieht einigermaßen normally distributed aus

## Classic ANOVA
PelaChl_anova <- aov(PelaChl ~ trt, data = phyto_plankton_tbl)
summary(PelaChl_anova)

library(brms)

##conflicts_prefer(dplyr::add_rownames)
##conflicts_prefer(stats::chisq.test)
##conflicts_prefer(rstatix::cohens_d)
##conflicts_prefer(rstatix::eta_squared)
##conflicts_prefer(stats::fisher.test)
##conflicts_prefer(TH.data::geyser)
##conflicts_prefer(brms::kidney)
##conflicts_prefer(dplyr::lag)
##conflicts_prefer(rstatix::make_clean_names)
##conflicts_prefer(magrittr::set_names)
##conflicts_prefer(effectsize::standardize)

chloro_mod <- brm(log(PelaChl) ~ trt * time + (1|block), data = phyto_plankton_tbl, family = gaussian())
summary(chloro_mod)

I

I searched in different forums and tried to connect to the tbb library, but only found a code for C to do so. I tried reinstalling the Rtools but when i run:

install.packages("Rcpp")
Rcpp::evalCpp("2+2")

it works and puts out 4. So Rtools is working right?

Data:

structure(list(tank = c(1, 2, 3, 5, 7, 8, 9, 10, 11, 13, 14, 
16, 17, 18, 20, 22, 23, 24, 1, 2, 3, 5, 7, 8, 9, 10, 11, 13, 
14, 16, 17, 18, 20, 22, 23, 24, 1, 2, 3, 5, 7, 8, 9, 10, 11, 
13, 14, 16, 17, 18, 20, 22, 23, 24, 1, 2, 3, 5, 7, 8, 9, 10, 
11, 13, 14, 16, 17, 18, 20, 22, 23, 24, 1, 2, 3, 5, 7, 8, 9, 
10, 11, 13, 14, 16, 17, 18, 20, 22, 23, 24, 1, 2, 3, 5, 7, 8, 
9, 10, 11, 13, 14, 16, 17, 18, 20, 22, 23, 24), block = c(1, 
1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 1, 1, 1, 2, 
2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 1, 1, 1, 2, 2, 2, 3, 
3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 
4, 4, 5, 5, 5, 6, 6, 6, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 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1", "t2", 
    "t3", "t4", "t5"), class = "factor"), PelaChl = c(NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, 4.4, 0.8, 3.6, 2.2, 3.5, 2.1, 1.6, 1.3, 6.7, 3.2, 1.3, 
    1.3, 1.9, 2.6, 0.6, 5, 1.7, 1.1, 5.2, 1.5, 3.5, 6, 2.3, 1.7, 
    2.2, 1.2, 3.1, 1.9, 1.7, 1.1, 6.8, 1.6, 0.8, 4.9, 6.5, 1.2, 
    5.6, 3.4, 4.1, 15.6, 3.8, 2.9, 3.5, 2.3, 5.3, 6.4, 1.7, 1.9, 
    5.2, 3.3, 2.8, 1.7, 13.6, 0.9, 8.5, 5.9, 5.3, 13.1, 7.2, 
    4.5, 7.9, 2.8, 11.4, 9.8, 1.9, 11.9, 34.6, 25.3, 6.1, 3.7, 
    11, 3, 33, 8.4, 21.4, 21.1, 20.6, 12.4, 19.2, 2.3, 23, 22.4, 
    6.7, 34.8, 18.1, 9.5, 20.1, 117.9, 24.6, 22.5)), row.names = c(NA, 
-108L), class = c("tbl_df", "tbl", "data.frame"))
> phyto_plankton_tbl<- big_tbl[[14]]
> dput(phyto_plankton_tbl)
structure(list(tank = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24), block = c(1, 
1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 
6, 6), trt = c("P+/F+", "Control", "P-/F+", "LV", "P+/F+", "LV", 
"Control", "P-/F+", "P-/F+", "Control", "P+/F+", "LV", "P-/F+", 
"Control", "LV", "P+/F+", "Control", "P+/F+", "LV", "P-/F+", 
"LV", "P+/F+", "P-/F+", "Control"), t0 = c(NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA), t1 = c(4.4, 0.8, 3.6, 1.6, 2.2, 3.1, 3.5, 2.1, 1.6, 
1.3, 6.7, 2.7, 3.2, 1.3, 0.9, 1.3, 1.9, 2.6, 1.2, 0.6, 3.6, 5, 
1.7, 1.1), t2 = c(5.2, 1.5, 3.5, 1.9, 6, 6.1, 2.3, 1.7, 2.2, 
1.2, 3.1, 3.7, 1.9, 1.7, 0.9, 1.1, 6.8, 1.6, 2.2, 0.8, 7.3, 4.9, 
6.5, 1.2), t3 = c(5.6, 3.4, 4.1, 6, 15.6, 2.6, 3.8, 2.9, 3.5, 
2.3, 5.3, 2.1, 6.4, 1.7, 2.2, 1.9, 5.2, 3.3, 2.3, 2.8, 3.5, 1.7, 
13.6, 0.9), t4 = c(8.5, 5.9, 5.3, 7.2, 13.1, 3.7, 7.2, 4.5, 7.9, 
2.8, 11.4, 2.1, 9.8, 1.9, 5, 11.9, 34.6, 25.3, 4, 6.1, 6.8, 3.7, 
11, 3), t5 = c(33, 8.4, 21.4, 6.5, 21.1, 18.5, 20.6, 12.4, 19.2, 
2.3, 23, 10.5, 22.4, 6.7, 8.8, 34.8, 18.1, 9.5, 8, 20.1, 4.2, 
117.9, 24.6, 22.5)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
-24L))
0

There are 0 best solutions below