I can't install/run package rms and others

I need some help here please, I've tried everything, I can't use the library(rms) despite the fact that it's installed, please check this screenprint, I've even reisntalled R and RStudio

install.packages('rms')
#WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
  
#  https://cran.rstudio.com/bin/windows/Rtools/
#  Installing package into ‘C:/Users/abroc/OneDrive - UBC/Documents/R/win-library/4.1’
#(as ‘lib’ is unspecified)
#trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/rms_6.2-0.zip'
#Content type 'application/zip' length 2167600 bytes (2.1 MB)
#downloaded 2.1 MB

#package ‘rms’ successfully unpacked and MD5 sums checked

#The downloaded binary packages are in
#C:\Users\abroc\AppData\Local\Temp\Rtmp6l5UM6\downloaded_packages

install.packages('rms')

#Loading required package: Hmisc
#Error: package or namespace load failed for ‘Hmisc’ in namespaceExport(ns, exports):
#  undefined exports: htmlDependencies<-, HTML, a, as.tags, attachDependencies, br, browsable, capturePlot, code, copyDependencyToDir, css, defaultPngDevice, div, doRenderTags, em, extractPreserveChunks, findDependencies, h1, h2, h3, h4, h5, h6, hr, htmlDependencies, htmlDependency, htmlEscape, htmlPreserve, htmlTemplate, html_print, img, includeCSS, includeHTML, includeMarkdown, includeScript, includeText, is.browsable, is.singleton, knit_print.html, knit_print.shiny.tag, knit_print.shiny.tag.list, makeDependencyRelative, p, parseCssColors, plotTag, pre, renderDependencies, renderDocument, renderTags, resolveDependencies, restorePreserveChunks, save_html, singleton, span, strong, subtractDependencies, suppressDependencies, surroundSingletons, tag, tagAppendAttributes, tagAppendChild, tagAppendChildren, tagFunction, tagGetAttribute, tagHasAttribute, tagList, tagSetChildren, tags, takeSingletons, urlEncodePath, validateCssUnit, withTags
#Error: package ‘Hmisc’ could not be loaded
#In addition: Warning message:
#  S3 methods ‘as.character.html’, ‘as.character.shiny.tag’, ‘as.character.shiny.tag.list’, ‘as.tags.character’, ‘as.tags.default’, ‘as.tags.html’, ‘as.tags.html_dependency’, ‘as.tags.list’, ‘as.tags.shiny.tag’, ‘as.tags.shiny.tag.function’, ‘as.tags.shiny.tag.list’, ‘format.html’, ‘format.shiny.tag’, ‘format.shiny.tag.list’, ‘print.html’, ‘print.html_dependency’, ‘print.shiny.tag’, ‘print.shiny.tag.list’ were declared in NAMESPACE but not found 

> .libPaths()
#[1] "C:/Users/abroc/OneDrive - UBC/Documents/R/win-library/4.1" "C:/Program Files/R/R-4.1.2/library"                       
#Warning message:
#  S3 methods ‘as.character.html’, ‘as.character.shiny.tag’, ‘as.character.shiny.tag.list’, ‘as.tags.character’, ‘as.tags.default’, ‘as.tags.html’, ‘as.tags.html_dependency’, ‘as.tags.list’, ‘as.tags.shiny.tag’, ‘as.tags.shiny.tag.function’, ‘as.tags.shiny.tag.list’, ‘format.html’, ‘format.shiny.tag’, ‘format.shiny.tag.list’, ‘print.html’, ‘print.html_dependency’, ‘print.shiny.tag’, ‘print.shiny.tag.list’ were declared in NAMESPACE but not found 

Here is the screenprint
https://drive.google.com/file/d/1p-IjoETu64WIIwfegzQjEEGnQg-3DTD8/view?usp=sharing

Thanks in advance,

Andres

Try reinstalling the Hmisc package

Install.packages("Hmisc")

It is possible though that your problem is caused by the use of a synced folder (OneDrive in your case) for your package library, R has known problems with this. I recommend you to set your package library in a non synced folder.

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"

For a more detailed explanation, you can read this blog post

Andres,

Many thanks for your kind help, I'll try now and let you know how it goes.

Best,

Andres

Andres,

Te comento que no funciono, al parecer R no tiene los permisos de administrador para escribir en ese archivo... como puedo cambiar esto?

Este fue el mensaje que tuve

> R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"
> install.packages('rms')
Installing package into ‘C:/Users/abroc/OneDrive - UBC/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/rms_6.2-0.zip'
Content type 'application/zip' length 2167600 bytes (2.1 MB)
downloaded 2.1 MB

package ‘rms’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\abroc\AppData\Local\Temp\Rtmp2xlGlM\downloaded_packages

Primero ejecute el R_LIBS_SITE="C:\Program Files\R\R-4.1.2\library" pero sigue sin cambiar...

> R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"
> .libPaths()
[1] "C:/Users/abroc/OneDrive - UBC/Documents/R/win-library/4.1" "C:/Program Files/R/R-4.1.2/library"                       
> 

Esto mas y no te molesto mas, te comento que logre solucionar el problema siguiendo esta solucion

Let's assume you want your packages to reside in C:\R\Library :

  1. Create the folder C:\R\Library
  2. Click Start --> Control Panel --> User Accounts --> Change my environmental variables
  3. The Environmental Variables window pops up. If you see R_LIBS_USER , highlight it and click Edit . Otherwise click New . Both actions open a window with fields for Variable and Value .
  4. In my case, R_LIBS_USER was already there, and the value was a path to my desktop. I added to the path the folder that I created, separated by semicolon as mentioned above. C:\R\Library;C:\Users\Eric.Krantz\Desktop\R stuff\Packages . NOTE: I could have removed the path to the Desktop location and simply left C:\R\Library .

Saludos,

Andres

Definir esa variable en tu entorno de R no cambia la ubicación de tu librería de paquetes, tienes que definirla como una variable de entorno de sistema en tus archivos de arranque para R, tal como lo explico en la respuesta que te di y con mayor detalle en el artículo de blog que te proporcioné.

Por otro lado este mensaje indica que rms se instaló correctamente

Tu problema inicial no era con el paquete rms en si, sino con una dependencia de éste, el paquete Hmisc así que reinstalar rms no era relevante para tu problema.

Lo que has hecho con la solución que mencionas es definir la variable de entorno a nivel de tu sistema operativo, esto no es aconsejable porque el cambio no queda documentado y a futuro si tienes algún problema relacionado con esto va a ser más difícil de identificar la causa.

Gracias por el mensaje, seguiré trabajando para poder usar la solución que me diste al inicio
Saludos,

Por si te es más cómodo, el artículo de blog que te mencione también tiene versión en español

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.