This commit is contained in:
pero1203 2021-03-04 13:40:44 +01:00
commit 0a03792fac
2 changed files with 80 additions and 1 deletions

View File

@ -60,7 +60,7 @@ ID <- params[1]
#---------------------------- CUSTOm FUNCTIONS -----------------------------#
source("modules/mod_EVOLI/R/Functions_QC/my_functions_QC.R")
source("modules/mod_EVOLI/R/Functions_QC/my_functions_QC_dan.R")
#---------------------------- CUSTOm FUNCTIONS -----------------------------#

View File

@ -0,0 +1,79 @@
#------------------------------------ Load some usefull functions ------------------------------------#
# Ustvarimo svojo funkcijo, ki vedno števila z 0.5 zaokrožila navzgor
# (glej "Variables and syntax Quality Climate 22072019 - FDV (1)".xlsx)
round2 = function(x) {
x <- round(x, 1)
# Najprej rekodiramo rezultate kot želi
# stranka: glej file
# "Variables and syntax Quality Climate 22072019 - FDV (1).xlsx"
x <- ifelse(x >= 4.9, 5,
ifelse(x >=4.1 & x <= 4.8, 4, ifelse(
x >= 3.1 & x <= 4.0, 3, ifelse(
x >= 2.1 & x <= 3.0, 2, ifelse(
x >= 1.3 & x <= 2.0, 1, NA
)
)
)
)
)
x
}
#prepare data for plot
prep.dat <- function(df, variable) {
df <- round2(rowMeans(df[, variable], na.rm = TRUE) / 4 * 5)
df <- data.frame(prop.table(table(df)) * 100)
names(df)[1] <- "Frequency"
names(df)[2] <- "Prcentage"
# Check if there is no labels
# We want to show values from 1 - 5
# Therefore is some is missing we will
# create it and assign it 0
# if (nrow(df) < 5) {
# miss <- 1:5
# # Check diff
# dif <- setdiff(miss, df[,1])
# # Check how many data we are missing
# miss.dummy <- df[1:length(dif),]
# # Clone data
# miss.dummy$Frekvens <- dif
# # # Add zeero
# miss.dummy$Procent <- 0
# # Finally Rbind
# df <- rbind(miss.dummy, df)
# # And order
# df <- df[order(df$Frekvens),]
# }
return(df)
}
# name po katerih bomo razvrstili stolpce v grafu
labScore <- function(df, labelord) {
df$label <- ifelse(df$Frequency == 1,
"Meget utilfredsstillende",
ifelse(
df$Frequency == 2,
"Utilfredsstillende",
ifelse(
df$Frequency == 3,
"Gennemsnitlig",
ifelse(
df$Frequency == 4,
"Meget tilfredsstillende",
ifelse(df$Frequency == 5, "S\u00E6rdeles tilfredsstillende", NA)
)
)
))
# Imena po katerih bomo razvrstili stolpce v grafih
df$name <- labelord
return(df)
}
#---------------------------------- //Load some usefull functions// ----------------------------------#