Forum Discussion
R Script Error: Package or namespace load failed for 'tidyverse': .onLoad....
Hi,
Currently unable to resolve the error message below when attempting to refresh my desktop PBI report file.
I have the following installed on my cpu:
- Download Microsoft R Open 4.0.2
- Download R-4.2.0 for Windows
- R Studio( 2022.02.0 Build 443)
- install.packages("tidyverse")
- install.packages("dplyr")
- install.packages("stringr")
- Microsoft PBI Desktop (2.106.883.0)
The following R- Script is used in my PBI report:
library(tidyverse)
library(dplyr)
library(stringr)
regx_0 <-'([0]{6,}\\d{1})'
regx_9 <-'([9]{6,}\\d{1})'
# Only selecting distinct Material Numbers
dataset <- dataset %>% distinct(`Material Number`)
# Filtering data to records with valid Material Numbers (fewer than 8 digits after decimal)
data_clean <- dataset %>% filter(!str_detect(`Material Number`,'\\.\\d{8,}$'))
data_clean <- data_clean %>% mutate(Material_Number_Clean = `Material Number`)
# Filtering data to invalid records (Material Number > 8 digits after decimal)
data <- dataset %>% filter(str_detect(`Material Number`,'\\.\\d{8,}$'))
# Identifying if floating points are a bunch of 0's or 9's
data00 <- data %>% filter(str_detect(`Material Number`, regx_0))
data99 <- data %>% filter(str_detect(`Material Number`, regx_9))
# If 0's just strip off the floating points
data00 <- data00 %>% mutate(Material_Number_Clean = str_replace(`Material Number`,regx_0,''))
# If 9's, round up one decimal place
data99 <- data99 %>% mutate(Material_Number_Clean = str_replace(`Material Number`,regx_9,''))
data99 <- data99 %>% mutate(round = str_replace_all(Material_Number_Clean,'[0-9]','0'))
data99 <- data99 %>% mutate(round = str_replace(round, '0$','1'))
data99 <- data99 %>% mutate(Material_Number_Clean = as.character(as.numeric(Material_Number_Clean) + as.numeric(round)))
data99 <- data99 %>% select(-round)
# Union clean data, 0's data, and 9's data together
OUT <- bind_rows(data_clean, data00, data99)
1 Reply
- v-kkf-msftCommunity Support
Hi Anonymous ,
The most current version of R supported on both Power BI Desktop and the Power BI service is version 3.4.4.
Please also refer to the package versions supported by Power BI Service.
Create visuals by using R packages in the Power BI service
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.