Is there a way to get gini index values for every node in rpart model?
Gini impurity can be calculated as $1-p_{1}^2-p_{2}^2$ for each node. For example, if node 1 contains 40% '1' and 60% '0', gini = 1 - 0.4^2 - 0.6^2. The information of node size n, number of '0' dev are stored in model$frame. The Gini for each node could be calculated with node size n and number of '0' dev in model$frame:
frame &lt;- model$frame
frame[['gini']] = 1 - (frame[['dev']] / frame[['n']])^2 - (1 - frame[['dev']] / frame[['n']])^2

frame[,c('var','n','dev','gini')]
&gt;      var  n dev      gini
&gt; 1     x3 10   5 0.5000000
&gt; 2 &lt;leaf&gt;  4   1 0.3750000
&gt; 3 &lt;leaf&gt;  6   2 0.4444444

The Gini improvment for each split is calculated by weighted difference between parent and children nodes.
frame[['improve']] = NA
for (i in 1:nrow(frame)) {
  if (frame[i,'var'] == '&lt;leaf&gt;') next

  ind = which(rownames(frame) %in% (as.numeric(rownames(frame)[i])*2+c(0,1)))
  frame[i,'improve'] = frame[i,'n']*frame[i,'gini'] - frame[ind[1],'n']*frame[ind[1],'gini'] - frame[ind[2],'n']*frame[ind[2],'gini']
}

frame[,c('var','n','dev','gini','improve')]
&gt;      var  n dev      gini   improve
&gt; 1     x3 10   5 0.5000000 0.8333333
&gt; 2 &lt;leaf&gt;  4   1 0.3750000        NA
&gt; 3 &lt;leaf&gt;  6   2 0.4444444        NA

#comparing with
model$splits
&gt;    count ncat   improve index  adj
&gt; x3    10    2 0.8333333     1 0.00
&gt; x2    10    2 0.2380952     2 0.00
&gt; x2     0    2 0.7000000     3 0.25