-1

I have a simple table in R named Tag_Count:

Tag 1    freq
Cookies   1
Cakes     2
Burritos  5

I want to remove all rows where freq value is less than 3. I tried:

Tag_Count_2 <- Tag_Count[Tag_Count$freq <= 3,]
Tag_Count_2 <- Tag_Count[freq < 4]

But neither worked.

Claire
  • 25
  • 5
  • Sorry, I meant 3. But I used your suggestion and it spit back the table with nothing altered. – Claire Jul 15 '16 at 02:37

2 Answers2

0

We can try

Tag_Count[!(Tag_Count$freq <= 3),]

If this is not a data.frame, then

Tag_Count[!(Tag_Count[,"freq"] <= 3),]
akrun
  • 874,273
  • 37
  • 540
  • 662
0

You can try this

library(dplyr)

df1 <-  df %>%
     filter(freq >= 3)

print(df1)
      Tag1 freq
1 Burritos    5

data
df <- data.frame(Tag1 = c("Cookies","Cakes","Burritos"),freq = c(1,2,5), stringsAsFactors = F)
Arun kumar mahesh
  • 2,289
  • 2
  • 14
  • 22