mirror of
https://asciireactor.com/otho/cs-5821.git
synced 2024-11-23 15:05:09 +00:00
66 lines
793 B
R
66 lines
793 B
R
|
x <- c (1,3,2,5)
|
||
|
x
|
||
|
|
||
|
y = c(5,4,7)
|
||
|
|
||
|
length(x)
|
||
|
|
||
|
length(y)
|
||
|
|
||
|
ls()
|
||
|
|
||
|
|
||
|
x+y
|
||
|
|
||
|
x = matrix ( data = c (1,2,3,4), nrow=2, ncol=2)
|
||
|
|
||
|
matrix ( c(1,2,3,4),2,2,byrow=TRUE)
|
||
|
|
||
|
sqrt( x )
|
||
|
|
||
|
|
||
|
x = rnorm(50)
|
||
|
y = x + rnorm(50,mean=50,sd=.1)
|
||
|
cor(x,y)
|
||
|
|
||
|
|
||
|
set.seed(1303)
|
||
|
rnorm(50)
|
||
|
|
||
|
set.seed(3)
|
||
|
y = rnorm(100)
|
||
|
mean(y)
|
||
|
|
||
|
var(y)
|
||
|
sqrt(var(y))
|
||
|
sd (y)
|
||
|
|
||
|
|
||
|
x = rnorm(100)
|
||
|
y = rnorm(100)
|
||
|
plot(x,y)
|
||
|
|
||
|
|
||
|
pdf("Figure.pdf")
|
||
|
plot(x,y,col="green")
|
||
|
dev.off()
|
||
|
|
||
|
x = seq (1 ,10)
|
||
|
x =1:10
|
||
|
x = seq ( - pi , pi , length =50)
|
||
|
|
||
|
|
||
|
y=x
|
||
|
f = outer(x,y,function(x,y) cos(y)/(1+x^2))
|
||
|
contour(x,y,f)
|
||
|
contour(x,y,f,nlevels=45,add=T)
|
||
|
fa=(f-t(f))/2
|
||
|
contour(x,y,fa,nlevels=15)
|
||
|
|
||
|
image (x ,y , fa )
|
||
|
persp (x ,y , fa )
|
||
|
persp (x ,y , fa , theta =30)
|
||
|
persp (x ,y , fa , theta =30 , phi =20)
|
||
|
persp (x ,y , fa , theta =30 , phi =70)
|
||
|
persp (x ,y , fa , theta =30 , phi =40)
|