1. Uvozite podatke v program R.
library(readxl)

podatki <- read_excel("./Nogomet.xlsx")

podatki <- as.data.frame(podatki)

head(podatki)
##   Rang            Ime Pozicija Starost Vrednost                Klub Tekme
## 1    1  Kylian Mbappe        4      22      144 Paris Saint-Germain    16
## 2    2 Erling Haaland        4      21      135   Borussia Dortmund    10
## 3    3     Harry Kane        4      28      108   Tottenham Hotspur    16
## 4    4  Jack Grealish        1      26       90     Manchester City    15
## 5    5  Mohamed Salah        2      29       90        Liverpool FC    15
## 6    6  Romelu Lukaku        4      28       90          Chelsea FC    11
##   Zadetki Asistence Karton_rumen
## 1       7        11            3
## 2      13         4            1
## 3       7         2            2
## 4       2         3            1
## 5      15         6            1
## 6       4         1            0

Opis spremenljivk:

1.Rang: Rang nogometaša glede na vrednost 2.Ime: Ime igralca 3.Pozicija: Pozicija igralca (1:Zvezni igralec, 2:Krilni igralec,3:Branilec,4:Napadalec,5:Vratar) 4.Starost: Starost igralca 5.Vrednost: Ocenjena vrednost igralca v milijonih EUR za leto 2021 6.Klub: Klub, kjer igralec igra 7.Tekme: Število odigranih tekem v letu 2021 8.Zadetki: Število zadetkov v letu 2021 9.Asistence: Število danih asistenc v letu 2021 10.Karton_rumen: Število dobljenih rumenih kartonov v letu 2021

  1. Prikažite frekvenčno porazdelitev pozicije igralcev.

Najprej prepis podatkov pozicij iz številk 1-5 v nazive.

podatki$Pozicija <- factor(podatki$Pozicija, 
                           levels= c(1, 2, 3, 4, 5),
                           labels= c("Zvezni igralec", "Krilni igralec", "Branilec", "Napadalec", "Vratar"))
library(ggplot2)
ggplot(podatki, aes(x=Pozicija, fill= Pozicija)) +
  geom_bar(colour= "black") +
  ylab("Frekvenca") +
  scale_fill_brewer(palette= "Blues") +
  theme_minimal() +
  geom_text(stat = "count", aes(label = after_stat(count)), vjust = 1.5)

table(podatki$Pozicija)
## 
## Zvezni igralec Krilni igralec       Branilec      Napadalec         Vratar 
##             48              9             23             14              6
  1. Narišite razsevni grafikon med številom odigranih tekem in številom zadetkov ter ga razložite.
library(ggplot2)
ggplot(podatki, aes(x=Tekme, y=Zadetki)) +
  geom_point()

Pozitivna korelacija.

Piersonov korelacijski koeficient:

cor(podatki$Tekme, podatki$Zadetki)
## [1] 0.2807887

Pozitivna šibka (linearna) korelacija.

  1. Ocenite povprečno število rumenih kartonov branilcev. Ali lahko trdimo, da je povprečno število rumenih kartonov pri napadalcih nižje?
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
podatkiBranilci <- podatki %>%
  filter(Pozicija == "Branilec")
mean(podatkiBranilci$Karton_rumen)
## [1] 1.913043

H0: Mu_napadalci = 1.913 H1: Mu_napadalci < 1.913

library(dplyr)
podatkiNapadalci <- podatki %>%
  filter(Pozicija == "Napadalec")
t.test(podatkiNapadalci$Karton_rumen,
       alternative = "less", 
       mu = 1.913)
## 
##  One Sample t-test
## 
## data:  podatkiNapadalci$Karton_rumen
## t = -0.79125, df = 13, p-value = 0.2215
## alternative hypothesis: true mean is less than 1.913
## 95 percent confidence interval:
##      -Inf 2.247475
## sample estimates:
## mean of x 
##  1.642857

Ne moremo zavrniti H0. Ne moremo trditi, da napadalci dobijo v povprečju manj rumenih kartonov kot branilci.