Check if R package is installed then load library

前端 未结 6 945
半阙折子戏
半阙折子戏 2020-12-15 07:49

Our R scripts are used on multiple users on multiple computers and hence there are deviations in which packages are installed on each computer. To ensure that each script wo

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 08:32

    Use library(x,character.only=TRUE). Also you don't need the last line as suppressPackageStartupMessages(library(x,character.only=TRUE)) already loads the package.

    EDIT: @LarsKotthoff is right, you already load the package inside of the if brackets. There you already use option character.only=TRUE so everything is good if you just remove last to lines of your function body.

提交回复
热议问题