(a []string)
| 252 | } |
| 253 | |
| 254 | func (s *DiscreteStats) getSummaryStr(a []string) string { |
| 255 | s.summary(a) |
| 256 | summaryArray := s.getSummaryData() |
| 257 | result := "" |
| 258 | for _, i := range summaryArray { |
| 259 | var n, v string |
| 260 | n, v = i[0], i[1] |
| 261 | result = result + "#" + n + " : " + v + "\n" |
| 262 | } |
| 263 | result = result + "----------\n" + "Top 20 variable\n\n" |
| 264 | type kv struct { |
| 265 | Key string |
| 266 | Value int |
| 267 | } |
| 268 | |
| 269 | //sortByStr map by value |
| 270 | var ss []kv |
| 271 | for k, v := range s.counter { |
| 272 | ss = append(ss, kv{k, v}) |
| 273 | } |
| 274 | |
| 275 | sort.Slice(ss, func(i, j int) bool { |
| 276 | return ss[i].Value > ss[j].Value |
| 277 | }) |
| 278 | |
| 279 | for _, kv := range ss { |
| 280 | result = result + "#" + kv.Key + " : " + I2S(kv.Value) + "\n" |
| 281 | } |
| 282 | |
| 283 | return result |
| 284 | } |
| 285 | |
| 286 | // getPlot generates a bar chart visualization for discrete data |
| 287 | func (s *DiscreteStats) getPlot() string { |
nothing calls this directly
no test coverage detected