rr1234
October 13, 2020, 12:39am
1
Hi All,
I am trying to check if a specific R-package is installed or not and I am using these commands:
packages <- c("ggplot2")
a<-installed.packages()
packages<-a[,1]
is.element("boot", packages)
I get the output as TRUE
When I check for some fictitious package like tidyrrr
packages <- c("tidyrrr")
a<-installed.packages()
packages<-a[,1]
is.element("boot", packages)
I still get the same output TRUE. hence my question is:
How do I check to see if a specific package is installed or not?
Thanks
Raj
Use the %in%
operator
packages <- installed.packages()
"ggplot2" %in% packages[,1]
#> [1] TRUE
"tidyrrr" %in% packages[,1]
#> [1] FALSE
Created on 2020-10-13 by the reprex package (v0.3.0)
1 Like
rr1234
October 15, 2020, 5:44am
3
This works like a charm. You Sir are a genius!!!! I couldn't find this explained clearly anywhere on the web. Thanks a ton
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
system
Closed
October 22, 2020, 12:21pm
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.