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

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -