Plotting Flashcards

1
Q

generate random normal variates, with a given mean and std dev

A

rnorm()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

evaluate the normal probability density, for a given mean and standard deviation

A

dnorm() - evaluates the lower tail by default

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

generate random binary random variable

A

rbinom() - binomial distribution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Take a sample from a range of numbers without replacement or with replacement

A

sample(1:10, 4) will get 5 2 1 9

sample(1:10, 4, replacement = T) will get 5 2 1 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to see the parameters of the base graphics system

A

type in :

?par - “coursera - memorize this page”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The main two functions of the base plotting system

A

hist()

plot(x,y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

set margins in base plotting

A

par(mar = c(2,2,2,2)) # this bottom, left, top, right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

plot line on scatterplot

A
use abline()
abline(vector, lwd = 3, col = 'blue')
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Label x and y axis

A

plot(x,y, xlab = ‘label’, ylab ‘label’, main = ‘scatterplot’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

put multiple plots on the page

A
  1. setup par(mfrow=c(2,1)) creates a pane of 2 rows one column
  2. plot(x,y) #first plot
  3. plot(x,y) #second plot
    you set things up by using par(mfrow =
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

alternate way to setup canvas than mfrow

A

mfcol() does column, rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

add data to existing plots

A

points()

points(x[g==’Male’], y[g==’Male’], col = ‘Blue’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

par variable that controls the type of shape (open circle, filled circle, etc_)

A

pch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

see examples of different values for plotting symbols (circle, filled circle, etc)

A

example(pch)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

add label to coordinate in scatterplot

A

text(x,y, ‘label’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

add legend to plot

A

legend(‘topleft’, legend = ‘data’, pch = 20)

17
Q

make a scatterplot in lattice

A

xyplot(y~x | f) # shows the relationship b/w x and y before men and women separately, whatever after pipe is the condition you want to group by. A separate panel will be created for each categorization.

18
Q

Using functions in the base plotting system in lattice

A

YOU CANT DO THIS, once you are in the “lattice” world, you can only use lattice functions. There are generally analgous functions to the baseplot in lattice.

19
Q

How do you use the lattice package

A

library(lattice)

20
Q

View help page on package

A

package ? lattice

library(help = lattice)

21
Q

scatterplot matrix in lattice package

A

splom(~dataframe)

22
Q

main function in ggplot

A

qplot()

23
Q

data type needed for ggplot

A

data.frame

24
Q

talk about facets parameter of qplot function

A

the paremeter is defined by rows~columns
facets = .~var then you will have three tables side by side in one row separated by 3 columns
facets = var~. then you will have three tables stack on top of eachother in one column but three rows