I have some data the I would like to write to a temporary CSV file in R.
Users have the option to specify a filename of their choice, which is stored in an environment (called 'envr') separate from .GlobalEnv
if (!is.null(envr$filename)) {
write.csv(df, file = paste(envr$filename, ".csv", sep = ""))
}
In order to do this successfully, I need to create a temporary file that is assigned to the filename chosen by the user.
if (!is.null(envr$filename)) {
filename <- tempfile(fileext = ".csv")
write.csv(df, file = filename)
}
How can I easily integrate tempfile() into the first if statement above without having to assign it to a variable name?
Aucun commentaire:
Enregistrer un commentaire