[R] replace question mark with a dash

Felipe Carrillo mazatlanmexico at yahoo.com
Sun Apr 25 20:21:01 CEST 2010


Hi:
I have the following dataset in R( thanks Gabor for your help) but now 
the problem is that all the dashes are converted to questions marks ("?")
I am trying to get the dashes back using:

mydf <- data.frame(lapply(mydf,function(x) replace(mydf,"?"(x),"-"))) 

but isn't working. I also tried:

mydf <- replace(mydf,mydf=="?","-)")

Thanks for any suggestions.


 
mydf <-structure(list(IDDate = c("2/26/2010", "2/27/2010", "2/28/2010", 
"3/1/2010", "3/2/2010", "3/3/2010", "3/4/2010", "3/5/2010", "3/6/2010", 
"3/7/2010", "3/8/2010", "3/9/2010", "3/10/2010", "3/11/2010", 
"Biweekly Lower 90% Confidence Interval", "Biweekly Total", "Biweekly Upper 90% Confidence Interval", 
"Brood-year  Lower 90% Confidence Interval", "Brood Year Total", 
"Brood-year Upper 90% Confidence Interval"), First = c("0 ( ? )", 
"n (0 ? 0)", "357 (123 ? 123)", "144 (95 ? 152)", "73 (126 ? 152)", 
"43 (108 ? 108)", "n (0 ? 0)", "270 (101 ? 140)", "121 (111 ? 112)", 
"0 ( ? )", "34 (111 ? 111)", "102 (111 ? 140)", "0 ( ? )", "35 (125 ? 125)", 
"-537", "1425", "3388", "2578499", "4455877", "6333255"), Second = c("0 ( ? )", 
"n (0 ? 0)", "0 ( ? )", "99 (65 ? 71)", "0 ( ? )", "86 (66 ? 76)", 
"n (0 ? 0)", "0 ( ? )", "40 (66 ? 66)", "0 ( ? )", "33 (74 ? 74)", 
"0 ( ? )", "35 (66 ? 66)", "35 (70 ? 70)", "-549", "402", "1353", 
"74306", "314206", "541552"), Third = c("7,002 (33 ? 39)", 
"n (0 ? 0)", "130,342 (29 ? 57)", "22,741 (31 ? 56)", "8,365 (31 ? 53)", 
"5,962 (33 ? 60)", "n (0 ? 0)", "22,461 (30 ? 61)", "12,485 (31 ? 55)", 
"7,352 (31 ? 56)", "2,908 (32 ? 48)", "3,265 (27 ? 48)", "1,993 (30 ? 55)", 
"1,445 (33 ? 62)", "35097", "296085", "557074", "2249920", "7347719", 
"12058021"), Fourth = c("0 ( ? )", "n ( ? )", "0 ( ? )", 
"0 ( ? )", "0 ( ? )", "34 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", 
"0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "-250", 
"40", "330", "98786", "225913", "353040"), Fifth = c("0 ( ? )", 
"n (0 ? 0)", "0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "n (0 ? 0)", 
"0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", 
"0 ( ? )", "0", "0", "0", "-184", "977", "2138")), .Names = c("IDDate", 
"First", "Second", "Third", "Fourth", "Fifth"), class = "data.frame", row.names = c(NA, 
-20L))
mydf
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA






More information about the R-help mailing list