Edit Data In R Using The DataEditR Package

by | R

In this tutorial, you will learn how to edit data in R using the DataEditR package. You can watch the full video of this tutorial at the bottom of this blog.

DataEditR is an R package that will let you build dashboards and reports in R using a GUI. Then, we will be able to point-and-click, edit, and enter data. You can also download it from CRAN. Check out the R For Power BI Users course to know how to download the package.

Let’s go through a short demo. It’s a data set from CRAN where we can do basic data editing manipulation and then save it. We’ll use a GUI to do it when R is a coding tool.

First, let’s boot up the RStudio, type in the library (DataEditR), and hit Enter. Make sure you have it installed if you don’t have it.

Edit Data In R

Next type in browseVignettes (DataEditR). It is a good function to run because this is where we can check the tutorials for this package.

Edit Data In R

Run the browseVignettes, then click the HMTL link. 

Scroll down to see the list of the DataEditR tutorials. You will learn about how to boot it up, how it works, how to import data into it, and more. Check this out as you get more advanced.

Edit Data In R

Let’s head back to the RStudio, and focus on the data editing elements of this package.

How To Edit Data In R Using The DataEditR Package

Let’s type in library(Ecdat) followed by data(package = Ecdat), then run this package.

Edit Data In R

These are the R data sets in Ecdat. There are a lot of business-oriented data sets that are good to use for practice or demos.

For this demo, we are going to use the Housing data set. Type in data_edit(Housing) to open up a new window.

Now we are in the Housing data editor.  We can also upload a new file here.

We have a few options here. The first one is the Select Columns.

Edit Data In R

These are buttons where we can select which one we want.

The next one is the Filter Rows.

We can filter numbers or strings and add or remove filters.

Next is the Synchronise option. It loads back into our data set initial setup.

Now let’s move on to the two options on how to save your data. 

The Save selection to file option is for certain things we need to save in our clipboard. 

Edit Data In R

We can also save the entire data set by clicking the Save to file option.

For example, we want to save the entire data set as a CSV file.

Right-click one of the cells in the column to see the different options. In this example, we select the Insert row above.

Edit Data In R

We can enter data in the fields. This is something that we cannot do in Power Query.

There are cases when we want to build a web app where people can enter their data. It shoots right into an R file, which goes to whatever pipeline we want. It’s like a front-end tool.

It is also easy to change the names of columns in the DataEditR because it’s all just point-and-click. 

For example, we want to edit the stories header to n_stories. All we have to do is click the cell and rename it.

Edit Data In R

Another feature is to extend and fill several numbers, dates, or even text to other cells. It’s similar to how it works in Excel.

Click a cell, extend, and fill to other cells.

Then select parts of the data set and right-click to change the alignment of the cells.

We can also use the Crop to selection option by highlighting the cells and cropping the selected cells.

This package is in development. The big takeaway is the ability to edit data in R, especially changing the column names and inserting a column.

The V1 is a default placeholder for column names in R.

Now, let’s click Done.

This is the altered data set. We can also keep a copy by saving it.

***** Related Links *****
What If Parameter For Data Models In Power BI
Power Query Best Practices For Your Data Model
Power BI Progress Tracker For Sales And Order Data

Conclusion

We can use the DataEditR package for data entry because of its Excel-like interface, and its point-and-click then-edit feature.

The R tool is a reproducible tool where any change is fully editable. However, using GUI is not the most reproducible tool but it has its own user interface advantages.

I hope you can use this tutorial when editing your own data in R. Please don’t forget to subscribe to the Enterprise DNA TV channel.

All the best,

George

Related Posts