@@ -261,6 +261,18 @@ ng_bar_chart <- function(o,TN, CF, n, mincount){
261261 return (ngp )
262262}
263263
264+ # this version we pass in the ngram data frame already sorted
265+ ng_bar_chart_freq <- function (ngdf ){
266+
267+ # put them in descending order -- tricky (http://stackoverflow.com/questions/40224892/r-plotly-barplot-sort-by-value)
268+ ngdf $ ngrams = factor (ngdf $ ngrams , levels = unique(ngdf $ ngrams )[order(ngdf $ freq , decreasing = FALSE )])
269+
270+ ngp <- plot_ly( ngdf , y = ~ ngrams , x = ~ freq , type = " bar" ,showlegend = FALSE ) %> %
271+ layout(xaxis = list (showticklabels = TRUE , title = ' Frequency' )) %> %
272+ layout(yaxis = list (showticklabels = FALSE , title = ' ' ))
273+
274+ return (ngp )
275+ }
264276
265277
266278# ############################################################################
@@ -546,25 +558,25 @@ Comparison_Plots <- function(e, CF, CF_levels, nTimePeriods=1, ng_size , zoom_le
546558# '
547559# ' @return standard R plot
548560# ' @export
549- traminer_threadMap <- function (df ,TN , CF ){
550-
551- # setting color palettes
552- # first find the number of distinct colors
553- nColors = length(unique(df [,CF ]))
554- pal <- diverge_hcl(nColors )
555-
556- # reformat the data for traminerR
557- df = convert_TN_to_TramineR(df , TN , CF )
558-
559-
560- # plot sequence - also try seqfplot?
561- # add grouping variable?
562- return (seqiplot( seqdef(df , cpal = pal ) , withlegend = T , main = " ThreadMap" , border = NA ,idxs = 1 : nrow(df )) )
563-
564- # return(seqfplot( seqdef(df, cpal=pal) , withlegend = T, main = "ThreadMap", border = NA,idxs=1:nrow(df)) )
565-
566-
567- }
561+ # traminer_threadMap <- function(df,TN, CF){
562+ #
563+ # # setting color palettes
564+ # # first find the number of distinct colors
565+ # nColors = length(unique(df[,CF]))
566+ # pal <- diverge_hcl(nColors)
567+ #
568+ # # reformat the data for traminerR
569+ # df = convert_TN_to_TramineR(df, TN, CF)
570+ #
571+ #
572+ # #plot sequence - also try seqfplot?
573+ # # add grouping variable?
574+ # return(seqiplot( seqdef(df, cpal=pal) , withlegend = T, main = "ThreadMap", border = NA,idxs=1:nrow(df)) )
575+ #
576+ # # return(seqfplot( seqdef(df, cpal=pal) , withlegend = T, main = "ThreadMap", border = NA,idxs=1:nrow(df)) )
577+ #
578+ #
579+ # }
568580
569581# This one is not currently used.
570582threadLengthBarchart <- function (o , TN ){
0 commit comments