Re: [R] R Identifying columns with specific character

2018-04-19 Thread Julia Cabrera via R-help
Farnoosh I want to start by appreciating your reply. Thank you so much. I am waiting to know your plan why not give me pic [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.e

Re: [R] Identifying columns with specific character

2018-04-18 Thread Rui Barradas
Hello, To the OP: The dollar sign is a meta character, so it must be escaped, that is what was wrong with your code. The right regular expression would be grepl("\\$", x) When a regular expression doesn't work, try reading the help page ?regex. Another good source you can try is https://reg

Re: [R] Identifying columns with specific character

2018-04-18 Thread Jeff Newmiller
Your message came through all messed up because you did not tell your email program to use plain text format. This at best delays a responds and at worst prevents us from understanding your question as you intended. 1) The columns became factors when you created the data frame because you did n

Re: [R] Identifying columns with specific character

2018-04-18 Thread Jim Lemon
Hi Farnoosh, Perhaps this will help: drop_dollar<-function(x) return(as.numeric(as.character(gsub("\\$","",x sapply(My.Data,drop_dollar) Jim On Thu, Apr 19, 2018 at 7:23 AM, Farnoosh Sheikhi via R-help wrote: > Hello, > I have a data frame with 400 columns and wanted to filter character col

[R] Identifying columns with specific character

2018-04-18 Thread Farnoosh Sheikhi via R-help
Hello, I have a data frame with 400 columns and wanted to filter character columns with "$" in it.For example: >  x <- c("$5", "$89", "$10", "$34")  >  y <- c(1:4)>  My.Data <- data.frame (x,y)> My.Data    x y1  $5 12 $89 23 $10 34 $34 4 I want to detect the columns with $ and remove the $ from t