Replacing '?' in a dataframe in R with ZEROs in R -


this question has answer here:

i need replacing '?' on data frame zeros in r language.

any highly appreciated. regards

df <- data.frame(   a=c(1,"?",3),   b=c(1:3),   c=c("a", "b", "?") )  df <- apply(df, margin = 2, fun = function(x) {   x[x == "?"] <- 0   x }) as.data.frame(df) #   b c # 1 1 1 # 2 0 2 b # 3 3 3 0 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -