Wolfram言語

Knowledgebaseへの幅広いアクセス

全米科学財団の助成金

全米科学財団(NSF)は,2015年にほぼ12,000件の助成金を与えた.ここでは,www.nsf.gov/awardsearch/download.jspからのデータに基づいて,助成金,調査員,関係機関について調べる.特に,このデータを含む実体ストアをResourceObjectとしてロードして,助成金のサイズの分布,提案書と助成金の定量的特性と定性的特性,関連機関の地理的散らばりについて調べる.

まず,NSFデータを含む助成金の実体ストアをResourceObjectからロードする.

In[1]:=
Click for copyable input
nsfStore = ResourceData[ ResourceObject[ Association[ "Name" -> "National Science Foundation Grants - 2015", "UUID" -> "0e9655df-86b6-4e20-bcc9-87365562357b", "ResourceType" -> "DataResource", "Version" -> "1.0.0", "Description" -> "Data on National Science Foundation grants (and \ associated investigators and institutions) awarded in the the year \ 2015.", "ContentSize" -> Quantity[0, "Bytes"], "ContentElements" -> {"EntityStore"}]]]
Out[1]=

このセッションのためにストアを登録する.

In[2]:=
Click for copyable input
PrependTo[$EntityStores, nsfStore];

ストアからの"NSFGrant"実体タイプを使って使用可能な助成金特性を見る.

In[3]:=
Click for copyable input
EntityValue["NSFGrant", "Properties"]
Out[3]=

ランダムに選択した助成金についてのデータを返す.

完全なWolfram言語入力を表示する
In[4]:=
Click for copyable input
TextGrid[List @@@ (RandomEntity["NSFGrant"]["PropertyAssociation"] // SortBy[#, ByteCount] & // Normal // Take[#, 16] &), Dividers -> All, Background -> {Automatic, {{LightBlue, None}}}] // TraditionalForm
Out[4]//TraditionalForm=

助成金の額の分布をプロットする.

In[5]:=
Click for copyable input
awardAmounts = EntityValue["NSFGrant", "AwardAmount"];
In[6]:=
Click for copyable input
Histogram[awardAmounts, ScalingFunctions -> {Identity, "Log"}, PlotRange -> All, AxesLabel -> Automatic]
Out[6]=

最も高額の3つの助成金の詳細を表示する.

In[7]:=
Click for copyable input
EntityValue[ EntityClass["NSFGrant", "AwardAmount" -> TakeLargest[3]], "Dataset"]
Out[7]=

NSFの分野ごとの助成金総額を調べる.

完全なWolfram言語入力を表示する
In[8]:=
Click for copyable input
TextGrid[SortBy[{#1, Total[#2[[All, -1]]]} & @@@ Normal[GroupBy[ EntityValue["NSFGrant", {"Directorate", "AwardAmount"}], First]], Last] // DeleteMissing[#, 1, 2] & // Reverse, Alignment -> {{Left, Decimal}, Automatic}, Dividers -> All, Background -> {Automatic, {{LightBlue, None}}}]
Out[8]=

助成金額(米ドル)の1桁目の数字をベンフォード(Benford)の法則で比較する.

完全なWolfram言語入力を表示する
In[9]:=
Click for copyable input
With[{$s = QuantityMagnitude[ EntityValue["NSFGrant", EntityProperty["NSFGrant", "AwardAmount"]]]}, ListPlot[{Rest[Sort[Tally[IntegerDigits[#][[1]] & /@ $s]]], Table[{d, Length[$s] Log10[1 + 1/d]}, {d, 9}]}, Filling -> Axis, PlotLegends -> {"NSF grants", "Benford"}]]
Out[9]=

数学,物理学,化学の助成金で最も多く使われた単語のワードクラウドを作る.

In[10]:=
Click for copyable input
keywords = EntityValue[EntityClass["NSFGrant", "Division" -> #], "KeywordTally"] & /@ {"Division Of Mathematical Sciences", "Division Of Physics", "Division Of Chemistry"};
In[11]:=
Click for copyable input
Row[WordCloud[ Merge[Association @@ (Rule @@@ #) & /@ DeleteMissing[#], Total]] & /@ keywords]
Out[11]=

ZIPコードと金額によって全米科学財団の助成金を可視化する.

完全なWolfram言語入力を表示する
In[12]:=
Click for copyable input
amountsandinsts = EntityValue[ "NSFGrant", {EntityProperty["NSFGrant", "AwardAmount"], EntityProperty["NSFGrant", "Institution"]}];
In[13]:=
Click for copyable input
amountsinzips = (#[[1, 1]] -> Total[#[[All, -1]]]) & /@ Normal[GroupBy[Transpose[{EntityValue[ amountsandinsts[[All, -1]], EntityProperty["NSFInstitution", "ZIPCode"] ], amountsandinsts[[All, 1]]}], First]][[All, -1]];
In[14]:=
Click for copyable input
GeoRegionValuePlot[SortBy[amountsinzips, Last], ColorFunction -> ColorData["GreenPinkTones"], GeoRange -> Entity["Country", "UnitedStates"], PlotLegends -> Histogram]
Out[14]=

関連する例

de en es fr ko pt-br ru zh