title: Count the number of cities visited in R
body: <p>I have a data table that contains two variables, the first column contains a number of cities a person visited and the other one is the rating of the trip, example as code below:</p>
  
  <pre><code>trips &lt;- data.frame(
    Cities_Visitted=c("New York/San Diego","Chicago/New York","Chicago/New 
                      York/Los Angeles"),
    Trip_Rating=c(6,8,3))
  </code></pre>
  
  <p>and i have another vector that contains a full list of cities, as below:</p>
  
  <pre><code>city_list &lt;- c("New York","Chicago","Los Angeles","Houston","San Diego")
  </code></pre>
  
  <p>What i want to achieve is to add a new column to the trips data frame that indicates the number of cities in the city_list are included in each trip, the result would be like this:</p>
  
  <pre><code>               Cities_Visitted Trip_Rating Total_Number_Cities
             New York/San Diego           6                   2
               Chicago/New York           8                   2
   Chicago/New York/Los Angeles           3                   3
  </code></pre>
  
  <p>Is there anyway to achieve this in R?</p>