transfer from old repo
This commit is contained in:
parent
cfa4a5f9cc
commit
277e2b8cf3
1111 changed files with 83736 additions and 0 deletions
73
side projects/assignment.R
Normal file
73
side projects/assignment.R
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# Sample data set is generated with rownames and colnames
|
||||
ds <- do.call(cbind,lapply(1:133,function(i){
|
||||
sample(c(1,2,3,4,5,rep(NA,12)),size=17)
|
||||
}))
|
||||
rownames(ds) <- letters[seq_len(nrow(ds))]
|
||||
colnames(ds) <- paste0("sub",seq_len(ncol(ds)))
|
||||
|
||||
# df[as.character(as.matrix(ds))==0] <- 17
|
||||
|
||||
# Clearing NAs and applying the max cost instead
|
||||
# ds[is.na(ds)] <- 17
|
||||
|
||||
# I believe this would actually be the organic data set
|
||||
df <- data.frame("ID"=colnames(ds),t(ds))
|
||||
|
||||
|
||||
|
||||
openxlsx::write.xlsx(df,"assign_sample.xlsx")
|
||||
write.csv(df,"assign_sample.csv",na = "",row.names = FALSE)
|
||||
|
||||
|
||||
|
||||
|
||||
df[as.matrix(df)==0] <- 17
|
||||
|
||||
assigned <- df |>
|
||||
group_assignment(cap_classes = rep(8, 17),excess_space = 1)
|
||||
|
||||
df |> group_assignment()
|
||||
|
||||
|
||||
assigned$`Group assignment`
|
||||
|
||||
assigned$`Cost evaluation` |> assignment_plot(1:5)
|
||||
|
||||
|
||||
|
||||
|
||||
pre_grouped <- data.frame("ID"=sample(df$ID,10),"group"=sample(1:17,10))
|
||||
ds <- df
|
||||
|
||||
assigned <- df |>
|
||||
group_assignment(excess_space = 1.05,
|
||||
pre_assign = pre_grouped)
|
||||
|
||||
lengths(assigned[[1]])
|
||||
|
||||
#
|
||||
# ds <- read.csv("assign_sample.csv")
|
||||
#
|
||||
# ls <- read.csv("assign_sample.csv") |> group_assignment(cap_classes = 8, excess_space = 1)
|
||||
#
|
||||
# ls |> assignment_plot()
|
||||
#
|
||||
# lst <- ls
|
||||
#
|
||||
# "[["(ls,4) |> head(10)
|
||||
|
||||
# View(ls$export)
|
||||
#
|
||||
# pre_grouped <- data.frame("ID"=sample(ds$ID,10),"group"=sample(1:17,10))
|
||||
# write.csv(pre_grouped,"pre_grouped.csv",row.names = FALSE)
|
||||
#
|
||||
# assigned <- ds |>
|
||||
# group_assignment(excess_space = 1.05,
|
||||
# pre_assign = pre_grouped)
|
||||
|
||||
# ls <-
|
||||
# read.csv("assign_sample.csv") |> group_assignment(
|
||||
# cap_classes = 8,
|
||||
# excess_space = 1,
|
||||
# pre_assign = read.csv("pre_grouped.csv")
|
||||
# )
|
||||
Loading…
Reference in a new issue