| To: | "bhavin toprani" <b_toprani@hotmail.com> |
|---|---|
| Subject: | Re: proportion of states life expectancy > 70 |
| From: | "Douglas Bates" <bates@stat.wisc.edu> |
| Date: | Thu, 6 Dec 2007 12:52:54 -0600 |
| Cc: | "s-news@lists.biostat.wustl.edu" <s-news@lists.biostat.wustl.edu> |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=mS3x4i8XiXrnXALYQ2i80ZuQLkOogwJGol/n1PXZL3c=; b=LQjihVIC1b9JJZrZLGv69iotx23/hyC5NFAj9RVDMvCBSA/vUBhP8KJCoyoUi2V1XIVoyvtc3pLDl1IkdNunmj7lGOtiVQTpVvw7z4TB6q+jurpkIE2yAKaA8woKr7vMWR/YGpy11zqa/f1TxcLXGR9ad+ACppizAhKQcagR2Oc= |
| Domainkey-signature: | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=PRtWyfJ67qHbSwkjbxegfsLkcABXO81anueRUg9Wnr245s2naCj5F607DH3qkhrHnT0WB2ugIKJnOrYawOEapQjrf41gMPxpZAtsCx7l8m84tO6YhXhVCJOOsopXZAZl8yuH7zA6AOLzsA+Cw7MHgyKlIFiqDi4bdqdtz4Ku7tY= |
| In-reply-to: | <BAY114-W117569695E180FAC4F7DB98D770@phx.gbl> |
| References: | <BAY114-W117569695E180FAC4F7DB98D770@phx.gbl> |
On Nov 27, 2007 10:38 PM, bhavin toprani <b_toprani@hotmail.com> wrote: > Dear all, > Could you please suggest an easy command eg, if, for ,etc to find the > proportion of states having life expectancy greater than 70? > Thanks for your help in advance. > example of dataframe > Life.Exp > Alabama 69.05 > Alaska 69.31 > Arizona 70.55 > Arkansas 70.66 > California 71.71 > Colorado 72.06 I haven't seen a response to this. The general way to approach this is to sum the logical indicators. When the TRUE/FALSE values are used in an arithmetic expression they are converted to 1/0 values. Suppose that your data frame is called mydf. Then the expression sum(mydf$Life.Exp > 70)/nrow(mydf$Life.Exp) should do it. If you want to be careful about the possibility of missing data you should use sum(mydf$Life.Exp > 70, na.rm = TRUE)/sum(!is.na(mydf$Life.Exp)) instead. |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Printing GraphSheet to a pdf file, Tony Plate |
|---|---|
| Next by Date: | Re: proportion of states life expectancy > 70, Tim Hesterberg |
| Previous by Thread: | Printing GraphSheet to a pdf file, Data Analytics Corp. |
| Next by Thread: | Re: proportion of states life expectancy > 70, Tim Hesterberg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |