I want to do a simple replace in R for the following column:
df
Songs
1 Saga (Skit) [feat. RZA
2 Revenge
3 Whatever You Want
4 What About Us
5 But We Lost It
6 Barbies
I want to do two different replacements:
1) Replace "[" with blank
2) Replace "]" with blank
Need to do this separately though because some of my values only has 1 on the brackets like the first value in the Songs
column.
df[,1]<-gsub("[","",df[,1])
Error:
Error in gsub("[", "", newdf2[, 1]) :
invalid regular expression '[', reason 'Missing ']''
How do I go about going around this invalid regular expression error?
Thanks!