KevOMalley743
KevOMalley743

Reputation: 581

R: Reading strings from .txt into a vector in r

I'm trying to integrate R and python with reticulate.

I have my required python packages frozen to myfolder\requirements.txt

I have created a new vitualenv using the reticulate functions and I'd like to install the packages from the .txt file which is laid out like this:

argon2-cffi==20.1.0
async-generator==1.10
attrs==20.2.0
backcall==0.2.0
bleach==3.2.1
certifi==2020.6.20
cffi==1.14.3
colorama==0.4.3
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
entrypoints==0.3

the reticulate command is

library(reticulate)
virtualenv_install('env', c(vector of packages))

is there a quick way to read my requirements.txt into a vector of strings that will work in the virtualenv_install() code?

Thanks

Upvotes: 0

Views: 86

Answers (1)

meriops
meriops

Reputation: 1037

With requirements.txt exactly as in your post:

library(reticulate)
vp <- readLines("requirements.txt")
virtualenv_install('env', vp)

Upvotes: 1

Related Questions