From ggrothendieck at myway.com  Tue Mar 15 23:44:08 2005
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Tue Mar 15 23:55:10 2005
Subject: [Rd] Lemon drops
References: <x2r7igon5j.fsf@biostat.ku.dk>
Message-ID: <loom.20050315T233915-735@post.gmane.org>

Peter Dalgaard <p.dalgaard <at> biostat.ku.dk> writes:

: 
: I bumped into the following situation:
: 
: Browse[1]> coef
:             deg0NA deg4NA deg8NA deg0NP deg4NP deg8NP
: (Intercept)    462    510    528    492    660    762
: Browse[1]> coef[,1]
: [1] 462
: Browse[1]> coef[,1,drop=F]
:             deg0NA
: (Intercept)    462
: 
: where I really wanted neither, but
: 
: (Intercept)
:         462
: 
: Anyone happen to know a neat way out of the conundrum?
: 
: I can think of
: 
: rowSums(coef[,1,drop=F])
: 
: or of course
: 
: val <- coef[,1]
: names(val) <- rownames(x))
: 
: but the first one is sneaky and the second gets a bit tedious...
: 


If by tedious you mean its not a single expression
then the basic idea of your solution #2 can be preserved
while doing it in a single expression like this:

structure(coef[,1], .Names = rownames(x))


[Rd] Lemon drops
Gabor Grothendieck