Dear users,
I have a dataset in Excel, I have imported in R and I want to make a cross-tabulation output.
Any suggestion what packages to use? I have tried the sjPlot and tab_xtab:
The script below it aggregated the data separately and I want them both in 1 table merged
############################ Tabulation ########################################
############################ Importing an Excel file ###########################
library(readxl)
data - read_excel("C:/Users/hasimif/Desktop/R Language/Input/data.xlsx")
View(data)
###################### CROSSTAB TABULATION PACKAGE #############################
install.packages("sjPlot")
req <- substitute(require(x, character.only = TRUE))
libs<-c("sjPlot")
sapply(libs, function(x) eval(req) || {install.packages(x); eval(req)})
################################################################################
################################ Agregations ###################################
sjPlot::tab_xtab(var.row = data$P_03, var.col = data$P_02, title = "Disaggregated data of the amount of export in 2022 by nr of employees",
var.labels = c("Amount of export in 2022", "Number of employees"),
digits = 2, show.row.prc = TRUE)
sjPlot::tab_xtab(var.row = data$P_03, var.col = data$P_04, title = "Disaggregated data of the amount of export in 2022 by share of export in sales revenue",
var.labels = c("Amount of export in 2022", "Share of export in sales revenue"),
digits = 2, show.row.prc = TRUE)