Last active
November 5, 2018 18:49
-
-
Save knapply/ca5e979f430018bfe95817b0e8b977cd to your computer and use it in GitHub Desktop.
R: Length from scratch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r_length <- function(x) { | |
out <- 0L | |
for (i in x) { | |
out <- out + 1L | |
} | |
out | |
} | |
r_vector <- 1:20 | |
r_length(r_vector) | |
#> [1] 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment