How can I tell if a certain package was already installed?

后端 未结 4 801
庸人自扰
庸人自扰 2021-02-15 15:18

When I install the yaml package, an annoying error message pops up in RStudio if it had been previously installed. How can I tell if the package was already installed so I can d

4条回答
  •  旧时难觅i
    2021-02-15 16:17

    Alternatively, you can use the require function. It will try to load the package and silently return a logical stating whether or not the package is available. There is also a warning if the package cannot be loaded.

    test1 <- require("stats")
    test1
    
    test2 <- require("blah")
    test2
    

提交回复
热议问题