-
Notifications
You must be signed in to change notification settings - Fork 46
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_Bei Wang resubmission #44
base: master
Are you sure you want to change the base?
Conversation
…ushing these files in github, I only pushed .Rmd but not other. I realize Rmd cannot be rendered in github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great code overall. Though I didn't comment at every tiny place but I learned a lot from the details!
neworder <- c("versicolor","setosa","virginica") | ||
|
||
iris2 <- arrange(transform(iris, | ||
Species=factor(Species,levels=neworder)),Species)#I don't know if there is a simpler way to change order of the panels in facet_wrap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used
iris$Species <- factor(iris$Species, levels = c("versicolor","setosa","virginica"))
for changing the order
This might still be complicated if there's lots of species
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a simpler way of changing the order for this specific set!
xlab("Dimond Cut")+ | ||
ylab("Number of Diamonds")+ | ||
annotate("text", x="Premium", y=4500, label="My Best Diamonds\nof course")+ | ||
annotate("rect", xmin="Premium", xmax="Ideal", ymin=0, ymax=5000, alpha=0.5)# I don't know how to move the shade and text more to the left/right, since x-aix is discrete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can set a value to x/xmin/xmax. I tried it and found that 1 is the center of the first item, 2 is the second, 1.5 is the boundary of the first and the second, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, that's helpful!
@@ -29,20 +29,32 @@ library("magrittr") #so I can do some piping | |||
|
|||
What error is being thrown? How do you correct it? (hint, the error message tells you) | |||
|
|||
**My answer/comment:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice way of highlighting your answers and comments! I will try using it in my code.
scale_color_brewer(palette = "Set2")+ | ||
geom_boxplot(outlier.alpha=0, alpha=0)+ | ||
coord_flip()+ | ||
geom_point(aes(color=class), position= position_jitter(height=0))+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add height = 0 and I got randomly arranged dots instead of aligned ones. Thanks because now I know how to fix it, but I am still confused about what did setting height to 0 actually change...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the position_jitter (height=) sets the resolution of the jitters on the y axis; the default is set to 0.4. Here it is actually x-axis because I flipped the coordinate. Since the x axis (Car class) is a categorical variable that composed integers. So in order to have the jitter only be set to integers, height should be set to 0. I didn't find much about this function, so this is just what I think it might be:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the dots you got by not setting height=0, I'm guessing its arranged by every 0.4?
This is a resubmission, I previously didnt push all files but only two .Rmd, which can't be rendered on github (can't be viewed). Turned out that I should've pushed all of them.