Here is an idea via dplyr,
library(dplyr)
data %>%
mutate(grp = cumsum(c(1, diff(n < 2) != 0)),
grp = replace(grp, n >=2, grp[n >= 2] + row_number()[n >= 2])) %>%
group_by(grp) %>%
summarise(x = toString(x), n = sum(n)) %>%
ungroup() %>%
select(-grp)
which gives,
# A tibble: 4 x 2
x n
<chr> <int>
1 Amazon, FB 2
2 Google 2
3 IBM 3
4 MS 3
NOTE: If you really want to use Other then, at the end of the pipe, add the following,
... %>% mutate(x = replace(x, grepl(',', x), 'Other'))
To 'decipher' the cumsum part for the grouping lets break it down.
We want to create groups where all values within that group are less than 2. However, inevitably, we also create groups for values greater (or equal) than 2. In order to avoid summarising those groups, we replace them by adding an incremental value on them. This will ensure that groups with values greater than 2 will only have one element in, thus ensuring they won't get summarised at the end as well.
The trick to get the groups is to create a logical vector with values less than 2, and take the difference to find when it changes from TRUE to FALSE (hence the ...!= 0 part). Since the diff will remove a value, we add it manually by c(1, diff(...)). Note that instead of 1 you could put TRUE. The cumsum then creates the groups. In order to avoid summarising the groups with values > 2, we replace them by adding their row_number to them. Why row_number? Because it increases thus making all groups unique.
x <- c(1, 1, 3, 4, 2, 1, 1, 1, 5)
x < 2
#[1] TRUE TRUE FALSE FALSE FALSE TRUE TRUE TRUE FALSE
diff(x < 2) != 0
#[1] FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE
cumsum(c(1, diff(x < 2) != 0))
#[1] 1 1 2 2 2 3 3 3 4