sql - R, RPostgreSQL: a vector in a query -
using rpostgresql package have query vector
in string
:
dbgetquery(con, "select id_table id_user in tmp")
where tmp
should list or vector of length= 10k, how can this? thanks.
you can use paste0. here example take state.abb dataset
valid_state_logic=paste0("(",paste0("'",state.abb,"'", collapse=","),")") print(valid_state_logic) [1] "('dc','al','ak','az','ar','ca','co','ct','de','fl','ga','hi','id','il','in','ia','ks','ky','la','me','md','ma','mi','mn','ms','mo','mt','ne','nv','nh','nj','nm','ny','nc','nd','oh','ok','or','pa','ri','sc','sd','tn','tx','ut','vt','va','wa','wv','wi','wy')"
Comments
Post a Comment