Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: save table output to a matrix


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: save table output to a matrix
Date   Thu, 4 Apr 2013 00:55:00 +0100

Indeed, you said that and I missed it. My excuse is that you didn't
spell that out as requested (-plotmatrix- (SSC)).

You might be able to figure this out from -makematrix- (SJ) but it
could be easier just to write your own loops:

sysuse auto, clear

matrix means = J(5,2,.)

forval i = 1/5 {
forval j = 0/1 {
su mpg if foreign == `j' & rep78 == `i', meanonly
matrix means[`i', `j' + 1] = r(mean)
}
}

On 4 April 2013 00:37, Dimitriy V. Masterov <dvmaster@gmail.com> wrote:
> Nick,
>
> That's exactly what I am doing. I am just having trouble getting the
> mean of z for each of the x*y groups into a matrix form that
> plotmatrix can use.
>
> DVM
>
> On Wed, Apr 3, 2013 at 4:23 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>> Have a look at -plotmatrix- (SSC, Adrian Mander).
>>
>> (I'd rather represent values by bar lengths than colour shades, which
>> could use -tabplot- (SSC).)
>>
>> Nick
>> njcoxstata@gmail.com
>>
>> On 4 April 2013 00:15, Dimitriy V. Masterov <dvmaster@gmail.com> wrote:
>>> Is it possible to save the output of table command to a matrix? I
>>> would like to stick the output of  -table x y, c(mean z)- into a
>>> matrix so that I can use plotmatrix on it.
>>>
>>> The end goal is to produce plots like the average wage ones from
>>>
>>> http://www.adeptanalytics.org/radyakin/stata/graphics/radyakin_graphics.htm
>>>
>>> If there's a better way to do that, please let me know.
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
Nick
njcoxstata@gmail.com
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index