R & Packages not working

Hello,
I have already done all my calculations on R. When I wanted to reload and update R, I could neither load my packages nor read in my data set (it always says Default).
I will send you a list with the packages. I have tried everything and am in despair because I only need access to my results.

install.packages('foreign')
install.packages('haven')
install.packages('dplyr')
install.packages("psych")
install.packages("Mice")
install.packages("VIM")
install.packages("ggplot2")
install.packages("bda")
install.packages('lmtest')
install.packages('olsrr')
install.packages('jtools')
install.packages('moments')
install.packages('lmtest')
install.packages('zoo')
install.packages("caret")
install.packages("tidyverse")
install.packages("gridExtra")
install.packages("modelr")
install.packages("broom")
install.packages("mosaic")
install.packages('knitr')
install.packages("corrplot")
install.packages("correlation")
install.packages('DescTools')
install.packages("robustbase")
install.packages("mediation")
install.packages("htmlTable")
install.packages("readxl")

library(htmlTable)
library(robustbase)
library(DescTools)
library(caret)
library(tidyverse)
library(gridExtra)
library(modelr)
library(broom)
library(mosaic)
library(knitr)
library(corrplot)
library(olsrr)
library(jtools)
library(moments)
library(lmtest)
library(zoo)
library(foreign)
library(psych)
library(haven)
library(readxl)
library(dplyr)
library(mice)
library(VIM)
library(ggplot.multistats)
library(bda)
library(correlation)
library(mediation)

When I execute the packages, it looks as if the packages can be loaded well. With the library function, it usually comes to such error messages: > library(htmlTable)
Error in library(htmlTable) : there is no package named 'htmlTable'.

library(robustbase)
library(DescTools)
library(caret)
Load necessary package: ggplot2
Error: package or namespace load failed for 'ggplot2' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package named 'rlang'
Error: Package 'ggplot2' could not be loaded.
library(tidyverse)
Error in library(tidyverse) : there is no package named 'tidyverse' > library(gridExtra)
library(gridExtra)
library(modelr)
Error in library(modelr) : there is no package named 'modelr' > library(broom) > library(broom)
library(broom)
Error: package or namespace load failed for 'broom' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package named 'rlang'
library(mosaic)
Error in library(mosaic) : there is no package named 'mosaic' > library(knitr)
library(knitr)
library(corrplot)
corrplot 0.92 loaded
library(olsrr)
Error: package or namespace load failed for 'olsrr' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called 'car'
library(jtools)
Error: package or namespace load failed for 'jtools' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package named 'rlang'
library(moments)
library(lmtest)
Load necessary package: zoo

Attache package: 'zoo

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

library(zoo)
library(foreign)
library(psych)
Error in library(psych) : there is no package named 'psych' > library(haven)
library(haven)
Error: package or namespace load failed for 'haven' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package named 'rlang'
library(readxl)
library(dplyr)
Error: package or namespace load failed for 'dplyr' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package named 'rlang'
library(mice)
Error: package or namespace load failed for 'mice' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package named 'rlang'
library(VIM)
Load necessary package: colorspace
Load required package: grid
Error: package or namespace load failed for 'VIM' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package named 'car'
library(ggplot.multistats)........

Thanks for help.
greats Dodo

try installing 'rlang' , and then try again

thanks for your help.

I already tried so it's installing but library says that it's not exiting

install.packages("rlang")
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/dorin/OneDrive/Dokumente/R/win-library/4.0’
(as ‘lib’ is unspecified)

There is a binary version available but the source version is later:
binary source needs_compilation
rlang 1.0.2 1.0.6 TRUE

Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rlang_1.0.2.zip'
Content type 'application/zip' length 1718546 bytes (1.6 MB)
downloaded 1.6 MB

package ‘rlang’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘C:\Users\dorin\OneDrive\Dokumente\R\win-library\4.0’ for modifying
Try removing ‘C:\Users\dorin\OneDrive\Dokumente\R\win-library\4.0/00LOCK’

library(rlang)
Error in library(rlang) : es gibt kein Paket namens ‘rlang’

And when i install the others afterwards its the same Error Error in library(rlang) : there is no package named 'rlang'.

I'm not really adding value here; I'm just pointing out to you the parts of the text you should attend to...
R is asking you to remove the lock from a previous failure so that it can attempt to try again.

use your file system to look for 00LOCK in the path quoted ; when you find it ; delete it.
Try to do this, and then try to install rlang again.

1 Like

Ok this worked but just for some packages.

I still have the message that some packages are not existing: Error in library(lifecycle) : es gibt kein Paket namens ‘lifecycle’

And i can't importe an excle Dataset

thank you a lot ! The first problem is solved :slight_smile:

Are you sure you installed it? Try

packageVersion('lifecycle')

[[quote="Dodo, post:5, topic:159961"]
And i can't importe an excle Dataset
[/quote]

what libraries do you have loaded? What is your code? Any error messages?

yes i'm sure, its not working.
I think there is a biger mistake, because its not just this package which is not installed even when i installed them and the are unpacked
its the library function which is not working

I have a whole skipt with codes, but i can't even try them because its not working to put data in R. When i click import dataset from excel there is written: invalid and then ... package is not existing (.... once it was lifecycle once cli)

Maybe i have a mistake in my pathway ? i dont know what to do

#Masterarbeit Mediation

#all packages :
install.packages("cli")
library(cli)
install.packages('foreign')
library(foreign)
install.packages('haven')
library(haven)
install.packages('dplyr')
library(dplyr)
install.packages("psych")
library(psych)
install.packages("mice")
library(mice)
install.packages("VIM")
library(VIM)
install.packages("ggplot2")
library(ggplot2)
install.packages("bda")
library(bda)
install.packages('lmtest')
library(lmtest)
install.packages('olsrr')
library(olsrr)
install.packages('jtools')
library(jtools)
install.packages('moments')
library(moments)
install.packages('zoo')
library(zoo)
install.packages("caret")
library(caret)
install.packages("tidyverse")
library(tidyverse)
install.packages("gridExtra")
library(gridExtra)
install.packages("modelr")
library(modelr)
install.packages("broom")
library(broom)
install.packages("mosaic")
library(mosaic)
install.packages('knitr')
library(knitr)
install.packages("corrplot")
library(corrplot)
install.packages("correlation")
library(correlation)
install.packages('DescTools')
library(DescTools)
install.packages("robustbase")
library(robustbase)
install.packages("mediation")
library(mediation)
install.packages("htmlTable")
library(htmlTable)

The output is always the same they didn't found any package !
And this started when i wanted to update the packages and R can't even handle this

It is a mistake to have install.packages() in your repeatable scripts. if its installed in your system; then its installed in the system; and library() is enough to use it.
for project work; you should research using renv() to manage your package dependencies for a given project.
Pay close attention to the error messages R shows you; we already identified two examples of R telling you what went wrong in an install, in your most recent post you havent even shared any single error message so it is impossible to support you.

Okay, perhaps you need to try another repository. Try
Tools > Global Options > Packages and change the CRAN Primary Repository. The general advice is to pick one geographically close to you.

Edit

After reading nirgrahamuk's reply, I realized that I had assumed you were starting with a new environment. If you change repositories, do so after restarting R and RStudio and try a single package download.

Thank you, i've already tried it. It's not working

Okay, would you reboot, re load R and RStudio and give us your version number of RStudio plus the output of sessionInfo()?
Thanks

Please check your version of the RStudio you are using , and remember that text strings are case sensitive.

1 Like

This topic was automatically closed 7 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.