How to get parameters from config file in R script

前端 未结 4 2023
一整个雨季
一整个雨季 2020-12-08 09:59

Is there a way to read parameters from a file in an R script?

I want to create a config file that has

db_host=xxxx
db_name=xxxx
db_user=xxxx
db_pass=         


        
4条回答
  •  我在风中等你
    2020-12-08 10:36

    What you describe here is a desire for common configuration across systems, platforms, languages, ...

    That is a big topic and much ink has been spilled on this. Some people see XML as the answer, other prefer simpler related formats like JSON. You could also try Apache-style config files as most languages have libraries for it (but R may be an exception).

    I happen to like Google ProtocolBuffers which are fast, efficient, cross-platform, multi-language, forward-compatible ... but have the one downside of not being ascii files (though you can read ascii files first and then create proto files). For R, there is the RProtoBuf package.

提交回复
热议问题