parse(file = "", n = NULL, text = NULL, prompt = "?", keep.source = getOption("keep.source"), srcfile = NULL, encoding = "unknown")
file | the file or connection object from which input to the parser should be read. |
n | the number of expressions to parse. If this number is negative, parsing continues to the end of the file. By default, parse reads to the end of the file or text. |
text | an object coerced to a character vector to use as input to the parser. |
prompt | any object, as the prompt for standard input. In TIBCO Enterprise Runtime for R, this argument is not implemented, and a warning is generated if it is specified. |
keep.source | a logical value. If TRUE, the file location information is stored with parsed expressions. This is used to print the source code for functions with the original formatting. |
srcfile | an object of class "srcfile". By default is NULL. In TIBCO Enterprise Runtime for R, this argument is not implemented, and a warning is generated if it is specified. |
encoding | the string encoding (see Encoding) to use for newly-created strings. In TIBCO Enterprise Runtime for R, this argument is not implemented. If this argument is specified, a warning is generated. |
my.file <- tempfile("my.file") cat("x <- 1\n y <- 2; max(x,y)\n", file = my.file)# parse everything in my.file parse(file = my.file)
# parse the first expression in my.file parse(n=1, file = my.file)
# parse from a text string parse(text = "x <- 1\n y <- 2; max(x,y)\n")
unlink(my.file) # clean up