RStudio’s data viewer provides a quick way to look at the contents of data frames and other column-based data in your R environment. You invoke it by clicking on the grid icon in the Environment pane, or at the console by typing
While the data viewer in 0.98 was limited to the first 1,000 rows, you can now view all the rows of your data set. RStudio loads just the portion of the data you’re looking at into the user interface, so things won’t get sluggish even when you’re working with large data sets.
We’ve also added fixed column headers, and support for column labels imported from SPSS and other systems.
RStudio isn’t designed to act like a spreadsheet, but sometimes it’s helpful to do a quick sort or filter to get some idea of the data’s characteristics before moving into reproducible data analysis. Towards that end, we’ve built some basic sorting and filtering into the new data viewer.
Click a column once to sort data in ascending order, and again to sort in descending order. For instance, how big is the biggest diamond?
To clear all sorts and filters on the data, click the upper-left column header.
Click the new Filter button to enter Filter mode, then click the white filter value box to filter a column. You might, for instance, want to look at only at smaller diamonds:
Not all data types can be filtered; at the moment, you can filter only numeric types, characters, and factors.
You can also stack filters; for instance, let’s further restrict this view to small diamonds with a Very Good cut:
You can search the full text of your data frame using the new Search box in the upper right. This is useful for finding specific records; for instance, how many people named John were born in 2013?
If you invoke the data viewer on a variable as in
View(mydata), the data viewer will (in most cases) automatically refresh whenever data in the variable changes.
You can use this feature to watch data change as you manipulate it. It continues to work even when the data viewer is popped out, a configuration that combines well with multi-monitor setups.
We hope these improvements help make you understand your data more quickly and easily. Try out the RStudio Preview Release and let us know what you think!
Austin Chia, Founder of Any Instructor, describes his transition from studying biology to becoming a healthcare data analyst.
In this series, we walk through lesser-known tips and tricks to help you work more effectively and efficiently in R Markdown. The final post focuses on making your document look and work better.