installing packages and library R 4.4 and Rtools

I have used older version of R for long time and recently installed R 4.4 and R tools. Trying to installed packages and call the library. I'm getting below error.

installed.packages("ggplot2")
Package LibPath Version Priority Depends Imports LinkingTo Suggests Enhances License License_is_FOSS License_restricts_use OS_type Archs
MD5sum NeedsCompilation Built
installed.packages("data.table")
Package LibPath Version Priority Depends Imports LinkingTo Suggests Enhances License License_is_FOSS License_restricts_use OS_type Archs
MD5sum NeedsCompilation Built

Welcome to the forum.

I do not not see an error.

R is simply confirming that {ggplot2} and {data.table} are installed.

What are you trying to do?

I tried to run the below scripts and found below errors.

library(data.table)
Error in library(data.table) : there is no package called ‘data.table’

filename_csv <- data.table(read.csv('~/file_name.csv', header = TRUE)

Error in data.table(read.csv("~/file_name.csv", :
could not find function "data.table"

Strange.

 installed.packages("ABHgenotypeR")

is giving me

     Package LibPath Version Priority Depends Imports LinkingTo Suggests Enhances License License_is_FOSS
     License_restricts_use OS_type Archs MD5sum NeedsCompilation Built

and I definitely don't have it installed so I seem to be misreading
?installed.packages

try

install.packages("data.table")
library(data.table)

Once {data.table} is installed I think that what you want is:

library(data.table)
mydata <- fread("file_name.csv")

fread is data.table's function for reading .csv files.

I think you are misusing installed.packages(). If you want to install the packages, use install.packages(). If you want to check whether the packages are installed, try system.file(package="ggplot2").

Any idea why installed.packages() in telling @ thush and me that we have missing packages installed?

I don't think it is. By design, it generates a data frame of all packages found under the specified directory. The first argument is supposed to be a directory/path. In this case, the directory ("ggplot2" or "ABHgenotypeR" or whatever) does not exist, so the data frame is empty. What you're seeing is the column headings for the empty data frame.

I tried install.packages("ggplot2"). but didn't solve the issue.

install.packages("ggplot2")
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/src/contrib:
cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
package ‘ggplot2’ is not available for this version of R

Still seems to do nothing.

installed.packages("R/x86_64-pc-linux-gnu-library/4.3")
     Package LibPath Version Priority Depends Imports LinkingTo Suggests Enhances License
     License_is_FOSS License_restricts_use OS_type Archs MD5sum NeedsCompilation Built

@jrkrideau You left out "~/" at the start of the file path. With that (and 4.4 rather than 4.3) it works for me.

1 Like

@thush Are you connected to the internet? Can you open that URL in a web browser?

I cannot open this link "https://cran.rstudio.com/src/contrib:"
This works: https://cran.rstudio.com/src/contrib/PACKAGES

Other than quotation marks I don't see the difference.

This works
'https://cran.rstudio.com/src/contrib/PACKAGES '

Let's try another repository. Try

install.packages("ggplot2", repository = https://mirror.csclub.uwaterloo.ca/CRAN/")

Arrgh, you are correct and I thought I had tried that!