I wrote a code in R To do some change in a text after count the number of character And if the number of character grater than 5 do the change And it is working here is my code
dataset<- c ("there is a rain " , "I am student" )
dataset <-data.frame(x= dataset)
dataset $x<-as.character(dataset $x)
words <- unlist(strsplit(dataset $x, " "))
nchar(words)
K <- character(length(words))
K[nchar(words) < 6] <- words[nchar(words) < 6]
K[nchar(words) > 5] <- gsub('e', 'X',
words[nchar(words) > 5], perl = TRUE)
the result
[1] "there" "is" "a" "rain" "I" "am" "studXnt"
As you can see it do the change but my problem is that It merge between the texts So If I have 50 rows then I do not know the text belong of which row Because at the end I need to save the change on original text
The result I expect
[1] There is a rain
[2] I am studXnt
Thank you