The Incanter macro $
also pulls rows out of a dataset. In this recipe, we'll see this in action.
For this recipe, we'll use the same dependencies, imports, and data as we did in the Selecting columns with $ recipe.
Similar to how we use $
in order to select columns, there are several ways in which we can use it to select rows, shown as follows:
$
, and pass it the index of the row we want as well as passing :all
for the columns:user=> (i/$ 0 :all chn-data) ("AG.AGR.TRAC.NO" "684290" "738526" "52661" "" "880859" "" "" "" "59657" "847916" "862078" "891170" "235524" "126440" "469106" "282282" "817857" "125442" "703117" "CHN" "66290" "705723" "824113" "" "151281" "669675" "861364" "559638" "191220" "180772" "73021" "858031" "734325" "Agricultural machinery, tractors" "100432" "" "796867" "" "China" "" "" "155602" "" "" "770629" "747900" "346786" "" "398946" "876470" "" "795713" "" "55360" "685202" "989139" "798506" "")
$
with a vector (There's a lot of data, even for three rows, so I won't show it here):(i/$ (range 3) :all chn-data)
user=> (i/$ 0 [:Indicator-Code :1992] chn-data) ("AG.AGR.TRAC.NO" "770629") user=> (i/$ (range 3) [:Indicator-Code :1992] chn-data) | :Indicator-Code | :1992 | |-------------------+--------| | AG.AGR.TRAC.NO | 770629 | | AG.CON.FERT.PT.ZS | | | AG.CON.FERT.ZS | |