-
Notifications
You must be signed in to change notification settings - Fork 3
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
Lab 03, Question 7 (Part 1) #13
Comments
Hi Adrian - It's helpful if you can provide a little more context. You can copy and paste images from the text into these discussions. Your current code is also welcome so we can see where you are going wrong. Remember to use "fences" ``` around the code so it formats correctly. The "preview" tab above ☝ is helpful for checking formatting before posting.
Jesse |
Note the subset operator
To select elements you need to use a logical statement inside a subset operator: x[ x == "A" | x == "C" ]
# same as x[ c( TRUE, FALSE, TRUE ) ]
[1] "A" "C" You can also reference by position: x[ c( 1, 3 ) ]
[1] "A" "C" Try this by itself - what are you getting here? Teams$year [1924 & 2000 ] |
When I do the logical statement inside a subset operator by itself, my graph stays the same and the console writes out the following:
I'm trying to see if I can write the logical statement into another way that can help me emphasize my subset of data on my graph. Any ideas that can lead me in the right direction? |
I believe the problem is you don't have a complete logical statement inside the subset. The logical statement should return TRUE or FALSE and should have the form:
The reason you don't reference values directly is because you often select one variable based upon criteria from another. x[ > 10 ] # incorrect
x[ x > 10 ] # correct For example: id <- paste0( "id-100", 1:4 )
group <- c("treatment","control","treatment","control")
gender <- c("male","male","female","female")
id
[1] "id-1001" "id-1002" "id-1003" "id-1004"
# asking for the ID directly
id[ id == "id-1002" ]
[1] "id-1002"
# asking for the ID of study participants that meet criteria
id[ group == "treatment" ]
[1] "id-1001" "id-1003"
id[ group == "treatment" & gender == "male" ]
[1] "id-1001" |
Thanks for your help Dr. @lecy! @adrianc09 were you able to resolve this? |
@jamisoncrawford Thanks to Dr. @lecy's help, I was able to highlight all points in 1924. However, I'm trying to figure out how my code can incorporate the points in 2000 simultaneously. This is the code I used to highlight:
I'm trying to figure out what I can change to highlight both groups. Thank you very much for your help, Dr. @lecy! |
I actually just went back to read Dr. @lecy's responses one more time and was able to figure out my error; both groups are highlighted now! |
@adrianc09 awesome! Sorry I was quite swamped earlier in the week - I tend to be more responsive, especially to posts on GitHub. (It's tied to my personal email so I get mobile notifications, unlike my GSU email). So one thing to add is that you need to change the arguments in your visualization functions so that they resemble the NYT graphic. E.g. The video walkthrough does a decent job walking through these: |
Hi everyone!
Our book talks about highlighting three specific outliers, but I'm having some trouble emphasizing the 1924 and 2000 points on question 7. Maybe it's because we have to emphasize multiple points that fit into the years 1924 and 2000. I may be forgetting something that we learned previously. If anyone could offer a hint of some sort that'd be great!
The text was updated successfully, but these errors were encountered: