How to input R package from local PC directory - r

I need to use a package from Hogg's Introduction to Mathematical Statistics text. It is not found on cranR. R input follows below. Package is in 3.5 directory.
library(hmcpkg, lib.loc="C:/Users/mmsta/Documents/R/win-library/3.5")
Error message:
Error in library(hmcpkg, lib.loc = "C:/Users/mmsta/Documents/R/win-library/3.5") : ‘hmcpkg’ is not a valid installed package
How to do without going to Hogg website when I have the directory hmcpkg on my hard drive? This is a generic question; I have encountered this before. I would also like to avoid the complexity of github.
Thanks.
Mary A. Marion

Related

Error installing xml2 in R (Unable to load shared object)

Let's start with, i am pretty new to both linux (CentOS) and R.
I was given a task to install xml2 package, for that i ran
install.packages("xml2")
and error occured
** R
** inst
** byte-compile and prepare package for lazy loading'
** help
Error : unable to load shared object '/home/<username>/R/x86_64-redaht-linux-gnu-library/3.6/00LOCK-xml2/00new/xml2/libs.so':
libicui18n.so.58: cannot open shared obejct file: No such file or directory
Error: installaing RD objects failed for package 'xml2'
* removing '/home/<username>/R/x86_64-redaht-linux-gnu-library/3.6/xml2'
Then i went ahead and did some research on this issue and found much (maybe to resolve it), but couldn't really understand because of lack of knowledge.
So first thing i did was to search if i even have libicui18n.so.58 by doing locate libicui18n and could find something but not 58.
So I started by downloading ICU 58 source and compiling it manually.
It was successfully done.
Still, there was a same error. Although i could find libicui18n.so.58 by doing locate libicui18n this time.
Now i'm lost because there are so many locations where it shows all the versions of libicui18n.so.58.
Also, when i do $LD_LOCATION_PATH, there's nothing for the output.
Please, if you could, explain it to me what i need to do to resolve it now.
Also, the output of locate command is:
/home/Zach/.local/lib/python3.7/site-packages/PyQt5/Qt5/lib/libicui18n.so.56
/home/Zach/Downloads/test/icu-release-58-3/icu4c/source/lib/libicui18n.so
/home/Zach/Downloads/test/icu-release-58-3/icu4c/source/lib/libicui18n.so.58
/home/Zach/Downloads/test/icu-release-58-3/icu4c/source/lib/libicui18n.so.58.3
/opt/anaconda3/lib/libicui18n.so
/opt/anaconda3/lib/libicui18n.so.58
/opt/anaconda3/lib/libicui18n.so.58.2
/opt/anaconda3/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so
/opt/anaconda3/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so.58
/opt/anaconda3/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so.58.2
/opt/anaconda3/pkgs/icu-58.2-he6710b0_3/lib/libicui18n.so
/opt/anaconda3/pkgs/icu-58.2-he6710b0_3/lib/libicui18n.so.58
/opt/anaconda3/pkgs/icu-58.2-he6710b0_3/lib/libicui18n.so.58.2
/root/opt/lib/libicui18n.so
/root/opt/lib/libicui18n.so.58
/root/opt/lib/libicui18n.so.58.2
/root/opt/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so
/root/opt/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so.58
/root/opt/pkgs/icu-58.2-h9c2bf20_1/lib/libicui18n.so.58.2
/usr/lib/rstudio/lib/libicui18n.so.56
/usr/lib64/libicui18n.so
/usr/lib64/libicui18n.so.50
/usr/lib64/libicui18n.so.50.2
/usr/lib64/webkit2gtk-4.0/libicui18n.so.57
/usr/lib64/webkit2gtk-4.0/libicui18n.so.57.1
/usr/local/lib/libicui18n.so
/usr/local/lib/libicui18n.so.58
/usr/local/lib/libicui18n.so.58.3
/var/lib/docker/overlay2/8aab92bb1b0ffb1addfc835da5c31c169d7af7cc5c825a93f529ab8d4c9cdead/diff/usr/lib/x86_64-linux-gnu/libicui18n.so.66
/var/lib/docker/overlay2/8aab92bb1b0ffb1addfc835da5c31c169d7af7cc5c825a93f529ab8d4c9cdead/diff/usr/lib/x86_64-linux-gnu/libicui18n.so.66.1
/var/lib/docker/overlay2/d445cc4c7c11f7e66bcd0f198287e6b6830b33099fcfe884bc3d0e57d0116c16/diff/usr/lib/x86_64-linux-gnu/libicui18n.so.67
/var/lib/docker/overlay2/d445cc4c7c11f7e66bcd0f198287e6b6830b33099fcfe884bc3d0e57d0116c16/diff/usr/lib/x86_64-linux-gnu/libicui18n.so.67.1
/var/lib/flatpak/runtime/org.kde.Platform/x86_64/5.11/02ede84d3591a5ea8028204d86059bffaccb778159ec53c859bbc60d9e7025e8/files/lib/libicui18n.so.57
/var/lib/flatpak/runtime/org.kde.Platform/x86_64/5.11/02ede84d3591a5ea8028204d86059bffaccb778159ec53c859bbc60d9e7025e8/files/lib/libicui18n.so.57.1
/volumes/user/home/Zach/.local/lib/python3.7/site-packages/PyQt5/Qt5/lib/libicui18n.so.56
/volumes/user/home/Zach/Downloads/test/icu-release-58-3/icu4c/source/lib/libicui18n.so
/volumes/user/home/Zach/Downloads/test/icu-release-58-3/icu4c/source/lib/libicui18n.so.58
/volumes/user/home/Zach/Downloads/test/icu-release-58-3/icu4c/source/lib/libicui18n.so.58.3```

install.packages function does not recognize new library path in RStudio

I am connecting remotely to a work server and need to be able to install R packages via RStudio. I have read through other questions/answers on this topic, but haven't been able to solve this for myself. I think the following input and output shows my issues the best: (edit: I do not have admin powers, but can call IT as last resort)
>.libPaths("C:/RWorkSpace") #setting new file path
>.libpaths() #testing
[1] "C:/RWorkSpace" "C:/Program Files/R/R-3.4.1/library"
>install.packages("bibliometrix", dependencies = TRUE, lib="C:/RWorkSpace")
The downloaded source packages are in
‘C:\Users\cortiz\AppData\Local\Temp\7\RtmpOsVuTB\downloaded_packages’
>library(bibliometrix)
Error in library(bibliometrix) : There is no package called 'bibliometrix'
>installed.packages()["bibliometrix","C:/RWorkSpace"]
Error in installed.packages()["bibliometrix","C:/RWorkSpace"] : subscript out of bounds
I just need to download the package and dependencies, and I expected them to be downloaded to the folder I specified ("C:/RWorkSpace").
very new to working with R in general so please bear with me. Any help greatly appreciated!

Weird issue while testing R package: package `[package name]` found more than once, using the first from [file path]

I'm working on a somewhat complex package (that I unfortunately can't share) that involves a Shiny app, and it an issue has surfaced where I'm getting these warnings when testing:
package [package name] found more than once, using the first from [file path]
In library(testthat) : package ‘testthat’ already present in search()
The first one occurs because I'm using system.file to pull a file in inst that I use for testing.
I've tried to do some debugging with .libPaths and by forcing system.file to go to the .libPaths default with the lib.loc argument, but that doesn't do anything.
I've tried uninstalling the package, which works because then there are not multiple results for find.package.
It seems like testthat adds the current directory to the library paths while it's running, and this creates the issue with system.file and consequently, find.package.
I'm really confused as to what's causing this. I'm combing through the changes I've made and I can't seem to find anything. Any ideas are helpful. I've tried googling this error messages and all that comes up is the source.
The issue here was with changing the option setting for verbose. That caused more output to result from the code, which broke a lot of tests. I hope this helps someone in the future.

Error when installing the 'graphics' package (but not others) in R

I am a starter in R and new to StackOverflow and this is the first time I raise a question, I hope i'm following all the rules...
Anyway. I got R (3.5.0 version) and R-Studio on my laptop with Win 10 Home installed (under the same parent folder 'D:\') and reset the temporary file directory to a folder in D:\ so that the Chinese in C:\Users\中文\documents (which is the default place for tempo files) doesn't affect the connection btw R-studio and R (I was told any relevant directory has to be in English to make R-Studio work).
The problem is, I cannot install the 'graphics' package when I run
install.packages('graphics')
The resulting error says something like this:
>Error in install.packages : Updating loaded packages
>Restarting R session...
>Error in gzfile(file, "wb") : cannot open the connection
>Error saving session (options): R code execution error
>WARNING: Forcing suspend of process in spite of all session data not being fully saved.
It's quite weird since the 'graphics' package is pretty basic and as a matter of fact I haven't found anyone reporting such errors on the internet.
It also bothers me that other packages like 'forecast' and 'XML' can be successfully installed without any error report.
I've looked at some similar questions on StackOverflow, having error reports with "Error in gzfile(file, "wb") : cannot open the connection", but they all seem to have something else to complete the sentence. In my case it just stops the error description with "cannot open the connection". Also I couldn't find people having similar problems with "Error saving session (options): R code execution error".
I do realize that this is quite unusual. I can't even find the proper tags other than r for this question. Although it seems that no one has trouble with the 'graphics', this problem is really bothering me and I hope someone can give possible solutions. Thanks a lot.

Cannot find function readDICOM, though oro.dicom is installed

I am struggeling with reading DICOM files in R. I have installed the oro.dicom package, using:
install.packages("oro.dicom", repos="https://cran.cnr.berkeley.edu/")
I have set the working directory to where the files are located.
When trying to read a dicom file, using...
slice=readDICOM("IM-0001-0011.dcm")
... I get the following error message:
Error: could not find function "readDICOM"
Can someone help?
Thank you,
Lena
You should load package with library(oro.dicom) fisrt before you will use functions from that package,

Resources