I'd like to write a function that takes a filename and produces a .pdf file on a *nix platform and a .wmf on a windows platform with that filename and width of 6 inches height 4.
graph <- function(filename){
setwd("graphics")
ext <- ifelse(.Platform$OS.type == "unix", "pdf", "wmf")
name <- paste(filename, ext, sep=".")
ifelse(.Platform$OS.type == "unix", pdf(name, width=6, height=4), wmf(name, width=6, height=4))
}
That's my attempt but I'm getting this error
Error in ans[test & !nas] <- rep(yes, length.out = length(ans))[test & : replacement has length zero
any ideas? I feel like I'm overlooking something.