From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Use format() to improve readability

Use format() to improve readability

- [Instructor] When you create reports, you want to make sure that readability is clear for everybody who's looking at it, but you may not want to change the actual underlying numbers. Use format to improve that readability and here's how. The first thing that I've done is created a data frame called smalldf and you'll see that up here over in the global environment, here it is, and we can take a quick look at what that appears to be if I type in smalldf. There it is, a simple data frame. But let's clean that up a bit and we can use format. So I type in format and I want to format smalldf and let's say that I want to increase the number of the floating digits, the first column, which is called floats. So to change that, I type in digits and I'd like to increase it to 10. Now what you'll notice, the first column, the first variable, which is labeled floats has become longer and you'll notice that there are now 10…

Contents