Sie sind auf Seite 1von 6

##STAT200-------

x <- 10.5 #numeric variable

class(x)

z <- 1+2i

class(z)

y <- as.integer(x) #integer variable

class (y)

a <- 1; b <- 2

c <- a>b

class(c)

#Student Profile Dataset

name <-
c("ane","john","zar","faye","nik","angel","joy","Ai","yon","debs","arjay","fin","kate","treb","boy")

sex <- c("F","M","F","F","M","F","F","F","M","M","M","F","F","M","M")

residence <- c("dorm","cottage-in","cottage-out","cottage-in","cottage-in","dorm","dorm","cottage-


out","cottage-out","cottage-out","cottage-out","cottage-in","cottage-out","cottage-in","dorm")

age <- c(17,21,21,18,18,19,20,19,20,20,20,18,19,20,20)

height <-c(175,172,152,150,151,161,163,144.78,168,167.64,158,165,170,168,165.1)

weight <- c(54,40,50,44,51,60,54,50,51,48,61,59,85,70,62)

GPA.Last.Sem <- c(1.96,2.24,2.32,2.63,2.29,2.11,2.65,2.01,2.09,2.21,2.25,2.68,2.83,2.75,2.31)

Weekly.Allowance <- c(600,1000,1500,1000,1000,1000,750,500,1000,1000,1000,500,700,1250,500)

student.profile <- data.frame(name,sex,residence,age,height,weight,GPA.Last.Sem,Weekly.Allowance)

sex.freq <- table(sex) #frequency distribution of sex

sex.relfreq <- (sex.freq/15)*100 #relative frequency


residence.freq <- table(residence) #frequency distribution of residence

residence.relfreq <- (residence.freq/15)*100 #relative frequency

barplot(sex.freq) #bar graph of sex

colors.bar <- c("yellow","sky blue")

barplot(sex.freq,col=colors.bar)

barplot(residence.freq) #bar graph of residence

colors.bar.res <- c("yellow","green","red")

barplot(residence.freq,col=colors.bar.res)

pie(sex.freq) #pie chart of sex

colors.pie.sex <- c("yellow","green")

pie(sex.freq,col=colors.pie.sex)

pie(residence.freq) #pie chart of residence

colors.pie.residence <- c("light green","light blue","pink")

pie(residence.freq,col=colors.pie.residence)

hist(age,right=FALSE)#histogram of age

colors.hist <- c("blue","red","green","violet")

hist(age,

right=FALSE,

col=colors.hist,#set the color palette)

main="Histogram of Age",#the main title

xlab="age") #x-axis label

hist(height,right=FALSE)#histogram of height
colors.hist <- c("blue","red","green","violet","pink","yellow","gray")

hist(height,

right=FALSE,

col=colors.hist,#set the color palette)

main="Histogram of height",#the main title

xlab="height") #x-axis label

hist(weight,right=FALSE) #histogram of weight

colors.hist <- c("blue","red","green","violet","pink")

hist(weight,

right=FALSE,

col=colors.hist,#set the color palette)

main="Histogram of weight",#the main title

xlab="weight") #x-axis label

hist(GPA.Last.Sem,right=FALSE) #histogram of GPA Last Sem

colors.hist <- c("blue","red","green","violet","pink","black")

hist(GPA.Last.Sem,

right=FALSE,

col=colors.hist,#set the color palette)

main="Histogram of GPA.Last.Sem",#the main title

xlab="GPA.Last.Sem") #x-axis label

hist(Weekly.Allowance,right=FALSE) #histogram of Weekly Allowance

colors.hist <- c("blue","red","green","violet","brown","yellow")

hist(Weekly.Allowance,

right=FALSE,

col=colors.hist,#set the color palette)

main="Histogram of Weekly.Allowance",#the main title


xlab="Weekly.Allowance") #x-axis label

stem(height) #stem and leaf plot

boxplot(height,horizontal=TRUE) #boxplot of height

color.box <- c("pink")

boxplot(height,

horizontal=TRUE,

col=color.box)

stem(weight) #stem and leaf plot

boxplot(weight,horizontal=TRUE) #boxplot of weight

color.box <- c("yellow")

boxplot(weight,

horizontal=TRUE,

col=color.box)

stem(age) #steam and leaf plot

boxplot(age,horizontal=TRUE) #boxplot of age

color.box <- c("green")

boxplot(age,

horizontal=TRUE,

col=color.box)

stem(GPA.Last.Sem) #steam and leaf plot

boxplot(GPA.Last.Sem,horizontal=TRUE) #boxplot of GPA.Last.Sem

color.box <- c("violet")

boxplot(GPA.Last.Sem,

horizontal=TRUE,

col=color.box)
stem(Weekly.Allowance) #steam and leaf plot

boxplot(Weekly.Allowance,horizontal=TRUE) #boxplot of Weekly. Allowance

color.box <- c("blue")

boxplot(Weekly.Allowance,

horizontal=TRUE,

col=color.box)

mean(age) #mean of age

median(age) #median of age

max(age)# maximum of age

min(age)# minimun of age

max(age)-min(age)#range of age

sd(age)#standard deviation of age

var(age)# variance of age

summary(age)

mean(weight) #mean of weight

median(weight) #median of weight

max(weight)# maximum of weight

min(weight)# minimun of weight

max(weight)-min(weight)#range of weight

sd(weight)#standard deviation of weight

var(weight)# variance of weight

summary(weight)

mean(height) #mean of height

median(height) #median of height

max(height)# maximum of height


min(height)# minimun of height

max(height)-min(height)#range of height

sd(height)#standard deviation of height

var(height)# variance of height

summary(height)

mean(Weekly.Allowance) #mean of Weekly.Allowance

median(Weekly.Allowance) #median of Weekly.Allowance

max(Weekly.Allowance)# maximum of Weekly.Allowance

min(Weekly.Allowance)# minimun of Weekly.Allowance

max(Weekly.Allowance)-min(Weekly.Allowance)#range of Weekly.Allowance

sd(Weekly.Allowance)#standard deviation of Weekly.Allowance

var(Weekly.Allowance)# variance of Weekly.Allowance

summary(Weekly.Allowance)

mean(GPA.Last.Sem) #mean of GPA.Last.Sem

median(GPA.Last.Sem) #median of GPA.Last.Sem

max(GPA.Last.Sem)# maximum of GPA.Last.Sem

min(GPA.Last.Sem)# minimun of GPA.Last.Sem

max(GPA.Last.Sem)-min(GPA.Last.Sem)#range of GPA.Last.Sem

sd(GPA.Last.Sem)#standard deviation of GPA.Last.Sem

var(GPA.Last.Sem)# variance of GPA.Last.Sem

summary(GPA.Last.Sem)

Das könnte Ihnen auch gefallen