datatable editor-DT package in R

[This article was first published on Methods – finnstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

datatable editor DT package, In this tutorial, we are going to discuss DT package from R. DT stands for data tables and datatable() is the main function of DT package.

datatable() is completely different from data.table() function

DT package is very easy to use and based on this package can filter, search, and export data into different formats easily.

DT package outputs can easily render into R console, R Shiny, and R Markdown.

LSTM Network in R » Recurrent Neural network »

First, we need to install the package, if you are not installed run below command

Load Library

install.packages("DT")
library(DT)
datatable(iris)

Here we are going to make use of the iris package for demonstration purposes. Now in the RStudio viewer pane, you can see the HTML results. You can sort the variables and able to change the number of entries in the Show button.

Random Forest in R » Complete Tutorial »

If you don’t want to display the row numbers in the data frame simply run the below code.

datatable(iris,rownames = FALSE)

In search box, you can type the number and can search the particular number from the dataset.

Suppose if you want to search the number based on column-wise, you can pass one more argument that is filter.

datatable(iris,rownames = FALSE,filter = "top")

If you don’t want a display search bar at the top and change display entries into some other number can easily do that.

Decision Trees in R » Classification & Regression »

datatable(iris,options = list(searching=FALSE, pageLength=20))

different styling fetures are available in DT package.

So you can make use of different CSS styles.

datatable(iris,rownames = FALSE,clas='hover cell-border stripe')

Data entry and correction are very important in the data cleaning part. Suppose if you want to correct the entry you can make use of datatable editor option.

KNN Algorithm Machine Learning » Classification & Regression »

datatable(iris,rownames = FALSE, editable = 'cell')

Now you can edit the cell you want. This feature will be more helpful when you are working on shiny because you can enable this option on the server side and the user side also.

If you want to change the column names then simply add the argument colnames.

datatable(iris,rownames = FALSE,colnames = c("A","B","C","D","E"))

If you want to change the particular column names then

Principal component analysis (PCA) in R »

datatable(iris,rownames = FALSE,colnames = c("X"="Sepal.Length","Y"="Petal.Length"))

If you want to change the title then make use of the caption.

datatable(iris, caption="Rawdata")

You can add the buttons into the data table and make it more interactive also.

Correlation Analysis Different Types of Plots in R »

datatable(iris,extensions = 'Buttons',
options = list(dom='Bfrtip',
buttons=c('copy', 'csv', 'excel', 'print', 'pdf')))

Buttons can be more helpful feature if you are using shiny.

How to find dataset differences in R Quickly Compare Datasets »

The post datatable editor-DT package in R appeared first on finnstats.

To leave a comment for the author, please follow the link and comment on their blog: Methods – finnstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)