I am working on the R package and am having a terrible time trying to load data for internal use in the package.
The package is configured using LazyData: false , and the data itself is in a file named params.csv in the data directory. If, as part of one of my functions, I write the following:
data(params, envir=environment())
Then the file is downloaded, and I can use it in the code. But, as indicated in the docs, it loads read.table(file, sep=";") , and I have character values โโthat I don't want to consider as factors. If it was a regular read.table call, I would add stringsAsFactors=FALSE , and everything would be fine.
In the ?data notes section, it is suggested to use the R file in the data folder to manually perform this download, but I cannot figure it out. I tried to make a file called params.r in the data directory as follows:
read.table("params.csv", sep=";", stringsAsFactors=FALSE)
but when it loads, R complains that the read.table function read.table not found. Again, the docs say that data somehow loads utils before finding the file, but when I put the standard library(utils) call at the beginning of my script, it complains that utils cannot be found.
I even tried to set options(stringsAsFactors=FALSE) before calling data , but this does not work either. Data is still being downloaded as factors.
Are there package experts who know how to get around this? I would prefer not to manually manually delete everything in the desired format after loading; it just seems inelegant.