Ggplot_Assignment1

.docx

School

University of Illinois, Urbana Champaign *

*We aren’t endorsed by this school

Course

557

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

15

Uploaded by MajorDiscovery13494 on coursehero.com

Ggplot_Assignment1 Swanand Shetwal 2024-02-05 R Markdown library (ggplot2) library (ggplot2movies) Q1.a. Using the “mtcars” dataset, plot a scatter plot where x=qsec and y=disp. add “cyl” as the facet and plot the graph. ggplot (mtcars, aes ( x = qsec, y = disp)) + geom_point () + facet_grid ( rows = vars (cyl))
Q1.b. Using the “mtcars” dataset, plot a graph where x=wt and y=hp. set the xlim from 2 to 6 and plot the graph with “gear” as the facet. add a smooth line to the graphs suppressWarnings ({ ggplot (mtcars, aes ( x = wt, y = hp)) + geom_point () + facet_grid ( rows = vars (gear)) + geom_smooth () + coord_cartesian ( xlim= c ( 2 , 6 )) }) ## `geom_smooth()` using method = 'loess' and formula = 'y ~ x' ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : span too small. fewer data values than degrees of freedom. ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : pseudoinverse used at 1.5027 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : neighborhood radius 1.2673 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : reciprocal condition number 0 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : There are other near singularities as well. 0.65656 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : Chernobyl! trL>n 5 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : Chernobyl! trL>n 5 ## Warning in sqrt(sum.squares/one.delta): NaNs produced ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : span too
small. fewer ## data values than degrees of freedom. ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at ## 1.5027 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius ## 1.2673 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition ## number 0 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : There are other near ## singularities as well. 0.65656 ## Warning in stats::qt(level/2 + 0.5, pred$df): NaNs produced ## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning ## -Inf
Q1.c. the “mtcars” dataset, plot a graph where x=drat and y=mpg. set the xlim from 2 to 5 and plot the graph with “cyl” as the facet. add a smooth line to the graphs suppressWarnings ({ ggplot (mtcars, aes ( x = drat, y = mpg)) + geom_point () + facet_grid ( rows = vars (cyl)) + geom_smooth () + coord_cartesian ( xlim= c ( 2 , 5 )) }) ## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : pseudoinverse used at 3.9258 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : neighborhood radius 0.3058 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : reciprocal condition number 0 ## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ## : There are other near singularities as well. 0.0784 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at ## 3.9258 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius ## 0.3058 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition ## number 0 ## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x ## else if (is.data.frame(newdata)) ## as.matrix(model.frame(delete.response(terms(object)), : There are other near ## singularities as well. 0.0784
#—–Histogram head (attenu) ## event mag station dist accel ## 1 1 7.0 117 12 0.359 ## 2 2 7.4 1083 148 0.014 ## 3 2 7.4 1095 42 0.196 ## 4 2 7.4 283 85 0.135 ## 5 2 7.4 135 107 0.062 ## 6 2 7.4 475 109 0.054 Q3.a. Using the “attenu” dataset, plot a basic histogram for variable “mag” and set binwidth = 0.1. ggplot (attenu, aes ( x = mag)) + geom_histogram ( binwidth = 0.1 )
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help