Displaying 1 result from an estimated 1 matches for "male_heart".
2007 Feb 09
1
Using variable names in for loops - Generating plots semi-automatically from a series of variables Partly solved
...s not
lines(Female[i]~Age)
dev.off()
}
detach(data)
--
This doesn't work, of course, because Male[i] is a character variable
which is the same as the name of a column in the dataframe, but it is
not the column itself, nor is it the name of the column.
> eval(expression(Male[1]))
[1] "Male_HEART"
So, how can I refer here to something in the dataframe?
This next code works, but by kind of bypassing my real question :-
--
Diseases <- c("Cardiovascular disease" ... ,"All causes")
Male <- names(data)[grep("Male",names(data))]
Female <- names(data)[...