How to use a variable to install an R package
1
0
Entering edit mode
22 months ago
nonaddldy ▴ 10

In GEO analysis, there are many different GPL platform as I should get the corresponding information of package before loading the .db R library, so I downloaded sort of GPL .db R library as the following:

gpl       organism           bioc_package
GPL32     Mus musculus       mgu74a
GPL33     Mus musculus       mgu74b
GPL34     Mus musculus       mgu74c
GPL74     Homo sapiens       hcg110
GPL75     Mus musculus       mu11ksuba
GPL76     Mus musculus       mu11ksubb
GPL77     Mus musculus       mu19ksuba
GPL78     Mus musculus       mu19ksubb
GPL79     Mus musculus       mu19ksubc
GPL80     Homo sapiens       hu6800
GPL81     Mus musculus       mgu74av2
GPL82     Mus musculus       mgu74bv2
GPL83     Mus musculus       mgu74cv2
GPL85     Rattus norvegicus  rgu34a
GPL86     Rattus norvegicus  rgu34b
GPL87     Rattus norvegicus  rgu34c
GPL88     Rattus norvegicus  rnu34
GPL89     Rattus norvegicus  rtu34
GPL91     Homo sapiens       hgu95av2
GPL92     Homo sapiens       hgu95b
GPL93     Homo sapiens       hgu95c
GPL94     Homo sapiens       hgu95d
GPL95     Homo sapiens       hgu95e
GPL96     Homo sapiens       hgu133a
GPL97     Homo sapiens       hgu133b
GPL98     Homo sapiens       hu35ksuba
GPL99     Homo sapiens       hu35ksubb
GPL100    Homo sapiens       hu35ksubc
GPL101    Homo sapiens       hu35ksubd
GPL201    Homo sapiens       hgfocus
GPL339    Mus musculus       moe430a
GPL340    Mus musculus       mouse4302
GPL341    Rattus norvegicus  rae230a
GPL342    Rattus norvegicus  rae230b
GPL570    Homo sapiens       hgu133plus2
GPL571    Homo sapiens       hgu133a2
GPL886    Homo sapiens       hgug4111a
GPL887    Homo sapiens       hgug4110b
GPL1261   Mus musculus       mouse430a2
GPL1352   Homo sapiens       u133x3p
GPL1355   Rattus norvegicus  rat2302
GPL1708   Homo sapiens       hgug4112a
GPL2891   Homo sapiens       h20kcod
GPL2898   Rattus norvegicus  adme16cod
GPL3921   Homo sapiens       hthgu133a
GPL4191   Homo sapiens       h10kcod
GPL5689   Homo sapiens       hgug4100a
GPL6097   Homo sapiens       illuminaHumanv1
GPL6102   Homo sapiens       illuminaHumanv2
GPL6244   Homo sapiens       hugene10sttranscriptcluster
GPL6947   Homo sapiens       illuminaHumanv3
GPL8300   Homo sapiens       hgu95av2
GPL8490   Homo sapiens       IlluminaHumanMethylation27k
GPL10558  Homo sapiens       illuminaHumanv4.db
GPL11532  Homo sapiens       hugene11sttranscriptcluster
GPL13497  Homo sapiens       HsAgilentDesign026652
GPL13534  Homo sapiens       IlluminaHumanMethylation450k
GPL13667  Homo sapiens       hgu219
GPL15380  Homo sapiens       GGHumanMethCancerPanelv1
GPL15396  Homo sapiens       hthgu133b
GPL17897  Homo sapiens       hthgu133a

Herein, I want to just input the GPL number, then the corresponding library can be loaded

gpl_db<-paste(subset(gpl_info,GPL=="GPL32")[,3],".db",sep="")
library(get(gpl_db))

However, there is an error report typed that the package cannot be loaded in this way due to the length of the package is not 1, so how should I do to install a package by a variable?

GEO R • 1.1k views
ADD COMMENT
0
Entering edit mode

Assuming that you have used install.packages(), any particular reason for not loading it using library() at the beginning of your function?

ADD REPLY
5
Entering edit mode
22 months ago
Basti ★ 2.0k

Use the character.only argument from the library() function :

library(gpl_db,character.only=TRUE)
ADD COMMENT

Login before adding your answer.

Traffic: 2157 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6