Thanks Gabor, Simon and Marc...I got this to work with the grep() and
rowSums examples you provided.
Mark
On 2/20/06, Marc Schwartz <[EMAIL PROTECTED]> wrote:
> On Mon, 2006-02-20 at 18:41 -0600, [EMAIL PROTECTED] wrote:
> > I have a dataframe called "data" with 5 records (in rows) each of
> >
On Mon, 2006-02-20 at 18:41 -0600, [EMAIL PROTECTED] wrote:
> I have a dataframe called "data" with 5 records (in rows) each of
> which has been scored on each of many variables (in columns).
>
> Five of the variables are named var1, var2, var3, var4, var5 using
> headers. The other variables are
data <- data.frame(var1=c(1,2,3), var2=c(3,4,5), var3=c(4,5,6), foo =
c(100,200,300))
# sum rows with "var" in their name
rowSums(data[, grep("var", names(data))])
1 2 3
8 11 14
[EMAIL PROTECTED] wrote:
> I have a dataframe called "data" with 5 records (in rows) each of
> which has been sc
See:
?rowSums
On 2/20/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I have a dataframe called "data" with 5 records (in rows) each of
> which has been scored on each of many variables (in columns).
>
> Five of the variables are named var1, var2, var3, var4, var5 using
> headers. The other
I have a dataframe called "data" with 5 records (in rows) each of
which has been scored on each of many variables (in columns).
Five of the variables are named var1, var2, var3, var4, var5 using
headers. The other variables are named using other conventions.
I can create a new variable called var