‘DataEditR’ is a shiny package that allows users to visualize datasets in spreadsheets direclty in R, and modify that data in the same way one would use Google Sheets or Excel.
The package was created by Dillon Hammill in 2020. Some main purposes of ‘DataEditR’:
In this brief introduction, we’ll be looking at the first three techniques using the dataset ‘iris’.
Dig Deeper: You can learn more details and additional functionality on Hammill’s GitHub page or their CRAN Vignette.
Package ‘DataEditR’ is a collection of functions and shiny modules meant to easily work with datasets.
##Install and Load
Install ‘DataEditR’ using the code below:
install.packages("DataEditR")
library(DataEditR)One frustration for new users to R is exiting R to see the complete dataset in its home website or file, or using a function to show a truncated version of it in R. For example, the function ‘head()’ is often used to get an idea of a dataset without overloading the script or the viewer.
head(iris)This is helpful but is only a small window that leaves a lot of unknowns. With ‘DataEditR’, the primary function ‘data_edit()’ gives the user or viewer the entire data set at their disposal in a dialogue box.
data_edit(iris)
The visualization is clean and complete with row numbers and column headings. It looks similar to regularly used spreadsheet software such as Excel or Google Sheets.
If the user prefers to view the data in the R Viewer or in a brower, you can add the “viewer” argument to indicate the medium.
data_edit(iris, viewer = "viewer")data_edit(iris, viewer = "browser")Once you have brought up the data set in your preferred medium, it is easy to manipulate the data just as you would in other data software. - You can edit a cell by simply clicking in the cell and deleting / adding information - You can add or delete columns and rows by right clicking a cell and choosing the appropriate option - You can widen columns by clicking, holding, and dragging the lines separating the column headers - You can duplicate the information in cells by clicking and holding the bottom right of a cell with the desired values and dragging your mouse to cover the area of cells in which you wish that information to be duplicated
Select
Create New Column
Add Data
You can use the select and filter options at the top to find specific data in the set that you need to reference or manipulate.
Filter Icons
Select Columns
Filter Rows
The changes you make will not disrupt the original data set. To revert back to the original set, simply click the ‘Cancel’ button in the top left. This will lose your work. We will cover saving the data at the end of this tutorial.
Open up ‘iris’ in the dialogue box and experiment.
data_edit(iris)As you can see in the dialogue box, there are options at the top for importing data into the tool. You can use the search box to find a data set already in R. Alternatively, you can use the ‘Browse’ button at the top to open up a file browser for your device and directly import from your device or a shared file.
Simply opening the function ‘data_edit()’ with no arguments will open the dialogue box without any data set prescribed, and you can add your data from there, either by importing it or simply by typing it in yourself just as you would in a new Excel document.
Importing Data
data_edit()You can use your new data set by saving it as a new object in R through adding the ‘save_as’ argument.
new_iris <- data_edit(iris, save_as = "new_iris")You can also save it as a file by clicking the save option in the buttons at the top right, which will open a file browser on your device and allow you to save the data set as a file to your device or shared drive.
‘DataEditR’ is a great tool for those unfamiliar with using data sets or those who quickly need to manipulate data and datasets on the go.
By mimicking spreadsheet software that is already popular, it allows users to visualize and use data in the same way they are used to using common software such as Excel.
Check out these links to learn more about package ‘DataEditR’.