r - ggplot2 : How to write mean value as text on a plot? -


i have following dataframe :

 my.data=read.table(text="         values tag class  1   100.0000000  x3    cs  2   100.0000000  x5    cs  3    54.2370601  x7    cs  4    63.4813701  x7    cs  5    51.0402580  x7    cs  6    60.1430236  x7    cs  7    70.3939619  x7    cs  8    56.5981165  x7    cs  9    75.4148038  x7    cs  10   88.2687052  x7    cs  11   70.9697583  x7    cs  12   54.2014007  x7    cs  13   63.4325244  x7    cs  14   51.0086771  x7    cs  15   60.1034812  x7    cs  16   70.3397973  x7    cs  17   56.5630966  x7    cs  18   75.3652206  x7    cs  19   88.2007869  x7    cs  20   70.9258461  x7    cs  21   38.6325912  x9    cs  22   27.7455102  x9    cs  23   21.1778773  x9    cs  24  100.0000000  x9    cs  25   73.0803007  x9    cs  26   55.7814809  x9    cs  27   85.8614803  x9    cs  28   38.5666461  x9    cs  29   27.7114796  x9    cs  30   21.1580450  x9    cs  31   72.9906659  x9    cs  32   55.7292434  x9    cs  33   85.7810739  x9    cs  34    0.0000000 xas    cs  35   49.0701633 xpw    cs  36   40.0228822 xpw    cs  37   23.8702273 xpw    cs  38  100.0000000 xpw    cs  39   89.3022370 xpw    cs  40   53.2611491 xpw    cs  41   69.9892886 xpw    cs  42    0.0000000 xpw    cs  43   14.8840750  x3    cd  44   17.7316138  x3    cd  45    6.1164435  x3    cd  46    0.0000000  x3    cd  47    1.1435141  x3    cd  48   14.8904265  x3    cd  49   17.7375474  x3    cd  50    6.1241709  x3    cd  51    1.1506441  x3    cd  52   14.6751282  x3    cd  53   17.5364297  x3    cd  54    5.8621689  x3    cd  55    0.9089743  x3    cd  56   74.4165986  x5    cd  57   76.7441666  x5    cd  58   80.9582780  x5    cd  59   58.5811936  x5    cd  60   62.3494607  x5    cd  61   69.1719883  x5    cd  62   57.2509995  x5    cd  63   61.1402872  x5    cd  64   68.1819250  x5    cd  65   74.3887236  x5    cd  66   76.7211353  x5    cd  67   80.9428400  x5    cd  68   58.5360647  x5    cd  69   62.3121736  x5    cd  70   69.1469947  x5    cd  71   57.2044213  x5    cd  72   61.1018026  x5    cd  73   68.1561287  x5    cd  74   74.3425809  x5    cd  75   76.6830205  x5    cd  76   80.9173038  x5    cd  77   58.4613610  x5    cd  78   62.2504669  x5    cd  79   69.1056522  x5    cd  80   57.1273184  x5    cd  81   61.0381141  x5    cd  82   68.1134585  x5    cd  83   66.3076784  x7    cd  84   60.5650688  x7    cd  85   68.2935472  x7    cd  86   49.3767792  x7    cd  87   40.7484217  x7    cd  88   52.3605769  x7    cd  89   36.4202616  x7    cd  90   25.5835605  x7    cd  91   40.1677332  x7    cd  92   66.3298303  x7    cd  93   60.5954120  x7    cd  94   68.3131654  x7    cd  95   49.4100626  x7    cd  96   40.7940127  x7    cd  97   52.3900536  x7    cd  98   36.4620636  x7    cd  99   25.6408202  x7    cd  100  40.2047541  x7    cd  101  66.1477122  x9    cd  102  75.6876522  x9    cd  103  81.4426220  x9    cd  104  55.0173821  x9    cd  105  67.6939692  x9    cd  106  75.3411217  x9    cd  107  51.6125069  x9    cd  108  65.2486246  x9    cd  109  73.4746140  x9    cd  110  66.2054974  x9    cd  111  75.7174719  x9    cd  112  81.4600003  x9    cd  113  55.0941665  x9    cd  114  67.7335933  x9    cd  115  75.3642139  x9    cd  116  51.6951034  x9    cd  117  65.2912480  x9    cd  118  73.4994541  x9    cd  119  25.6270138 xas    cd  120  45.2920118 xas    cd  121  44.5101287 xas    cd  122   0.0000000 xas    cd  123  17.9916840 xas    cd  124  16.8196263 xas    cd  125   7.3447585 xpw    cd  126  24.4280115 xpw    cd  127  54.9277702 xpw    cd  128   0.0000000 xpw    cd  129   4.6378241 xpw    cd  130  43.1246155 xpw    cd  131  39.7525599 xpw    cd  132 100.0000000 xpw    cd") 

i can plot :

qplot(tag,values,colour=factor(class),data=my.data,geom="jitter") +      stat_summary(fun.y='mean', geom='errorbarh',                   aes(xmin=as.integer(tag)-0.45, xmax=as.integer(tag)+0.45),                   height=0) +      facet_grid(.~class) 

plot http://img11.hostingpics.net/pics/230718rplot01.jpg

do know how can replace bars representing mean value of mean text (its numerical value) ? replacing geom='errorbarh' geom='text' doesn't work.

also know if can add standard deviation numeric value @ bottom or top of each column ?

fun0 <- function(x) -10  qplot(tag,values,colour=factor(class),data=my.data,geom="jitter")+   stat_summary(fun.y='mean', geom='text',                 aes(label=signif(..y..,4),x=as.integer(tag)))+    stat_summary(fun.y="fun0",fun.ymin='sd', geom='text',                 aes(label=paste("sd:",signif(..ymin..,2)),x=as.integer(tag)))+   facet_grid(.~class) 

enter image description here


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -