[R] A question on graphical representation
Ron Michael
ron_michael70 at yahoo.com
Sat Mar 1 19:51:25 CET 2014
Hi,
Let say I Have following data:
> Info <- structure(list(Person = structure(1:6, .Label = c("A", "B", "C",
+ "D", "E", "F"), class = "factor"), Attr1 = c(0.52, 0.14, 0.63,
+ 0.43, 0.89, 18.46), Attr2 = c(0.06, 3.35, 0.62, 1.42, 1.96, 8.38
+ )), .Names = c("Person", "Attr1", "Attr2"), row.names = c(NA,
+ -6L), class = "data.frame")
> Info
Person Attr1 Attr2
1 A 0.52 0.06
2 B 0.14 3.35
3 C 0.63 0.62
4 D 0.43 1.42
5 E 0.89 1.96
6 F 18.46 8.38
> Diff <- Info[, 'Attr1'] - Info[, 'Attr2']
> Diff
[1] 0.46 -3.21 0.01 -0.99 -1.07 10.08
> Overall_Diff <- sum(Diff)
> Overall_Diff
[1] 5.28
Now we see that the overall difference between attribute-1 and attribute-2 for persons A-F is 5.28. Now I was asked this question: tell me out of that overall difference, how much is attributed to person A, person B,.... person F? In case the 'Diff' variable all have positive values, I probably consider making a pie-chart. However this is not possible (probably) in this present case, because some values are negative and some values are positive.
So my question is how to build a robust graphical representation to answer this question?
Your help will be highly appreciated.
Thanks for your pointer.
More information about the R-help
mailing list