fork download
  1. poem1 <- "This is a line\nThis is a line\n\nAnother line\n\nAnd another one\nThis is the last one"
  2. poem2 <- "Some poetry\n\nMore poetic stuff\nAnother very poetic line\n\nThis is the last line of the poem"
  3. library(stringr)
  4. str_count(poem1, "\\R+")
  5. # => [1] 4
  6. str_count(poem2, "\\R+")
  7. # => [1] 3
  8. ## Line counts:
  9. str_count(poem1, "\\R+") + 1
  10. # => [1] 5
  11. str_count(poem2, "\\R+") + 1
  12. # => [1] 4
Success #stdin #stdout 0.28s 42408KB
stdin
Standard input is empty
stdout
[1] 4
[1] 3
[1] 5
[1] 4