Untitled

 avatar
unknown
plain_text
2 years ago
533 B
9
Indexable
z<-read.csv("schoolDenmark_small.csv")

## Problem 2
nrow(z)

## Problem 3
f <- function(a,b) {
  x <- z[with(z, t_mohammad == a & t_good == b),]
  m <- function(y) {mean(x[[y]],na.rm=TRUE)}
  c(
    nrow(x),
    m("above_median_student"),
    m("above_median_non_danes"),
    m("above_median_grades"),
    m("bigcity"),
    m("school_type")
  )
}

DaTable <- data.frame(
  f(1,1),
  f(1,0),
  f(0,1),
  f(0,0)
)

names(DaTable) = c(
  "Good Trad. Muslim",
  "Poor Trad. Muslim",
  "Good Trad. Dane",
  "Poor Trad. Dane"
  )

DaTable
Editor is loading...