The best way is to download the data file and save it into a local folder
Then you can read it as much as you like
November 26, 2019
The best way is to download the data file and save it into a local folder
Then you can read it as much as you like
The commands in this page produce the plots of the following page
plot(survey$height_cm, main="1") plot(survey$height_cm, main="2", col="red") plot(survey$height_cm, main="3", cex=2) plot(survey$height_cm, main="4", cex=0.5) plot(survey$height_cm, main="5", pch=16) plot(survey$height_cm, main="6", pch=".")
The commands in this page produce the plots of the following page
plot(survey$height_cm, main="1", type = "l") plot(survey$height_cm, main="2", type = "o") plot(survey$height_cm, main="3", type = "b") plot(survey$height_cm, main="4", type = "p") plot(survey$height_cm, main="5", xlim=c(1,20)) plot(survey$height_cm, main="6", xlim=c(30,51))
plot(survey$height_cm, ylim=c(0,200)) points(survey$weight_kg, pch=2)
plot(survey$height_cm, type="l", ylim=c(0,200)) lines(survey$weight_kg, col="red")
plot(survey$height_cm, col=survey$Gender)
legend("topleft", legend=c("Female", "Male"), fill=c(1,2))
plot(survey$height_cm) abline(h=mean(survey$height_cm), col="red", lwd=5)
This command adds a straight line in a specific position
abline(h=1) adds a horizontal line in 1abline(v=2) adds a vertical line in 2abline(a=3, b=4) adds an \(y=a +b\cdot x\) line
a is the intercept when \(x=0\)b is the slopeplot(survey$height_cm) abline(v=20, col="blue") abline(a=160, b=0.5)
plot(survey$height_cm, survey$weight_kg)
plot(survey$height_cm, survey$hand_span_cm)
Instead of
plot(survey$height_cm, survey$weight_kg)
we can write
plot(survey$weight_kg ~ survey$height_cm)
or even
plot(weight_kg ~ height_cm, data = survey)
plot(height_cm ~ hand_span_cm, data = survey)
plot(height_cm ~ hand_span_cm, data = survey,
subset = Gender=="Female")
plot(height_cm ~ hand_span_cm, data = survey,
subset = Gender=="Male")
It is easier to specify the data.frame and which values to plot
plot(height_cm ~ weight_kg, data=survey)
survey$handness <- as.factor(survey$handness) plot(Gender ~ handness, data=survey)
plot(Gender ~ weight_kg, data=survey)
plot(weight_kg ~ Gender, data=survey)
Plotting a numeric value depending on a factor results in a boxplot
It is a graphical version of summary().

plot(weight_kg ~ Gender, data=survey, boxwex=0.3,
notch=TRUE, col="grey")
plot(survey)

plot() can be used with one or two vectors, or with a formulaplot(y ~ x) looks like plot(x, y)plot(y~x, data=dframe) is better than plot(dframe$x, dframe$y)The figure type depends on the data type of the vector
points() or lines()barplot()boxplot()pairs()plot() command defines the ranges, labels and titlepoints(), lines()text()segment(), arrows(),rect(), polygon() xspline()legend()Learn more on the help page of each command
Colors can be specified in several ways: