Message Boards Message Boards

0
|
295 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to convert this association list

Posted 1 month ago

How do you convert the list in goldMedals enter image description here

to this one in the code below

enter image description here

3 Replies

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. Posting code Images doesn't help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

enter image description here

POSTED BY: EDITORIAL BOARD

If there's no simple rule for splitting the given association, then the simplest way might be to edit it by hand. At a glance, the order of entries seems the same in both codes. If so, you could just paste |>, <| at the appropriate junctures.

POSTED BY: Michael Rogers
Posted 1 month ago
goldMedals = <|"USA" -> 39, "China" -> 38, "Japan" -> 27|>;

listOfAssociations = Map[Association, Normal@goldMedals]

BarChart[listOfAssociations,ChartLayout->"Stacked",ChartLabels->Automatic]
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract