koleszterin<-read.table("cholestg.txt",header=TRUE)

head(koleszterin)
koleszterin

koleszterin2<-subset(koleszterin,day==2)
koleszterin2
koleszterin2<-koleszterin2[c("patient","group","cholest")]
koleszterin2

colnames(koleszterin2)<-c("patient","group","cholest2")

koleszterin14<-subset(koleszterin,day==14)

koleszterin14<-koleszterin14[c("patient","group","cholest")]


colnames(koleszterin14)<-c("patient","group","cholest14")

koleszterin14

kol<-merge(koleszterin2,koleszterin14,by=c("patient","group"))

koleszterinNA<-subset(koleszterin,is.na(day))

koleszterinNA<-koleszterinNA[c(1,2,4)]

colnames(koleszterinNA)<-c("patient","group","cholest2")

koleszterinNA$cholest14<-koleszterinNA$cholest2
koleszterinNA

kolegyes<-rbind(kol,koleszterinNA)

kolegyes

?t.test

# Hibás szintakszis: t.test(kolegyes$cholest2,kolegyes$group)

t.test(subset(kolegyes,group==1)$cholest14,subset(kolegyes,group==2)$cholest14)

t.test(cholest14 ~ group, data=kolegyes)

with(kolegyes, t.test(cholest14 ~ group))

with(kolegyes,ks.test(cholest14,"pnorm"))

# Először nem raktuk be a lenti parancsba
# az na.rm=TRUE -t, így a hiányzó értékek miatt
# hibát tapasztaltunk

with(kolegyes,ks.test(cholest14,"pnorm",mean(cholest14,na.rm=TRUE),sd(cholest14,na.rm=TRUE)))

with(kolegyes,mean(cholest14))

View(kolegyes)

mean(kolegyes$cholest2)

with(kolegyes, wilcox.test(cholest14 ~ group))

with(subset(kolegyes,group=1), wilcox.test(cholest2,cholest14,paired=TRUE))

teszt<-read.table("mcnemar.csv",header=FALSE,sep=";")

str(teszt)

teszt[,1]<-as.numeric(teszt[,1])
teszt[,2]<-as.numeric(teszt[,2])

str(teszt)


table(teszt[,1],teszt[,2])

mcnemar.test(table(teszt[,1],teszt[,2]))

mean(teszt[,1])
mean(teszt[,2])




