Why do I have to re-install a package all over again? When I tried to run code, it returns an error until I install the specific package again. What could be the problem?
Below shows the problem, I had to install 'tidyr' again for it to run.
newtable4a <- pivot_longer(table4a, 2:3, names_to = "year", values_to = "cases")
Fehler in pivot_longer(table4a, 2:3, names_to = "year", values_to = "cases") : konnte Funktion "pivot_longer" nicht finden
I expected that if the package was already installed, then the pivot_longer()
function would run as there was no need for me to re-install tidyr
again.
When writing every code, be sure to use the library() function. Each .r file is working in the base form. For example, if you start a new r script it should be run this way:
library(tidyr)
newtable4a <- pivot_longer(table4a, 2:3, names_to = "year", values_to = "cases")
Without doing this, R is working in the base form. It's also a good idea to re-install packages from time to time because they do update.