podatki <- read.table("./Film.csv",
header=TRUE,
sep=";",
dec=",")
head(podatki)
## Spol Film Vsecnost
## 1 1 1 47
## 2 1 1 38
## 3 1 1 41
## 4 1 1 35
## 5 1 1 43
## 6 1 1 49
Opis spremenljivk:
podatki$SpolFaktor <- factor(podatki$Spol,
levels = c(1, 2),
labels = c("M", "Z"))
podatki$FilmFaktor <- factor(podatki$Film,
levels = c(1, 2),
labels = c("The Notebook", "Dokumentarec"))
str(podatki)
## 'data.frame': 40 obs. of 5 variables:
## $ Spol : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Film : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Vsecnost : int 47 38 41 35 43 49 38 39 44 48 ...
## $ SpolFaktor: Factor w/ 2 levels "M","Z": 1 1 1 1 1 1 1 1 1 1 ...
## $ FilmFaktor: Factor w/ 2 levels "The Notebook",..: 1 1 1 1 1 1 1 1 1 1 ...
hist(podatki$Vsecnost,
main = "Porazdelitev spr. všečnost filma",
ylab = "Frekvenca",
xlab = "Všečnost filma",
breaks = seq(0, 50, 5),
right = FALSE)
library(ggplot2)
ggplot(podatki, aes(x = Vsecnost)) +
geom_histogram(binwidth = 5, colour = "gray") +
facet_wrap(~FilmFaktor, ncol = 1) +
ylab("Frekvenca")
library(ggplot2)
ggplot(podatki, aes(x = Vsecnost, fill = SpolFaktor)) +
geom_histogram(position=position_dodge(2), binwidth = 5, colour = "gray") +
facet_wrap(~FilmFaktor, ncol = 1) +
ylab("Frekvenca") +
labs(fill = "Spol")
library(ggplot2)
ggplot(podatki, aes(x = Vsecnost)) +
theme_bw() +
geom_histogram(binwidth = 5, colour = "gray") +
facet_wrap(~SpolFaktor:FilmFaktor) +
ylab("Frekvenca") +
labs(fill = "Spol")
## Ignoring unknown labels:
## • fill : "Spol"
ggplot(podatki, aes(x = FilmFaktor, y = Vsecnost)) +
geom_boxplot() +
xlab("Film")
ggplot(podatki, aes(x = FilmFaktor, y = Vsecnost, fill = SpolFaktor)) +
geom_boxplot() +
scale_fill_brewer(palette = "Blues") +
xlab("Ogledan film") +
labs(fill = "Spol") +
theme_light()
Tole spodaj ni relevantno!!
library(Rmisc)
## Loading required package: lattice
## Loading required package: plyr
Statistika <- summarySE(podatki,
measurevar = "Vsecnost",
groupvars = c("FilmFaktor", "SpolFaktor"),
conf.interval = 0.95)
Statistika
## FilmFaktor SpolFaktor N Vsecnost sd se ci
## 1 The Notebook M 10 42.2 4.779586 1.511438 3.419110
## 2 The Notebook Z 10 32.4 5.796551 1.833030 4.146603
## 3 Dokumentarec M 10 13.8 7.238784 2.289105 5.178314
## 4 Dokumentarec Z 10 12.7 7.364328 2.328805 5.268123
library(ggplot2)
ggplot(Statistika, aes(x = FilmFaktor, y = Vsecnost, shape = SpolFaktor)) +
geom_point(position = position_dodge(.9),
stat="identity",
colour="magenta",
size = 3) +
geom_errorbar(aes(ymin = Vsecnost - ci, ymax = Vsecnost + ci),
width = 0.1,
position = position_dodge(.9)) +
ylim(c(0, 50)) +
xlab("Ogledan film") +
labs(shape="Spol")