Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW02 - Daniel Krochmal #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sn0wscape
Copy link

@sn0wscape sn0wscape commented Jul 14, 2020

  • a complete HW02 assignment passed in this single commit
  • Added answers to the questions in part A and corrected the code
  • Added comments to the code in part B

+ Added answers to the questions in part A and corrected the code
+ Added comments to the code in part B
@sn0wscape sn0wscape changed the title + a complete HW02 assignment passed in this single commit HW02 - Daniel Krochmal Jul 14, 2020
@sn0wscape sn0wscape closed this Jul 15, 2020
@sn0wscape sn0wscape reopened this Jul 15, 2020
mpg %>%
ggplot(mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = drv)) +
geom_smooth(se = F) #se = F makes it so it won't show the error in the line of fit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unsure how to create a single smoothing line for all of the data on graph 4. I found that using geom_smooth(se = F) alone created a smoothing line for each drv dataset. However, using the "group" function, shown here: geom_smooth(aes(group = 1), se = F, color = "black", size = 1), I was able to create one single smoothing line for all drv datasets.

) +

#Rename x and y labels
xlab("Diamond Cut") +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you pointed out on my HW02_B, x and y axis labels can be named within a single labs function. However, the xlab and ylab functions you used here seem nice and simple. They would be great for scenarios where everything does not need a complete relabeling.

@sn0wscape
Copy link
Author

This was a really clever way to do this. I actually wasn't able to figure out how to reorder the three species... so I applaud you!
Robert's answer key uses
facet_wrap(facets = ~factor(Species, levels = c("versicolor", "setosa", "virginica")), scales = "free_y"
to accomplish the same task. Personally, I don't think either is more/less convenient... but it's always nice to appreciate the various ways one can code.

Thanks! I actually think that the code you cited is a little more elegant, so I appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants