R coding Flashcards
(97 cards)
Whats mtcars
it is a data set set into R
Is(mtcars)
lists the column names in mtcars
What does $ mean in mtcars$mpg?
$ accesses lists of models within the dataframe/list here its mpg within mtcars
mean()
finds the mean
median()
finds the median
what does sort(mtcars$mpg, decreasing = TRUE)
Sorts the Mpg values within the mtcars dataset from highest to lowest
what does sort(mtcars$mpg, decreasing = FALSE) mean ?
it will sort the dataset from lowest to highest. since the default is False. you can write sort(mtcars$mpg) instead
range ()
displays the lowest and highest value in the dataset
How do i create a dataset and run it?
goals <- c (0 0,2,3,0,1)
goals
output:
[1] 0 0 2 3 0 1
sort()
ascending order displayed
rev()
displays in reversed order
table(x)
shows frequency in x
table(x,y)
shows frequency in x, y
max()
shows max value in dataset
min()
shows min value in dataset
sum()
shows total value in dataset
give me a manual way of calculating mean
( 2 +3 +4 + 5 + 6) / 5 = 4
diff(range())
shows the difference in range from max - min
how to create a function?
name <- function (x) {
}
how can i run the name function?
name(10)
name(dataset)
hist(dataset)
displays the dataset by using a histogram
inflation_clean$period
shows the entire period column from the inflation_clean dataset
inflation_clean$period[5]
shows the 5th row from the period column
inflation_clean$mpg[1:33]
shows from the FIRST row from 1-33 the data is being displayed