Do you have an example of your code that you think should be executing?
Yes! Here's the code with the nested function:
arrange(filter(ToothGrowth, dose==0.5)len);
here's the code with the pipe:
filtered_tg <- ToothGrowth %>%
filter(dose==0.5)
arrange(len) %>%
Thanks! For the first one, you need a comma after the call to filter
. I think what you want is:
arrange(filter(ToothGrowth, dose == 0.5), len)
For the second one, you can't end a statement with a pipe, because R is expecting more input. It's like asking R to evaluate 1 +
. One plus what? It isn't clear to R that your statement is finished. If you get rid of %>%
after arrange(len)
, then you should be good to go.
Okay, so I added a comma after len for the code with the nested function, and it worked! Thank you so much for helping me work through the first layer of the forest. For some reason, though, the pipe still won't work. I tried the following:
filtered_tg <- ToothGrowth %>%
filter(dose==0.5)
arrange(len)
Should there be a comma or a pipe after the filter?
You got it! Pipe after filter and you’re set. It helps if you translate the pipe as “and then” in your head. So “ToothGrowth, and then filter, and then arrange”. Can help you mike sure your piping in the right places.
Wow! It worked! Thank you so much for your help. I'll keep what you've suggested in mind when using pipes, going forward.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.