1
Hello.
How to insert the average in all NA values. I have a code that I read the file, I check if it’s in and it doesn’t have, but when I turn it into a number, several NA appear and if I remove it, the data is greatly reduced from 4000 to about 600:
df<-read.csv("autores.csv", header=T, stringsAsFactors=F, sep=";")
table(is.na(df)) #não há NA
df_numero<-lapply(df[-1], as.numeric)
#recria o dataframe pois lapply retorna lista
df1<-data.frame(df_numero)
table(is.na(df)) #há NA
This must be because the data needs to be cleaned, there are probably strange characters such as commas (
1,234.00
) or things like that. See first how the values that disappear fromdf
are and only then applyas.numeric
.– Rui Barradas