I'd like a write a loop in R which checks the the dataframe in order to change 0 values into a median. Unfortunately I get an error.
It's just a part of my loop.
y <- median(df[1])
Error in median.default(df[1]) : need numeric data
If I use, it works.
y <- median(df$name_of_the_column)
this is my loop. I haven't finished the loop. its still in process.
i = 1
for (x in df) {
if (df[i][df[i] == 0]) {
df[i][df[i]] <- median(df[i])
}