Archivo de etiquetas| Cheatsheet

R Cheatsheet: Importing and Subsetting Data

Creating a data set from a file

z<-read.csv(“file.csv”)

Counting number of rows in a data set:

nrow(z)

Obtaining first n rows of a data set

head(z,2)

Obtaining last n rows of a data set

tail(z,2)

Excluding NA values from a data set and then calculating its mean

max_value_ozone_may<-max(na.exclude(ozone_values_may$Ozone))

Obtaining a subset with a condition

solar_mean_month_6<-z[(z$Month==6),]