4
$\begingroup$

I wanted to create a word cloud of countries according to their GDP. I need to extract this information from my own dataset and not from Mathematica. So I made a list of countries and GDPs:

DataACT0Combination = Transpose[{DataACT1, DataACT3}]
 {{"Afghanistan", 1919.}, {"Albania", 11840.}, {"Algeria", 
      15027.}, {"Andorra", "-"}, {"Angola",6844.}, {"AntiguaBarbuda", 
  "-"}, {"Argentina", 20048.}, {"Armenia", 8621.}, {"Australia", 
  48899.}, {"Austria", 48005.}, {"Azerbaijan", 17439.}, {"Bahamas", 
  24555.}, {"Bahrain", 50704.}, {"Bangladesh", 3891.}, {"Barbados", 
  17100.}, {"Belarus", 18000.}}]

Unfortunately Mathematica won't allow me to do a WordCloud [DataACT0Combination ]. Why is this?

enter image description here

$\endgroup$
1
  • $\begingroup$ Some of the weights you are using are "-" when they should be positive numbers. $\endgroup$
    – Jason B.
    Jan 10, 2020 at 17:53

1 Answer 1

6
$\begingroup$
data = {{"Afghanistan", 1919.}, {"Albania", 11840.}, {"Algeria", 
    15027.}, {"Andorra", "-"}, {"Angola", 6844.}, {"AntiguaBarbuda", 
    "-"}, {"Argentina", 20048.}, {"Armenia", 8621.}, {"Australia", 
    48899.}, {"Austria", 48005.}, {"Azerbaijan", 17439.}, {"Bahamas", 
    24555.}, {"Bahrain", 50704.}, {"Bangladesh", 3891.}, {"Barbados", 
    17100.}, {"Belarus", 18000.}};

WordCloud cannot handle data with non-numeric weights (such as {"Andorra", "-"}), so we need to pre-process input data to remove pairs with non-numeric weights:

WordCloud[DeleteCases[{_, Except[_?NonNegative]}]@data]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.