I need to compare two string, for example i have data <- c('"Trafik kembali lancar di kedua - dua arah. Selamat memandu","Kemalangan motorsikal di Km 224.8 utara dari Simpang Ampat ke Pedas Linggi. Tiada laluan terhalang.").
i want to make a comparison that says
if there is a word Pedas in data return heavy traffic else return traffic clear
To clarify, R is the language, and RStudio is just the IDE (see FAQ below for disambiguation). Since this question isn't about the IDE itself, I'm going to move it to General.
What you're describing sounds like a good use-case for grepl() or a similar string-matching function which:
search for matches to argument pattern within each element of a character vector
Hi @akmalirham! The function you're looking for is regexpr() (r after p, not p after r). It's part of the base, so if you have the name right you oughtn't need a package to use it