R-ecology-lesson
R-ecology-lesson copied to clipboard
Introduce print() fun and comment char earlier
[Submitted by email]
- Three ways to force R to print the value: using parentheses; typing the object name; using print() function.
The function print() was not introduced in this episode in the current version, possibly because functions haven't been introduced yet; maybe mention this function in the subsection of "Functions and their arguments"? This function is used in the episode "Manipulating, analyzing and exporting data with tidyr" later on.
-
The comment character # should be introduced earlier. In the current setup, comments showed up in the subsection "Objects vs. variables" but no explanation at all there.
-
It would be great to mention that the grammar of the language determines whether an expression is complete or not. e.g. x<- ## incomplete expression
Nothing would happen after entering Enter, because it's waiting for the expression to be completed. This is also a good place to introduce the comment character #.
- Well spotted! I think it would be worth demonstrating the
print()
function. It would probably fit best in the beginning, with the other 2 ways to print objects. Of course, functions have not been explained there, but it might be ok to say "this is a function. We will learn more about functions soon" - True, comments are used shortly before they are explained. I think this is really only an issue if learners are following the lesson by themselves. In a live course, the instructor probably won't copy the comments. Even in a self-learning situation, I think the syntax highlighting makes clear that the comments are comments. Anyways, a solution could be to rewrite this part, so that the comments are included in the regular text instead.
- This is (to some extent) addressed in interacting with R, albeit the section is not talking about syntax, just saying that "It means that you haven’t finished entering a complete command.". Personally, I think this is clear enough, though.