-1

Just a quick one, I'm trying to eliminate a string of text in my dataset in a specific column. When I call summary(mydata$myanimals), I get a strange result in the form of:

Ant: 100 Bat: 100 Cat: 100 Dog: 0 Emu: 100

Why would there be a "0" for records labeled "Dog". I've tried dplyr to filter it out, but it remains like this when calling the summary function. Any insights? I'd like to get rid of Dog all together but it won't go away.

  • It don't help to answer your question when you write down quick...can you please give us a working example with data of what you are doing. – and-bri Oct 02 '16 at 23:23
  • Agreeing and emphasizing: we'd like to help. We have no idea whether mydata is a data.frame, data.table, or list. We don't know what data type myanimals is: factor? numeric vector with named elements? A minimal working example would make it possible to help you. – Jason Oct 02 '16 at 23:31
  • Hard to give an example as my data is 3M rows. It is more just whether anyone had any conceptual ideas as to why a zero would appear under an animal "type". I'm working with a df and the column is a factor – Scott Hunter Oct 02 '16 at 23:33
  • 1
    Use `dput(head(mydata))` and paste the output. – Eric Watt Oct 02 '16 at 23:35
  • 1
    The answer to the riddle will lead through it being a factor and then `droplevels`. But in the future, please use `str()` or `dput(head(my_data))` to provide us with _something_ to go on. Otherwise, trying to help quickly becomes very frustrating guesswork. And frustrated people down vote and vote to close questions. – joran Oct 02 '16 at 23:37
  • structure(c(5L, 5L, 5L, 5L, 5L, 5L), .Label = c("Ant", "Bat", "Cat", "Dog", "Emu", "Elephant", "Tiger"), class = "factor") – Scott Hunter Oct 02 '16 at 23:39

1 Answers1

0

Thanks guys,

myData$myanimals<-droplevels(myData$myanimals) worked nicely