Watts-College / paf-513-template

https://watts-college.github.io/paf-513-template/
MIT License
0 stars 0 forks source link

Lab4- Error using "Run Document" in R Studio #9

Open krangaraju opened 7 months ago

krangaraju commented 7 months ago

@JasonSills Hi, I tried using Run Document on Lab 4 template and got the below error

"Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'htmltools' 0.5.3 is already loaded, but >= 0.5.4 is required
Calls: <Anonymous> -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted"

When I tried to update the htmltools package to a newer version, I keep getting the error that this package is currently loaded and restarting R is recommended. Do you want to restart R prior to install? I select Yes and this dialog box keeps popping up again and again without updating the htmltools package. I tried to install it through Tools menu and also from the Packages tab but same error. I even tried installing Shiny and fastmap in hopes there are dependencies but that didn't help either. Not sure what is going wrong.
Thanks, Kamala.

swest235 commented 7 months ago

@krangaraju remember to tag @JasonSills in order to get a reply.

I am having a similar issue as well with the base code not allowing me to run. I originally got an error saying that I didn't have the updated version of Shiny but when attempted to install the latest version of it I got an additional error saying there is no function called flexdashboard. When running it originally I also was given an error saying there is no "selectinput" function.

image

image

JasonSills commented 7 months ago

@swest235 - Did you try installing the flexdashboard package?

JasonSills commented 7 months ago

@krangaraju -

Try this:

First shut down R with Ctrl + Alt + F10. Then, before you do anything else, go into your output pane in the lower righthand side of RStudio, click the Packages tab, and click "Update". You should be able to update your package from there.

krangaraju commented 7 months ago

@JasonSills I tried it just now but the Ctrl+Alt+F10 didn't shutdown R studio. So I manually did the Quit session and reopened R studio again but the issue persists.

JasonSills commented 7 months ago

@lecy - Do you have recommendation here? We are getting an error that the htmltools is not updated, but the package will not update (see string above for exact error and details). I'm thinking the next step is to remove the package, quit, and reload but wanted to get your opinion first.

lecy commented 7 months ago

In general, if I am having package conflicts while trying to install I will close RStudio and open a Base R console, then try installing.

Try 1st

RStudio automatically loads some packages when you open it, and depending on the dependency structure those can lock up other packages. Installing from the Base R console will eliminate those issues.

Try 2nd

Some packages can still get locked through one application or another, which will cause the re-install to fail. In that case you can usually go into your R Library (often in Documents) and find the package list, then just delete the folder for the problem package. Then open a new R console and try installing the package fresh.

R packages are designed to be light and portable, so most are just libraries of functions that are loaded when you load the package. There are a few exceptions, like devtools, where packages need to be installed at a root level and are registered so they are recognized by the operating system as a legitimate program that you trust. I don't know the details of htmltools but I don't think it is that type of package.

Try 3rd

I wasn't clear if it is a problem with htmltools or flexdashboard. All of thecomments above about htmltools would also apply to flexdashboard.

If that fails, you can also try installing from GitHub.

remotes::install_github('rstudio/flexdashboard')

Try 4th

The error message is that you need a new version of htmltools. It means you need to update that package, but perhaps you need to update the other components needed to run flexdashboard? Which version of R and RStudio are you using?

R.Version()

RStudio >> Help >> Check for Updates

I know that shiny tools are more sometimes sensitive to the R and RStudio version than most packages because RStudio has to launch a virtual server to run the apps locally.

krangaraju commented 7 months ago

Thank you @JasonSills and @lecy I was able to delete the folder for htmltools and reinstall and it worked. If it helps others, I faced the same issue with fastmap also before I could do a "Run document" and I did the exact same thing as htmltools to reinstall that package too before everything worked.

swest235 commented 7 months ago

@swest235 - Did you try installing the flexdashboard package?

@JasonSills That was silly on my part, that is all resolved. I keep getting the error for the selectInput function though. It repeatedly says that function can not be found. I have Shiny, flexdashboard, dplyr, lahman, all installed and loaded.

JasonSills commented 7 months ago

@swest235 Are you getting the error when running the code chunk or when running the document/ knitting? Try the latter.

Here is a long string from a previous course that is covering the same issue from a few different perspectives, there are a few solutions in this link: https://github.com/DS4PS/cpp-526-fall-2019/issues/19

bpiontek commented 7 months ago

@swest235, Thank you for asking about the 'no "selectInput" function' error. I was having the same issue, but was able to fix the issue by reading the string from the prior course that Prof. Sills posted this afternoon. I ended up just having to add "library(shiny)" to the first code chunk in the lab, along with "library(Lahman)" and "library(dplyr)".