dplyr -- tidyverse, pipes, correlation, same variable across time "a" "b"
Here are two possible rewrites. For the first one, notice how Hmisc::rcorr already computes correlations ($r) and p-values ($P) matrices so you can base all your work from it, provided you extract the rights rows (a_vars) and columns (b_vars) and only keep the diagonal values:

correlations &lt;- rcorr(as.matrix(all_items), type = "spearman")
a_vars &lt;- ends_with("a", vars = names(all_items))
b_vars &lt;- ends_with("b", vars = names(all_items))
all_correlation &lt;- data.frame(
  item    = seq_along(a_vars),
  Result  = diag(correlations$r[a_vars, b_vars]),
  P_Valor = diag(correlations$P[a_vars, b_vars])
)


What I don't like too much about this approach is that it only uses 3 of the 36 correlations that were computed by rcorr. In this second approach, I start by splitting the data into two tables (one for a and one for b) so as to compute only 3 correlations via Map. I also switched from rcorr to the base cor.test which has (IMO) a more intuitive behavior: when given two vectors as input, it computes one correlation, not four.

a &lt;- all_items %&gt;% select(ends_with("a"))
b &lt;- all_items %&gt;% select(ends_with("b"))
cor_test &lt;- Map(cor.test, a, b)
all_correlation &lt;- data.frame(
  item    = seq_along(a),
  Result  = sapply(cor_test, `[[`, "estimate"),
  P_Valor = sapply(cor_test, `[[`, "p.value")
)