From 2ade61411a014b3eed24bd2b382687d55233a9b5 Mon Sep 17 00:00:00 2001 From: leshe4ka46 Date: Sat, 15 Nov 2025 16:30:38 +0300 Subject: R(Cluster) --- lab2/Rplots.pdf | Bin 5314 -> 0 bytes lab2/abc.Rdata | Bin 109 -> 0 bytes lab2/intro.r | 48 ------------------------------------ lab2/main.r | 74 -------------------------------------------------------- 4 files changed, 122 deletions(-) delete mode 100644 lab2/Rplots.pdf delete mode 100644 lab2/abc.Rdata delete mode 100755 lab2/intro.r delete mode 100755 lab2/main.r (limited to 'lab2') diff --git a/lab2/Rplots.pdf b/lab2/Rplots.pdf deleted file mode 100644 index 7074237..0000000 Binary files a/lab2/Rplots.pdf and /dev/null differ diff --git a/lab2/abc.Rdata b/lab2/abc.Rdata deleted file mode 100644 index c40c2da..0000000 Binary files a/lab2/abc.Rdata and /dev/null differ 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") -- cgit v1.2.3