This error seems to be associated with a previous package installation being interrupted / terminated abnormally. You can fix this by removing the lock file as said. Within the R console, try:
In diagnosing these types of issues, it's important to know the difference between R and RStudio. Package installation is an R issue. RStudio is an IDE for R