dat <- mtcars
{mtcars-2,echo=TRUE} head(dat) ## 3. Find the Unique
Values in the cyl Column Using unique () Unique values “unique()” Inside
(): ((the name of the data frame)$ used to access specific columns of a
data frame (the name of the column in the data frame))
{mtcars-3,echo=TRUE} unique(dat$cyl) ## 4. Slice Data for
cyl Values of 4 and 6 and Store it in a New Data Frame df …Store it in a
New Data Frame df using “<-” …Slice data… using the subset() … for
cyl values of 4 and 6 using the (the name of the data frame, a column
such as a column in a data frame %in% c(a, b)) + c(a, b) for whether it
matches any value in the set
df <-subset(dat,cyl%in%c(4,6))
df
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.