Reputation: 1
I have data frame in which one factor is Soil.pH and I want to replace all values of this factor that are bigger than 3 with the value 999.
Using the code df[Soil.pH>3]<-999
I get an error of duplicate subscripts for columns.
I should probably use the replace function like replace(df,Soil.pH>3,999)
. Any help would be appreciated
Upvotes: 0
Views: 1955
Reputation: 1820
You're almost there. Try this:
df$Soil.pH[df$Soil.pH > 3] <- 999
This will replace values in the data-frame.
Upvotes: 2