I have a question which confused me for a long time: how should I remove a pattern starting with question mark?
For example:
## dataframe named test
x y
1 gffsd?lang=dfs
2 sdldfsd?lang=gsd
3 eoriwesd?lang=fh
4 eriywo?lang=asd
What I want is:
x y
1 gffsd
2 sdldfsd
3 eoriwesd
4 eriywo
I tried several method, including:
test$y = sapply(strsplit(test$y, '?'), head, 1)
test$y = sapply(strsplit(test$y, '?lang='), head, 1)
gsub("?",NA, test$y, fixed = TRUE)
Unfortunately all of them failed.
Thanks in advance!
BTW, anybody knows how to replace "®" to "-"