setwd("L:/Data/Teaching/MyCourse/105-1_Programming/Code")
x <- 3
x
y = 3
3 -> z
y
z
x[1]
x[2]
y <- 1:30
y
yy <- 1:30
yy
1:30 -> z
1:30 -> zz
zz
yy[1]
yy[2]
yy[18]
yy[39]
yy[30]
?c
c( 3, 7, 5 )
xx <- c( 3, 7, 5)
xx
xx <- c( 3, 3, 8)
xx
y <- "beautiful"
y <- beautiful
y <- "beautiful"
y
y <- c( "beautiful", "handsome" )
y
x
y
x <- c( 3, 7, 5 )
x
y
c( x, y ) -> z
z
x
class(x)
class(y)
classs(z)
class(z)
class(x[1])
class(x[2])
class(x[3])
class(y[1])
class(y[2])
class(y[3])
y[1]
y[2]
y[3]
class(y[4])
class(x[4])
x[4]
class( z[1])
class( z[1] )
class( z[1:3] )
z[1]
z[1:3]
class( z[1:3] )
z[4:5]
class( z[4:5] )
?seq
seq( from = 1, to = 9)
seq( from = 1, to = 9, by = 2)
seq( 1, 9 )
seq( 1, 9, by = 2 )
seq( 1, 9, length = 9)
seq( 1, 9, length = 5)
seq( 1, 9, length = 3)
seq( 1, 9, length = 2)
seq( from = 0, to = 1, by = 0.1)
seq( from = 0, to = 1, by = 3)
seq( from = 1, to = 6, by = 3)
seq( from = 1, to = 6, by = pi)
seq( from = 1, to = 10, by = pi)
seq( 17 )
?rep
rep( 3, times = 5)
rep( 1: 4, 2)
rep( 1: 4, 3)
rep( 1: 4, 10)
rep( 1:4, each = 2)
rep( 1:4, c( 2,2,2,2) )
rep( 1:4, c( 3,3,3,3) )
rep( 1:4, c( 1,2,3,4) )
rep( 1:4, c( 2,1,2,1) )
rep( 1:4, each = 2, length = 4)
rep( 1:4, each = 2, length = 10)
rep( 1:4, each = 2, length = 12)
rep( 1:4, each = 2, length = 13)
rep( 1:4, each = 2, times = 3)
x <- c( 2, 4, 6 )
x
is.numeric( x )
is.integer( x )
is.character( x )
class( x )
class( c( 2, 5, 8 ) )
class( c( "beautiful", "handsome" ) )
class( c( 2, 5, "beauty" ) )
c( 2, 5, "beauty" )
class( c( 2, 5, "beauty" ) )
u1 <- c( 2.2, 4.4, 6.6 )
u2 <- as.numeric( c( 2.2, 4.4, 6.6 ) )
u3 <- as.vector( c( 2.2, 4.4, 6.6 ), mode = "numeric" )
u1
u2
u3
u1 <- c( 2, 4, 6 )
u1
class( u1 )
u1 <- as.integer( c( 2, 4, 6 ) )
u1
class( u1 )
is.numeric( u1 )
is.integer( u1 )
is.character( u1 )
v1 <- c( 2, 4, 6 )
v2 <- as.numeric( c( 2, 4, 6 ) )
v3 <- as.vector( c( 2, 4, 6 ), mode = "numeric" )
v1
v2
v3
class( v1 )
class( v2 )
class( v3 )
x1 <- as.integer( c( 2, 4, 6 ))
x1
class( x1 )
x2 <- as.vector( c( 2, 4, 6, mode = "integer"))
c2
x2
class( x2 )
x2 <- as.vector( c( 2, 4, 6), mode = "integer" )
x2
class( x2 )
y1 <- c( "beautiful", "handsome" )
y1
c("beautiful", "handsome")
as.character( c("beautiful", "handsome") )
y2 <- as.character( c("beautiful", "handsome") )
y2
y1
y2
class( y1 )
class( y2 )
as.vector( c( "beautiful", "handsome" ), mode = "charater" )
as.vector( c( "beautiful", "handsome" ), mode = "character" )
as.vector( c( "beautiful", "handsome" ), mode = "character" ) -> y3
y3
class( y3 )
ls()
rm( ls() )
ls()
rm( xx )
ls()
rm( ls() )
rm( "ls()" )
rm(list=ls(all=TRUE))
ls()
rm( list = ls( all=TRUE ) )
list = ls( all=TRUE )
list
y1 <- c( "beautiful", "handsome" )
y2 <- as.character( c("beautiful", "handsome") )
as.vector( c( "beautiful", "handsome" ), mode = "character" ) -> y3
ls()
list = ls( all=TRUE )
list
as.integer( c( -1.2, 0, 3.4 ) )
as.integer( c( -1.2, 0, 3.5 ) )
as.integer( c( -1.2, 0, 3.6 ) )
as.integer( c( -1.2, 0, 3.9 ) )
as.integer( c( -1.2, 0, 4.1 ) )
as.integer( c( -1.3, 0, 4.1 ) )
as.integer( c( -1.9, 0, 4.1 ) )
as.integer( c( -0.9, 0, 4.1 ) )
as.character( c( 2, 4, 6 ) )
as.integer( c("beautiful", "cool", "handsome") )
c("beautiful", "cool", "handsome")
as.integer( c("beautiful", "cool", "handsome") )
x <- c( 1.2, 3.4, 5.6 )
x
y <- as.numeric( c( 1.2, 3.4, 5.6 ) )
y
z <- numeric()
z <- numeric( )
z[1:3]
z[1:3] <- c(1.2, 3.4, 5.6)
z
z[4]
z[1:3]
z[4]
w <- 1.2
w
w[1]
w[2]
w[2] <- 3.4
w[3] <- 5.6
w
if
i
if <- 3
if = 3
repeat = 3
FALSE = 3
Inf = 3
pi = 5
pi
rm(pi)
pi
letters
letters = 4
letters
rm( letters )
letters
0/0
1/0
-1/0
x <- c( 1, NA, 3 )
x
x[2]
x[1]
x[3]
x[2] + x[2]
x[1] + x[2]
x[3] + x[2]
x[1] + x[3]
a <- Inf
a
b <- Inf
b
a + b
a - b
a * b
a / b
2^3
2 + 3
2 - 3
2 * 3
2/3
-3 * 3
-3 * +3
-3 * -3
+3 * +3
13/4
13 / 4
13 %/% 4
13 %% 4
15 %% 4
14 %% 4
3.6 + 1.25
x <- 3.6
y <- 1.25
x + y
x - y
x * y
x / y
x <- 1:10
x
y <- 1:10*2
y
x + y
y - x
x - y
( y - x )/2
( y - x )/10
( x - y )/10
a <- 5
a
b <- 2
a %/% b
a %% b
x <-2
y <- 4
x
y
x^y
y^x
y <- 3
x^y
y^x
y <- 0:4
y
x^6
x^y
x
y
x^y
y^x
log(10)
log10(10)
log10(100)
log(100)
log2( 2)
log2( 10 )
exp( 2)
log(2)
log( 7.389056)
log( 2 )
exp( 0.6921472)
exp( 0.6931472)
log2( 8 )
2^3
log10( 8 )
10^0.90309
x <- 0:7
x
x <- 0:7*pi/6
x
sin(x)
sx <- sin(x)
sx
asin( sx )
x1 <- asin( sx )
x
x1
x1 - x
x <- 0:7*pi/6
x
sx <- sin( x )
x1 <- asin( sx )
x
x1
x1 - x
?sin
x <- 0:7*pi/16
x
sx <- sin(x)
sx
x1 <- asin( sx )
x1
x1 - x
cx <- cos(x)
cx
x2 <- acos( cx )
x2
x
x2 - x
tx <- tan(x)
tx
x3 <- atan( tx )
x3
x
x3 - x
factorial( 4 )
factorial( 1 )
factorial( 2 )
factorial( 3 )
factorial( 4 )
ceiling( 2.55 )
fkki==( 2.55 )
floor( 2.55 )
trunc( 2.55 )
round( 2.55, digits = 2 )
round( 2.55, digits = 1 )
round( 2.55, digits = 0 )
signif( 2.55, digits = 2)
signif( 2.55, digits = 1)
signif( 2.55, digits = 1)
x <- c( 1.2, 3.5, -4.7, 0 )
min(x)
length( x )
sum( x )
mean( x )
sd( x )
var( x )
median( x )
]
x1 <- 1:6
x2 <- rep( 4, 6)
x3 <- 6:1
min( x1, x2, x3 )
?min
x1
x2
x3
max( x1, x2, x3 )
pmin( x1, x2, x3)
pmax( x1, x2, x3)
x <- c( 1.22, 3.555, -4.75, 0 )
ceiling( x )
floor( x )
trunc( x )
round( x, digits = 1 )
signif( x, digits = 2 )
x <- c( 1.22, 3.555, -4.75, 0 )
ceiling( x )
floor( x )
trunc( x )
round( x, digits = 1 )
signif( x, digits = 3 )
x <- c( 1.22, 2.55, 3.78, -4.75)
x[2]
x[4]
x[ c(1,3) ]
x[-2]
x[ -c(2, 4) ]
x[ -length(x) ]
x
x[ -length(x) ]
x[ c(1, 0, 2) ]
x[ c(-1, 0, -2) ]
x
x[ c(-1, -2) ]
x[ c(1, 2) ]
c(1, 0, 2)
x[ c(1, 0, -2) ]
x[ c(1, -2) ]
x[ c(1.2, 3.4) ]
x
x[ c(1.2, 3.8) ]
x[ c(-1.2, -3.4) ]
x
x <- c(  1, 0, -1, 2 )
y <- c( -2, 1, 0, -2 )
x
y
x*y
2*x
x*2
c( 1, 2, 3, 4 ) * x
x
x*(1:2)
x*c( 1,2,1,2)
sum( x* y)
x*y
look <- c("beautiful", "handsome", "cool")
look
?substr
substr( look, start = 1, stop = 4 )
substr( look, start = 1, stop = 6 )
substr( look, start = 1, stop = 2 )
?substring
substring( look, first = 1, last = 4 )
substring( look, first = 1, last = 2 )
substring( look, first = 1, last = 3 )
look.more <- c( look, "pretty" )
look.more
c( look, "pretty")
paste( look, "people")
paste( "They look like", look, "people" )
?paste
paste( "They look like", look, "people", collapse="." )
paste( "They look like", look, "people", collapse=". " )
letters[1:10]
letters
letters[1:5]
letters[1:10]
letters[25:27]
letters[24:26]
LETTERS
LETTERS[24:26]
month.name[1:12]
month.name
month.name
month.abb
savehistory("L:/Data/Teaching/MyCourse/105-1_Programming/Code/data_161008_U04_DataFormat_BasicComputing.Rhistory")
