How to create and write text files in R?

Sometimes during our data analysis process, we might need to quickly generate or modify data stored as txt files. In this tutorial we will learn how to programmatically create text files in your file system and append text to them using the R language. Create a text file We can use the file.create() method to … Read more

Changing column header names in R DataFrames

Once you acquire your Data set, most probably you will need to tweak your variable (columns) naming convention. In this tutorial we will learn how to rename R DataFrame columns by leveraging the base capabilities of R and also look into dplyr features for renaming columns. Create R DataFrame We’ll get started by creating an … Read more

How to change zero values to NA in R DataFrames with dplyr?

Often times after importing a DataFrame you’ll want to replace zero values to empty or missing (NA) values in your DataFrame column cells. In this tutorial we will look into several practical examples of this. Create example R DataFrame We will start by defining some fictitious data that includes several cells with missing values. Feel … Read more

How to drop the last column of your R DataFrame?

In this short tutorial we’ll examine how you can use Base R and the dplyr library to remove the last (or multiple n last columns) of your DataFrame. Let’s start by building a simple R DataFrame from multiple vectors: This will return: [1] “city” “direct” “online” “partners” Remove DataFrame last column with Base R We … Read more