Here're a couple alternatives if you want to use the index instead of
the variable name:
# Reproducible data frame
a1 <- 1:15
a2 <- letters[1:15]
a3 <- LETTERS[1:15]
a4 <- 15:1
a5 <- letters[15:1]
df <- data.frame(a1, a2, a3, a4, a5)
df
# a1 a2 a3 a4 a5
# 1 1 a A 15 o
# 2 2 b B 14
On 03/28/2014 05:27 PM, Luana Marotta wrote:
Hi all,
I'm trying to find out what is the equivalent in R for the following Stata
code:
Let's say I have the variables: a1, a2, a3, a4, a5
forvalues i = 1(1)5 {
summary a`i'
}
That is, I want to know how to loop through variables in R.
Hi L
2 matches
Mail list logo