Skip to content

Commit dab953b

Browse files
committed
updated demo notebook
1 parent a72895e commit dab953b

4 files changed

Lines changed: 597 additions & 2125 deletions

File tree

acro_demo_2026.R

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
## -----------------------------------------------------------------------------
2+
# Check if acro is installed
3+
if (!requireNamespace("acro", quietly = TRUE)) {
4+
# If not installed, install it
5+
install.packages("acro")
6+
}
7+
8+
9+
## -----------------------------------------------------------------------------
10+
library("acro")
11+
12+
13+
## -----------------------------------------------------------------------------
14+
acro_init()
15+
16+
17+
## -----------------------------------------------------------------------------
18+
data <- farff::readARFF("data/nursery.arff")
19+
data <- as.data.frame(data)
20+
21+
names(data)[names(data) == "class"] <- "recommendation"
22+
23+
24+
## -----------------------------------------------------------------------------
25+
data$children <- as.numeric(as.character(data$children))
26+
data[is.na(data)] <- round(runif(sum(is.na(data)), min = 4, max = 10), 0)
27+
unique(data$children)
28+
29+
30+
## -----------------------------------------------------------------------------
31+
head(data)
32+
33+
34+
## -----------------------------------------------------------------------------
35+
rows <- data[, c("recommendation")]
36+
columns <- data[, c("parents")]
37+
38+
table <- acro_table(index = rows, columns = columns, deparse.level = 1)
39+
table
40+
41+
42+
## -----------------------------------------------------------------------------
43+
44+
acro_enable_suppression()
45+
table <- acro_table(index = rows, columns = columns, deparse.level = 1)
46+
table
47+
48+
49+
## -----------------------------------------------------------------------------
50+
myrows <- list(data[, c("parents")], data[, c("finance")])
51+
mycolumns <- data[, c("recommendation")]
52+
myvalues <- data[, c("children")]
53+
# convert the values to an array
54+
myvalues <- matrix(myvalues, ncol = 1)
55+
56+
57+
table4 <- acro_crosstab(
58+
index = myrows,
59+
columns = mycolumns,
60+
values = myvalues,
61+
aggfunc <- list("mean")
62+
)
63+
table4
64+
65+
66+
## -----------------------------------------------------------------------------
67+
68+
help(package = "acro")
69+
70+
71+
## -----------------------------------------------------------------------------
72+
details <- acro_print_outputs()
73+
74+
75+
## -----------------------------------------------------------------------------
76+
acro_remove_output("output_0")
77+
78+
79+
## -----------------------------------------------------------------------------
80+
acro_rename_output("output_1", " crosstab_recommendation_vs_parents")
81+
acro_rename_output("output_2", "mean_children_by_parents_finance_vs_recommendation")
82+
83+
84+
## -----------------------------------------------------------------------------
85+
86+
acro_add_comments(
87+
"mean_children_by_parents_finance_vs_recommendation",
88+
"too few cases of recommend to report"
89+
)
90+
91+
92+
## -----------------------------------------------------------------------------
93+
acro_custom_output("acro_demo_2026.R", "This is the code that produced this session")
94+
95+
96+
## -----------------------------------------------------------------------------
97+
myfolder <- "Routputs"
98+
suffix <- format(Sys.time(), "%e_%m_%Y_%H_%M")
99+
foldername <- paste(myfolder, suffix, sep = "_")
100+
acro_finalise(foldername, ext = "json")

0 commit comments

Comments
 (0)