RPubs will retire in June 2027. Your existing documents will stay accessible through December 31, 2031
and Connect Cloud is the recommended home for new publishing. Read the blog post

Recently Published

table questionnaire 2.1
# --- 0) Packages --- packs <- c("readr", "dplyr", "flextable", "officer", "rlang") new_packs <- packs[!(packs %in% installed.packages()[,"Package"])] if(length(new_packs)) install.packages(new_packs) lapply(packs, library, character.only = TRUE) # --- 1) Read data --- df <- readr::read_csv( "C:/Users/selfi/OneDrive/Desktop/analysis_data_masters.csv", show_col_types = FALSE ) # --- 2) Rename columns with spaces (IMPORTANT) --- df <- df %>% dplyr::rename( sex = sex, type_org = `type of org`, general_exp = `general exp`, current_exp = `current exp`, supervision = supervision, IDP_status = `IDP status`, disabilitiy = disabilitiy, care = care, household = household ) # --- 3) Recode: 1 = Так, 2 = Ні (IDP, disability, care, household) --- df <- df %>% dplyr::mutate( IDP_status = factor(IDP_status, levels = c(1, 2), labels = c("Так", "Ні")), disabilitiy = factor(disabilitiy, levels = c(1, 2), labels = c("Так", "Ні")), care = factor(care, levels = c(1, 2), labels = c("Так", "Ні")), household = factor(household, levels = c(1, 2), labels = c("Так", "Ні")) ) # --- 4) Helper: frequency block for one variable (keeps factor order) --- freq_block <- function(data, var, indicator_label) { v <- rlang::sym(var) data %>% dplyr::filter(!is.na(!!v), as.character(!!v) != "") %>% dplyr::count(!!v, name = "n", .drop = FALSE) %>% # keep factor order dplyr::mutate( `%` = round(100 * n / sum(n), 1), Показник = indicator_label, Категорія = as.character(!!v) ) %>% dplyr::select(Показник, Категорія, n, `%`) } # --- 5) Build full table --- table_data <- dplyr::bind_rows( freq_block(df, "sex", "Стать"), freq_block(df, "type_org", "Тип організації"), freq_block(df, "general_exp", "Загальний стаж"), freq_block(df, "current_exp", "Поточний стаж"), freq_block(df, "supervision", "Частота супервізії"), freq_block(df, "IDP_status", "Статус ВПО"), freq_block(df, "disabilitiy", "Інвалідність"), freq_block(df, "care", "Потреба в догляді"), freq_block(df, "household", "Домогосподарство") ) # --- 6) Flextable formatting (like screenshot) --- ft <- flextable::flextable(table_data) %>% flextable::set_caption("Анкетні дані") %>% flextable::merge_v(j = "Показник") %>% flextable::bold(j = "Показник", bold = TRUE) %>% flextable::align(j = c("Показник","Категорія"), align = "left", part = "all") %>% flextable::align(j = c("n","%"), align = "center", part = "all") %>% flextable::autofit() %>% flextable::border_remove() %>% flextable::border_outer(border = fp_border(width = 1)) %>% flextable::border_inner_h(border = fp_border(width = 1)) %>% flextable::border_inner_v(border = fp_border(width = 1)) # Preview in Viewer ft # --- 7) Export to Word --- doc <- officer::read_docx() %>% officer::body_add_flextable(ft) print(doc, target = "anketni_dani.docx")
Final Project
COD
All Costs
All_Costs
Project Document
Data Science
Plot
Plot
Plot
Plot
Plot
Plot