-1

I've got a CSV file of about 30K rows and I'm reading that into a variable using

bugs=read.table("bugs.txt", sep="~", header=T, stringsAsFactors=F)

I'm building a simple plot using qplot with

qplot(data=bugs, x=version) + theme(axis.text.x = element_text(angle = 90, hjust = 1))

The issue is that the graph includes all the data. What I'd like to do is eliminate any versions where the count is less than say 250. Is that possible to do without trimming the actual dataset itself manually?

The columns of my csv are

id~reporter~component~created~status~version

I'm pretty new to R and trying to learn it with some data from our bug tracking software.

thank you

anoopb
  • 533
  • 4
  • 6
  • 20

1 Answers1

1

Without redefining bugs, you could subset the data frame within the qplot call:

qplot(data=filter(bugs, count_variable_name>=250), x=version) + theme(axis.text.x = element_text(angle = 90, hjust = 1))

where filter is a function in the dplyr package.

It's not clear what your dataset looks like, if count is an explicit variable in the dataset, and what geom is being used by qplot. If you provide details on your dataset, l can give a more robust answer.

Brian
  • 105
  • 1
  • 8
  • Hi thanks very much. I've added some more information about the dataset in the original post. – anoopb Mar 30 '16 at 02:48
  • 1
    In the future please submit a reproducible example, [as outlined here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). I still don't fully understand your dataset, but I believe this should work: `ggplot(data=(count(bugs, version) %>% filter(n>=1)), aes(x=version, y=n)) + geom_bar(stat="identity") + theme(axis.text.x = element_text(angle = 90, hjust = 1))` You'll need to load the `ggplot2` and `dplyr` packages. See the relevant discussion of plot vs ggplot [here](http://stackoverflow.com/questions/5322836/choosing-between-qplot-and-ggplot-in-ggplot2) – Brian Mar 30 '16 at 18:26