podatki <- data.frame("ID" = c(1, 2, 3, 4),
"Noga" = c(36, 37, 40, 43),
"Starost" = c(25, 26, 19, 22),
"spol" = c("Z", "Z", "M", "M") )
print(podatki)
## ID Noga Starost spol
## 1 1 36 25 Z
## 2 2 37 26 Z
## 3 3 40 19 M
## 4 4 43 22 M
Rad bi naredil novo tabelo s podatki, ki je brez spremenljivke Noga.
podatki2 <- podatki[ , -2]
print(podatki2)
## ID Starost spol
## 1 1 25 Z
## 2 2 26 Z
## 3 3 19 M
## 4 4 22 M
rada bi napisala novo tabelo, ki vkljucije samo 1. in 3. studenta
podatki3 <- podatki [c(-2,-4), ]
print(podatki3)
## ID Noga Starost spol
## 1 1 36 25 Z
## 3 3 40 19 M
podatki [1,2] <- 38
print(podatki)
## ID Noga Starost spol
## 1 1 38 25 Z
## 2 2 37 26 Z
## 3 3 40 19 M
## 4 4 43 22 M
podatki$Visina <- c(160, 164, 175, 179)
print(podatki)
## ID Noga Starost spol Visina
## 1 1 38 25 Z 160
## 2 2 37 26 Z 164
## 3 3 40 19 M 175
## 4 4 43 22 M 179
podatki$Starost1 <-podatki$Starost + 1
print(podatki)
## ID Noga Starost spol Visina Starost1
## 1 1 38 25 Z 160 26
## 2 2 37 26 Z 164 27
## 3 3 40 19 M 175 20
## 4 4 43 22 M 179 23
summary(podatki[,c(-1,-4)])
## Noga Starost Visina Starost1
## Min. :37.00 Min. :19.00 Min. :160.0 Min. :20.00
## 1st Qu.:37.75 1st Qu.:21.25 1st Qu.:163.0 1st Qu.:22.25
## Median :39.00 Median :23.50 Median :169.5 Median :24.50
## Mean :39.50 Mean :23.00 Mean :169.5 Mean :24.00
## 3rd Qu.:40.75 3rd Qu.:25.25 3rd Qu.:176.0 3rd Qu.:26.25
## Max. :43.00 Max. :26.00 Max. :179.0 Max. :27.00
mean(podatki$Starost)
## [1] 23
sd(podatki$Visina)
## [1] 8.962886
#install.packages("psych")
library("psych")
## Warning: package 'psych' was built under R version 4.3.2
describe(podatki)
## vars n mean sd median trimmed mad min max range skew kurtosis
## ID 1 4 2.5 1.29 2.5 2.5 1.48 1 4 3 0.00 -2.08
## Noga 2 4 39.5 2.65 39.0 39.5 2.22 37 43 6 0.32 -2.01
## Starost 3 4 23.0 3.16 23.5 23.0 2.97 19 26 7 -0.24 -2.12
## spol* 4 4 1.5 0.58 1.5 1.5 0.74 1 2 1 0.00 -2.44
## Visina 5 4 169.5 8.96 169.5 169.5 11.12 160 179 19 0.00 -2.30
## Starost1 6 4 24.0 3.16 24.5 24.0 2.97 20 27 7 -0.24 -2.12
## se
## ID 0.65
## Noga 1.32
## Starost 1.58
## spol* 0.29
## Visina 4.48
## Starost1 1.58
#install.packages("pastecs")
library("pastecs")
## Warning: package 'pastecs' was built under R version 4.3.2
round (stat.desc(podatki[,c(-1,-4)]), 2)
## Noga Starost Visina Starost1
## nbr.val 4.00 4.00 4.00 4.00
## nbr.null 0.00 0.00 0.00 0.00
## nbr.na 0.00 0.00 0.00 0.00
## min 37.00 19.00 160.00 20.00
## max 43.00 26.00 179.00 27.00
## range 6.00 7.00 19.00 7.00
## sum 158.00 92.00 678.00 96.00
## median 39.00 23.50 169.50 24.50
## mean 39.50 23.00 169.50 24.00
## SE.mean 1.32 1.58 4.48 1.58
## CI.mean.0.95 4.21 5.03 14.26 5.03
## var 7.00 10.00 80.33 10.00
## std.dev 2.65 3.16 8.96 3.16
## coef.var 0.07 0.14 0.05 0.13