The bio.infer package contains a data frame /usr/lib/R/library/bio.infer/data/itis.ttable.rda that needs to be modified.
After loading the bio.infer package and attaching the data frame with the data() function, I wrote the data frame to a text file with write.table().
Using emacs I added another row to the data frame then applied read.table() to create a data frame, but it's in my pwd, not the R library data subdirectory for the bio.infer package.
What is the R function to copy/save/write either the text file or the local copy of itis.ttable to /usr/lib/R/library/bio.infer/data/itis.ttable.rda? I've looked in the R docs and my library of R books without seeing how to add this row to the library's data frame.
Use load
and save
with rda files.
#Path to the data file
fname <- system.file("data", "itis.ttable.rda", package = "bio.infer")
stopifnot(file.exists(fname))
#Load data into new environment
e <- new.env()
load(fname, envir = e)
#Manipulate it
e$itis.ttable <- rev(e$itis.ttable) #or whatever
#Write back to file
save(itis.ttable, file = fname, envir = e)
Though as David Robinson mentioned, you probably shouldn't be overwriting the copy in the package. It is likely more sensible to make your own copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With