00R Basic and Intro Flashcards
how to explicitly specify that u are using a particular function from a package
ggplot2::ggplot()…package::function().
How to install package ?
install.packages(“tidyverse”)
how to load package?
library(tidyverse)
which one has double quote? Loading or installing package?
Installing package
ggpplot
gplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy),)
To set an aesthetic manually, set the aesthetic by name as an argument of your geom function; i.e. it goes outside of aes(). You’ll need to pick a level that makes sense for that aesthetic:
geom_point(mapping = aes(x = displ, y = hwy), color = “blue”)
what is the first argument in ggplot??
data
which geom create scatter plot?
geom_point()
what is an aesthetics?
An aesthetic is a visual prop‐ erty of the objects in your plot. Aesthetics include things like the size, the shape, or the color of your points
Once you map an aesthetic, ggplot2 takes care of the rest. It selects a reasonable scale to use with the aesthetic, and it constructs a legend that explains the mapping between levels and values.
What does this does glimpse(mpeg)?
displays the type of each column
What happened when u see + and code does not execute?
Sometimes you’ll run the code and nothing happens. Check the left-hand of your console: if it’s a +, it means that R doesn’t think you’ve typed a complete expression and it’s waiting for you to finish it. In this case, it’s usually easy to start from scratch again by pressing ESCAPE to abort processing the current command.
“The simple graph has brought more information to the data analyst’s mind than any other device.”
— John Tukey
What is ggplot2?
R has several systems for making graphs, but ggplot2 is one of the most elegant and most versatile. ggplot2 implements the grammar of graphics, a coherent system for describing and building graphs. With ggplot2, you can do more faster by learning one system and applying it in many places
what is relationship between ggplot2 and tidyverse?
ggplot2, one of the core members of the tidyverse.
How to view all ur data set in R studio pane?
View(flights)
What are tibbles?
Tibbles are data frames, but slightly tweaked to work better in the tidyverse.
What is data frame?
A data frame is a rectangular collection of variables (in the columns) and observations (in the rows)
what is difference between ggplot2::mpg and mpg?
The first we explicitly call the data frame mpg and second we have already import the ‘tidyverse’ which ia a collection of packages including mpg
what is the graphing template ?
ggplot(data = ) +
(mapping = aes())
What is aesthetics ?
An aesthetic is a visual property of the objects in your plot. Aesthetics include things like the size, the shape, or the color of your points
in aesthetic , how do u use colour?
(If you prefer British English, like Hadley, you can use colour instead of color.)
what is scaling? what is relation with colour?
To map an aesthetic to a variable, associate the name of the aesthetic to the name of the variable inside aes(). ggplot2 will automatically assign a unique level of the aesthetic (here a unique color) to each unique value of the variable, a process known as scaling
aesthetic
For each aesthetic, you use aes() to associate the name of the aesthetic with a variable to display. The aes() function gathers together each of the aesthetic mappings used by a layer and passes them to the layer’s mapping argument. The syntax highlights a useful insight about x and y: the x and y locations of a point are themselves aesthetics, visual properties that you can map to variables to display information about the data.
can u select ads properties manually?
yes …ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), color = “blue”). To set an aesthetic manually, set the aesthetic by name as an argument of your geom function; i.e. it goes outside of aes(). You’ll need to pick a level that makes sense for that aesthetic: 1. The name of a color as a character string. 2. The size of a point in mm. 3. The shape of a point as a number, as shown in Figure 3.1.
aes can be ?
colour , size , shape etc?