70 lines
1.2 KiB
Text
70 lines
1.2 KiB
Text
|
library(ggplot2)
|
||
|
|
||
|
centre <- function(x, type, ...) {
|
||
|
switch(type,
|
||
|
mean = mean(x),
|
||
|
median = median(x),
|
||
|
trimmed = mean(x, trim = .1))
|
||
|
}
|
||
|
|
||
|
myVar1
|
||
|
myVar.2
|
||
|
data$x
|
||
|
foo "bar" baz
|
||
|
# test "test"
|
||
|
"test # test"
|
||
|
|
||
|
(123) (1) (10) (0.1) (.2) (1e-7)
|
||
|
(1.2e+7) (2e) (3e+10) (0x0) (0xa)
|
||
|
(0xabcdef1234567890) (123L) (1L)
|
||
|
(0x10L) (10000000L) (1e6L) (1.1L)
|
||
|
(1e-3L) (4123.381E-10i)
|
||
|
(3.) (3.E10) # BUG: .E10 should be part of number
|
||
|
|
||
|
# Numbers in some different contexts
|
||
|
1L
|
||
|
0x40
|
||
|
.234
|
||
|
3.
|
||
|
1L + 30
|
||
|
plot(cars, xlim=20)
|
||
|
plot(cars, xlim=0x20)
|
||
|
foo<-30
|
||
|
my.data.3 <- read() # not a number
|
||
|
c(1,2,3)
|
||
|
1%%2
|
||
|
|
||
|
"this is a quote that spans
|
||
|
multiple lines
|
||
|
\"
|
||
|
|
||
|
is this still a quote? it should be.
|
||
|
# even still!
|
||
|
|
||
|
" # now we're done.
|
||
|
|
||
|
'same for
|
||
|
single quotes #'
|
||
|
|
||
|
# keywords
|
||
|
NULL, NA, TRUE, FALSE, Inf, NaN, NA_integer_,
|
||
|
NA_real_, NA_character_, NA_complex_, function,
|
||
|
while, repeat, for, if, in, else, next, break,
|
||
|
..., ..1, ..2
|
||
|
|
||
|
# not keywords
|
||
|
the quick brown fox jumped over the lazy dogs
|
||
|
null na true false inf nan na_integer_ na_real_
|
||
|
na_character_ na_complex_ Function While Repeat
|
||
|
For If In Else Next Break .. .... "NULL" `NULL` 'NULL'
|
||
|
|
||
|
# operators
|
||
|
+, -, *, /, %%, ^, >, >=, <, <=, ==, !=, !, &, |, ~,
|
||
|
->, <-, <<-, $, :, ::
|
||
|
|
||
|
# infix operator
|
||
|
foo %union% bar
|
||
|
%"test"%
|
||
|
`"test"`
|
||
|
|