Primary functions for data analysis:
read_csv() : imports text files in CSV format into the R environment.
- ex:
read_csv("path/filename.csv")
- ex:
filter() : select only certain rows from a table.
- ex:
filter(text_column=="value")orfilter(number_column > 0)
- ex:
select() : select only certain columns from a table.
- ex:
select(column1, column2, column6)
- ex:
group_by() : group the rows in a dataset based on the values in one or more columns.
- ex:
group_by(column)orgroup_by(column_a, column_b, …)
- ex:
summarise() : apply summary functions (see below) to the whole table, or to groups if
group_by()is used.- ex:
summarise(total = sum(number_column)orsummarise(average = mean(number_column))
- ex:
arrange() : sort results based on one or more columns; ascending is the default, use
desc()for descending.- ex:
arrange(column)orarrange(desc(column))
- ex:
count() : group the data based on a column or columns and apply the n() summary function to those groups.
- ex:
count(text_column)
- ex:
mutate() : create a new column in a table, or overwrite an existing column with new information.
- ex:
mutate(new_column = number_column1 + number_column2)
- ex: