Is there a new line constant that's platform independent in R? I'm used to C# and there's Environment.NewLine
which will return \r\n
on windows and \n
otherwise. Searching turned up nothing, but I assume there has to be something somewhere so that scripts can be platform independent.
Related question: Is there a way to detect the platform a script is running on? This could be useful to know for other reasons (which I haven't thought of yet).
EDIT: Here's why I'm asking. I'm downloading files from an FTP server, but want to get a list of files and only download files that are on the server that don't exist locally. Here's how I'm getting the list of files:
filesonserver <- unlist(strsplit(getURL(basePath, ftp.use.epsv=F, dirlistonly=T), "\n"))
On windows, the files are separated by \r\n
. On my mac (where I'm currently working), they're separated by \n
. I was looking for a way to make this platform independent. I haven't tried just separating by \n
on windows, which might work. There might also be a way to get the list of files as a vector without having to split them, which would avoid this entirely...