r - How to do side by side bar chart ggplot and retain original sorting -


thanks in advance help. have been searching stack overflow , google issue , have not been successful.

i need side side horizontal bar chart of word , frequency in 2 files.

my data frame below:

   head(comp,10)               word freq rdfreq    170     project   67      5    20     business   64     14    117  management   53     13    59  development   34      4    211     support   27      6    215     systems   25     10    102 information   22      2    201    software   21      6    203   solutions   20      2    220   technical   20      2 

i have used melt create frequency frame below:

   dfp1 <- melt(comp, value.factor = true)     head(dfp1,20)               word variable value    1       project     freq    67    2      business     freq    64    3    management     freq    53    4   development     freq    34    5       support     freq    27    6       systems     freq    25    7   information     freq    22    8      software     freq    21    9     solutions     freq    20    10    technical     freq    20    11 applications     freq    19    12     planning     freq    18 

my code plot

   g <- ggplot(dfp1, aes(x = word, y= value, order=-   as.integer(value)))    g <- g + geom_bar(aes(fill = variable), position = "dodge", stat="identity")    g <- g + coord_flip()     g <- g + theme(axis.text.y = element_text(size=12))    g <- g + labs(x = "keyword", y = "count",                title = paste("file1 vs file2")               )    print(g) 

the plot sorted word instead of descending order of frequency. again , looking forward responses.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -