- Jun 2021
-
jrnold.github.io jrnold.github.io
-
str_replace_all("past/present/future", "/", "\\\\")
Why are there two backslashes replacing a single forward-slash?
-
The \\1 pattern is called a backreference. It matches whatever the first group matched. This allows the pattern to match a repeating pair of letters without having to specify exactly what pair letters is being repeated.
I wonder if this was written early in the editing of the text. The main text already describes this. If this is here as a reminder, maybe it could be worded differently so that it doesn't seem as if it was written early in the editing of the text and sort of forgotten here?
-
[A-Za-z][A-Za-z]
Could this notation be explained in the main text so that when we try to solve the problem we have the tool at our disposal?
-
-
r4ds.had.co.nz r4ds.had.co.nz
-
help
"helped"?
-
-
jrnold.github.io jrnold.github.io
-
[y == -Inf] <- 0 y[y == Inf]
How does this work? How come the evaluation of the conditional y == (-)Inf happens in the index of y?
-
-
r4ds.had.co.nz r4ds.had.co.nz
-
stop("!") %>% tryCatch(error = function(e) "An error")
Would it be possible to go step by step here explaining how the evaluation happens?
-
-
jrnold.github.io jrnold.github.io
-
What weather conditions make it more likely to see a delay?
Is there a way of doing this more systematically through z-scores?
flights2 <- flights %>% left_join(weather) %>% pivot_longer(temp:visib, names_to = "weather_condition", values_to = "weather_value") %>% group_by(weather_condition) %>% mutate(weather_value = (weather_value - mean(weather_value, na.rm = TRUE)/sd(weather_value, na.rm = TRUE)))
flights2 %>% ggplot(aes(weather_value, dep_delay, fill = weather_condition)) + geom_point()
I should warn that, although I tried this, not only does it take long to render, but it also simply didn't color my points. I'm not sure why.
-
The following diagram shows the relations between the Batting, Pitching, and Fielding tables.
Is there a reason why Batting in particular is in the middle? Or could any of the other two have been placed there instead?
-
- May 2021
-
r4ds.had.co.nz r4ds.had.co.nz
-
How would you match the literal string "$^$"?
I only understood what the question meant after looking at the answers. Perhaps the wording is fine as it is, but maybe adding the clarification that the entirety of the string should exclusively include "$^$" would help?
-
-
r4ds.had.co.nz r4ds.had.co.nz
-
When using integers to separate strings, the length of sep should be one less than the number of names in into.
Why is this a thing?
-
in s
"in a similar"
-
-
jrnold.github.io jrnold.github.io
-
~key
In the textbook, this is "~names", rather than "~key".
-
-
r4ds.had.co.nz r4ds.had.co.nz
-
character
logical?
-
-
jrnold.github.io jrnold.github.io
-
mean delay of a flight for all values of the previous flight
It's not really clear to me why doing the means here makes sense... I'll come back to this and maybe later it'll click, but so far I've re-read this three times in three different days and it still doesn't click... Maybe there's another way of phrasing why this is being done the way it is?
-
We could also use the | operator. However, the | does not scale to many choices. Even with only three choices, it is quite verbose.
Could we use & too? Could that be written here?
-
-
jrnold.github.io jrnold.github.io
-
es
Could this answer include when I would use it, which is what the question asks. I wasn't sure what to answer because I couldn't think of scenarios where a mutate wouldn't do the job just as well?
-
-
jrnold.github.io jrnold.github.io
-
affect
affects?
-
-
jrnold.github.io jrnold.github.io
-
factor(1)
Even though this looks similar to the time in which we did "group = 1", this seems different enough to warrant an explanation? At least I don't really understand how this works. On a hunch, I tried replacing "factor(1)" with "identity", and I got the same graph. How did that work? I tried looking up factor in the documentation, and it clarified what that meant, but I still am not sure how that relates to ggplot.
-
-
r4ds.had.co.nz r4ds.had.co.nz
-
fun.min = min, fun.max = max, fun = median
These are new. How do they work? How come I can simply pass them keywords like "min", "max", and "median"?
-
will place each object exactly where it falls in the context of the graph. This is not very useful for bars, because it overlaps them. To see that overlapping
This was worded in a way that was confusing. I ended up searching this and making sense of it through https://stackoverflow.com/questions/39117455/ggplot2-geom-bar-and-position-identity . Maybe specifying that each bar is starting from y=0 or count=0 could help? Or asking readers to notice the scale of the y-axis?
-