In a previous post you saw how to create a data frame in R using a set off x and y values as shown:
x ItmVal
1 A 69
2 B 47
3 C 11
4 D 12
5 E 42
6 F 24
Here 1 to six are line numbers.
It is easy to draw a bar graph using this data:
------
> dap <- br="" data.frame="">+ x=factor(c("A","B","C","D","E","F"), levels=c("A","B","C","D","E","F")),
+ ItmVal=c(69,47,11,12,42,24)
+ )
------------>
You map the data to aesthetics as shown and you can display your graph as shown.
ggplot-bargraph1
On the other hand if you want a different color for each of the different x values you could use this:
ggplot_bargraph2
x ItmVal
1 A 69
2 B 47
3 C 11
4 D 12
5 E 42
6 F 24
Here 1 to six are line numbers.
It is easy to draw a bar graph using this data:
------
> dap <- br="" data.frame="">+ x=factor(c("A","B","C","D","E","F"), levels=c("A","B","C","D","E","F")),
+ ItmVal=c(69,47,11,12,42,24)
+ )
------------>
You map the data to aesthetics as shown and you can display your graph as shown.
ggplot-bargraph1
On the other hand if you want a different color for each of the different x values you could use this:
ggplot_bargraph2
No comments:
Post a Comment