#Basic Commandsx <- c(1,2,3,4,5)
x
x = c(5,3,9)
x
y = c(3,7,2)
class(x)
length(x)
x+y
z = x+y
z
ls()
rm(z)
ls()
rm(list=ls())
ls()
?matrix
x = matrix(data=c(1,2,3,4), nrow=2, ncol=2)
x
x = matrix(c(1:6), 2, 2)
x
matrix(c(1:6), 2, 2, byrow=TRUE)
sqrt(x)
x^2
x = rnorm(50)
x
x = rnorm(50)
x
set.seed(123)
x = rnorm(50)
x
set.seed(123)
x = rnorm(50)
x
y = x+rnorm(50, mean=50, sd=.1)
cor(x,y)
#Gaphicsplot(x,y)
plot(x,y, xlab="x-axis", ylab="y-axis", main="Plot of X vs Y")
?contour
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)
#Indexing DataA = matrix(1:16,4,4)
A
A[2,3]
A[c(1,3),c(2:4)]
A[2,]
A[,2]
A[,1:2]
A[-3,]
dim(A)
A = A[-4,]
dim(A)
dim(A)[1]
#Loading Data and Plottinggallup = read.csv("http://www.utexas.edu/cola/_webservices/policyagendas/mip/instances.csv?from=1945&to=2012")
View(gallup)
plot(Year, Percentage)
plot(gallup$Year, gallup$Percentage)
plot(gallup$MajorTopic, gallup$Percentage)
plot(as.factor(gallup$MajorTopic), gallup$Percentage)
hist(gallup$Percentage)
pairs(gallup)
summary(gallup)
summary(gallup$MajorTopic)
write.csv(gallup, "gallup.csv")
Kommentare
Kommentar veröffentlichen