i want put pvalues on barplot represent them asterisk (* pval = .05 .01, ** asterisk between .009 .001 , *** smaller .001. lets assume have random data called scores , barplot them , test comparing 100 85,88, , 82. 30 , 76 internal controls ( no test test). extracted pvalues , stored in empty vector represented pval. how can convert pval numbers , put on corresponding bars? @ lose on this. maybe loop , text? want 100 control, 85 - 82 should have pval on them , 30 , 76 nothing on them.
scores<- c(100, 85, 88, 82, 30, 76); barplot(scores); pvalues; [1] 3.826535e-05 1.038895e-01 4.257805e-05
you can use returned value barplot x-values of bars , use text place asterisks.
## sample data scores<- c(100, 85, 88, 82, 30, 76) pvalues <- c(na, 3.826535e-05, 1.038895e-01, 4.257805e-05, na, na) ## asterisks bartext <- ifelse(pvalues < 1e-3, "***", ifelse(pvalues < 1e-2, "**", ifelse(pvalues < 5e-2, "*", ""))) bartext <- ifelse(is.na(bartext), "", bartext) ## make plot breaks <- barplot(scores) text(breaks, scores+2, labels=bartext) 
Comments
Post a Comment