Reputation: 5049
With a data frame df
I have a large number of discrete values for metric
and their counts cnt
I wanted to get a bar plot
of the counts for each discrete value of metric
.
So I do the following,
df <- read.csv("metric.csv", header=T)
df$metric <- as.factor(df$metric)
ggplot(df, aes(x=metric, y=cnt)) +
geom_bar(stat = 'identity')
With the above I get an empty plot like below with this - why ?
The data I used for the data frame df
is here - http://wikisend.com/download/569376/metric.csv
How do I get a bar plot out of this data ?
Upvotes: 0
Views: 450
Reputation: 7248
I'm not immediately aware of any limitations of geom_bar, but it is unsurprising that this doesn't work very well -- I interrupted it on my machine, so I don't even know what it looks like when it finishes rendering.
Are you sure that a bar plot is appropriate for this data? Which is to say, is the "metric" column effectively a factor?
Running a scatter plot completes rapidly with results that might be more useful (here using a log scale because a linear scale is hurt by the outlier)
ggplot(df, aes(x=metric, y=cnt) +
geom_point() +
scale_y_log10()
yields
Upvotes: 1