1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430
|
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> pkgname <- "utils"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('utils')
>
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("LINK")
> ### * LINK
>
> flush(stderr()); flush(stdout())
>
> ### Name: LINK
> ### Title: Create Executable Programs
> ### Aliases: LINK
> ### Keywords: utilities
>
> ### ** Examples
> ## Not run:
> ##D ## examples of front-ends linked against R.
> ##D ## First a C program
> ##D CC=`R CMD config CC`
> ##D R CMD LINK $CC -o foo foo.o `R CMD config --ldflags`
> ##D
> ##D ## if Fortran code has been compiled into ForFoo.o
> ##D FLIBS=`R CMD config FLIBS`
> ##D R CMD LINK $CC -o foo foo.o ForFoo.o `R CMD config --ldflags` $FLIBS
> ##D
> ##D ## And for a C++ front-end
> ##D CXX=`R CMD config CXX`
> ##D R CMD COMPILE foo.cc
> ##D R CMD LINK $CXX -o foo foo.o `R CMD config --ldflags`
> ## End(Not run)
>
>
> cleanEx()
> nameEx("Question")
> ### * Question
>
> flush(stderr()); flush(stdout())
>
> ### Name: Question
> ### Title: Documentation Shortcuts
> ### Aliases: Question ?
> ### Keywords: documentation
>
> ### ** Examples
>
> ?lapply
lapply package:base R Documentation
_A_p_p_l_y _a _F_u_n_c_t_i_o_n _o_v_e_r _a _L_i_s_t _o_r _V_e_c_t_o_r
_D_e_s_c_r_i_p_t_i_o_n:
'lapply' returns a list of the same length as 'X', each element of
which is the result of applying 'FUN' to the corresponding element
of 'X'.
'sapply' is a user-friendly version and wrapper of 'lapply' by
default returning a vector, matrix or, if 'simplify = "array"', an
array if appropriate, by applying 'simplify2array()'. 'sapply(x,
f, simplify = FALSE, USE.NAMES = FALSE)' is the same as 'lapply(x,
f)'.
'vapply' is similar to 'sapply', but has a pre-specified type of
return value, so it can be safer (and sometimes faster) to use.
'replicate' is a wrapper for the common use of 'sapply' for
repeated evaluation of an expression (which will usually involve
random number generation).
'simplify2array()' is the utility called from 'sapply()' when
'simplify' is not false and is similarly called from 'mapply()'.
_U_s_a_g_e:
lapply(X, FUN, ...)
sapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
vapply(X, FUN, FUN.VALUE, ..., USE.NAMES = TRUE)
replicate(n, expr, simplify = "array")
simplify2array(x, higher = TRUE)
_A_r_g_u_m_e_n_t_s:
X: a vector (atomic or list) or an 'expression' object. Other
objects (including classed objects) will be coerced by
'base::as.list'.
FUN: the function to be applied to each element of 'X': see
'Details'. In the case of functions like '+', '%*%', the
function name must be backquoted or quoted.
...: optional arguments to 'FUN'.
simplify: logical or character string; should the result be simplified
to a vector, matrix or higher dimensional array if possible?
For 'sapply' it must be named and not abbreviated. The
default value, 'TRUE', returns a vector or matrix if
appropriate, whereas if 'simplify = "array"' the result may
be an 'array' of "rank" (='length(dim(.))') one higher than
the result of 'FUN(X[[i]])'.
USE.NAMES: logical; if 'TRUE' and if 'X' is character, use 'X' as
'names' for the result unless it had names already. Since
this argument follows '...' its name cannot be abbreviated.
FUN.VALUE: a (generalized) vector; a template for the return value from
FUN. See 'Details'.
n: integer: the number of replications.
expr: the expression (a language object, usually a call) to
evaluate repeatedly.
x: a list, typically returned from 'lapply()'.
higher: logical; if true, 'simplify2array()' will produce a ("higher
rank") array when appropriate, whereas 'higher = FALSE' would
return a matrix (or vector) only. These two cases correspond
to 'sapply(*, simplify = "array")' or 'simplify = TRUE',
respectively.
_D_e_t_a_i_l_s:
'FUN' is found by a call to 'match.fun' and typically is specified
as a function or a symbol (e.g. a backquoted name) or a character
string specifying a function to be searched for from the
environment of the call to 'lapply'.
Function 'FUN' must be able to accept as input any of the elements
of 'X'. If the latter is an atomic vector, 'FUN' will always be
passed a length-one vector of the same type as 'X'.
Arguments in '...' cannot have the same name as any of the other
arguments, and care may be needed to avoid partial matching to
'FUN'. In general-purpose code it is good practice to name the
first two arguments 'X' and 'FUN' if '...' is passed through: this
both avoids partial matching to 'FUN' and ensures that a sensible
error message is given if arguments named 'X' or 'FUN' are passed
through '...'.
Simplification in 'sapply' is only attempted if 'X' has length
greater than zero and if the return values from all elements of
'X' are all of the same (positive) length. If the common length
is one the result is a vector, and if greater than one is a matrix
with a column corresponding to each element of 'X'.
Simplification is always done in 'vapply'. This function checks
that all values of 'FUN' are compatible with the 'FUN.VALUE', in
that they must have the same length and type. (Types may be
promoted to a higher type within the ordering logical < integer <
double < complex, but not demoted.)
Users of S4 classes should pass a list to 'lapply' and 'vapply':
the internal coercion is done by the 'as.list' in the base
namespace and not one defined by a user (e.g. by setting S4
methods on the base function).
'lapply' and 'vapply' are primitive functions.
_V_a_l_u_e:
For 'lapply', 'sapply(simplify = FALSE)' and 'replicate(simplify =
FALSE)', a list.
For 'sapply(simplify = TRUE)' and 'replicate(simplify = TRUE)': if
'X' has length zero or 'n = 0', an empty list. Otherwise an
atomic vector or matrix or list of the same length as 'X' (of
length 'n' for 'replicate'). If simplification occurs, the output
type is determined from the highest type of the return values in
the hierarchy NULL < raw < logical < integer < double < complex <
character < list < expression, after coercion of pairlists to
lists.
'vapply' returns a vector or array of type matching the
'FUN.VALUE'. If 'length(FUN.VALUE) == 1' a vector of the same
length as 'X' is returned, otherwise an array. If 'FUN.VALUE' is
not an 'array', the result is a matrix with 'length(FUN.VALUE)'
rows and 'length(X)' columns, otherwise an array 'a' with 'dim(a)
== c(dim(FUN.VALUE), length(X))'.
The (Dim)names of the array value are taken from the 'FUN.VALUE'
if it is named, otherwise from the result of the first function
call. Column names of the matrix or more generally the names of
the last dimension of the array value or names of the vector value
are set from 'X' as in 'sapply'.
_N_o_t_e:
'sapply(*, simplify = FALSE, USE.NAMES = FALSE)' is equivalent to
'lapply(*)'.
For historical reasons, the calls created by 'lapply' are
unevaluated, and code has been written (e.g. 'bquote') that relies
on this. This means that the recorded call is always of the form
'FUN(X[[i]], ...)', with 'i' replaced by the current (integer or
double) index. This is not normally a problem, but it can be if
'FUN' uses 'sys.call' or 'match.call' or if it is a primitive
function that makes use of the call. This means that it is often
safer to call primitive functions with a wrapper, so that e.g.
'lapply(ll, function(x) is.numeric(x))' is required to ensure that
method dispatch for 'is.numeric' occurs correctly.
If 'expr' is a function call, be aware of assumptions about where
it is evaluated, and in particular what '...' might refer to. You
can pass additional named arguments to a function call as
additional named arguments to 'replicate': see 'Examples'.
_R_e_f_e_r_e_n_c_e_s:
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
Language_. Wadsworth & Brooks/Cole.
_S_e_e _A_l_s_o:
'apply', 'tapply', 'mapply' for applying a function to *m*ultiple
arguments, and 'rapply' for a *r*ecursive version of 'lapply()',
'eapply' for applying a function to each entry in an
'environment'.
_E_x_a_m_p_l_e_s:
require(stats); require(graphics)
x <- list(a = 1:10, beta = exp(-3:3), logic = c(TRUE,FALSE,FALSE,TRUE))
# compute the list mean for each list element
lapply(x, mean)
# median and quartiles for each list element
lapply(x, quantile, probs = 1:3/4)
sapply(x, quantile)
i39 <- sapply(3:9, seq) # list of vectors
sapply(i39, fivenum)
vapply(i39, fivenum,
c(Min. = 0, "1st Qu." = 0, Median = 0, "3rd Qu." = 0, Max. = 0))
## sapply(*, "array") -- artificial example
(v <- structure(10*(5:8), names = LETTERS[1:4]))
f2 <- function(x, y) outer(rep(x, length.out = 3), y)
(a2 <- sapply(v, f2, y = 2*(1:5), simplify = "array"))
a.2 <- vapply(v, f2, outer(1:3, 1:5), y = 2*(1:5))
stopifnot(dim(a2) == c(3,5,4), all.equal(a2, a.2),
identical(dimnames(a2), list(NULL,NULL,LETTERS[1:4])))
hist(replicate(100, mean(rexp(10))))
## use of replicate() with parameters:
foo <- function(x = 1, y = 2) c(x, y)
# does not work: bar <- function(n, ...) replicate(n, foo(...))
bar <- function(n, x) replicate(n, foo(x = x))
bar(5, x = 3)
>
> ?"for" # but quotes/backticks are needed
Control package:base R Documentation
_C_o_n_t_r_o_l _F_l_o_w
_D_e_s_c_r_i_p_t_i_o_n:
These are the basic control-flow constructs of the R language.
They function in much the same way as control statements in any
Algol-like language. They are all reserved words.
_U_s_a_g_e:
if(cond) expr
if(cond) cons.expr else alt.expr
for(var in seq) expr
while(cond) expr
repeat expr
break
next
_A_r_g_u_m_e_n_t_s:
cond: A length-one logical vector that is not 'NA'. Conditions of
length greater than one are accepted with a warning, but only
the first element is used. Other types are coerced to
logical if possible, ignoring any class.
var: A syntactical name for a variable.
seq: An expression evaluating to a vector (including a list and an
expression) or to a pairlist or 'NULL'. A factor value will
be coerced to a character vector.
expr, cons.expr, alt.expr: An _expression_ in a formal sense. This is
either a simple expression or a so called _compound
expression_, usually of the form '{ expr1 ; expr2 }'.
_D_e_t_a_i_l_s:
'break' breaks out of a 'for', 'while' or 'repeat' loop; control
is transferred to the first statement outside the inner-most loop.
'next' halts the processing of the current iteration and advances
the looping index. Both 'break' and 'next' apply only to the
innermost of nested loops.
Note that it is a common mistake to forget to put braces ('{ ..
}') around your statements, e.g., after 'if(..)' or 'for(....)'.
In particular, you should not have a newline between '}' and
'else' to avoid a syntax error in entering a 'if ... else'
construct at the keyboard or via 'source'. For that reason, one
(somewhat extreme) attitude of defensive programming is to always
use braces, e.g., for 'if' clauses.
The 'seq' in a 'for' loop is evaluated at the start of the loop;
changing it subsequently does not affect the loop. If 'seq' has
length zero the body of the loop is skipped. Otherwise the
variable 'var' is assigned in turn the value of each element of
'seq'. You can assign to 'var' within the body of the loop, but
this will not affect the next iteration. When the loop
terminates, 'var' remains as a variable containing its latest
value.
_V_a_l_u_e:
'if' returns the value of the expression evaluated, or 'NULL'
invisibly if none was (which may happen if there is no 'else').
'for', 'while' and 'repeat' return 'NULL' invisibly. 'for' sets
'var' to the last used element of 'seq', or to 'NULL' if it was of
length zero.
'break' and 'next' do not return a value as they transfer control
within the loop.
_R_e_f_e_r_e_n_c_e_s:
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
Language_. Wadsworth & Brooks/Cole.
_S_e_e _A_l_s_o:
'Syntax' for the basic R syntax and operators, 'Paren' for
parentheses and braces.
'ifelse', 'switch' for other ways to control flow.
_E_x_a_m_p_l_e_s:
for(i in 1:5) print(1:i)
for(n in c(2,5,10,20,50)) {
x <- stats::rnorm(n)
cat(n, ": ", sum(x^2), "\n", sep = "")
}
f <- factor(sample(letters[1:5], 10, replace = TRUE))
for(i in unique(f)) print(i)
> ?`+`
Arithmetic package:base R Documentation
_A_r_i_t_h_m_e_t_i_c _O_p_e_r_a_t_o_r_s
_D_e_s_c_r_i_p_t_i_o_n:
These unary and binary operators perform arithmetic on numeric or
complex vectors (or objects which can be coerced to them).
_U_s_a_g_e:
+ x
- x
x + y
x - y
x * y
x / y
x ^ y
x %% y
x %/% y
_A_r_g_u_m_e_n_t_s:
x, y: numeric or complex vectors or objects which can be coerced to
such, or other objects for which methods have been written.
_D_e_t_a_i_l_s:
The unary and binary arithmetic operators are generic functions:
methods can be written for them individually or via the 'Ops'
group generic function. (See 'Ops' for how dispatch is computed.)
If applied to arrays the result will be an array if this is
sensible (for example it will not if the recycling rule has been
invoked).
Logical vectors will be coerced to integer or numeric vectors,
'FALSE' having value zero and 'TRUE' having value one.
'1 ^ y' and 'y ^ 0' are '1', _always_. 'x ^ y' should also give
the proper limit result when either argument is infinite (i.e.,
'+- Inf').
Objects such as arrays or time-series can be operated on this way
provided they are conformable.
For double arguments, '%%' can be subject to catastrophic loss of
accuracy if 'x' is much larger than 'y', and a warning is given if
this is detected.
'%%' and 'x %/% y' can be used for non-integer 'y', e.g. '1 %/%
0.2', but the results are subject to representation error and so
may be platform-dependent. Because the IEC 60059 representation
of '0.2' is a binary fraction slightly larger than '0.2', the
answer to '1 %/% 0.2' should be '4' but most platforms give '5'.
Users are sometimes surprised by the value returned, for example
why '(-8)^(1/3)' is 'NaN'. For double inputs, R makes use of IEC
60559 arithmetic on all platforms, together with the C system
function 'pow' for the '^' operator. The relevant standards
define the result in many corner cases. In particular, the result
in the example above is mandated by the C99 standard. On many
Unix-alike systems the command 'man pow' gives details of the
values in a large number of corner cases.
Arithmetic on type double in R is supposed to be done in 'round to
nearest, ties to even' mode, but this does depend on the compiler
and FPU being set up correctly.
_V_a_l_u_e:
Unary '+' and unary '-' return a numeric or complex vector. All
attributes (including class) are preserved if there is no
coercion: logical 'x' is coerced to integer and names, dims and
dimnames are preserved.
The binary operators return vectors containing the result of the
element by element operations. The elements of shorter vectors
are recycled as necessary (with a 'warning' when they are recycled
only _fractionally_). The operators are '+' for addition, '-' for
subtraction, '*' for multiplication, '/' for division and '^' for
exponentiation.
'%%' indicates 'x mod y' and '%/%' indicates integer division. It
is guaranteed that 'x == (x %% y) + y * ( x %/% y )' (up to
rounding error) unless 'y == 0' where the result of '%%' is
'NA_integer_' or 'NaN' (depending on the 'typeof' of the
arguments).
If either argument is complex the result will be complex,
otherwise if one or both arguments are numeric, the result will be
numeric. If both arguments are of type integer, the type of the
result of '/' and '^' is numeric and for the other operators it is
integer (with overflow, which occurs at +/- (2^31 - 1), returned
as 'NA_integer_' with a warning).
The rules for determining the attributes of the result are rather
complicated. Most attributes are taken from the longer argument.
Names will be copied from the first if it is the same length as
the answer, otherwise from the second if that is. If the
arguments are the same length, attributes will be copied from
both, with those of the first argument taking precedence when the
same attribute is present in both arguments. For time series,
these operations are allowed only if the series are compatible,
when the class and 'tsp' attribute of whichever is a time series
(the same, if both are) are used. For arrays (and an array
result) the dimensions and dimnames are taken from first argument
if it is an array, otherwise the second.
_S_4 _m_e_t_h_o_d_s:
These operators are members of the S4 'Arith' group generic, and
so methods can be written for them individually as well as for the
group generic (or the 'Ops' group generic), with arguments 'c(e1,
e2)' (with 'e2' missing for a unary operator).
_I_m_p_l_e_m_e_n_t_a_t_i_o_n _l_i_m_i_t_s:
R is dependent on OS services (and they on FPUs) for
floating-point arithmetic. On all current R platforms IEC 60559
(also known as IEEE 754) arithmetic is used, but some things in
those standards are optional. In particular, the support for
_denormal numbers_ (those outside the range given by '.Machine')
may differ between platforms and even between calculations on a
single platform.
Another potential issue is signed zeroes: on IEC 60659 platforms
there are two zeroes with internal representations differing by
sign. Where possible R treats them as the same, but for example
direct output from C code often does not do so and may output
'-0.0' (and on Windows whether it does so or not depends on the
version of Windows). One place in R where the difference might be
seen is in division by zero: '1/x' is 'Inf' or '-Inf' depending on
the sign of zero 'x'.
_N_o_t_e:
'**' is translated in the parser to '^', but this was undocumented
for many years. It appears as an index entry in Becker _et al_
(1988), pointing to the help for 'Deprecated' but is not actually
mentioned on that page. Even though it had been deprecated in S
for 20 years, it was still accepted in R in 2008.
_R_e_f_e_r_e_n_c_e_s:
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
Language_. Wadsworth & Brooks/Cole.
D. Goldberg (1991) _What Every Computer Scientist Should Know
about Floating-Point Arithmetic_ ACM Computing Surveys, *23(1)*.
Postscript version available at <URL:
http://www.validlab.com/goldberg/paper.ps> Extended PDF version at
<URL: http://www.validlab.com/goldberg/paper.pdf>
_S_e_e _A_l_s_o:
'sqrt' for miscellaneous and 'Special' for special mathematical
functions.
'Syntax' for operator precedence.
'%*%' for matrix multiplication.
_E_x_a_m_p_l_e_s:
x <- -1:12
x + 1
2 * x + 3
x %% 2 #-- is periodic
x %/% 5
>
> ?women # information about data set "women"
women package:datasets R Documentation
_A_v_e_r_a_g_e _H_e_i_g_h_t_s _a_n_d _W_e_i_g_h_t_s _f_o_r _A_m_e_r_i_c_a_n _W_o_m_e_n
_D_e_s_c_r_i_p_t_i_o_n:
This data set gives the average heights and weights for American
women aged 30-39.
_U_s_a_g_e:
women
_F_o_r_m_a_t:
A data frame with 15 observations on 2 variables.
'[,1]' 'height' numeric Height (in)
'[,2]' 'weight' numeric Weight (lbs)
_D_e_t_a_i_l_s:
The data set appears to have been taken from the American Society
of Actuaries _Build and Blood Pressure Study_ for some (unknown to
us) earlier year.
The World Almanac notes: "The figures represent weights in
ordinary indoor clothing and shoes, and heights with shoes".
_S_o_u_r_c_e:
The World Almanac and Book of Facts, 1975.
_R_e_f_e_r_e_n_c_e_s:
McNeil, D. R. (1977) _Interactive Data Analysis_. Wiley.
_E_x_a_m_p_l_e_s:
require(graphics)
plot(women, xlab = "Height (in)", ylab = "Weight (lb)",
main = "women data: American women aged 30-39")
>
> ## Not run:
> ##D require(methods)
> ##D ## define a S4 generic function and some methods
> ##D combo <- function(x, y) c(x, y)
> ##D setGeneric("combo")
> ##D setMethod("combo", c("numeric", "numeric"), function(x, y) x+y)
> ##D
> ##D ## assume we have written some documentation
> ##D ## for combo, and its methods ....
> ##D
> ##D ?combo # produces the function documentation
> ##D
> ##D methods?combo # looks for the overall methods documentation
> ##D
> ##D method?combo("numeric", "numeric") # documentation for the method above
> ##D
> ##D ?combo(1:10, rnorm(10)) # ... the same method, selected according to
> ##D # the arguments (one integer, the other numeric)
> ##D
> ##D ?combo(1:10, letters) # documentation for the default method
> ## End(Not run)
>
>
> cleanEx()
> nameEx("RShowDoc")
> ### * RShowDoc
>
> flush(stderr()); flush(stdout())
>
> ### Name: RShowDoc
> ### Title: Show R Manuals and Other Documentation
> ### Aliases: RShowDoc
> ### Keywords: documentation
>
> ### ** Examples
>
>
> cleanEx()
> nameEx("RSiteSearch")
> ### * RSiteSearch
>
> flush(stderr()); flush(stdout())
>
> ### Name: RSiteSearch
> ### Title: Search for Key Words or Phrases in Documentation
> ### Aliases: RSiteSearch
> ### Keywords: utilities documentation
>
> ### ** Examples
>
>
> cleanEx()
> nameEx("Rprof")
> ### * Rprof
>
> flush(stderr()); flush(stdout())
>
> ### Name: Rprof
> ### Title: Enable Profiling of R's Execution
> ### Aliases: Rprof
> ### Keywords: utilities
>
> ### ** Examples
>
> ## Not run:
> ##D Rprof()
> ##D ## some code to be profiled
> ##D Rprof(NULL)
> ##D ## some code NOT to be profiled
> ##D Rprof(append = TRUE)
> ##D ## some code to be profiled
> ##D Rprof(NULL)
> ##D ...
> ##D ## Now post-process the output as described in Details
> ## End(Not run)
>
>
> cleanEx()
> nameEx("Rprofmem")
> ### * Rprofmem
>
> flush(stderr()); flush(stdout())
>
> ### Name: Rprofmem
> ### Title: Enable Profiling of R's Memory Use
> ### Aliases: Rprofmem
> ### Keywords: utilities
>
> ### ** Examples
> ## Not run:
> ##D ## not supported unless R is compiled to support it.
> ##D Rprofmem("Rprofmem.out", threshold = 1000)
> ##D example(glm)
> ##D Rprofmem(NULL)
> ##D noquote(readLines("Rprofmem.out", n = 5))
> ## End(Not run)
>
>
> cleanEx()
> nameEx("Rscript")
> ### * Rscript
>
> flush(stderr()); flush(stdout())
>
> ### Name: Rscript
> ### Title: Scripting Front-End for R
> ### Aliases: Rscript
> ### Keywords: utilities
>
> ### ** Examples
> ## Not run:
> ##D Rscript -e 'date()' -e 'format(Sys.time(), "%a %b %d %X %Y")'
> ##D
> ##D ## example #! script for a Unix-alike
> ##D
> ##D #! /path/to/Rscript --vanilla --default-packages=utils
> ##D args <- commandArgs(TRUE)
> ##D res <- try(install.packages(args))
> ##D if(inherits(res, "try-error")) q(status=1) else q()
> ##D
> ## End(Not run)
>
>
> cleanEx()
> nameEx("SHLIB")
> ### * SHLIB
>
> flush(stderr()); flush(stdout())
>
> ### Name: SHLIB
> ### Title: Build Shared Object/DLL for Dynamic Loading
> ### Aliases: SHLIB
> ### Keywords: utilities
>
> ### ** Examples
> ## Not run:
> ##D # To link against a library not on the system library paths:
> ##D R CMD SHLIB -o mylib.so a.f b.f -L/opt/acml3.5.0/gnu64/lib -lacml
> ## End(Not run)
>
>
> cleanEx()
> nameEx("Sweave")
> ### * Sweave
>
> flush(stderr()); flush(stdout())
>
> ### Name: Sweave
> ### Title: Automatic Generation of Reports
> ### Aliases: Sweave Stangle SweaveSyntaxLatex SweaveSyntaxNoweb
> ### Keywords: utilities
>
> ### ** Examples
>
> testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package = "utils")
>
> ## enforce par(ask = FALSE)
> options(device.ask.default = FALSE)
>
> ## create a LaTeX file
> Sweave(testfile)
Writing to file Sweave-test-1.tex
Processing code chunks with options ...
1 : keep.source print term verbatim (Sweave-test-1.Rnw:15)
2 : keep.source term hide (Sweave-test-1.Rnw:17)
3 : echo keep.source print term verbatim (Sweave-test-1.Rnw:22)
4 : keep.source term verbatim (Sweave-test-1.Rnw:30)
5 : echo keep.source term verbatim (Sweave-test-1.Rnw:45)
6 : echo keep.source term verbatim pdf (Sweave-test-1.Rnw:53)
7 : echo keep.source term verbatim pdf (Sweave-test-1.Rnw:63)
You can now run (pdf)latex on 'Sweave-test-1.tex'
>
> ## This can be compiled to PDF by
> ## tools::texi2pdf("Sweave-test-1.tex")
> ## or outside R by
> ## R CMD texi2pdf Sweave-test-1.tex
> ## which sets the appropriate TEXINPUTS path.
> ## create an R source file from the code chunks
> Stangle(testfile)
Writing to file Sweave-test-1.R
> ## which can be sourced, e.g.
> source("Sweave-test-1.R")
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
[1] 0.91897737 0.78213630 0.07456498 -1.98935170 0.61982575 -0.05612874
[7] -0.15579551 -1.47075238 -0.47815006 0.41794156 1.35867955 -0.10278773
[13] 0.38767161 -0.05380504 -1.37705956 -0.41499456 -0.39428995 -0.05931340
[19] 1.10002537 0.76317575
One Sample t-test
data: x
t = -0.0332, df = 19, p-value = 0.9739
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-0.414283 0.401340
sample estimates:
mean of x
-0.006471519
>
> ## Don't show:
> if(!interactive()) unlink("Sweave-test-1*")
> ## End Don't show
>
>
>
> cleanEx()
> nameEx("SweaveSyntConv")
> ### * SweaveSyntConv
>
> flush(stderr()); flush(stdout())
>
> ### Name: SweaveSyntConv
> ### Title: Convert Sweave Syntax
> ### Aliases: SweaveSyntConv
> ### Keywords: utilities
>
> ### ** Examples
>
> testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package = "utils")
>
> ## convert the file to latex syntax
> SweaveSyntConv(testfile, SweaveSyntaxLatex)
Wrote file Sweave-test-1.Stex
>
> ## and run it through Sweave
> Sweave("Sweave-test-1.Stex")
Writing to file Sweave-test-1.tex
Processing code chunks with options ...
1 : keep.source print term verbatim (Sweave-test-1.Stex:15)
2 : keep.source term hide (Sweave-test-1.Stex:17)
3 : echo keep.source print term verbatim (Sweave-test-1.Stex:22)
4 : keep.source term verbatim (Sweave-test-1.Stex:30)
5 : echo keep.source term verbatim (Sweave-test-1.Stex:45)
6 : echo keep.source term verbatim pdf (Sweave-test-1.Stex:53)
7 : echo keep.source term verbatim pdf (Sweave-test-1.Stex:63)
You can now run (pdf)latex on 'Sweave-test-1.tex'
>
> ## Don't show:
> if(!interactive()) unlink("Sweave-test-1*")
> ## End Don't show
>
>
>
> cleanEx()
> nameEx("URLencode")
> ### * URLencode
>
> flush(stderr()); flush(stdout())
>
> ### Name: URLencode
> ### Title: Encode or Decode a (partial) URL
> ### Aliases: URLencode URLdecode
> ### Keywords: utilities
>
> ### ** Examples
>
> (y <- URLencode("a url with spaces and / and @"))
[1] "a%20url%20with%20spaces%20and%20/%20and%20@"
> URLdecode(y)
[1] "a url with spaces and / and @"
> (y <- URLencode("a url with spaces and / and @", reserved = TRUE))
[1] "a%20url%20with%20spaces%20and%20%2f%20and%20%40"
> URLdecode(y)
[1] "a url with spaces and / and @"
> URLdecode("ab%20cd")
[1] "ab cd"
>
>
>
> cleanEx()
> nameEx("adist")
> ### * adist
>
> flush(stderr()); flush(stdout())
>
> ### Name: adist
> ### Title: Approximate String Distances
> ### Aliases: adist
> ### Keywords: character
>
> ### ** Examples
>
> ## Cf. http://en.wikipedia.org/wiki/Levenshtein_distance
> adist("kitten", "sitting")
[,1]
[1,] 3
> ## To see the transformation counts for the Levenshtein distance:
> drop(attr(adist("kitten", "sitting", counts = TRUE), "counts"))
ins del sub
1 0 2
> ## To see the transformation sequences:
> attr(adist(c("kitten", "sitting"), counts = TRUE), "trafos")
[,1] [,2]
[1,] "MMMMMM" "SMMMSMI"
[2,] "SMMMSMD" "MMMMMMM"
>
> ## Cf. the examples for agrep:
> adist("lasy", "1 lazy 2")
[,1]
[1,] 5
> ## For a "partial approximate match" (as used for agrep):
> adist("lasy", "1 lazy 2", partial = TRUE)
[,1]
[1,] 1
>
>
>
> cleanEx()
> nameEx("alarm")
> ### * alarm
>
> flush(stderr()); flush(stdout())
>
> ### Name: alarm
> ### Title: Alert the User
> ### Aliases: alarm
> ### Keywords: utilities
>
> ### ** Examples
>
> alarm()
>
>
>
> cleanEx()
> nameEx("apropos")
> ### * apropos
>
> flush(stderr()); flush(stdout())
>
> ### Name: apropos
> ### Title: Find Objects by (Partial) Name
> ### Aliases: apropos find
> ### Keywords: data documentation environment
>
> ### ** Examples
>
> require(stats)
>
> ## Not run: apropos("lm")
> apropos("GLM") # more than a dozen
[1] ".__C__anova.glm" ".__C__anova.glm.null" ".__C__glm"
[4] ".__C__glm.null" "glm" "glm.control"
[7] "glm.fit" "predict.glm" "residuals.glm"
[10] "summary.glm"
> ## that may include internal objects starting '.__C__' if
> ## methods is attached
> apropos("GLM", ignore.case = FALSE) # not one
character(0)
> apropos("lq")
[1] "evalq" "evalqOnLoad"
>
> cor <- 1:pi
> find("cor") #> ".GlobalEnv" "package:stats"
[1] ".GlobalEnv" "package:stats"
> find("cor", numeric = TRUE) # numbers with these names
.GlobalEnv package:stats
1 3
> find("cor", numeric = TRUE, mode = "function") # only the second one
package:stats
3
> rm(cor)
>
> ## Not run: apropos(".", mode="list") # a long list
>
> # need a DOUBLE backslash '\\' (in case you don't see it anymore)
> apropos("\\[")
[1] ".__T__[:base" "[" "[.AsIs"
[4] "[.Date" "[.POSIXct" "[.POSIXlt"
[7] "[.data.frame" "[.difftime" "[.factor"
[10] "[.hexmode" "[.listof" "[.noquote"
[13] "[.numeric_version" "[.octmode" "[.simple.list"
[16] "[.warnings" "[<-" "[<-.Date"
[19] "[<-.POSIXct" "[<-.POSIXlt" "[<-.data.frame"
[22] "[<-.factor" "[[" "[[.Date"
[25] "[[.POSIXct" "[[.data.frame" "[[.factor"
[28] "[[.numeric_version" "[[<-" "[[<-.data.frame"
[31] "[[<-.factor" "[[<-.numeric_version"
>
>
>
> cleanEx()
> nameEx("aregexec")
> ### * aregexec
>
> flush(stderr()); flush(stdout())
>
> ### Name: aregexec
> ### Title: Approximate String Match Positions
> ### Aliases: aregexec
> ### Keywords: character
>
> ### ** Examples
>
> ## Cf. the examples for agrep.
> x <- c("1 lazy", "1", "1 LAZY")
> aregexec("laysy", x, max.distance = 2)
[[1]]
[1] 3
attr(,"match.length")
[1] 4
[[2]]
[1] -1
attr(,"match.length")
[1] -1
[[3]]
[1] -1
attr(,"match.length")
[1] -1
> aregexec("(lay)(sy)", x, max.distance = 2)
[[1]]
[1] 3 3 5
attr(,"match.length")
[1] 4 2 2
[[2]]
[1] -1
attr(,"match.length")
[1] -1
[[3]]
[1] -1
attr(,"match.length")
[1] -1
> aregexec("(lay)(sy)", x, max.distance = 2, ignore.case = TRUE)
[[1]]
[1] 3 3 6
attr(,"match.length")
[1] 4 3 1
[[2]]
[1] -1
attr(,"match.length")
[1] -1
[[3]]
[1] 3 3 6
attr(,"match.length")
[1] 4 3 1
> m <- aregexec("(lay)(sy)", x, max.distance = 2)
> regmatches(x, m)
[[1]]
[1] "lazy" "la" "zy"
[[2]]
character(0)
[[3]]
character(0)
>
>
>
> cleanEx()
> nameEx("aspell")
> ### * aspell
>
> flush(stderr()); flush(stdout())
>
> ### Name: aspell
> ### Title: Spell Check Interface
> ### Aliases: aspell
> ### Keywords: utilities
>
> ### ** Examples
>
> ## Not run:
> ##D ## To check all Rd files in a directory, (additonally) skipping the
> ##D ## \references sections.
> ##D files <- Sys.glob("*.Rd")
> ##D aspell(files, filter = list("Rd", drop = "\references"))
> ##D
> ##D ## To check all Sweave files
> ##D files <- Sys.glob(c("*.Rnw", "*.Snw", "*.rnw", "*.snw"))
> ##D aspell(files, filter = "Sweave", control = "-t")
> ##D
> ##D ## To check all Texinfo files (Aspell only)
> ##D files <- Sys.glob("*.texi")
> ##D aspell(files, control = "--mode=texinfo")
> ## End(Not run)
>
> ## List the available R system dictionaries.
> Sys.glob(file.path(R.home("share"), "dictionaries", "*.rds"))
[1] "/mnt/r-base-3.1.1/share/dictionaries/en_stats.rds"
>
>
>
> cleanEx()
> nameEx("available.packages")
> ### * available.packages
>
> flush(stderr()); flush(stdout())
>
> ### Name: available.packages
> ### Title: List Available Packages at CRAN-like Repositories
> ### Aliases: available.packages
> ### Keywords: utilities
>
> ### ** Examples
> ## Not run:
> ##D ## Restrict install.packages() (etc) to known-to-be-FOSS packages
> ##D options(available_packages_filters =
> ##D c("R_version", "OS_type", "subarch", "duplicates", "license/FOSS"))
> ##D ## or
> ##D options(available_packages_filters = list(add = TRUE, "license/FOSS"))
> ##D
> ##D ## Give priority to released versions on CRAN, rather than development
> ##D ## versions on Omegahat, R-Forge etc.
> ##D options(available_packages_filters =
> ##D c("R_version", "OS_type", "subarch", "CRAN", "duplicates"))
> ## End(Not run)
>
>
> cleanEx()
> nameEx("bibentry")
> ### * bibentry
>
> flush(stderr()); flush(stdout())
>
> ### Name: bibentry
> ### Title: Bibliography Entries
> ### Aliases: bibentry print.bibentry
> ### Keywords: utilities documentation
>
> ### ** Examples
>
> ## R reference
> rref <- bibentry(
+ bibtype = "Manual",
+ title = "R: A Language and Environment for Statistical Computing",
+ author = person("R Core Team"),
+ organization = "R Foundation for Statistical Computing",
+ address = "Vienna, Austria",
+ year = 2013,
+ url = "http://www.R-project.org/")
>
> ## Different printing styles
> print(rref)
R Core Team (2013). _R: A Language and Environment for Statistical
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
<URL: http://www.R-project.org/>.
> print(rref, style = "Bibtex")
@Manual{,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2013},
url = {http://www.R-project.org/},
}
> print(rref, style = "citation")
R Core Team (2013). _R: A Language and Environment for Statistical
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
<URL: http://www.R-project.org/>.
A BibTeX entry for LaTeX users is
@Manual{,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2013},
url = {http://www.R-project.org/},
}
> print(rref, style = "html")
<p>R Core Team (2013).
<EM>R: A Language and Environment for Statistical Computing</EM>.
R Foundation for Statistical Computing, Vienna, Austria.
<a href="http://www.R-project.org/">http://www.R-project.org/</a>.
</p>
> print(rref, style = "latex")
R Core Team (2013).
\emph{R: A Language and Environment for Statistical Computing}.
R Foundation for Statistical Computing, Vienna, Austria.
\url{http://www.R-project.org/}.
> print(rref, style = "R")
bibentry(bibtype = "Manual",
title = "R: A Language and Environment for Statistical Computing",
author = person(given = "R Core Team"),
organization = "R Foundation for Statistical Computing",
address = "Vienna, Austria",
year = "2013",
url = "http://www.R-project.org/")
>
> ## References for boot package and associated book
> bref <- c(
+ bibentry(
+ bibtype = "Manual",
+ title = "boot: Bootstrap R (S-PLUS) Functions",
+ author = c(
+ person("Angelo", "Canty", role = "aut",
+ comment = "S original"),
+ person(c("Brian", "D."), "Ripley", role = c("aut", "trl", "cre"),
+ comment = "R port, author of parallel support",
+ email = "ripley@stats.ox.ac.uk")
+ ),
+ year = "2012",
+ note = "R package version 1.3-4",
+ url = "http://CRAN.R-project.org/package=boot",
+ key = "boot-package"
+ ),
+
+ bibentry(
+ bibtype = "Book",
+ title = "Bootstrap Methods and Their Applications",
+ author = as.person("Anthony C. Davison [aut], David V. Hinkley [aut]"),
+ year = "1997",
+ publisher = "Cambridge University Press",
+ address = "Cambridge",
+ isbn = "0-521-57391-2",
+ url = "http://statwww.epfl.ch/davison/BMA/",
+ key = "boot-book"
+ )
+ )
>
> ## Combining and subsetting
> c(rref, bref)
R Core Team (2013). _R: A Language and Environment for Statistical
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
<URL: http://www.R-project.org/>.
Canty A and Ripley BD (2012). _boot: Bootstrap R (S-PLUS) Functions_. R
package version 1.3-4, <URL: http://CRAN.R-project.org/package=boot>.
Davison AC and Hinkley DV (1997). _Bootstrap Methods and Their
Applications_. Cambridge University Press, Cambridge. ISBN
0-521-57391-2, <URL: http://statwww.epfl.ch/davison/BMA/>.
> bref[2]
Davison AC and Hinkley DV (1997). _Bootstrap Methods and Their
Applications_. Cambridge University Press, Cambridge. ISBN
0-521-57391-2, <URL: http://statwww.epfl.ch/davison/BMA/>.
> bref["boot-book"]
Davison AC and Hinkley DV (1997). _Bootstrap Methods and Their
Applications_. Cambridge University Press, Cambridge. ISBN
0-521-57391-2, <URL: http://statwww.epfl.ch/davison/BMA/>.
>
> ## Extracting fields
> bref$author
[[1]]
[1] "Angelo Canty [aut] (S original)"
[2] "Brian D. Ripley <ripley@stats.ox.ac.uk> [aut, trl, cre] (R port, author of parallel support)"
[[2]]
[1] "Anthony C. Davison [aut]" "David V. Hinkley [aut]"
> bref[1]$author
[1] "Angelo Canty [aut] (S original)"
[2] "Brian D. Ripley <ripley@stats.ox.ac.uk> [aut, trl, cre] (R port, author of parallel support)"
> bref[1]$author[2]$email
[1] "ripley@stats.ox.ac.uk"
>
> ## Convert to BibTeX
> toBibtex(bref)
@Manual{boot-package,
title = {boot: Bootstrap R (S-PLUS) Functions},
author = {Angelo Canty and Brian D. Ripley},
year = {2012},
note = {R package version 1.3-4},
url = {http://CRAN.R-project.org/package=boot},
}
@Book{boot-book,
title = {Bootstrap Methods and Their Applications},
author = {Anthony C. Davison and David V. Hinkley},
year = {1997},
publisher = {Cambridge University Press},
address = {Cambridge},
isbn = {0-521-57391-2},
url = {http://statwww.epfl.ch/davison/BMA/},
}
>
> ## Format in R style
> ## One bibentry() call for each bibentry:
> writeLines(paste(format(bref, "R"), collapse = "\n\n"))
bibentry(bibtype = "Manual",
key = "boot-package",
title = "boot: Bootstrap R (S-PLUS) Functions",
author = c(person(given = "Angelo",
family = "Canty",
role = "aut",
comment = "S original"),
person(given = c("Brian", "D."),
family = "Ripley",
role = c("aut", "trl", "cre"),
email = "ripley@stats.ox.ac.uk",
comment = "R port, author of parallel support")),
year = "2012",
note = "R package version 1.3-4",
url = "http://CRAN.R-project.org/package=boot")
bibentry(bibtype = "Book",
key = "boot-book",
title = "Bootstrap Methods and Their Applications",
author = c(person(given = c("Anthony", "C."),
family = "Davison",
role = "aut"),
person(given = c("David", "V."),
family = "Hinkley",
role = "aut")),
year = "1997",
publisher = "Cambridge University Press",
address = "Cambridge",
isbn = "0-521-57391-2",
url = "http://statwww.epfl.ch/davison/BMA/")
> ## One collapsed call:
> writeLines(format(bref, "R", collapse = TRUE))
c(bibentry(bibtype = "Manual",
key = "boot-package",
title = "boot: Bootstrap R (S-PLUS) Functions",
author = c(person(given = "Angelo",
family = "Canty",
role = "aut",
comment = "S original"),
person(given = c("Brian", "D."),
family = "Ripley",
role = c("aut", "trl", "cre"),
email = "ripley@stats.ox.ac.uk",
comment = "R port, author of parallel support")),
year = "2012",
note = "R package version 1.3-4",
url = "http://CRAN.R-project.org/package=boot"),
bibentry(bibtype = "Book",
key = "boot-book",
title = "Bootstrap Methods and Their Applications",
author = c(person(given = c("Anthony", "C."),
family = "Davison",
role = "aut"),
person(given = c("David", "V."),
family = "Hinkley",
role = "aut")),
year = "1997",
publisher = "Cambridge University Press",
address = "Cambridge",
isbn = "0-521-57391-2",
url = "http://statwww.epfl.ch/davison/BMA/"))
>
>
>
> cleanEx()
> nameEx("browseEnv")
> ### * browseEnv
>
> flush(stderr()); flush(stdout())
>
> ### Name: browseEnv
> ### Title: Browse Objects in Environment
> ### Aliases: browseEnv wsbrowser
> ### Keywords: interface
>
> ### ** Examples
>
> if(interactive()) {
+ ## create some interesting objects :
+ ofa <- ordered(4:1)
+ ex1 <- expression(1+ 0:9)
+ ex3 <- expression(u, v, 1+ 0:9)
+ example(factor, echo = FALSE)
+ example(table, echo = FALSE)
+ example(ftable, echo = FALSE)
+ example(lm, echo = FALSE, ask = FALSE)
+ example(str, echo = FALSE)
+
+ ## and browse them:
+ browseEnv()
+
+ ## a (simple) function's environment:
+ af12 <- approxfun(1:2, 1:2, method = "const")
+ browseEnv(envir = environment(af12))
+ }
>
>
>
> cleanEx()
> nameEx("browseURL")
> ### * browseURL
>
> flush(stderr()); flush(stdout())
>
> ### Name: browseURL
> ### Title: Load URL into a WWW Browser
> ### Aliases: browseURL
> ### Keywords: file
>
> ### ** Examples
>
> ## Not run:
> ##D ## for KDE users who want to open files in a new tab
> ##D options(browser = "kfmclient newTab")
> ##D browseURL("http://www.r-project.org")
> ## End(Not run)
>
>
> cleanEx()
> nameEx("browseVignettes")
> ### * browseVignettes
>
> flush(stderr()); flush(stdout())
>
> ### Name: browseVignettes
> ### Title: List Vignettes in an HTML Browser
> ### Aliases: browseVignettes print.browseVignettes
> ### Keywords: documentation
>
> ### ** Examples
>
>
> cleanEx()
> nameEx("capture.output")
> ### * capture.output
>
> flush(stderr()); flush(stdout())
>
> ### Name: capture.output
> ### Title: Send Output to a Character String or File
> ### Aliases: capture.output
> ### Keywords: utilities
>
> ### ** Examples
>
> require(stats)
> glmout <- capture.output(example(glm))
Error in find.package(package, lib.loc, verbose = verbose) :
there is no package called 'MASS'
Calls: capture.output ... withVisible -> eval -> eval -> <Anonymous> -> find.package
Execution halted
|