12 R Programming (Swirl) Looking at Data

12 R Programming (Swirl) Looking at Data

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

ls()

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

7 years ago

Date created

Mar 1, 2020

Cards (12)

Section 1

(12 cards)

ls()

Front

list the variables in your workspace

Back

What does the row and column in a dimension refer to?

Front

the number of rows refers to the number of observations, while the number of columns refer to the number of variables.

Back

summary(plants)

Front

summary() provides different output for each variable, depending on its class. For numeric data, summary() displays the minimum, 1st quartile, median, mean, 3rd quartile, and maximum. These values help us understand how the data are distributed. For categorical variables (called 'factor' variables in R), summary() displays the number of times each value (or 'level') occurs in the data.

Back

ncol(...)

Front

to see only the number of columns in a data frame

Back

tail(plants, 15)

Front

to preview the end of the dataset. Use tail() to view the last 15 rows.

Back

nrow(...)

Front

to see only the number of rows in a data frame

Back

object.size(plants)

Front

to know how much space the dataset is occupying in memory

Back

str(...)

Front

It combines many of the features of the other functions you've already seen, all in a concise and readable format. At the very top, it tells us that the class of dataset is 'data.frame' and that it has 5166 observations and 10 variables. It then gives us the name and class of each variable, as well as a preview of its contents.

Back

names(plants)

Front

return a character vector of column (i.e. variable) names.

Back

head(plants, 10)

Front

show you the first 10 rows of the dataset called "plants".

Back

table(plants$Active_Growth_Period)

Front

For a categorical/factor variable, we can see how many times each value actually occurs in the data.

Back

Why is it common to find data stored in a data frame?

Front

It is the default class for data read into R using functions like read.csv() and read.table().

Back