The R Project SVN R

Rev

Rev 32492 | Rev 37100 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32492 Rev 32569
Line 2... Line 2...
2
\title{Read R Code from a File or a Connection}
2
\title{Read R Code from a File or a Connection}
3
\usage{
3
\usage{
4
source(file, local = FALSE, echo = verbose, print.eval = echo,
4
source(file, local = FALSE, echo = verbose, print.eval = echo,
5
       verbose = getOption("verbose"),
5
       verbose = getOption("verbose"),
6
       prompt.echo = getOption("prompt"),
6
       prompt.echo = getOption("prompt"),
7
       max.deparse.length = 150, chdir = FALSE)
7
       max.deparse.length = 150, chdir = FALSE,
-
 
8
       encoding = getOption("encoding"))
8
}
9
}
9
\alias{source}
10
\alias{source}
10
\arguments{
11
\arguments{
11
  \item{file}{a connection or a character string giving the pathname
12
  \item{file}{a connection or a character string giving the pathname
12
    of the file or URL to read from.}
13
    of the file or URL to read from.}
Line 27... Line 28...
27
    \code{TRUE} and gives the maximal length of the \dQuote{echo} of a
28
    \code{TRUE} and gives the maximal length of the \dQuote{echo} of a
28
    single expression.}
29
    single expression.}
29
  \item{chdir}{logical; if \code{TRUE} and \code{file} is a pathname,
30
  \item{chdir}{logical; if \code{TRUE} and \code{file} is a pathname,
30
    the \R working directory is temporarily changed to the directory
31
    the \R working directory is temporarily changed to the directory
31
    containing \code{file} for evaluating.}
32
    containing \code{file} for evaluating.}
-
 
33
  \item{encoding}{character string.  The encoding to be assumed for the
-
 
34
    when \code{file} is a character string: see \code{\link{file}}.  A
-
 
35
    possible value is \code{"unknown"}: see the Details.}
32
}
36
}
33
\description{
37
\description{
34
  \code{source} causes \R to accept its input from the named file (the
38
  \code{source} causes \R to accept its input from the named file (the
35
  name must be quoted). Input is read from that file until the end of
39
  name must be quoted) or connection.  Input is read and
36
  the file is reached.   \code{\link{parse}} is used to scan the
40
  \code{\link{parse}}d by from that file until the end of the file is
37
  expressions in, they are then evaluated sequentially in the chosen
41
  reached, then the parsed expressions are evaluated sequentially in the
38
  environment.
42
  chosen environment.
39
}
43
}
40
\details{
44
\details{
41
  All versions of \R accept input from a connection with end of line
45
  All versions of \R accept input from a connection with end of line
42
  marked by LF (as used on Unix), CRLF (as used on DOS/Windows)
46
  marked by LF (as used on Unix), CRLF (as used on DOS/Windows)
43
  or CR (as used on classic MacOS).  The final line can be incomplete, that
47
  or CR (as used on classic MacOS).  The final line can be incomplete, that
Line 46... Line 50...
46
  If \code{\link{options}}("keep.source") is true (the default), the
50
  If \code{\link{options}}("keep.source") is true (the default), the
47
  source of functions is kept so they can be listed exactly as input.
51
  source of functions is kept so they can be listed exactly as input.
48
  This imposes a limit of 128K chars on the function size and a nesting
52
  This imposes a limit of 128K chars on the function size and a nesting
49
  limit of 265.  Use \code{option(keep.source = FALSE)} when these
53
  limit of 265.  Use \code{option(keep.source = FALSE)} when these
50
  limits might take effect: if exceeded they generate an error.
54
  limits might take effect: if exceeded they generate an error.
-
 
55
 
-
 
56
  This paragraph applies if \code{file} is a filename (rather than a
-
 
57
  connection). If \code{encoding = "unknown"}, an attempt is made to
-
 
58
  guess the encoding.  The result of \code{\link{localeToCharset}} is
-
 
59
  used a guide.  If \code{encoding} has two or more elements, they are
-
 
60
  tried in turn.
51
}
61
}
52
\references{
62
\references{
53
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
63
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
54
  \emph{The New S Language}.
64
  \emph{The New S Language}.
55
  Wadsworth \& Brooks/Cole.
65
  Wadsworth \& Brooks/Cole.