-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
Consider raising attention to the potential ambiguity of the assignment arrow (<-) operator. #406
Comments
hi @massaraevi thank you for the observation! i think an additional bullet explaining this would be a nice addition to the instructor notes. would you be interested in submitting a PR? |
Addresses datacarpentry#406
I think this is a good catch. Anytime, the <- together would be the assignment arrow operator. |
The spacing would certainly work, however, I think novices often have difficulty differentiating between when spaces matter and when they do not. This could be potentially confusing. An alternative would be to place the negative number in parentheses "x < (-5)". That would make it easier to differentiate between the two. |
Hi @mbplatt, this suggestion seems like a good example for novice learners to practice using the assignment operator. I believe it would be a good alternative to include it as a Note for the instructor along with a tip to use the shortcut feature for the assignment operator. So the learner will distinguish wanting to use the operator instead of assigning x to -5. |
Looking at the lesson, I thought of few ways this could be clarified, depending on how generally it to be addressed:
|
@jdrasmus1 that all sounds good to me. would you be interested in submitting a PR with those changes? |
In the section "Intro to R" of the Instructor Notes, the assignment arrow operator (<-) is discussed. This is a good point to warn readers of the potential ambiguity of the operator in R. Since the operator consists of a symbol that resembles the "less than" comparison operator (<) and the minus symbol (-) for subtraction, if we have a logical expression like x<-5 (is x less than -5), the R interpretor may interpret this instruction as an assignment of 5 to x. In this case, the solution (and the general good coding practices recommendation) is to use spaces to reduce ambiguity. Therefore, if the intention is for a logical expression, it should be written as "x < -5" or if the assignment is intended, it should be "x <- 5".
The text was updated successfully, but these errors were encountered: