Multiple character replacement in R -


below part of code , can see, trying remove string of characters , meta characters. there way replacements in 1 line? tried writing symbols open , close parethesis after word function not work.

{      p1 <- gsub("function", "", deparse(s)[1]);            #removing word "function"     p2 <- gsub("\\(", "", p1);                            #removing open parenthesis     p3 <- gsub("\\)", "", p2);                            #removing close parenthesis     p4 <- gsub("\\s", "", p3);                            #removing spaces     variables <- strsplit(p4,",");                        #separating variables  } 

maybe not 1 line solution can simplify code this:

listtoreplace <- c("function", "\\(", "\\s")  string <- "function.... ...bbb((bbbb"  gsub(paste(listtoreplace,collapse="|"), "",     string) 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -