R plot with dense and sparse values -


how go plotting x , y based on count given table? don't think can use plot() here.

x    y    count ----------------- 1    1       10 1    2        5 2    1       15 2    2       10 

other putting occurrences of x , y in table, how plot graph given table?

assuming x , y factors couple of values, simple way this:

 data <- data.frame(x = c(1,1,2,2),                    y = c(1,2,1,2),                    "count" = c(10,5,15,10))   data$x <- as.factor(data$x)   data$y <- as.factor(data$y)   library(ggplot2)  ggplot(data, aes(x = x, y = count, fill = y)) +                 geom_bar(stat="identity", position = position_dodge()) 

or

 data <- data.frame(x = c(1,1,2,2),                    y = c(1,2,1,2),                    "count" = c(10,5,15,10))   data$x <- as.factor(data$x)   data$y <- as.factor(data$y)   library(ggplot2)  ggplot(data, aes(x = x, y = count)) +                 geom_bar(stat="identity", position = position_dodge()) + facet_wrap(~y) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -