I'm learning R programming language

I’m trying to learn R programming language through an excellent online course on datacamp.com and it’s a lot of fun. This is my second attempt of writing code after the classic “Hello World”. I know that I’m in the very beginning of this journey but I want to leave this code here as a milestone 😬

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 
# Count how many times a specific word was repeated in a text
rquote <- "Add text here "
words <- strsplit(rquote, " ") [[1]]
rcount <- 0
for(word in words) {
  if(word == "add word here") {
    rcount <- rcount + 1
  }
}
rcount
comments powered by Disqus