swirldev / swirl

:cyclone: Learn R, in R.
http://swirlstats.com
Other
1.14k stars 599 forks source link

Last element of vector does not check properly in R Programming Basic Building Blocks: Functions #890

Open erntan opened 2 years ago

erntan commented 2 years ago

In R Programming Basic Building Blocks: Functions, you are asked to return the last element of the vector c(4, 8, 0) using an anonymous function. When using the expression x[-1], we return the last two elements, yet the module evaluates this as correct, as shown below.

| Now try using evaluate() along with an anonymous function to return the last      
| element of the vector c(8, 4, 0). Your anonymous function should only take        
| one argument which should be a variable `x`.

> evaluate(function(x){x[-1]}, c(8, 4, 0))
[1] 4 0

| You got it!