x <- list(a = 1:5, b = rnorm(10))
lapply(x, mean)
## $a
## [1] 3
##
## $b
## [1] -0.09522292
sapply(x,mean)
## a b
## 3.00000000 -0.09522292
y <- list(c=1:5, d=4:10, e= 3:20)
ort <- sapply(y, mean)
min <- sapply(y, min)
max <- sapply(y,max)
tablo <- data.frame(ort,min,max)
library(kableExtra)
kable(tablo)
ort | min | max | |
---|---|---|---|
c | 3.0 | 1 | 5 |
d | 7.0 | 4 | 10 |
e | 11.5 | 3 | 20 |
############tez sapply betimleyici
library(readxl)
tez <- read_xlsx("C:/Users/reyhan/OneDrive/Belgeler/hacettepe/Rders/data/tezdata - Kopya.xlsx")
y <- list(net_toabt=tez$`reading_test_total_adjustment _tru`, net_mat=tez$problem_s_Total_true)
library(kableExtra)
library(e1071)
## Warning: package 'e1071' was built under R version 4.4.2
ort <- round(sapply(y, mean),2)
carpik <- round(sapply(y, skewness),2)
basik <- round(sapply(y, kurtosis),2)
betimle <- data.frame(ort,carpik, basik)
kable(betimle)
ort | carpik | basik | |
---|---|---|---|
net_toabt | 4.24 | -0.42 | -0.65 |
net_mat | 9.97 | 0.23 | -1.08 |
matris_a = matrix(1:9, 3,3)
matris_b = matrix(1:12,2,6)
liste_matris = list(matris_a,matris_b)
ilk_satir_liste <- list(sapply(liste_matris,function(abc){
abc[1,]
} ))
ilk_satir_liste
## [[1]]
## [[1]][[1]]
## [1] 1 4 7
##
## [[1]][[2]]
## [1] 1 3 5 7 9 11
satirda_enbuyuk <- sapply(ilk_satir_liste[[1]], max)
satirda_enbuyuk
## [1] 7 11
tez_mini <- data.frame(tez$`reading_test_total_adjustment _tru`,tez$have_m_Phone, tez$have_smart_tablet, tez$have_smart_watch, tez$mother_education)
kk <- split(tez_mini, tez$mother_education)
str(kk)
## List of 5
## $ 0:'data.frame': 8 obs. of 5 variables:
## ..$ tez..reading_test_total_adjustment._tru.: num [1:8] 0.67 6 6 3.33 8.67 4.67 10 7.33
## ..$ tez.have_m_Phone : num [1:8] 0 0 0 1 0 0 0 0
## ..$ tez.have_smart_tablet : num [1:8] 0 1 0 0 0 0 0 1
## ..$ tez.have_smart_watch : num [1:8] 1 0 0 0 0 0 0 0
## ..$ tez.mother_education : num [1:8] 0 0 0 0 0 0 0 0
## $ 1:'data.frame': 24 obs. of 5 variables:
## ..$ tez..reading_test_total_adjustment._tru.: num [1:24] -2 7.33 2 4.67 6 7.33 6 -0.67 6 4.67 ...
## ..$ tez.have_m_Phone : num [1:24] 1 0 0 0 0 1 1 0 0 1 ...
## ..$ tez.have_smart_tablet : num [1:24] 0 1 0 1 0 1 0 0 1 0 ...
## ..$ tez.have_smart_watch : num [1:24] 1 0 0 0 0 0 0 0 0 0 ...
## ..$ tez.mother_education : num [1:24] 1 1 1 1 1 1 1 1 1 1 ...
## $ 2:'data.frame': 21 obs. of 5 variables:
## ..$ tez..reading_test_total_adjustment._tru.: num [1:21] -2 6 -0.67 6 6 2 -2 4.67 3.33 0.67 ...
## ..$ tez.have_m_Phone : num [1:21] 1 0 0 0 1 0 0 1 0 0 ...
## ..$ tez.have_smart_tablet : num [1:21] 1 1 0 1 1 0 1 0 0 0 ...
## ..$ tez.have_smart_watch : num [1:21] 1 0 1 0 0 1 0 0 0 0 ...
## ..$ tez.mother_education : num [1:21] 2 2 2 2 2 2 2 2 2 2 ...
## $ 3:'data.frame': 16 obs. of 5 variables:
## ..$ tez..reading_test_total_adjustment._tru.: num [1:16] 2 -0.67 6 3.33 0.67 8.67 7.33 7.33 3.33 0.67 ...
## ..$ tez.have_m_Phone : num [1:16] 1 1 1 1 1 0 1 1 1 1 ...
## ..$ tez.have_smart_tablet : num [1:16] 0 1 1 1 0 0 0 0 1 1 ...
## ..$ tez.have_smart_watch : num [1:16] 0 1 0 0 1 0 0 0 1 0 ...
## ..$ tez.mother_education : num [1:16] 3 3 3 3 3 3 3 3 3 3 ...
## $ 4:'data.frame': 7 obs. of 5 variables:
## ..$ tez..reading_test_total_adjustment._tru.: num [1:7] 6 -0.67 2 3.33 4.67 8.67 7.33
## ..$ tez.have_m_Phone : num [1:7] 1 1 0 0 0 1 1
## ..$ tez.have_smart_tablet : num [1:7] 1 1 1 1 1 1 1
## ..$ tez.have_smart_watch : num [1:7] 1 1 1 0 0 0 0
## ..$ tez.mother_education : num [1:7] 4 4 4 4 4 4 4
sapply(kk, function(x) {
colMeans(x[, c("tez.have_m_Phone", "tez.have_smart_tablet", "tez.have_smart_watch")], na.rm = TRUE)
})
## 0 1 2 3 4
## tez.have_m_Phone 0.125 0.5833333 0.4285714 0.9375 0.5714286
## tez.have_smart_tablet 0.250 0.5000000 0.4761905 0.5000 1.0000000
## tez.have_smart_watch 0.125 0.1666667 0.1904762 0.3125 0.4285714
vektor_toabt <- as.vector(tez_mini$tez..reading_test_total_adjustment._tru.)
faktor_anne <- as.factor(tez_mini$tez.mother_education)
tapply(vektor_toabt, faktor_anne, mean)
## 0 1 2 3 4
## 5.833750 4.235417 3.412857 4.436875 4.475714
tapply(vektor_toabt, faktor_anne, range)
## $`0`
## [1] 0.67 10.00
##
## $`1`
## [1] -2.00 7.33
##
## $`2`
## [1] -2.00 8.67
##
## $`3`
## [1] -0.67 8.67
##
## $`4`
## [1] -0.67 8.67
by(tez_mini$tez..reading_test_total_adjustment._tru.,tez_mini$tez.mother_education, mean)
## tez_mini$tez.mother_education: 0
## [1] 5.83375
## ------------------------------------------------------------
## tez_mini$tez.mother_education: 1
## [1] 4.235417
## ------------------------------------------------------------
## tez_mini$tez.mother_education: 2
## [1] 3.412857
## ------------------------------------------------------------
## tez_mini$tez.mother_education: 3
## [1] 4.436875
## ------------------------------------------------------------
## tez_mini$tez.mother_education: 4
## [1] 4.475714
a_net_toabt <- tez$`reading_test_total_adjustment _tru`
b_net_mat <- tez$problem_s_Total_true
c_vektor_ders <- c(a_net_toabt,b_net_mat)
matris_c <- matrix(c_vektor_ders,76,2)
apply(matris_c,2,summary)
## [,1] [,2]
## Min. -2.000000 3.000000
## 1st Qu. 2.000000 6.000000
## Median 4.670000 9.500000
## Mean 4.240921 9.973684
## 3rd Qu. 6.000000 13.250000
## Max. 10.000000 18.000000
karsilastirma <- function(x){
rastgele <- sample(x,10)
rast_ort <- mean(rastgele)
hepsi_ort <- mean(x)
fark <- hepsi_ort - rast_ort
return(fark)
}
apply(matris_c, 2, karsilastirma)
## [1] 0.1069211 -1.2263158
Burada Türkçe ve matematik testlerinden rastgele alınan 10 puanın ortalaması ile testlerin genel ortalamasının farkı gösterilmeye çalışılmıştır. İnşallah doğrudur hocam.
hocam bunu anlamakta zorlandım. O yüzden şimdilik bir şey yapmadım.