Quick replace of NA - an error or warning

后端 未结 3 1951
Happy的楠姐
Happy的楠姐 2021-01-13 03:59

I have a big data.frame called \"mat\" of 49952 obs. of 7597 variables and I\'m trying to replace NAs with zeros. Here is and example how my data.frame looks like:



        
3条回答
  •  臣服心动
    2021-01-13 04:32

    See my detailed answer here.

    #install.packages("xlsx")
    library(xlsx)
    extracted_df <- read.xlsx("test.xlsx", sheetName='Sheet1', stringsAsFactors=FALSE)
    # Replace all NAs in a data frame with "G" character
    extracted_df[is.na(extracted_df)] <- "G"
    

提交回复
热议问题