Jesse John

Jesse John

About Jesse John

Jesse is passionate about data analysis and visualization. He uses the R statistical programming language for all aspects of his work.

howto · 2025-03-13

How to Create a 3D Surface Plot From (x,y,z) Coordinates

Learn how to create stunning 3D surface plots from (x, y, z) coordinates using Python. This article covers interpolation techniques to estimate z values and provides step-by-step instructions to visualize your data effectively. Perfect for data analysis and visualization enthusiasts.

howto · 2025-03-11

How to Read a Text File and Print Its Contents in Python

This article shows how to read a text file and print its contents to the screen using Python. The simplest, most direct method is described, along with multiple approaches that cater to different scenarios. Whether you're handling small or large files, this guide will equip you with essential skills for efficient file management in Python.

howto · 2024-02-15

How to Break a for Loop in R

This article shows how to use the break keyword to terminate a for loop in R. It also examines the use of the break keyword in nested for loops and shows how print statements can help us understand the working of our break command.

howto · 2024-02-15

How to Sum Selected Columns of an R Data Frame

This article shows how to calculate the sum of selected columns of an R data frame and store the values in a new column.

howto · 2024-02-15

How to Perform Time Series Analysis and Forecasts in R

This article introduces the functions in base R that facilitate time series analysis and forecasts. The reader must be familiar with the statistical and mathematical aspects of time series analysis and quickly outline R's basic functions to get started.

howto · 2024-02-15

How to Restart R in RStudio

This article explains the need to restart R and then mentions different methods to restart R using RStudio.

howto · 2024-02-15

How to Create a Ggplot2 Visualization With a Transparent Background

In this article, we will see how to create a ggplot2 visualization with a transparent background and export it to a PNG file using the ggsave() function. We will also see how to set the axis and grid line colours to make these elements visible.

howto · 2024-02-12

How to Add a Calculated Column to a Matrix in R

This article shows how to combine two matrices, or a matrix and a vector. It also shows how to add a calculated column such as a row sum or mean to an existing matrix.

howto · 2024-02-02

How to Remove the First Character From a String in R

This article demonstrates three techniques to remove the first character from a string or a vector of strings. It demonstrates the use of the substr function, the sub-function with a regular expression, and the str_sub function of the stringr package.

howto · 2024-02-02

How to Calculate the R-Squared Statistic in R

This article shows how to obtain the R-squared statistic in R from the summary of a linear regression model. It also shows how to calculate the R-squared statistic manually, both directly and by using a custom function.

howto · 2024-02-02

How to Export a Data Frame From R to Microsoft Excel

This article shows how to export a data frame from R to Microsoft Excel using the write.csv() function and functions provided by other packages. It also addresses problems that may occur in opening CSV files.

howto · 2024-02-02

How to Stop Running R Code With the Keyboard or Mouse

This article shows how to stop running R code with the keyboard or mouse.

howto · 2024-02-02

How to Drop Multiple Columns From a Data Frame Using Dplyr

This article shows how to drop multiple columns from a data frame using dplyr. The example code demonstrates the use of different selection helper functions and operators to drop multiple columns with a single line of code.

howto · 2024-02-02

How to Install R Packages From Source

This article shows how to use the install.packages() function to install R packages from source. It points out the two conditions that need to be met for the installation from source to be successful.

howto · 2024-02-02

How to Use Vectorized if Function With Multiple Conditions in R

This article shows how to use multiple conditions in the vectorized ifelse and if_else functions in creating or updating a column in a data frame. It also draws attention to the vectorized AND and OR operators.

howto · 2024-02-02

How to Read a Text File Line by Line in R

This article shows how to process or read a plain text file line by line in R.

howto · 2024-02-02

How to Pass Command Line Arguments to R CMD BATCH and Rscript

This article shows how to pass command line arguments to R CMD BATCH and Rscript, and how to save the output as a file.

howto · 2024-02-02

How to Remove User-Defined Objects From the Workspace in R

This article shows how to remove user-defined objects from the workspace in R using the rm() function and the Environment tab of R Studio.

howto · 2024-02-02

How to Uninstall R and All Its Packages on Windows

This article shows how to uninstall R and all its packages on Windows. Uninstalling R only removes the original installation files. To remove the packages, we need to find the paths to the R library folders, uninstall packages using R Studio, uninstall R, and then delete the library folders.

howto · 2024-02-02

How to Find the Null Space of a Matrix in R

This article shows how to find the null space of a matrix in R using the nullspace function of the pracma package.

howto · 2024-02-02

How to Remove Object Names and Dimnames in R

This article shows how to remove the names and dimnames of objects and get only the values in R. Different approaches such as the unname() function, the as.vector() function, etc. are illustrated with examples.

howto · 2024-02-02

How to Set Location of Current File as Working Directory in R Studio

This article shows how to set the location or path of the current R script or Rmd file as the working directory in R Studio, without any user intervention or interaction. It shows three methods specific to R Studio and one more generally applicable.

howto · 2024-02-02

How to Generate a Regular Sequence of Numbers in R

This article shows how to easily generate a regular sequence of numbers in R using the colon operator and the seq() function.

howto · 2024-02-02

How to Convert Multiple Columns From Integer to Numeric Type in R

This article shows how to convert multiple columns from integer to a numeric type using a single command in R. The examples include base R and dplyr approaches to perform the conversion.

howto · 2024-02-02

How to Interpret Output of system.time Function in R

This article briefly explains what is being measured by the system.time function in R. It then provides simple examples to illustrate what each of the components user, system and elapsed are measuring in the output of the function.

howto · 2024-02-02

How to Use the Source Function to Run Another R Script

This article demonstrates how to use the source function of base R to run another R script which may be located in the same directory as the first script or in a different directory. It explains how and when to use the chdir argument to change R's working directory temporarily.

howto · 2024-02-02

How to Customize the PCA Biplot in R

This article demonstrates how to customize the PCA biplot in R. Several defaults are modified to obtain a more useful visualization of the biplot.

howto · 2024-02-02

How to Use the if and if...else Statements in R

This article describes the syntax of if and if-else constructs of R, emphasizing the peculiarities. The code examples illustrate all the points provided.

howto · 2024-02-02

How to Compute Binomial Coefficients in Java

This article demonstrates the use of two libraries to calculate binomial coefficients for large values of n. The example code shows the use of CERN's colt library and the Apache Commons Numbers library.

howto · 2024-02-02

How to Use the group_by Function in R Dplyr

This article shows how to use the group_by() function from R's dplyr package to group rows for data analysis. It shows how we can combine group_by() with the summarize() or summarise(), filter() and mutate() functions to do the desired data analysis.

howto · 2024-02-02

How to Perform K-Means Clustering in Base R

This article shows how to perform K-means clustering using base R functions. All steps, including the elbow bend plot to choose K, and the PCA scatter plot when there are more than two variables, are demonstrated in base R.

howto · 2024-02-02

How to Create and Visualize a Correlation Matrix in R

This article first shows how to prepare data to create a correlation matrix in R. It then demonstrates the use of the cor() function to create a correlation matrix, and the ggcorr() function from the GGally package to visualize it.

howto · 2024-02-02

How to Test for Normality of Data in R

This article demonstrates three techniques to assess the normality of ungrouped, univariate data in R. Visually, we can assess the normality using a histogram or a Q-Q plot. For a quantitative measure, we can use the popular Shapiro-Wilk test.

howto · 2024-02-02

How to Create and Interpret Dummy Variables in R

This article shows how to easily create dummy variables in R using the fastDummies package. It concludes with a section on how to interpret the dummy variables in a linear regression model.

howto · 2024-02-02

How to Use Cross-Validation for a KNN Classification Model in R

This article demonstrates how to use the caret package to build a KNN classification model in R using the repeated k-fold cross-validation technique. The train function also creates and tests models for different specified values of K neighbors and builds the model with the highest accuracy.

howto · 2024-02-02

How to Create Combinations and Permutations of Vectors in R

This article demonstrates how to use R to make vector combinations and permutations, as well as how to count the amount of combinations and permutations. It demonstrates one method for dealing with identical items in vectors when the output requires unique combinations and permutations.

howto · 2024-02-02

How to Test Hypothesis in R

This article shows how to test hypotheses about sample statistics in R. It illustrates the syntax of the tests using different options of the t test and the Wilcoxon test as examples. It also shows how the user can discover many other test functions that are built into base R.

howto · 2024-02-02

How to Create a 3D Perspective Plot in R

This article shows using persp() function in R to create 3D perspective plots of a surface over the xy plane in R. It first explains the format of the arguments of the function and then illustrates the same with simple examples.

howto · 2024-02-02

How to Print a Multiplication Table in Python Using Basic Programming Concepts

This article illustrates basic programming concepts in Python using the example of a times table. Times tables are printed for a user-defined number and user-defined range of multiples.

howto · 2024-02-02

How to Differentiate Iterator and Generator in Python

This article gives the most basic differences between iterators and generators in Python, and illustrates these points with an example.

howto · 2024-02-02

How to Get Max Heap in Python

This article illustrates how to get a max heap in Python by combining the heapq module with custom code.

howto · 2024-02-02

How to Use the %*% Operator in R

With simple examples, this article illustrates how to use the %*% operator in R to multiply two conformable matrices or to get the dot product of vectors of equal length.

howto · 2024-02-02

How to Paste Strings Without Spaces in R

Using strings, vectors and a data frame for demonstration, this article shows how to remove spaces that are added when merging/concatenating strings, how to remove leading and trailing spaces from strings, and how to remove all spaces from a string.

howto · 2024-02-02

How to Filter a Data Frame With Multiple Conditions in R

This article shows how to filter the rows of a data frame using multiple conditions. It shows how to combine multiple conditions using Boolean operators, and how to control the order of evaluation using parentheses.

howto · 2024-02-02

How to Create a Random Matrix With Constant Row Sums in R

In this article, we will see how to create a matrix with randomly chosen non-negative values in each row such that the row sum is constant for all rows.

howto · 2024-02-02

How to Use the Predict Function on a Linear Regression Model in R

In this article we will learn how to correctly use R's predict function on a linear regression model. In particular, we will see that the function expects the input to be in a specific format with specific column names.

howto · 2024-02-02

How to Include a Local Image File in an R Presentation

In this article, we will learn how to insert a local image file in an R presentation easily, and also how to align and size it using CSS.

howto · 2024-02-02

How to Identify R Object Properties

In this article we will look at functions that help us identify the objects that we work with in R. Using functions such as str(), class(), typeof(), is.___() and attributes(), we can gain valuable information about various properties of our R objects.

howto · 2024-02-02

How to Size Plots in Beamer Slides Made Using R Markdown

In this article, we will see how to create plots of the desired size in a Beamer presentation PDF file created using R Markdown. We will use the R Markdown package to create the source file, and we will need a LaTeX installation to produce the PDF file.

howto · 2024-02-02

How to Locate R Script and Data Files Without Changing the Working Directory

This article shows how to combine an R Studio Project, the here package and the file.path() function to enable R to locate script and data files needed for the project without manually changing the working directory to the location of the current script.

howto · 2024-02-02

How to Check for Missing Values Using a Boolean Operator in R

This article shows why we may get the missing value where TRUE/FALSE needed error when using a Boolean condition in R, and then shows what we need to do to avoid that error.

howto · 2023-10-10

Use and in Python

This article shows the differences between the escape sequences for line feed, , and carriage return, . The example code shows how these two escape sequences sometimes give identical output and sometimes different output depending on whether the output is displayed on screen or written to a file.

howto · 2023-01-30

$ Operator Is Invalid for Atomic Vectors Error in R

In this article we will learn how to extract elements of a vector using the extract operators or the getElement function. In particular, we will also see why the $ operator does not work on vectors, and will learn how to use that by converting the vector to a data frame.

howto · 2022-02-23

Color-Blind Accessible Colors in Base R

This article shows how to use color-blind accessible colors in base R without any additional package. It describes the Okabe-Ito color palette that is built into base R and shows three ways in which we can use colors from the palette.