| 1 |
library(ggplot2) |
| 2 |
|
| 3 |
centre <- function(x, type, ...) { |
| 4 |
switch(type, |
| 5 |
mean = mean(x), |
| 6 |
median = median(x), |
| 7 |
trimmed = mean(x, trim = .1)) |
| 8 |
} |
| 9 |
|
| 10 |
myVar1 |
| 11 |
myVar.2 |
| 12 |
data$x |
| 13 |
foo "bar" baz |
| 14 |
# test "test" |
| 15 |
"test # test" |
| 16 |
|
| 17 |
(123) (1) (10) (0.1) (.2) (1e-7) |
| 18 |
(1.2e+7) (2e) (3e+10) (0x0) (0xa) |
| 19 |
(0xabcdef1234567890) (123L) (1L) |
| 20 |
(0x10L) (10000000L) (1e6L) (1.1L) |
| 21 |
(1e-3L) (4123.381E-10i) |
| 22 |
(3.) (3.E10) # BUG: .E10 should be part of number |
| 23 |
|
| 24 |
# Numbers in some different contexts |
| 25 |
1L |
| 26 |
0x40 |
| 27 |
.234 |
| 28 |
3. |
| 29 |
1L + 30 |
| 30 |
plot(cars, xlim=20) |
| 31 |
plot(cars, xlim=0x20) |
| 32 |
foo<-30 |
| 33 |
my.data.3 <- read() # not a number |
| 34 |
c(1,2,3) |
| 35 |
1%%2 |
| 36 |
|
| 37 |
"this is a quote that spans |
| 38 |
multiple lines |
| 39 |
\" |
| 40 |
|
| 41 |
is this still a quote? it should be. |
| 42 |
# even still! |
| 43 |
|
| 44 |
" # now we're done. |
| 45 |
|
| 46 |
'same for |
| 47 |
single quotes #' |
| 48 |
|
| 49 |
# keywords |
| 50 |
NULL, NA, TRUE, FALSE, Inf, NaN, NA_integer_, |
| 51 |
NA_real_, NA_character_, NA_complex_, function, |
| 52 |
while, repeat, for, if, in, else, next, break, |
| 53 |
..., ..1, ..2 |
| 54 |
|
| 55 |
# not keywords |
| 56 |
the quick brown fox jumped over the lazy dogs |
| 57 |
null na true false inf nan na_integer_ na_real_ |
| 58 |
na_character_ na_complex_ Function While Repeat |
| 59 |
For If In Else Next Break .. .... "NULL" `NULL` 'NULL' |
| 60 |
|
| 61 |
# operators |
| 62 |
+, -, *, /, %%, ^, >, >=, <, <=, ==, !=, !, &, |, ~, |
| 63 |
->, <-, <<-, $, :, :: |
| 64 |
|
| 65 |
# infix operator |
| 66 |
foo %union% bar |
| 67 |
%"test"% |
| 68 |
`"test"` |