Question: Description The science data frame has 1385 rows and 7 columns. The data are on attitudes to science, from a survey where there were results

Description The science data frame has 1385 rows and 7 columns. The data are on attitudes to science, from a survey where there were results from 20 classes in private schools and 46 classes in public schools. Usage science Format This data frame contains the following columns: State a factor with levels ACT Australian Capital Territory, NSW New South Wales PrivPub a factor with levels private school, public school school a factor, coded to identify the school class a factor, coded to identify the class sex a factor with levels f, m like a summary score based on two of the questions, on a scale from 1 (dislike) to 12 (like) Class a factor with levels corresponding to each class Source Francine Adams, Rosemary Martin and Murali Nayadu, Australian National University Examples classmeans <- with(science, aggregate(like, by=list(PrivPub, Class), mean)) names(classmeans) <- c("PrivPub","Class","like") dim(classmeans) attach(classmeans) boxplot(split(like, PrivPub), ylab = "Class average of attitude to science score", boxwex = 0.4) rug(like[PrivPub == "private"], side = 2) rug(like[PrivPub == "public"], side = 4) detach(classmeans) if(require(lme4, quietly=TRUE)) { science.lmer <- lmer(like ~ sex + PrivPub + (1 | school) + (1 | school:class), data = science, na.action=na.exclude) summary(science.lmer) science1.lmer <- lmer(like ~ sex + PrivPub + (1 | school:class), data = science, na.action=na.exclude) summary(science1.lmer) ranf <- ranef(obj = science1.lmer, drop=TRUE)[["school:class"]] flist <- science1.lmer@flist[["school:class"]] privpub <- science[match(names(ranf), flist), "PrivPub"] num <- unclass(table(flist)); numlabs <- pretty(num) ## Plot effect estimates vs numbers plot(sqrt(num), ranf, xaxt="n", pch=c(1,3)[as.numeric(privpub)], xlab="# in class (square root scale)", ylab="Estimate of class effect") lines(lowess(sqrt(num[privpub=="private"]), ranf[privpub=="private"], f=1.1), lty=2) lines(lowess(sqrt(num[privpub=="public"]), ranf[privpub=="public"], f=1.1), lty=3) axis(1, at=sqrt(numlabs), labels=paste(numlabs)) }

PROBLEM 2 For the data frame science (DAAG package)

(a) Make an appropriate pie chart

(b) Make an appropriate bar plot

library(tidyverse) > ggplot2::mpg #Format of a data set: Data frame with 234 rows and 11 variables 1 manufacturer 2 model > model name 3 displ > engine displacement, in litres or size of engine 4 year > year of manufacture 5 cyl > number of cylinders 6 trans > type of transmission 7 drv > f = front-wheel drive, r = rear wheel drive, 4 = 4 wheel drive 8 cty > city miles per gallon 9 hwy > highway miles per gallon or efficiency 10 fl > fuel type 11 class > type of car

PROBLEM 3 Run library(ggplot2) and data(mpg) before answering questions below.

(a) How many rows are in mpg? How many columns?

(b) What does the drv variable describe? Read the help for ?mpg to find out.

(c) Make a scatterplot of hwy versus cyl. Comment on the outcome.

(d) What happens if you make a scatterplot of class versus drv? Why is the plot not useful?

please include all information, thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!