I need to save a number of tables, in the same way, using the fwrite function.
I have tried the below.
FYI: group_name
is a character object of length 1 (should just print "group_one", for example).
# Save table
save_table <- function(x) {
table_name <- as.character(x)
fwrite(
x,
file =
paste0(
"tables/",
group_name,
"/",
table_name,
".csv"
)
)
}
I get the following error message:
Error in fwrite(x, file = paste0("tables/", group_name, "/", : is.character(file) && length(file) == 1L && !is.na(file) is not TRUE