Wolfram 语言

更丰富的知识库访问

国家科学基金(NSF)

美国国家科学基金(NSF)在 2015 颁发了将近 12,000 项资金. 在此用 www.nsf.gov/awardsearch/download.jsp 获取的数据对金费、研究者和其所属科研机构进行了分析. 特别是,你可以加载包含该数据的实体库作为 ResourceObject,从而研究金费额度分布、项目申请和所批金费的定量和定性属性,以及所属机构的地理分布.

首先,从 ResourceObject 加载一个包含 NSF 数据的实体库.

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]=

显示三个最高金费的详细内容.

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

查看每个领域的金费总额.

显示完整的 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]=

金费(美元)的首位数字的分布与本福特(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 编码绘制 NSF 奖项.

显示完整的 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 ja ko pt-br ru