Error in Lavaan summary

Hi! I am trying to run a CFA in Rstudio.
Here are the commands I've ran (sorry, new users can apparently only add one picture to a post)

# load data
D <- read.csv("C:/Users/User/Downloads/results-survey278539.csv")

# make subset
dat <- D[,6:25]

# rename variables
names(dat) <- paste("Q", sep = "", 1:20)

# compute means
colMeans(dat)

model<-'f1=~Q1+Q2+Q3+Q4+Q5+Q6+Q7+Q8
f2=~Q9+Q10+Q11+Q12+Q13+Q14
f3=~Q15+Q16+Q17+Q18+Q19+Q20'

fit<-lavaan::cfa(model,data=dat)
fit<-cfa(model,data=D)

Summary(fit)But when I run the Summary(fit) I get the following error:

.

It might have something to do with the fact that the Lavaan package might not be properly installed, if I run install.packages("lavaan") I get the following pop-up:

'One or more of the packages that will be updated by this installation are currently loaded. Restarting R prior to updating these packages is strongly recommended. RStudio can restart R and then automatically continue the installation after restarting. Do you want to restart R prior to installing?

If I click Yes, nothing happens, the pop-up just reappears. If I click no, I get the following outcome:

> install.packages("lavaan")
Installing package into ‘U:/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/lavaan_0.6-5.zip'
Content type 'application/zip' length 2818039 bytes (2.7 MB)
downloaded 2.7 MB

package ‘lavaan’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘U:\Documents\R\win-library\3.0’ for modifying
Try removing ‘U:\Documents\R\win-library\3.0/00LOCK’

If I run library(lavaan) nothing seems to be wrong.

I have just started using Rstudio so I have no idea how to fix this. Could someone help?

Have you tried following the instructions on the error message?

Remove it like you would remove any file in your computer, open the Windows file explorer, look for the file on that location and press delete.

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

I don't know how to remove that, that appears when I give the command to install lavaan.
Do I have to change my command to do that?

RStudio knows 'fit', so I don't understand what's going wrong with the Summary(fit)Screenshot 2020-04-09 at 16.02.59

Thank you, that worked for Lavaan.
Unfortunately, still an error when I try to run Summary(fit):

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.