diff options
| author | leshe4ka46 <alex9102naid1@ya.ru> | 2025-11-15 16:30:38 +0300 |
|---|---|---|
| committer | leshe4ka46 <alex9102naid1@ya.ru> | 2025-11-18 14:05:14 +0300 |
| commit | 2ade61411a014b3eed24bd2b382687d55233a9b5 (patch) | |
| tree | 1b91eb11d38a0a053a7a806fedadb8c8a676738b /lab2 | |
| parent | 5aaff9711387ce1ea1ec8ee5c5b4ecd9e1ea3dd1 (diff) | |
R(Cluster)
Diffstat (limited to 'lab2')
| -rw-r--r-- | lab2/Rplots.pdf | bin | 5314 -> 0 bytes | |||
| -rw-r--r-- | lab2/abc.Rdata | bin | 109 -> 0 bytes | |||
| -rwxr-xr-x | lab2/intro.r | 48 | ||||
| -rwxr-xr-x | lab2/main.r | 74 |
4 files changed, 0 insertions, 122 deletions
diff --git a/lab2/Rplots.pdf b/lab2/Rplots.pdf Binary files differdeleted file mode 100644 index 7074237..0000000 --- a/lab2/Rplots.pdf +++ /dev/null diff --git a/lab2/abc.Rdata b/lab2/abc.Rdata Binary files differdeleted file mode 100644 index c40c2da..0000000 --- a/lab2/abc.Rdata +++ /dev/null diff --git a/lab2/intro.r b/lab2/intro.r deleted file mode 100755 index 037210e..0000000 --- a/lab2/intro.r +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env Rscript - -v <- c(1:10, seq(11, 20, by = 2)) - -typeof(1) -typeof(1L) -typeof(v) -typeof(as.integer(v)) -head(v) -str(v) -plot(v) - - -save.image(file = "abc.Rdata") - -v <- seq(1, 10, by = 0.5) -v - -load("abc.Rdata") - -v - - -v <- c("a", "b", "c", "b", "a") - -f <- factor(v) - -func <- function(x, y = 0) { - return((x * x) + y) -} - -func(y = 3, 5) - - -m <- matrix(c(1:6, 11:13), nrow = 3, ncol = 3, byrow = TRUE) -m - -m[2:3, 1:2] - -df <- data.frame(a = c(1:5), b = c("a", "b", "c", "d", "e")) - -df$a -df$b - -df[df$a > 2, ] - - -q("no")
\ No newline at end of file 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") |
