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 vsebuje samo ID, starost in spol

podatki2 <-podatki[,-2]

print(podatki2)
##   ID starost spol
## 1  1      25    Z
## 2  2      26    Z
## 3  3      19    M
## 4  4      22    M

rad bi naredil novo taabelo s podatki, ki vključuje samo 1 in 3 študent

podatki3<-podatki[c(-2,-4),] 

print(podatki3)
##   ID Noga starost spol
## 1  1   36      25    Z
## 3  3   40      19    M

spreminjanje podatkov za nazaj

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

dodajanje nove kategorije

podatki$visina<-c(160,164,175.3,179)

print(podatki)
##   ID Noga starost spol visina
## 1  1   38      25    Z  160.0
## 2  2   37      26    Z  164.0
## 3  3   40      19    M  175.3
## 4  4   43      22    M  179.0

povečanje za 1

podatki$starost1<-podatki$starost+1

print(podatki)
##   ID Noga starost spol visina starost1
## 1  1   38      25    Z  160.0       26
## 2  2   37      26    Z  164.0       27
## 3  3   40      19    M  175.3       20
## 4  4   43      22    M  179.0       23

opisna statistika

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.7   Median :24.50  
##  Mean   :39.50   Mean   :23.00   Mean   :169.6   Mean   :24.00  
##  3rd Qu.:40.75   3rd Qu.:25.25   3rd Qu.:176.2   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] 9.025289
#install.packages("psych")
library("psych")

describe(podatki)
##          vars n   mean   sd median trimmed   mad min max range  skew kurtosis
## ID          1 4   2.50 1.29   2.50    2.50  1.48   1   4     3  0.00    -2.08
## Noga        2 4  39.50 2.65  39.00   39.50  2.22  37  43     6  0.32    -2.01
## starost     3 4  23.00 3.16  23.50   23.00  2.97  19  26     7 -0.24    -2.12
## spol*       4 4   1.50 0.58   1.50    1.50  0.74   1   2     1  0.00    -2.44
## visina      5 4 169.57 9.03 169.65  169.57 11.12 160 179    19 -0.01    -2.31
## starost1    6 4  24.00 3.16  24.50   24.00  2.97  20  27     7 -0.24    -2.12
##            se
## ID       0.65
## Noga     1.32
## starost  1.58
## spol*    0.29
## visina   4.51
## starost1 1.58
#install.packages("pastecs")
library(pastecs)

round(stat.desc(podatki[,c(-2,-4)]),2)
##                 ID 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           1.00   19.00 160.00    20.00
## max           4.00   26.00 179.00    27.00
## range         3.00    7.00  19.00     7.00
## sum          10.00   92.00 678.30    96.00
## median        2.50   23.50 169.65    24.50
## mean          2.50   23.00 169.57    24.00
## SE.mean       0.65    1.58   4.51     1.58
## CI.mean.0.95  2.05    5.03  14.36     5.03
## var           1.67   10.00  81.46    10.00
## std.dev       1.29    3.16   9.03     3.16
## coef.var      0.52    0.14   0.05     0.13