I am on mac, trying to source an R file, getting an error:
getwd() ##reveals the correct directory
I’m trying to do
source("test.R", local=TRUE)
I get this error:
Error in source("test.R", local = TRUE) :
test.R:1:2: unexpected input
1: {\
^
> Sys.info()
sysname "Darwin"
release "10.8.0"
version "Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386"
Is this a bug?
OK. The immediate issue is that you are trying to save your text document as an .rtf, which is what TextEdit does by default. If upon launching TextEdit you press Shift-Command-T, you can switch to plain text, and it will let you save the file with the .R extension.
But more generally, you really should not be using TextEdit. Either use RStudio (which is pretty great) or get a “real” text editor. Or even just use the R GUI.