Why is R library not loading in app.powerbi.com? - r

I keep getting the following error on app.powerbi.com:
"Error in pivot_wider(data, names_from=names,values_from=values): could not find function "pivot_wider""
I load the 'tidyr' package as a required library.
I get the same error when using "spread" instead of pivot_wider.
When I specify the function using:
tidyr::pivot_wider(data, names_from=names, values_from=values)
I get a different error:
"Error in loadNamespace(name): there is no package called 'tidyr'".
PowerBI Desktop everything works perfectly fine. It's only on the published PowerBI report that I get the error.
What can I do to resolve this issue?
Alternative library / function to 'pivot_wider' or 'spread'?

I was able to verify using print statements that the report on powerbi.com was not able to access the r packages that were installed.
I was using a .libPaths()[3] to point to the location where my libraries were installed, but this didn't work in powerbi.com.
I ended up re-installing R to a location where I could install packages to, since admin rights are necessary to write to the C:/users/program files location.

Related

Unable to locate package RCurl - R in Streamlit

Guys, I'm having problems deploying my streamlit application, I include the RCurl package in the packages.txt list, however the deploy is interrupted with the following message:
unable to locate package RCurl
Another interesting thing:
The first time I deployed, RCurl was not included, and my application ran normally.
However when I performed a second deployment of the same application, when executing a function dependent on this package it returned "there is no package called RCurl"
Importantly, this same function was performed on the first deploy.
From then on I tried both ways:
listing the RCurl in packages.txt, and
not listing RCurl in packages.txt
in the first form the deploy is completed but when executing the function the following message is returned "there is no package called RCurl"
and when trying the second way the deploy is interrupted with the following message: 'Unable to locate package RCurl'
Can anyone give me a hint of a possible solution?
Thanks!

how can fix this issue "Error in h2o.upload_model() : could not find function "h2o.upload_model"?

I have installed h2o package(in R from RStudio console). Post h2o.init() I am trying to use the built in function upload_model()/upload_mojo() but I am getting following error.
h2o.upload_mojo()
Error in h2o.upload_mojo() : could not find function "h2o.upload_mojo"
h2o.upload_model()
Error in h2o.upload_model() : could not find function "h2o.upload_model"
I found work around to resolve this issue. Please find below the steps I followed:
Remove the package using: remove.packages("h2o")
Quit the current session and launch the new one.
Move out lock file for h2o from path where package was installed mostly under R with file name like - 00LOCK-h2o
Install new/latest version of package via RStudio console using install.packages()
It should now resolve this issue.

Deploy custom R script as web service Azure ML Studio

I have an R script which takes as input an excel file with two columns containing dates-values and it gives as output 3 dates with the corresponding prediction values. I have already successfully implemented it in Azure Machine Learning Studio using three nodes. One containing the zipped packages I use, one with the input .csv file and the last one with the R script.
The problem is when I deploy it as a web service and I try to give as input new values for Col1 and Col2, I receive the following error.
FailedToParseValue: Failed to parse value '90000, 950000, 970000' as type 'System.Double'., Error code: LibraryExecutionError, Http status code:400
The zipped libraries I use attached are: Hmisc, gdata, forecast, lubridate, fma, expsmooth, ggplot2, tsibble, fpp2, and plyr. I have also tried using the notebooks provided but no good luck as I always face some kind of problem with package installation. Moreover, I tried to follow this approach https://azure.github.io/azureml-sdk-for-r/articles/train-and-deploy-to-aci/train-and-deploy-to-aci.html locally from R Studio but I have difficulty in adapting it to my case.
Any help would be greatly appreciated!
I didn't have any success installing packages via a zip. However the following worked for me in an Execute R Script and installed all dependancies also.
if(!require(package)) install.packages("package",repos = "https://ftp.heanet.ie/mirrors/cran.r-project.org/")
Make sure that your repo is from CRAN in your country.

Using the package RAdwords in an R script on a Unix server Error in rjson

I have the following script, which works perfectly fine, when I run it on my local PC:
library(RAdwords)
autX <- doAuth()
data <- getData(clientCustomerId='xxx-xxx-xxxx',
google_auth=autx
)
However, when I try to run the very same script on my Unix-Server, then I get this error message:
Error in rjson::fromJSON(RCurl::postForm("https://accounts.google.com/o/oauth2/token", :
STRING_ELT() can only be applied to a 'character vector', not a 'raw'
Question: What could be the reason and how can I fix it?
By the way:
I did copy the files .gitgnore and .google.auth.RData from the folder on my local PC, where I already did this authentification, to the directory on my server.
If I just type doAuth() alone I do not get an error message.
Issue:
getData()calls the function refreshToken() that updates the authentication token of the Google AdWords API. Within the function refreshToken the RCurl command returns a raw data file instead of a character file format. rjson::fromJSON returns an error that is solved with the addition of rawToChar().
Solution:
I created a patch of the function and updated the Github development version of RAdwords.
You can install the new package version with:
require(devtools)
install_github('jburkhardt/RAdwords')

What is this error: File does not exist error with roxygenise?

I have been using roxygen2::roxygenise quite successfully with my package to build exported and imported functions. However, I recently ran into this error which I am unable to resolve:
> roxygen2::roxygenise()
First time using roxygen2. Upgrading automatically...
Error: File file does not exist
This is not the first time I have used roxygen2 with this package. In addition, I am not quite sure what "File file does not exist" means. Has anyone else seen this and been able to resolve it?
I think you have to set the working directory of R to be the package folder
I got the same error when using:
roxygen2::roxygenise("mypackage")
But, I didn't get the error when I instead used:
library(roxygen2)
roxygenise()
I know this is no explanation and I can't comment upon whether this works beyond my case.

Resources