diff --git a/data/Scripts/a tidy calculator r-script.R b/data/Scripts/a tidy calculator r-script.R new file mode 100644 index 0000000..db82637 --- /dev/null +++ b/data/Scripts/a tidy calculator r-script.R @@ -0,0 +1,270 @@ +# Script produced on 4 December 2024 using R-Instat Version 0.8.0. +## A tidy calculation system practice + +# Creating a New Data Frame in R-Instat + +data <- data.frame(x1=as.numeric(rep(seq(1,1000), each=1, length.out=100)), x2=as.character(rep(NA, 100))) +data_book$import_data(data_tables=list(data=data)) + +rm(data) + + +## The R-Instat calculator +## A basic calculator + +# Doing basic calculations with the R-Instat calculator + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +calc <- 3 + 5 +calc +data_book$add_scalar(data_name="data", scalar_name="calc", scalar_value=calc) +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +rm(list=c("calc", "data", "scalars")) + + +# Doing basic calculations with the R-Instat calculator + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +calc <- 3 ^ 5 +calc +data_book$add_scalar(data_name="data", scalar_name="calc", scalar_value=calc) +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +rm(list=c("calc", "data", "scalars")) + + +## A column calculator + +# Using the R-Instat calculator to carry out column calculations: Producing a 5 times table + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +x2 <- x1 * 5 +data_book$add_columns_to_data(data_name="data", col_name="x2", col_data=x2, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="x2", property="labels", new_val="") +rm(list=c("x2", "data", "scalars")) + + +# Using the R-Instat calculator to carry out column calculations: Producing powers of 5 values + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +power5 <- x1 ^5 +data_book$add_columns_to_data(data_name="data", col_name="power5", col_data=power5, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="power5", property="labels", new_val="") +rm(list=c("power5", "data", "scalars")) + + +## The Maths Keyboard + +# Using the R-Instat calculator maths keyboard to carry out column calculations finding squareroots + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +sqrt <- sqrt(x1 ) +data_book$add_columns_to_data(data_name="data", col_name="sqrt", col_data=sqrt, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="sqrt", property="labels", new_val="") +rm(list=c("sqrt", "data", "scalars")) + + +## The Integer keyboard + +# Using the R-Instat calculator integer keyboard to carry out column calculations finding divisors + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +divisors <- DescTools::Divisors(x1 ) +data_book$add_columns_to_data(data_name="data", col_name="divisors", col_data=divisors, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="divisors", property="labels", new_val="") +rm(list=c("divisors", "data", "scalars")) + + +# Using the R-Instat calculator integer keyboard to carry out column calculations generating prime numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +primes <- primes::generate_n_primes(n=nrow(x=data)) +data_book$add_columns_to_data(data_name="data", col_name="primes", col_data=primes, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="primes", property="labels", new_val="") +rm(list=c("primes", "data", "scalars")) + + +# Using the R-Instat calculator integer keyboard to carry out column calculations generating abundant numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +abundant <- Zseq::Abundant(n=nrow(x=data), gmp=FALSE) +data_book$add_columns_to_data(data_name="data", col_name="abundant", col_data=abundant, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="abundant", property="labels", new_val="") +rm(list=c("abundant", "data", "scalars")) + + +# Using the R-Instat calculator integer keyboard to carry out column calculations generating deficient numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +deficient <- Zseq::Deficient(n=nrow(x=data), gmp=FALSE) +data_book$add_columns_to_data(data_name="data", col_name="deficient", col_data=deficient, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="deficient", property="labels", new_val="") +rm(list=c("deficient", "data", "scalars")) + + +# Using the R-Instat calculator integer keyboard to carry out column calculations generating fibonacci numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +fibonacci <- Zseq::Fibonacci(n=nrow(x=data)) +data_book$add_columns_to_data(data_name="data", col_name="fibonacci", col_data=fibonacci, before=FALSE, adjacent_column="x1") + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="fibonacci", property="labels", new_val="") +rm(list=c("fibonacci", "data", "scalars")) + + +## The basic keyboard + +# Doing basic calculations to check the ratios of the fibonacci numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +calc <- 13 / 8 +calc +data_book$add_scalar(data_name="data", scalar_name="calc", scalar_value=calc) +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +rm(list=c("calc", "data", "scalars")) + + +# Doin basic calculations to check the ratios of the fibonacci numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +21 / 13 +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +rm(list=c("data", "scalars")) + +# Doin basic calculations to check the ratios of the fibonacci numbers + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +calc <- 610 / 377 +calc +data_book$add_scalar(data_name="data", scalar_name="calc", scalar_value=calc) +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +rm(list=c("calc", "data", "scalars")) + + + +# Duplicating the fibonacci numbers Column and changing it's type to numeric + +fibonacci1 <- data_book$get_columns_from_data(data_name="data", col_names="fibonacci", use_current_filter=FALSE) +data_book$add_columns_to_data(data_name="data", col_name="fibonacci1", col_data=fibonacci1, before=FALSE, adjacent_column="fibonacci") + +data_book$convert_column_to_type(data_name="data", col_names="fibonacci1", to_type="integer") +rm(fibonacci1) + + +## The transform keyboard +# Using the transform keyboard and the lag button + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +fibonacci2 <- dplyr::lag(fibonacci1 ) +data_book$add_columns_to_data(data_name="data", col_name="fibonacci2", col_data=fibonacci2, before=FALSE, adjacent_column="fibonacci1") + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="fibonacci2", property="labels", new_val="") +rm(list=c("fibonacci2", "data", "scalars")) + + +## The basic keyboard +# Using the basic keyboard in the R-Instat calculator to generate the golden ratios + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +golden <- fibonacci1 / fibonacci2 +data_book$add_columns_to_data(data_name="data", col_name="golden", col_data=golden, before=FALSE, adjacent_column="fibonacci2") + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="golden", property="labels", new_val="") +rm(list=c("golden", "data", "scalars")) + + +# Generating a line plot for the golden ratio + +data <- data_book$get_data_frame(data_name="data") +last_graph <- ggplot2::ggplot(data=data, mapping=ggplot2::aes(y=golden, x=x1)) + ggplot2::geom_line(colour="blue", size=0.8) + ggplot2::geom_point() + theme_grey() +data_book$add_object(data_name="data", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) +data_book$get_object_data(data_name="data", object_name="last_graph", as_file=TRUE) +rm(list=c("last_graph", "data")) + + +## You can often avoid this halfway calculator dialogue until you are comfortable with the simple use of R-Instat + +# Using the Transform dialog instead to calculate squareroots + +x1 <- data_book$get_columns_from_data(data_name="data", col_names="x1", use_current_filter=FALSE) +sqrt <- sqrt(x=x1) +data_book$add_columns_to_data(data_name="data", col_name="sqrt", col_data=sqrt, before=FALSE, adjacent_column="x1") + +data_book$append_to_variables_metadata(data_name="data", col_names="sqrt", property="labels", new_val="") +rm(list=c("sqrt", "x1")) \ No newline at end of file diff --git a/data/Scripts/a whole world of data.R b/data/Scripts/a whole world of data.R new file mode 100644 index 0000000..200acc6 --- /dev/null +++ b/data/Scripts/a whole world of data.R @@ -0,0 +1,147 @@ +## A whole world of data r-script practical +# Script produced on 4 December 2024 using R-Instat Version 0.8.0. +# Importing the diamonds data into R-Instat from the library + +utils::data(package="ggplot2", X=diamonds) +data_book$import_data(data_tables=list(diamonds=diamonds)) + + +# Producing a Scatter Plot in R-Instat + +diamonds <- data_book$get_data_frame(data_name="diamonds") +last_graph <- ggplot2::ggplot(data=diamonds, mapping=ggplot2::aes(colour=cut, y=color, x=clarity)) + ggplot2::geom_jitter(width=0.40, height=0.40) + theme_grey() +data_book$add_object(data_name="diamonds", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) +data_book$get_object_data(data_name="diamonds", object_name="last_graph", as_file=TRUE) +rm(list=c("last_graph", "diamonds")) + + +# Create Filter subdialog: Created new filter +data_book$add_filter(filter=list(C0=list(column="carat", operation=">", value=1)), data_name="diamonds", filter_name="filter") + + +# Data Options subdialog: Set the current filter +data_book$set_current_filter(data_name="diamonds", filter_name="filter") + + +# Producing a Scatter Plot in R-Instat with filtered values of carat>1 + +diamonds <- data_book$get_data_frame(data_name="diamonds") +last_graph <- ggplot2::ggplot(data=diamonds, mapping=ggplot2::aes(colour=cut, x=clarity, y=color)) + ggplot2::geom_jitter(width=0.40, height=0.40) + theme_grey() +data_book$add_object(data_name="diamonds", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) +data_book$get_object_data(data_name="diamonds", object_name="last_graph", as_file=TRUE) +rm(list=c("last_graph", "diamonds")) + + +# Importing the mydata data into R-Instat from the library + +utils::data(package="openair", X=mydata) +data_book$import_data(data_tables=list(mydata=mydata)) + + +# Importing the efc data into R-Instat from the library + +utils::data(package="sjlabelled", X=efc) +data_book$import_data(data_tables=list(efc=efc)) + +## Datasets for specific points + +# Importing the datasaurus data into R-Instat from the library + +utils::data(package="datasauRus", X=datasaurus_dozen) +data_book$import_data(data_tables=list(datasaurus_dozen=datasaurus_dozen)) + +# Right click menu: Convert the dataset Column To Factor +data_book$convert_column_to_type(data_name="datasaurus_dozen", col_names="dataset", to_type="factor") + + + +# Producing a Scatter Plot in R-Instat + +datasaurus_dozen <- data_book$get_data_frame(data_name="datasaurus_dozen") +last_graph <- ggplot2::ggplot(data=datasaurus_dozen, mapping=ggplot2::aes(colour=dataset, y=y, x=x)) + ggplot2::geom_jitter(width=0.40, height=0.40) + theme_grey() + ggplot2::theme(legend.position="none") + ggplot2::facet_wrap(facets= ~ dataset, dir="h") +data_book$add_object(data_name="datasaurus_dozen", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) +data_book$get_object_data(data_name="datasaurus_dozen", object_name="last_graph", as_file=TRUE) +rm(list=c("last_graph", "datasaurus_dozen")) + + +# Importing the simpsons_paradox data into R-Instat from the library + +utils::data(package="datasauRus", X=simpsons_paradox) +data_book$import_data(data_tables=list(simpsons_paradox=simpsons_paradox)) + +# Right click menu: Convert Column(s) To Factor +data_book$convert_column_to_type(data_name="simpsons_paradox", col_names="dataset", to_type="factor") + + +# Producing a Scatter Plot in R-Instat + +simpsons_paradox <- data_book$get_data_frame(data_name="simpsons_paradox") +last_graph <- ggplot2::ggplot(data=simpsons_paradox, mapping=ggplot2::aes(colour=dataset, x=x, y=y)) + ggplot2::geom_jitter(width=0.40, height=0.40) + theme_grey() + ggplot2::theme(legend.position="none") + ggplot2::facet_wrap(facets= ~ dataset, dir="h") +data_book$add_object(data_name="simpsons_paradox", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) +data_book$get_object_data(data_name="simpsons_paradox", object_name="last_graph", as_file=TRUE) +rm(list=c("last_graph", "simpsons_paradox")) + + +# Producing a Scatter Plot in R-Instat with a line of best fit + +simpsons_paradox <- data_book$get_data_frame(data_name="simpsons_paradox") +last_graph <- ggplot2::ggplot(data=simpsons_paradox, mapping=ggplot2::aes(colour=dataset, y=y, x=x)) + ggplot2::geom_jitter(width=0.40, height=0.40) + ggplot2::geom_smooth(method="lm", se=TRUE) + theme_grey() + ggplot2::theme(legend.position="none") +data_book$add_object(data_name="simpsons_paradox", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) +data_book$get_object_data(data_name="simpsons_paradox", object_name="last_graph", as_file=TRUE) +rm(list=c("last_graph", "simpsons_paradox")) + + +# Importing the UCBAdmissions data into R-Instat from the library + +utils::data(package="datasets", X=UCBAdmissions) +data_book$import_data(data_tables=list(UCBAdmissions=UCBAdmissions)) + + +## Datasets from books + + + +# Importing the movielens data From the R-Instat Library + +utils::data(package="dslabs", X=movielens) +data_book$import_data(data_tables=list(movielens=movielens)) + + +## Agriculture data + +# Importing the gomezsplitsplit data From the R-Instat Library + +utils::data(package="agridat", X=gomez.splitsplit) +data_book$import_data(data_tables=list(gomez.splitsplit=gomez.splitsplit)) + + +## Data from lists + + +# Importing lists of Canadian municipalities into R-Instat + +canadian_municipalities <- read_corpora(data=rcorpora::corpora("geography/canadian_municipalities")) +data_book$import_data(data_tables=list(canadian_municipalities=canadian_municipalities)) + +rm(canadian_municipalities) + + +## Datasets from outside R Packages + +## MICS data + + +# Importing the MICS Dataset into R-Instat +# Dataset +# Get the current working directory +current_dir <- getwd() + +# Construct the desired file path by navigating up two directories and into "Library" +file_path <- file.path(dirname(dirname(current_dir)), "Library", "mics.RDS") + +# Read the RDS file +new_RDS <- readRDS(file = file_path) + +# Dialog: Import Dataset +data_book$import_RDS(data_RDS=new_RDS) +rm(new_RDS) diff --git a/data/Scripts/fun with lists.R b/data/Scripts/fun with lists.R new file mode 100644 index 0000000..992bf9e --- /dev/null +++ b/data/Scripts/fun with lists.R @@ -0,0 +1,112 @@ +## Fun with lists +# Script produced on 4 December 2024 using R-Instat Version 0.8.0. +## Animals lists + +# Producing a list of dinosaurs + +dinosaurs <- read_corpora(data=rcorpora::corpora("animals/dinosaurs")) +data_book$import_data(data_tables=list(dinosaurs=dinosaurs)) + +rm(dinosaurs) + + +# Using the Transform Text Column dialog to examine the length of dinosaurs names + +list <- data_book$get_columns_from_data(data_name="dinosaurs", col_names="list", use_current_filter=FALSE) +length <- stringr::str_length(string=list) +data_book$add_columns_to_data(data_name="dinosaurs", col_name="length", col_data=length, before=FALSE, adjacent_column="list") + +rm(list=c("length", "list")) + + +# Copying the Row Numbers into a column + +row <- data_book$get_row_names(data_name="dinosaurs") +data_book$add_columns_to_data(data_name="dinosaurs", col_name="row", col_data=row, before=TRUE) + +rm(row) + + +# Sorting the lengths of the names to find out the longest name + +data_book$sort_dataframe(data_name="dinosaurs", col_names="length", decreasing=TRUE) + + +## Food lists + +# Producing a list of bread and pastries + +breads_and_pastries <- read_corpora(data=rcorpora::corpora("foods/breads_and_pastries")) +data_book$import_data(data_tables=list(breads_and_pastries=breads_and_pastries)) + +rm(breads_and_pastries) + + +# Producing a list of fruits + +fruits <- read_corpora(data=rcorpora::corpora("foods/fruits")) +data_book$import_data(data_tables=list(fruits=fruits)) + +rm(fruits) + + +# Producing a list of vegetables + +vegetables <- read_corpora(data=rcorpora::corpora("foods/vegetables")) +data_book$import_data(data_tables=list(vegetables=vegetables)) + +rm(vegetables) + + +# Appending the food lists to create one data frame + +food <- dplyr::bind_rows(data_book$get_data_frame(data_name=c("breads_and_pastries","fruits","vegetables")), .id="type") +data_book$import_data(data_tables=list(food=food)) + +rm(food) + +# Right click menu: Convert Column(s) To Factor +data_book$convert_column_to_type(data_name="food", col_names="type", to_type="factor") + + +# Checking the Labels/Levels + +data_book$set_factor_levels(data_name="food", col_name="type", new_labels=c("breads_and_pastries","fruits","vegetables")) + + +## Crossword Clues + +# Producing a list of word clues + +clues_four <- read_corpora(data=rcorpora::corpora("words/word_clues/clues_four")) +data_book$import_data(data_tables=list(clues_four=clues_four)) + +rm(clues_four) + + + +# Using the Count in Factor the clue number for each word + +variable2 <- data_book$get_columns_from_data(data_name="clues_four", col_names="variable2", use_current_filter=FALSE) +clue <- dae::fac.nested(nesting.fac=variable2) +data_book$add_columns_to_data(data_name="clues_four", col_name="clue", col_data=clue, before=FALSE, adjacent_column="variable2") + +rm(list=c("clue", "variable2")) + + +# Using the Unstack dialog to make the data wider + +clues_four <- data_book$get_data_frame(data_name="clues_four") +clues_four_unstacked <- tidyr::pivot_wider(data=clues_four %>% dplyr::select(clue, list, variable2), names_from=clue, values_from=list, names_prefix="clue") +data_book$import_data(data_tables=list(clues_four_unstacked=clues_four_unstacked)) + +rm(list=c("clues_four_unstacked", "clues_four")) + + +# Right click menu: Delete Row(s) +data_book$remove_rows_in_data(data_name="clues_four_unstacked", row_names="1") + + +# Replacing the missing Values with blanks + +data_book$replace_value_in_data(data_name="clues_four_unstacked", col_names=c("clue1","clue2","clue3","clue4","clue5","clue6","clue7"), new_value="", old_is_missing=TRUE) \ No newline at end of file diff --git a/data/Scripts/fun with sequences.R b/data/Scripts/fun with sequences.R new file mode 100644 index 0000000..a2f7943 --- /dev/null +++ b/data/Scripts/fun with sequences.R @@ -0,0 +1,240 @@ +# Script produced on 4 December 2024 using R-Instat Version 0.8.0. +## Fun with Sequences +## This script will explore sequences. + +## Abundant numbers +# Understanding abundant numbers + +# Creating a New Data Frame + +data <- data.frame(x1=as.numeric(rep(seq(1,1000), each=1, length.out=500))) +data_book$import_data(data_tables=list(data=data)) + +rm(data) + + +# Generating abundant numbers using the R-Instat calculator and the integer keyboard + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +abundant <- Zseq::Abundant(n=nrow(x=data), gmp=FALSE) +data_book$add_columns_to_data(data_name="data", col_name="abundant", col_data=abundant, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="abundant", property="labels", new_val="") +rm(list=c("abundant", "data", "scalars")) + + + +# Generating divisors for the abundant numbers using the R-Instat calculator and the integer keyboard + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +divisors <- DescTools::Divisors(abundant ) +data_book$add_columns_to_data(data_name="data", col_name="divisors", col_data=divisors, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="divisors", property="labels", new_val="") +rm(list=c("divisors", "data", "scalars")) + + +## Calculating abundance + + +# Calculating the sum of the divisors using the R-Instat calculator and the list keyboard + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +sum <- sapply( divisors ,sum) +data_book$add_columns_to_data(data_name="data", col_name="sum", col_data=sum, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="sum", property="labels", new_val="") +rm(list=c("sum", "data", "scalars")) + + + +# Calculating abundance using the R-Instat calculator + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +abundance <- sum / abundant +data_book$add_columns_to_data(data_name="data", col_name="abundance", col_data=abundance, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="abundance", property="labels", new_val="") +rm(list=c("abundance", "data", "scalars")) + + +## Super-abundant numbers + + +# Calculating max column of the abundances using the R-Instat calculator + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +max <- cummax(abundance ) +data_book$add_columns_to_data(data_name="data", col_name="max", col_data=max, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="max", property="labels", new_val="") +rm(list=c("max", "data", "scalars")) + + +# Calculating differences of the max column of the abundances using the R-Instat calculator + +data <- data_book$get_data_frame(data_name="data", use_current_filter=FALSE) +attach(what=data) +scalars <- data_book$get_scalars(data_name="data") +attach(what=scalars) +diff <- c(NA,diff(x=max , lag = 1, differences = 1)) +data_book$add_columns_to_data(data_name="data", col_name="diff", col_data=diff, before=FALSE) + +detach(name=data, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data", col_names="diff", property="labels", new_val="") +rm(list=c("diff", "data", "scalars")) + + +# Editing a Cell in R-Instat + +data_book$replace_value_in_data(data_name="data", col_name="diff", new_value=0.33, rows="1") + + +# Create Filter subdialog: Created new filter +data_book$add_filter(filter=list(C0=list(column="diff", operation=">", value=0)), data_name="data", filter_name="filter") + + +# Filtering out the superabundant numbers + +data_book$set_current_filter(data_name="data", filter_name="filter") + + + +# Creating a New Data Frame + +data1 <- data.frame(x1=as.numeric(rep(seq(1,100000), each=1, length.out=100000))) +data_book$import_data(data_tables=list(data1=data1)) + +rm(data1) + + +# Generating divisors using the R-Instat calculator and the integer keyboard + +data1 <- data_book$get_data_frame(data_name="data1", use_current_filter=FALSE) +attach(what=data1) +scalars <- data_book$get_scalars(data_name="data1") +attach(what=scalars) +divisor <- DescTools::Divisors(x1 ) +data_book$add_columns_to_data(data_name="data1", col_name="divisor", col_data=divisor, before=FALSE) + +detach(name=data1, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data1", col_names="divisor", property="labels", new_val="") +rm(list=c("divisor", "data1", "scalars")) + + + +# Calculating the sum of divisors using the R-Instat calculator and the list keyboard + +data1 <- data_book$get_data_frame(data_name="data1", use_current_filter=FALSE) +attach(what=data1) +scalars <- data_book$get_scalars(data_name="data1") +attach(what=scalars) +sum <- sapply( divisor ,sum) + x1 +data_book$add_columns_to_data(data_name="data1", col_name="sum", col_data=sum, before=FALSE) + +detach(name=data1, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data1", col_names="sum", property="labels", new_val="") +rm(list=c("sum", "data1", "scalars")) + + + +# Calculating the relative abundance + +data1 <- data_book$get_data_frame(data_name="data1", use_current_filter=FALSE) +attach(what=data1) +scalars <- data_book$get_scalars(data_name="data1") +attach(what=scalars) +abundance <- sum / x1 +data_book$add_columns_to_data(data_name="data1", col_name="abundance", col_data=abundance, before=FALSE) + +detach(name=data1, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data1", col_names="abundance", property="labels", new_val="") +rm(list=c("abundance", "data1", "scalars")) + + +# Calculating the cumulative maxima + +data1 <- data_book$get_data_frame(data_name="data1", use_current_filter=FALSE) +attach(what=data1) +scalars <- data_book$get_scalars(data_name="data1") +attach(what=scalars) +max <- cummax(abundance ) +data_book$add_columns_to_data(data_name="data1", col_name="max", col_data=max, before=FALSE) + +detach(name=data1, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data1", col_names="max", property="labels", new_val="") +rm(list=c("max", "data1", "scalars")) + + + +# Calculating the differences of the cumulative maxima + +data1 <- data_book$get_data_frame(data_name="data1", use_current_filter=FALSE) +attach(what=data1) +scalars <- data_book$get_scalars(data_name="data1") +attach(what=scalars) +super <- c(NA,diff(x=max , lag = 1, differences = 1)) > 0 +data_book$add_columns_to_data(data_name="data1", col_name="super", col_data=super, before=FALSE) + +detach(name=data1, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data1", col_names="super", property="labels", new_val="") +rm(list=c("super", "data1", "scalars")) + + +# Replace Value In Data +data_book$replace_value_in_data(data_name="data1", col_name="super", rows="1", new_value=TRUE) + + +# Create Filter subdialog: Created new filter +data_book$add_filter(filter=list(C0=list(column="super", operation="==", value=TRUE)), data_name="data1", filter_name="filter") + + +# Filtering out the superabundant numbers + +data_book$set_current_filter(data_name="data1", filter_name="filter") + + +# Finding the count of divisors for the super-abundant numbers + +data1 <- data_book$get_data_frame(data_name="data1", use_current_filter=FALSE) +attach(what=data1) +scalars <- data_book$get_scalars(data_name="data1") +attach(what=scalars) +count <- sapply( divisor ,length) +data_book$add_columns_to_data(data_name="data1", col_name="count", col_data=count, before=FALSE) + +detach(name=data1, unload=TRUE) +detach(name=scalars, unload=TRUE) +data_book$append_to_variables_metadata(data_name="data1", col_names="count", property="labels", new_val="") +rm(list=c("count", "data1", "scalars")) \ No newline at end of file diff --git a/data/mics.RDS b/data/mics.RDS new file mode 100644 index 0000000..f6e2e1c Binary files /dev/null and b/data/mics.RDS differ