-1

How would I remove all rows containing the numeric '0' in Farmland across the entire data?

example of data:

dat <- read.csv("Bird_Dataset_2019.csv")
df <- aggregate(Farmland~ Species + Year + GRIDREF, data = dat, subset = Species == 'Turtle Dove', sum)

enter image description here

I have tried this code df[!apply(df, 1, function(x) any(df > 1)), ] but it returns the original dataset with warnings.

I expect looping and removing all rows by ID that have 0 in Farmland.

Lime
  • 738
  • 5
  • 17
  • 1
    Please read the instructions for posting at the top of the [tag:r] tag page. In particular please provide the input in a form that can be copied and pasted into R, not as images and show the expected output. – G. Grothendieck Nov 25 '19 at 15:01

1 Answers1

2

No need to use apply function, you can do:

df = df[df$Farmland !=0,]

or

df = df[df$Farmland > 0,]
dc37
  • 15,840
  • 4
  • 15
  • 32