14:01, 16th January 2022
5 Julia Projects for Beginners — Easy Ideas to Get Started Coding in Julia
For those new to the Julia programming language, building small beginner projects is an effective way to develop a solid foundation before tackling more complex challenges such as machine learning and data science. Five such projects offer a practical introduction to core concepts: a Mad Libs game that teaches string interpolation and user input handling, a number guessing game in which the player attempts to identify a randomly generated number using while loops and conditional logic, a reverse version in which the computer does the guessing by shuffling an array of possible values and iterating through them, a Rock Paper Scissors game that introduces chained conditionals and timed delays, and a password generator that demonstrates the use of external packages, arrays and the push function. Together, these projects cover a broad range of foundational Julia concepts including functions, loops, conditionals, random number generation and package management, providing a well-rounded starting point for anyone beginning to learn the language.
13:58, 16th January 2022
6 Julia Frameworks to Create Desktop GUI’s and Web Apps
Julia is a programming language commonly associated with technical fields such as machine learning and data science, but its capabilities extend to building desktop graphical user interfaces and web applications. Genie.jl is a full web framework inspired by Django, offering features such as a routing engine, templating and authentication. Gtk.jl provides bindings to the GTK windowing toolkit, enabling the creation of native desktop interfaces. Makie.jl is a widely used visualisation package capable of producing interactive, GPU-accelerated graphics that can also run in a browser. Blink.jl wraps the Electron runtime to allow HTML-based desktop applications to be built entirely in Julia, while Dash.jl, part of the Plotly ecosystem, enables the development of analytic web dashboards without requiring any JavaScript knowledge. For distributing desktop applications to users who do not have Julia installed, PackageCompiler can bundle an entire project and its dependencies into a single executable file, though some code modifications may be necessary to ensure compatibility.
17:52, 14th January 2022
Handling Categorical Data in R - Part 3
Part 3 of the "Handling Categorical Data in R" series focuses on manipulating and reshaping categorical data using the forcats package in R, covering three key operations: changing the value of levels, adding or removing levels and changing the order of levels. To modify level values, functions such as fct_collapse() and fct_recode() can be used to combine or rename categories, while fct_lump_min(), fct_lump_n() and fct_lump_prop() allow less frequent levels to be grouped together based on count or proportion thresholds. The fct_other() function provides a straightforward way to retain or drop specified levels, merging the remainder into an "Other" category, and fct_anon() enables the anonymisation of level labels for data sharing purposes. For adding or removing levels, fct_expand() introduces new categories, fct_drop() removes unused ones and fct_explicit_na() converts missing values into a clearly labelled category. Finally, the ordering of levels can be adjusted manually using fct_relevel(), sorted by frequency with fct_infreq(), arranged by order of appearance with fct_inorder() or modified further using fct_rev() and fct_shuffle() to reverse or randomise the sequence respectively.
18:22, 13th January 2022
Handling Categorical Data in R - Part 2
Part 2 of the Rsquared Academy series on handling categorical data in R focuses on summarising categorical data using a variety of functions and packages. Unlike numeric data, categorical data are best summarised through counts, proportions, cumulative frequencies and cross tables, and R provides several tools to achieve this.
Key functions covered include nlevels() and levels() for identifying the number and names of categories, table() and fct_count() for frequency tabulation, and prop.table() or proportions() for calculating proportions and percentages. There also are two-way and multidimensional tables using table() and xtabs(), alongside supporting functions such as margin.table(), addmargins() and ftable() for computing marginal totals and formatting complex tables.
Handling of missing values within tables is addressed through the useNA argument, and subsetting tables using bracket notation is demonstrated. For more detailed cross-tabulation output similar to that produced by SAS or SPSS, the CrossTable() function from the gmodels package and ds_cross_table() from the descriptr package are presented as useful alternatives.
15:45, 12th January 2022
How To Connect R Shiny to Postgres Database
Connecting R and R Shiny to a PostgreSQL database is a straightforward process that requires only a few packages and the relevant connection parameters, such as the database name, host, port and user credentials. To demonstrate this, a publicly available earthquake dataset from Kaggle is first imported into a PostgreSQL table using a GUI management tool, after which R establishes a connection to the database and retrieves the data using standard query functions.
Building on this foundation, an interactive R Shiny dashboard can be constructed that renders a map of earthquake locations, filtered dynamically by magnitude using a slider input, with the database queried each time the input value changes and the connection closed once the data has been retrieved. While this approach prioritises demonstrating proper connection handling over performance, it is noted that loading the full dataset outside the server function and filtering it locally could improve responsiveness.
13:16, 11th January 2022
Python Excel is a resource dedicated to helping users automate and manage Excel spreadsheet tasks using Python, covering operations such as reading, writing, modifying and organising data across Excel files. Several Python libraries are available for this purpose, the most widely used being openpyxl, which was developed by Eric Gazoni and Charlie Clark and supports reading and writing XLSX and related file formats without requiring Excel to be installed.
Other notable libraries include xlrd, which is suited to reading both XLS and XLSX files across Windows, Linux and Mac platforms, xlsxwriter, which specialises in data formatting and charting, xlwt, which is designed for older Excel 95 to 2003 file formats and xlutils, which bundles xlrd and xlwt together into a single package.
The practical value of combining Python with Excel is significant, particularly for professionals in data analysis, data mining and machine learning, where manually processing large volumes of spreadsheet data would be time-consuming and prone to error. By writing relatively simple code, tasks that might otherwise take days or weeks can be completed in seconds, making Python a powerful tool for automating repetitive office work and improving overall efficiency.
12:15, 10th January 2022
Build interactive web applications using the R programming language by leveraging the Shiny package, which simplifies the creation of dynamic user interfaces and server logic. A typical Shiny app consists of a user interface object defining layout and appearance, a server function containing computational instructions, and a call to the shinyApp function to combine them.
Installation requires running install.packages("shiny") and example apps like Hello Shiny demonstrate core concepts, such as using sliders to adjust histogram bins in real time. Apps are structured in an app.R file within a directory, launched with runApp and can be modified by editing parameters like titles, slider ranges, or visual elements. Users can relaunch apps through RStudio or command-line tools and further development involves exploring built-in examples, deploying apps online, or customising layouts and reactivity.
12:08, 10th January 2022
Top 7 Best R Shiny Books and Courses That Are Completely Free
Highlighting free resources for learning R Shiny, here are seven books and courses designed to support users at varying skill levels, from foundational concepts to advanced deployment techniques. The materials cover topics such as reactive programming, user interface design, production-grade application development, integration with JavaScript and AWS and practical deployment strategies using tools like Docker and Git. Courses are tailored for visual learners, while books provide in-depth guidance on building interactive applications, optimising performance and leveraging modern web technologies. All resources are accessible without cost, offering structured learning paths for individuals seeking to develop proficiency in R Shiny for data visualisation and web application development.
12:06, 10th January 2022
How renv restores packages from r-universe for reproducibility or production
Restoring packages from r-universe involves leveraging metadata embedded in package DESCRIPTION files to trace their origin to upstream git repositories. renv identifies the exact commit hash and remote repository URL from these fields, enabling precise reinstalls either via the cranlike repository if available or directly from git when necessary, ensuring reproducibility by relying on immutable commit identifiers rather than version numbers. This approach aligns with the r-universe model of continuous deployment from git, bypassing the need for archival storage by using upstream repositories as the definitive source of historical code.
12:04, 10th January 2022
Handling Categorical Data in R - Part 1
Categorical data, which is also known as qualitative data, is a fundamental component of data science projects and differs from numerical or other data types in how it is read, stored, summarised, reshaped and visualised. It is always discrete, consists of names or labels and takes on a limited, fixed number of possible values, with analysis typically involving data tables. These data are further divided into nominal data, which has no intrinsic order such as blood group or gender, and ordinal data, which can be ranked such as satisfaction ratings or education level, though the magnitude of differences between categories cannot be determined.
In R, such data are stored using a structure called a factor, and several functions are available for working with this data type, including is.factor() and is.ordered() for membership testing, as.factor() and as_factor() for converting other data types to factors, and the factor() and ordered() functions for finer control over specifying levels, modifying labels, handling missing values and creating ordered factors. The key distinction between as.factor() and as_factor() is that the former orders levels alphabetically, whilst the latter orders them by their first appearance in the data.