how can I delete a particular word from a column of a large dataset csv file? unable to open in google sheet or excel sheets gets stuck.

is there a function key?

can I use na.omit to delete a word in csv file?

example


word_to_remove <- "are "
column_to_process <- "d"
(start <- tibble(
  a="hello",
  b="my",
  c="friend",
  d="how are you?"
))

(end <- mutate(start,
               across(all_of(column_to_process),.fns = 
                   \(x)str_replace_all(x,
                                       pattern = word_to_remove,
                                       replacement = ""))))

you can use readr::read_csv() to get your csv read in as a data.frame into R to operate on

*Edited: to select a particular column

hey I followed the formula you sent. but I could not remove the word. do I need to attach another string of formula with it?

because when I used, it did apply but did not make the changes

Please attach a small data set so others can test the result of running it with @nirgrahamuk's code. If your data set is named DF, you can share the first ten rows by posting the output of

dput(head(DF, 10))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.