I have a data frame called Data
that I want to analyse with some basic statistics such as ACP.
But I found that inside the variable Land use change
there is some negative values.
So my goal is to use only variables without those negatives.
I tried to implement a loop to remove rows that contains negatives values of Land use change
.
When I try to run it into the console, it works but I can't "knit" the markdown document :
# Removing variables with negatives values for Land use change
for(i in 1:length(Data$Retail)) {
if(Data$`Land use change`[i]<0) {
Data <- Data[-c(i), ]
}
}
It returns me this error :
Error in if (Data$`Land use change`[i] < 0) { :
missing value where TRUE/FALSE needed
I tried to look for informations in other forums, and I found that this error returns when there is a NA
value in the if statement. But as you can see, I don't have any missing value inside the Land use change
column.
Any help is welcome !