How to load the package {sjPlot} in R? - r

There's an older post from a year ago, here, that touches upon a similar issue. Now I'm facing almost axactly the same issue as Bikash was approximately a year ago. However, the solution suggested there, does not seem to work in my case.
The error message when loading {sjPlot} with library(sjPlot) reads:
Error: package or namespace load failed for ‘sjPlot’
It also tells me (loosely translated from German):
Error: Object ‘asis_output’ not exported by 'namespace:knitr'
So whatever that means, I thought I try loading {knitr} first and then try loading {sjPlot} again. But I ran into the exact same error message...
Thanks in advance!

Related

Problem loading SjPlot after installing parameters

I'm getting the almost the same error as the previous post, but the answers there are not working for me. I was able to use sjPlot with no issues until this afternoon when I installed parameters and sandwich and clubsandwich. I don't know what else I can do to get over this.
the error:
> library(sjPlot)
Error: package or namespace load failed for ‘sjPlot’:
object ‘standard_error_robust’ was not exported by 'namespace:parameters'
In addition: Warning message:
package ‘sjPlot’ was built under R version 4.1.3
Any help would be much appreciated. Updating parameters didn't solve it. Meanwhile, is there an equivalent function for tab_model()? (since I cannot use it...). Thanks in advance.
devtools::install_github("strengejacke/sjPlot") worked for me :D

Rcpp can't find nloptrAPI.h header

I'm trying to find an Rcpp replacement for the base optimize function. This link
https://github.com/eddelbuettel/rcppnloptexample/blob/master/src/nlopt.cpp
is a potential solution but I can't get past the sourceCpp error
Error in Rcpp::sourceCpp("R/nlopt.cpp") :
Error 1 occurred building shared library.
> library('nloptr')
> Rcpp::sourceCpp("R/nlopt.cpp")
nlopt.cpp:4:10: fatal error: 'nloptrAPI.h' file not found
The header file is in fact on my computer at /Library/Frameworks/R.framework/Versions/4.1/Resources/library/nloptr/include
I can include the whole path to the header and it seems to work fine but that seems a bit kludgy.
What do I need to do to tell R or Rcpp where to look?
This link as some useful discussion about the issue of finding headers.
https://stackoverflow.com/questions/13995266/using-3rd-party-header-files-with-rcpp has useful information.
To find out where your 'missing' header is located, the /Library/Frameworks ... link above is useful, replacing nloptr with the name of the package that has the header you are looking for.

Does anyone know what this error message (from the 'readxl' package in R) means?

I'm trying to open an Excel worksheet in R using the 'readxl' package function 'read_excel'.
library(readxl)
Test <- read_excel("Test.xlsx",sheet = "Sheet1")
I've used the exact same bit of code on the exact same excel workbook many times over the past year, and it has never caused a problem. This time, though, I get:
Error: object ‘data_frame’ is not exported by 'namespace:vctrs'
I've tried calling the file different things, moving it to different locations, opening different files etc. but am now always getting this error with the read_excel function. I can usually work out what to do in response to an error message by searching for the relevant string in Google. However, I've tried searching for this error message, and haven't found anything that looks helpful yet. If anyone has any ideas, these would be much appreciated!
It looks like data_frame is relatively new to vctrs. You may need to update your vctrs package. You may have accidentally rolled back to an earlier version?
Seems it was added here:
vctrs 0.3.3 2020-08-27

R: Error in as.environment(pos) / Error during wrapup: no item called "package:[package]" on the search list

This is similar to this but with a followup question:
I'm preparing my package for submission to CRAN. In one script, it gives the titular error:
Error in as.environment(pos): no item called "package:shapefiles" on the search list
or
Error during wrapup: no item called "package:shapefiles" on the search list
If, like the similar thread linked above, I add
attachNamespace("shapefiles")
Then I no longer get that error, but instead I sometimes get the error or warning:
namespace(shapefiles) was already taken
I believe this happens if the function/script is run more than once. What's so weird about this to me is that
#' #import shapefiles
is in that script's markdown block,
Which means
import(shapefiles)
is in NAMESPACE, and
Imports:
shapefiles (>= 0.7),
is in DESCRIPTION. I have numerous other package dependencies which are imported the same way (correctly, I believe), and none of them produce this error. I don't see why this is behaving differently therefore, and would like to avoid having either issue before submitting to CRAN. The code that calls this package, in my script, is
shapefiles::read.shapefile(savename)
Script is here, for reference.
Thanks in advance for any ideas!
Edit: steps to reproduce:
setwd("/folder")
library(devtools)
install_github("SimonDedman/gbm.auto")
library(gbm.auto)
gbm.basemap(bounds = c(-81.7, -80.3, 24.7, 25.9),
savedir = "/folder")
I've just removed shapefiles:: from the code. The correct output is produced regardless.
Problem resolved itself after commenting out attachNamespace("shapefiles"). No idea why.

Text mining with tm in R antiword error

So I'm rather new to R, and I'm learning how to mine text from this handy website: https://eight2late.wordpress.com/2015/05/27/a-gentle-introduction-to-text-mining-using-r/
I do have my own text set of .doc, .docx, and .xlsx files and I'm trying to mine them. They're located in a folder in my working directory called 'files', but I have already encountered an error after simply writing a few lines of code.
The code I have so far is:
library(tm)
library(readtext)
data = readtext('files')
At this point, after waiting for 25 seconds or so, I get the error:
Error: System call to 'antiword' failed (1): The Big Block Depot is damaged
and the code stops running there.
I have tried searching online for solutions but it seems like a fairly rare error and so I only found 1 possible solution at https://github.com/ropensci/antiword/issues/1 but that did not work for me.
This solution suggested that one of my files were corrupt, and suggested using the code
fixInNamespace(antiword, pos="package:antiword")
to change the error to a warning to not interrupt the reading of the files. I tried that, and at first it raised the error of
Error in as.environment(pos):
no item called "package:antiword" on the search list
After which, I loaded the antiword library with a library(antiword) and changed the stop( to a warning(. However, when I ran the data = readtext('files') line again, it immediately raised the error
Error in is_windows() : could not find function "is_windows"
I'm at a loss here! Any help would be appreciated. Should I be using another package in this case?
I had the same problem with my code, where I tried to get a doc. file in R. I also used the readtext library. What helped me was converting the Word documents I was trying to get into R from doc. to docx. When I ran the same code after it worked.

Resources