aboutsummaryrefslogtreecommitdiff
path: root/lab2/main.r
diff options
context:
space:
mode:
Diffstat (limited to 'lab2/main.r')
-rwxr-xr-xlab2/main.r74
1 files changed, 0 insertions, 74 deletions
diff --git a/lab2/main.r b/lab2/main.r
deleted file mode 100755
index f468363..0000000
--- a/lab2/main.r
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env Rscript
-
-zip_income <- read.table("zipIncome.txt", header = TRUE, sep = "|")
-
-names(zip_income) <- c("zipCode", "income")
-
-head(zip_income)
-tail(zip_income)
-
-overall_mean <- mean(zip_income$income)
-overall_median <- median(zip_income$income)
-
-summary(zip_income)
-
-cat("Mean income:", overall_mean, "\n")
-cat("Median income:", overall_median, "\n")
-
-
-dim(zip_income)
-names(zip_income)
-
-unique(zip_income$zipCode)
-
-colSums(is.na(zip_income))
-
-zip_income_clean <- na.omit(zip_income)
-
-colSums(is.na(zip_income_clean))
-
-zip_income$income[is.na(zip_income$income)] <- -100
-zip_income$zipCode[is.na(zip_income$zipCode)] <- 99
-write.table(zip_income,
- file = "zip_income_clean.txt", # output filename
- sep = "|",
- row.names = FALSE
-)
-
-s1 <- c(seq(1, 10, by=1), seq(16, 25, by=1))
-
-df <- data.frame(x = seq(1, 20), y = s1)
-
-print(df)
-plot(df)
-
-model <- lm(y ~ x, data = df)
-summary(model)
-
-plot(df$x, df$y)
-abline(model, col = "red")
-
-plot(density(zip_income$income))
-
-hist(zip_income$income)
-
-library(lattice)
-densityplot(zip_income$income)
-densityplot(log(zip_income$income))
-
-x <- rnorm(10)
-y <- rnorm(10,2)
-
-t.test(x, y)
-
-# ----------------------------------
-
-zip_income <- read.table("zipIncome.txt", header = TRUE, sep = "|")
-
-names(zip_income) <- c("zipCode", "income")
-
-model <- lm(income ~ factor(zipCode), data = zip_income)
-summary(model)
-
-plot(zip_income$zipCode, zip_income$income)
-abline(model, col = "red")