'Can't generate word count of all words from *.txt file in R

I generated 10000 random words at Lorem Ipsum and saved as txt file. Then wrote following code:

R Code:

art <- read.delim(file.choose())   # selecting the txt file from local machine

art_u <- unlist(art)   # unlisting the words from a single string

art_split <- strsplit(art_u, split = " ", fixed = T)   # spliting the words

art_sep <- c()   # creating an empty vector to store splitted words
for (i in art_split){art_sep=c(art_sep, i)}   # storing the words into the vector

art_fac <- factor(art_sep)   # factorizing the words from the vector
art_sum <- summary(art_fac)   # getting result with counts
art_wc_df <- as.data.frame(art_sum)   # turning the result into a dataframe

In the created dataframe, after 99 observations/rows, the 100th observaton/row comes as others with a large count. It was tried both in RStudio and RGui, but gives the same result. Can't figure out what went wrong. Is there any way to fix it, or the coding went wrong?

NB: Tried on RStudio 2021.09.1 Build 372, RGui x64 4.1.2



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source