Description Usage Arguments Details Value Note References Examples
Interface to bc calculator.
1 2 3 |
... |
Each argument is a line passed to bc. |
scale |
Number of decimals. If unspecified, the value is taken
from the |
retclass |
class of returned value. |
cmd |
Character string representing the |
args |
Arguments used when issuing |
verbose |
Displays input and output to bc. For debugging. Logical
or can use |
Passes its arguments to bc and collects the result back as a "bc"
class object. There are "bc"
methods for print
,
S3
Ops
and exp
, log
, atan
, sin
and
cos
.
The default action is to collapse all lines that are returned into a
single line but if the user sets the BC_LINE_LENGTH
environment
variable, e.g. Sys.setenv(BC_LINE_LINE=100)
, say,
then no collapsing will be done and its the responsibility
of the user to ensure that the number specified is sufficiently large.
Note that in bc
the %
operator does not mean integer
remainder when scale
is nonzero.
bc
variable and function definitions are not maintained from
one call of bc
to the next.
Returns an object of class c("bc", "character")
.
The bc
function runs the bc
executable. This is normally
included with UNIX so no further setup is needed on that platform.
For Windows, bc
can be downloaded by issuing the R
command
bcInstall() with no arguments.
This will download it into the package itself and subsequent calls to
bc
will find it. Alternately Windows users can download bc
from the Download area of the home page of this package on googlecode placing
it anywhere in their path.
Main Gnu bc site: http://www.gnu.org/software/bc/, Windows distribution: http://sourceforge.net/projects/unxutils, Another Windows distribution (less convenient since it requires readline4.dll): http://gnuwin32.sourceforge.net/packages/bc.htm.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
# all these are the same
bc("1.1^100")
bc(1.1) ^ 100
zero <- bc(0); (zero + 1.1) ^ 100
# both these are same
bc("x=1; 1+x+x^2/2+x^3/6+x^4/24 - e(x)")
x <- bc(1); 1+x+x^2/2+x^3/6+x^4/24 - exp(x)
# both these are same
bc("define sqr(x) {\nreturn(x*x)}; sqr(10)")
sqr <- function(x) x*x; x <- bc(10); sqr(x)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.