This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
# Load the dataset
setwd("/Users/saitejaravulapalli/Documents/IUPUI_SEM 01/Intro to Statistic in R/DATA SET")
student_dropout <- read.csv("student dropout.csv")
# Determine the number of rows in the dataset
total_rows <- nrow(student_dropout)
print(total_rows)
## [1] 4424
# Calculate the number of rows for each subsample (roughly 50%)
sample_size <- round(0.5 * total_rows)
print(sample_size)
## [1] 2212
# Create 5-10 random subsamples
num_subsamples <- 5 # You can change this to the desired number of subsamples
# Create a list to store the subsample data frames
subsample_list <- list()
for (i in 1:num_subsamples) {
# Randomly sample rows with replacement for each column
sampled_rows <- sample(1:total_rows, size = sample_size, replace = TRUE)
# Create a new data frame for the subsample
subsample_df <- student_dropout[sampled_rows, ]
# Store the subsample in the list
subsample_list[[paste0("df_", i)]] <- subsample_df
}
for (i in 1:num_subsamples)
{
cat("Subsample", i, ":\n")
print(head(subsample_list[[i]]))
cat("\n")
}
## Subsample 1 :
## [1] "1;44;1;9003;1;39;120.0;1;38;19;3;5;120.0;0;0;0;1;1;0;23;0;0;6;6;0;0.0;0;0;6;8;0;0.0;0;15.5;2.8;-4.06;Enrolled"
## [2] "1;17;5;9500;1;1;137.0;1;1;1;4;4;127.6;1;0;0;1;0;0;18;0;0;7;7;7;13.528571428571428;0;0;8;9;8;14.655555555555557;0;12.4;0.5;1.79;Graduate"
## [3] "1;1;4;9500;1;1;142.0;1;38;37;9;5;127.3;1;0;0;1;0;0;18;0;0;8;8;7;15.075714285714286;0;0;8;8;7;15.075714285714286;0;10.8;1.4;1.74;Graduate"
## [4] "1;39;1;9003;1;1;130.0;1;19;19;9;5;100.0;0;0;0;0;1;0;29;0;0;6;9;0;0.0;0;0;6;6;0;0.0;0;13.9;-0.3;0.79;Dropout"
## [5] "1;1;1;9070;1;1;130.0;41;37;19;9;8;125.5;1;0;0;1;0;1;19;1;0;6;6;6;14.166666666666666;0;0;6;6;6;13.5;0;11.1;0.6;2.02;Graduate"
## [6] "1;17;4;9500;1;1;150.0;1;38;37;9;9;130.8;0;0;0;1;1;1;22;0;0;7;7;7;14.842857142857142;0;0;8;9;8;15.055555555555555;0;16.2;0.3;-0.92;Graduate"
##
## Subsample 2 :
## [1] "1;17;6;9500;1;1;143.0;1;1;38;3;3;133.2;1;0;0;1;0;0;18;0;0;7;7;7;13.918571428571427;0;0;8;9;8;13.8875;0;11.1;0.6;2.02;Graduate"
## [2] "2;39;1;9991;0;1;121.0;1;37;19;9;9;141.4;0;0;1;0;1;0;29;0;0;5;7;4;11.25;0;0;5;8;4;11.8;0;10.8;1.4;1.74;Dropout"
## [3] "1;1;5;9238;1;3;135.0;1;1;38;9;3;129.4;0;0;1;1;0;0;18;0;0;6;6;6;12.166666666666666;0;0;6;6;6;12.333333333333334;0;10.8;1.4;1.74;Graduate"
## [4] "1;39;1;9773;1;19;100.0;1;37;37;0;0;128.0;1;0;0;1;1;0;28;0;0;6;7;6;13.166666666666666;0;0;6;6;6;13.666666666666666;0;7.6;2.6;0.32;Graduate"
## [5] "2;1;1;9500;1;1;151.0;1;37;38;9;7;134.5;0;0;1;1;0;1;18;0;0;7;7;6;14.2;0;0;7;7;6;14.2;0;7.6;2.6;0.32;Graduate"
## [6] "1;39;1;8014;0;1;120.0;1;37;37;7;8;120.0;0;0;0;1;0;1;27;0;0;6;8;6;11.833333333333334;0;0;6;10;5;12.8;0;15.5;2.8;-4.06;Graduate"
##
## Subsample 3 :
## [1] "1;1;3;9119;1;1;117.0;1;1;1;3;5;111.1;0;0;0;1;1;1;19;0;0;5;10;5;11.8;0;0;5;12;3;11.5;0;11.1;0.6;2.02;Enrolled"
## [2] "1;1;4;171;1;1;127.0;1;1;1;9;5;124.2;1;0;0;0;0;0;19;0;0;0;0;0;0.0;0;0;0;0;0;0.0;0;9.4;-0.8;-3.12;Dropout"
## [3] "1;42;3;9500;1;1;136.0;1;1;1;4;4;148.8;1;0;0;1;0;1;19;0;0;8;8;8;14.2525;0;0;8;8;8;14.2525;0;9.4;-0.8;-3.12;Graduate"
## [4] "1;1;3;9070;1;1;132.0;1;1;3;9;7;126.1;1;0;0;1;0;1;18;0;0;6;6;6;15.833333333333334;0;0;6;6;6;15.333333333333334;0;11.1;0.6;2.02;Graduate"
## [5] "2;39;1;9853;1;12;133.1;1;37;37;7;8;103.0;0;0;0;1;0;0;41;0;0;6;0;0;0.0;0;0;6;0;0;0.0;0;16.2;0.3;-0.92;Dropout"
## [6] "1;17;5;9147;1;1;133.0;1;1;1;4;4;129.2;1;0;0;1;0;0;19;0;0;5;9;2;11.0;0;0;5;12;2;10.0;0;7.6;2.6;0.32;Dropout"
##
## Subsample 4 :
## [1] "1;43;3;9254;1;1;135.0;1;3;3;2;2;122.1;0;0;0;1;1;0;19;0;0;6;14;3;12.5;0;0;6;9;4;11.0;0;12.7;3.7;-1.7;Enrolled"
## [2] "1;7;1;9500;1;3;140.0;1;3;1;4;4;140.0;0;0;0;1;0;0;26;0;0;7;0;0;0.0;0;0;8;0;0;0.0;0;13.9;-0.3;0.79;Dropout"
## [3] "1;44;1;9130;1;39;150.0;1;37;37;9;3;150.0;1;0;0;1;1;0;21;0;1;6;8;6;12.5;0;0;6;11;3;13.333333333333334;0;13.9;-0.3;0.79;Dropout"
## [4] "1;1;1;9130;1;1;125.0;1;3;3;2;2;132.4;0;0;0;1;1;0;20;0;0;5;7;4;11.75;0;0;5;5;5;13.4;0;7.6;2.6;0.32;Graduate"
## [5] "1;1;2;9773;1;1;144.0;1;3;3;3;2;140.2;1;0;0;1;0;0;20;0;0;6;0;0;0.0;0;0;6;0;0;0.0;0;16.2;0.3;-0.92;Dropout"
## [6] "1;43;1;9070;1;1;108.0;1;38;38;7;7;105.2;1;0;0;1;1;0;25;0;11;17;18;13;11.538461538461538;0;10;15;15;10;12.4;0;12.7;3.7;-1.7;Dropout"
##
## Subsample 5 :
## [1] "1;1;1;9500;1;1;148.0;1;19;38;9;8;134.8;1;0;0;1;1;0;18;0;0;7;7;6;13.35;0;0;7;7;6;13.35;0;7.6;2.6;0.32;Graduate"
## [2] "1;1;1;9238;1;1;154.0;1;38;38;9;9;156.5;1;1;0;1;0;1;18;0;0;6;8;6;11.714285714285714;0;0;6;6;6;14.666666666666666;0;12.7;3.7;-1.7;Graduate"
## [3] "1;1;1;9238;1;1;108.0;1;19;38;9;7;110.5;1;0;0;1;0;1;22;0;0;6;6;6;12.166666666666666;0;0;6;6;6;12.5;0;12.4;0.5;1.79;Graduate"
## [4] "1;16;2;9238;1;1;130.0;1;37;37;5;6;126.9;1;0;0;1;0;0;18;0;0;6;8;6;13.571428571428571;0;0;6;11;5;12.166666666666666;0;9.4;-0.8;-3.12;Graduate"
## [5] "1;1;6;9500;1;1;140.0;1;19;19;1;4;133.3;1;0;0;1;0;1;17;0;0;8;8;8;13.41625;0;0;8;8;8;13.41625;0;9.4;-0.8;-3.12;Graduate"
## [6] "1;1;1;9670;1;1;141.0;1;19;3;4;0;137.9;1;0;0;0;1;0;20;0;0;5;6;3;12.0;0;0;5;5;4;12.75;0;7.6;2.6;0.32;Dropout"
# You now have a list of subsamples, with each subsample stored in a separate data frame
# For example, you can access the first subsample with subsample_list[[1]], the second with subsample_list[[2]], and so on.