Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ylY-00015S-4X for pgsql-general@postgresql.org; Tue, 04 Sep 2012 19:26:28 +0000 Received: from wsip-72-214-29-243.sd.sd.cox.net ([72.214.29.243] helo=joeconway.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ylU-0000Ms-Hh for pgsql-general@postgresql.org; Tue, 04 Sep 2012 19:26:27 +0000 Received: from www.joeconway.com (account jconway [192.168.4.40] verified) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 12269027; Tue, 04 Sep 2012 12:26:21 -0700 Message-ID: <504655DD.4030701@joeconway.com> Date: Tue, 04 Sep 2012 12:26:21 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20071019 Fedora/1.5.0.12-3.fc6 pango-text Thunderbird/1.5.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Aram Fingal CC: Postgres-General General Subject: Re: crosstab References: <1346773199616-5722632.post@n5.nabble.com> <1346784707.8977.6.camel@asus-1001PX.home> <73FF0C6A-965B-4456-BA90-2B8FD1CBC118@multifactorial.com> In-Reply-To: <73FF0C6A-965B-4456-BA90-2B8FD1CBC118@multifactorial.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.9 (/) X-Archive-Number: 201209/96 X-Sequence-Number: 190112 On 09/04/2012 12:17 PM, Aram Fingal wrote: > On Sep 4, 2012, at 2:51 PM, Vincent Veyron wrote: >> see the documentation for Additional Supplied Modules, in your >> case tablefunc : >> >> http://www.postgresql.org/docs/9.1/static/tablefunc.html > > I evaluated tablefunc about a year and a half ago and found that it > was not what I wanted because you have to explicitly list what you > want the columns to be. In some cases, there will be hundreds of > columns in the pivoted table. The Reshape library in R can pivot > tables without you even knowing ahead of time how many columns there > are going to be. Sure, but you cannot return that reshaped table to postgres without specifying the list of columns explicitly. That is because of how postgres works internally and has nothing to do with whether you are using crosstab from tablefunc, PL/R, or some hand-coded SQL statement to build your crosstab. But certainly if you can do all your work on the reshaped table within the R environment, PL/R will be easier to use. Joe -- Joe Conway credativ LLC: http://www.credativ.us Linux, PostgreSQL, and general Open Source Training, Service, Consulting, & 24x7 Support