Difficulties uploading Hmisc and gmodels

I have tried to upload the Hmisc and gmodel tools so that I can use the Describe and CrossTable functions on a datapack, and have downloaded RTools, used the studio to upload and extract the zips, and uploaded them as shown below

> install.packages(c("gmodels", "Hmisc"))
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 packages into ‘C:/Users/Robin/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘gtools’, ‘gdata’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/gtools_3.8.2.zip'
Content type 'application/zip' length 336453 bytes (328 KB)
downloaded 328 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/gdata_2.18.0.zip'
Content type 'application/zip' length 1264605 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/gmodels_2.18.1.zip'
Content type 'application/zip' length 114469 bytes (111 KB)
downloaded 111 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/Hmisc_4.4-0.zip'
Content type 'application/zip' length 3168038 bytes (3.0 MB)
downloaded 3.0 MB

package ‘gtools’ successfully unpacked and MD5 sums checked
package ‘gdata’ successfully unpacked and MD5 sums checked
package ‘gmodels’ successfully unpacked and MD5 sums checked
package ‘Hmisc’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\Robin\AppData\Local\Temp\RtmpKApZlC\downloaded_packages
> CrossTable(COPD$copd)
Error in CrossTable(COPD$copd) : could not find function "CrossTable"
> package.install("gmodels")
Error in package.install("gmodels") : 
  could not find function "package.install"
> install.packages("C:/Users/Robin/AppData/Local/Temp/RtmpKApZlC/downloaded_packages/Hmisc_4.4-0.zip", repos = NULL, type = "win.binary")
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/Robin/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
package ‘Hmisc’ successfully unpacked and MD5 sums checked

However, when I run the Describe function after doing that, I get this:

describe(COPD)
Error in describe(COPD) : could not find function "describe"

What have I done wrong, and how can I rectify it?

I don't understand what you mean with "upload" but the correct workflow would be like this

  • Install the packages once with install.packages(c("gmodels", "Hmisc"))

  • If the previous step succedes (you don't get any error messages), then you have to load the packages with:

    library(gmodels)
    library(Hmisc)
    

    Note: You have to repeat this step on each new R session where you want to use the packages.

  • If you get an error message while installing the packages, then post the whole error message here so we can try to figure out what is wrong.

I am taking the same course from London School of Economics. When I issued the library command it worked. We are all R beginners.

Why did it say Rtools was needed? Because it worked without it. The problem with Rtools is that it says that it won't work with Rstudio ver 3.6.3.

Because it is needed on windows for compiling packages from source, luckily, in this case al packages were available on binary versions so it wasn't necessary to compile but that won't always be the case.

The latest RTools40 is meant to be used with R 4.0.0 for your R version you need the previous version RTools35
https://cran.r-project.org/bin/windows/Rtools/history.html

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