'Barplot/barchart in R [duplicate]

I have a data table with two small columns.

I want to do a pairwise comparison between the values. The first column is results of one test and the second of another test. So I want a barplot where the first pair of bars show value [1,1] and next to it [1,2] then [1,2] besides [2,2] and so on.

I have 20 values (10 in each from 10 instances) and want 20 bars in one plot. I have no category variable but I want to preserve the order in which they appear in the column (each result corrosponds to an instance). Hence 20 values represented by 20 bars.

Hope you can help.

Edit: Sry for the bad explanation.



Solution 1:[1]

Based on your vague question I think this is what you want. Here is a quick example you can use to get your results:

counts <- table(mtcars$vs, mtcars$gear)
barplot(counts, main="Car Distribution by Gears and VS",
        xlab="Number of Gears", col=c("darkblue","red"),
        legend = rownames(counts), beside=TRUE)

enter image description here

Source: http://www.statmethods.net/graphs/bar.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mlegge