* [BABEL] Define tables with names in org? @ 2014-01-09 11:36 Rainer M Krug 2014-01-09 12:30 ` Christian Moe 0 siblings, 1 reply; 6+ messages in thread From: Rainer M Krug @ 2014-01-09 11:36 UTC (permalink / raw) To: emacs-orgmode -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi I would like to define a table with named columns and rows, so that the table is passed to R including the column and row names - is this possible? Thanks, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSzompAAoJENvXNx4PUvmC+oAIAM164A5/ctr7WSkpPCyjpFxs n/Vh/N7lN5ElJA2LAQHJN3yD1ZedLAPQnyOXZEGEIbNQW5y+fBXjM7friLGyueWk KN2B3+2NfiY3e6JfsoqnfLKKz0yFgEBIpJATa4vvRvuvs4XnBAl50ODYSWWTd1tw SLk6hJOteRbrDWLY6S6YVXn75+Bi7KSJfXspvdKv+nt1oU4owPWBBhLsLhukzV6o JIiDVBiAbn5Sb/lhjVt79qw7+2C0KlyT7D1Hijh2efCNKiFbMOf1bs5QSW6NjTs3 mfCzFGYY6KaG7MCTJDSNQWrQB1h7Ge6JU0qedwZg1r9OnuZ0CA9Adb+vImoBKic= =eCtM -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BABEL] Define tables with names in org? 2014-01-09 11:36 [BABEL] Define tables with names in org? Rainer M Krug @ 2014-01-09 12:30 ` Christian Moe 2014-01-09 13:56 ` Rainer M Krug 0 siblings, 1 reply; 6+ messages in thread From: Christian Moe @ 2014-01-09 12:30 UTC (permalink / raw) To: Rainer; +Cc: emacs-orgmode Rainer M Krug writes: > I would like to define a table with named columns and rows, so that > the table is passed to R including the column and row names - is this > possible? Yes, just use the leftmost column for row names and include the header argument :rownames yes. By default, the first row will be used for column names if followed by a hline. Without a hline, use :colnames yes. E.g.: #+name: colrownamestbl | | Alpha | Beta | Gamma | |--------+-------+------+-------| | First | A1 | B1 | C1 | | Second | A2 | B2 | C2 | | Third | A3 | B3 | C3 | #+begin_src R :var data=colrownamestbl :rownames yes :results output colnames(data) rownames(data) #+end_src #+RESULTS: : [1] "Alpha" "Beta" "Gamma" : [1] "First" "Second" "Third" Yours, Christian ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BABEL] Define tables with names in org? 2014-01-09 12:30 ` Christian Moe @ 2014-01-09 13:56 ` Rainer M Krug 2014-01-09 19:25 ` Eric Schulte 0 siblings, 1 reply; 6+ messages in thread From: Rainer M Krug @ 2014-01-09 13:56 UTC (permalink / raw) To: Christian Moe; +Cc: emacs-orgmode -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/09/14, 13:30 , Christian Moe wrote: > > Rainer M Krug writes: > >> I would like to define a table with named columns and rows, so >> that the table is passed to R including the column and row names >> - is this possible? > > Yes, just use the leftmost column for row names and include the > header argument :rownames yes. > > By default, the first row will be used for column names if followed > by a hline. Without a hline, use :colnames yes. > > E.g.: > > #+name: colrownamestbl | | Alpha | Beta | Gamma | > |--------+-------+------+-------| | First | A1 | B1 | C1 > | | Second | A2 | B2 | C2 | | Third | A3 | B3 | C3 > | > > #+begin_src R :var data=colrownamestbl :rownames yes :results > output colnames(data) rownames(data) #+end_src > > #+RESULTS: : [1] "Alpha" "Beta" "Gamma" : [1] "First" "Second" > "Third" Ah - I see. Nice. Thanks. One problem though: I define my variables in the beginning of the document, in a not exported heading so that they don't show in the report, and I want to have some variables with rownames and some without. Is this possible? * INTERNAL VARIABLES :noexport: ** Without column names #+NAME: WITHCOLNAMES | name | |---------------| | NPPyC | | DBBVy | | DBRFy | | DBSSy | | levelstress_2 | #+PROPERTY: var+ WITHCOLNAMES=WITHCOLNAMES ** Without column names #+NAME: COLS_TO_EVAL | name | |---------------| | NPPyC | | DBBVy | | DBRFy | | DBSSy | | levelstress_2 | #+PROPERTY: var+ COLS_TO_EVAL=COLS_TO_EVAL And this should be valid everywhere where I use WITHCOLNAMES and WITHOUTCOLNAMES in R without having to specify :rownames true each time? Rainer > > Yours, Christian > - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSzqp2AAoJENvXNx4PUvmCHqIH/jleiTYI2JhkMRW4d6B7jepF WzbGM4kdCasUPuK7KPKf5eqF/l03SMzvscH7tR3nfDxw9BO7J+r8BwO3U9U2h7+E vu/bTyevqNdLmT1RZGj2fXET6vSM3iLp2uTnC21oqc0AX769HknxoRAycTbD2I3a IKY2S0DHiJfc+wKfzcnRZja7zwIVY6FgyYuD2L3+HYqBDuff0KG+LK3xWh0xAll2 8ldeaQZEB77rzBkehuazDtrAAkuF+r8kfu3d78eY1C5mZ0Vfu5N18QqyHN+UDqtW fpvJbZVPZQdIiIMrNqsfaJvXRkGZUaX9+LW2FdTE92dW3L4mQxcu47O3WMPpNUs= =/iwa -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BABEL] Define tables with names in org? 2014-01-09 13:56 ` Rainer M Krug @ 2014-01-09 19:25 ` Eric Schulte 2014-01-10 9:20 ` Rainer M Krug 0 siblings, 1 reply; 6+ messages in thread From: Eric Schulte @ 2014-01-09 19:25 UTC (permalink / raw) To: Rainer; +Cc: emacs-orgmode, Christian Moe Rainer M Krug <Rainer@krugs.de> writes: > On 01/09/14, 13:30 , Christian Moe wrote: >> >> Rainer M Krug writes: >> >>> I would like to define a table with named columns and rows, so >>> that the table is passed to R including the column and row names >>> - is this possible? >> >> Yes, just use the leftmost column for row names and include the >> header argument :rownames yes. >> >> By default, the first row will be used for column names if followed >> by a hline. Without a hline, use :colnames yes. >> >> E.g.: >> >> #+name: colrownamestbl | | Alpha | Beta | Gamma | >> |--------+-------+------+-------| | First | A1 | B1 | C1 >> | | Second | A2 | B2 | C2 | | Third | A3 | B3 | C3 >> | >> >> #+begin_src R :var data=colrownamestbl :rownames yes :results >> output colnames(data) rownames(data) #+end_src >> >> #+RESULTS: : [1] "Alpha" "Beta" "Gamma" : [1] "First" "Second" >> "Third" > > Ah - I see. Nice. Thanks. > > One problem though: > > I define my variables in the beginning of the document, in a not > exported heading so that they don't show in the report, and I want to > have some variables with rownames and some without. Is this possible? > See "Indexable variable values" under (info "(org)var"), it may help. > > * INTERNAL VARIABLES :noexport: > > ** Without column names > #+NAME: WITHCOLNAMES > | name | > |---------------| > | NPPyC | > | DBBVy | > | DBRFy | > | DBSSy | > | levelstress_2 | > #+PROPERTY: var+ WITHCOLNAMES=WITHCOLNAMES > > ** Without column names > #+NAME: COLS_TO_EVAL > | name | > |---------------| > | NPPyC | > | DBBVy | > | DBRFy | > | DBSSy | > | levelstress_2 | > #+PROPERTY: var+ COLS_TO_EVAL=COLS_TO_EVAL > > And this should be valid everywhere where I use WITHCOLNAMES and > WITHOUTCOLNAMES in R without having to specify :rownames true each time? > > Rainer > > >> >> Yours, Christian >> > > -- > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation > Biology, UCT), Dipl. Phys. (Germany) > > Centre of Excellence for Invasion Biology > Stellenbosch University > South Africa > > Tel : +33 - (0)9 53 10 27 44 > Cell: +33 - (0)6 85 62 59 98 > Fax : +33 - (0)9 58 10 27 44 > > Fax (D): +49 - (0)3 21 21 25 22 44 > > email: Rainer@krugs.de > > Skype: RMkrug -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BABEL] Define tables with names in org? 2014-01-09 19:25 ` Eric Schulte @ 2014-01-10 9:20 ` Rainer M Krug 2014-01-10 12:31 ` Christian Moe 0 siblings, 1 reply; 6+ messages in thread From: Rainer M Krug @ 2014-01-10 9:20 UTC (permalink / raw) To: Eric Schulte; +Cc: emacs-orgmode, Christian Moe -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/09/14, 20:25 , Eric Schulte wrote: > Rainer M Krug <Rainer@krugs.de> writes: > >> On 01/09/14, 13:30 , Christian Moe wrote: >>> >>> Rainer M Krug writes: >>> >>>> I would like to define a table with named columns and rows, >>>> so that the table is passed to R including the column and row >>>> names - is this possible? >>> >>> Yes, just use the leftmost column for row names and include >>> the header argument :rownames yes. >>> >>> By default, the first row will be used for column names if >>> followed by a hline. Without a hline, use :colnames yes. >>> >>> E.g.: >>> >>> #+name: colrownamestbl | | Alpha | Beta | Gamma | >>> |--------+-------+------+-------| | First | A1 | B1 | C1 >>> | | Second | A2 | B2 | C2 | | Third | A3 | B3 | >>> C3 | >>> >>> #+begin_src R :var data=colrownamestbl :rownames yes :results >>> output colnames(data) rownames(data) #+end_src >>> >>> #+RESULTS: : [1] "Alpha" "Beta" "Gamma" : [1] "First" >>> "Second" "Third" >> >> Ah - I see. Nice. Thanks. >> >> One problem though: >> >> I define my variables in the beginning of the document, in a not >> exported heading so that they don't show in the report, and I >> want to have some variables with rownames and some without. Is >> this possible? >> > > See "Indexable variable values" under (info "(org)var"), it may > help. Thanks - but I don't see how this could help me in this case? To correct my example (to fast copy - paste): * INTERNAL VARIABLES :noexport: ** With column names #+NAME: WITH_COLNAMES | | name | |---|---------------| | a | NPPyC | | b | DBBVy | | c | DBRFy | | d | DBSSy | | e | levelstress_2 | #+PROPERTY: var+ WITH_COLNAMES=WITH_COLNAMES ** Without column names #+NAME: WITHOUT_COLNAMES | name | |---------------| | NPPyC | | DBBVy | | DBRFy | | DBSSy | | levelstress_2 | #+PROPERTY: var+ WITHOUT_COLNAMES=WITHOUT_COLNAMES * The code #+begin_src R # here WITH_COLNAMES will have colnames and WITHOUT_COLNAMES not #+end_src * And some more code #+begin_src R # here WITH_COLNAMES will have colnames and WITHOUT_COLNAMES not #+end_src So my concern is not about having rownames where I don't need them, but in having always to enter rownames in the definition (INTERNAL VARIABLES section), as I need them in the WITH_COLNAMES table. Rainer > >> >> * INTERNAL VARIABLES :noexport: >> >> ** Without column names #+NAME: WITHCOLNAMES | name | >> |---------------| | NPPyC | | DBBVy | | DBRFy >> | | DBSSy | | levelstress_2 | #+PROPERTY: var+ >> WITHCOLNAMES=WITHCOLNAMES >> >> ** Without column names #+NAME: COLS_TO_EVAL | name | >> |---------------| | NPPyC | | DBBVy | | DBRFy >> | | DBSSy | | levelstress_2 | #+PROPERTY: var+ >> COLS_TO_EVAL=COLS_TO_EVAL >> >> And this should be valid everywhere where I use WITHCOLNAMES and >> WITHOUTCOLNAMES in R without having to specify :rownames true >> each time? >> >> Rainer >> >> >>> >>> Yours, Christian >>> >> >> -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc >> (Conservation Biology, UCT), Dipl. Phys. (Germany) >> >> Centre of Excellence for Invasion Biology Stellenbosch >> University South Africa >> >> Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 >> 59 98 Fax : +33 - (0)9 58 10 27 44 >> >> Fax (D): +49 - (0)3 21 21 25 22 44 >> >> email: Rainer@krugs.de >> >> Skype: RMkrug > - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSz7tqAAoJENvXNx4PUvmCfYUH/i9HoQyLcOxgrdQbfCjjHbft WHbclImYXB7IPtCFb9j3M07IpwompjJU9fQpiRLudYgFlLqIre9qhM+uSxnVdbYo 82dKVORwfN+oZYG4+EwEV5v/aO7L6DhS90EZCik1e5jRUzLpyMrCHEyJEFZsLmIJ UT4emf4IA6qxhRdt0ulNeuu4TSUyYxD9+otx85hvPXkwCUzYoOJ26KRfAbX2sY/P E3OJ4g+tm7zU8GzH+7KMDCkOROTKlYfIMos+XisrQOrL1MdohVMISdrs63zXQRal WEGcTjMuXCXEoX6KGYmUCc4pS5WdALNObcd/9P3NFUm1Zd8DH95FDkWJT53inpE= =B5r8 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BABEL] Define tables with names in org? 2014-01-10 9:20 ` Rainer M Krug @ 2014-01-10 12:31 ` Christian Moe 0 siblings, 0 replies; 6+ messages in thread From: Christian Moe @ 2014-01-10 12:31 UTC (permalink / raw) To: Rainer; +Cc: emacs-orgmode, Christian Moe, Eric Schulte Rainer M Krug writes: > On 01/09/14, 20:25 , Eric Schulte wrote: >> See "Indexable variable values" under (info "(org)var"), it may >> help. > > Thanks - but I don't see how this could help me in this case? > > To correct my example (to fast copy - paste): > > * INTERNAL VARIABLES :noexport: > > ** With column names > #+NAME: WITH_COLNAMES > | | name | > |---|---------------| > | a | NPPyC | > | b | DBBVy | > | c | DBRFy | > | d | DBSSy | > | e | levelstress_2 | > #+PROPERTY: var+ WITH_COLNAMES=WITH_COLNAMES > > ** Without column names > #+NAME: WITHOUT_COLNAMES > | name | > |---------------| > | NPPyC | > | DBBVy | > | DBRFy | > | DBSSy | > | levelstress_2 | > #+PROPERTY: var+ WITHOUT_COLNAMES=WITHOUT_COLNAMES > > * The code > #+begin_src R > # here WITH_COLNAMES will have colnames and WITHOUT_COLNAMES not > #+end_src > > * And some more code > #+begin_src R > # here WITH_COLNAMES will have colnames and WITHOUT_COLNAMES not > #+end_src > > So my concern is not about having rownames where I don't need them, > but in having always to enter rownames in the definition (INTERNAL > VARIABLES section), as I need them in the WITH_COLNAMES table. I'm not sure I understand the example. You have two otherwise identical tables, with and without rownames. And then you assign them to two variables, WITHOUT_COLNAMES and WITH_COLNAMES. Do you mean WITHOUT_ROWNAMES and WITH_ROWNAMES ? If so, is your problem how to include or exclude the rownames when you assign the table to the respective variables? If so, I don't think it can be done with per-document global settings using +PROPERTY lines. Also, I think (?) that Eric's suggestion to index into the data wouldn't work, because however you slice the data, the issue is not what ends up as the leftmost column, but whether R understands the leftmost column as rownames or not. But I may be misunderstanding something here. You can use the :header-args: property of an outline heading to set :rownames yes or :rownames no for all the *src* blocks under that heading, if that is a meaningful way to structure your document. Going by your examples, though, it probably isn't. It might be simpler to solve the problem in R rather than Org by either adding or removing rownames as needed. Yours, Christian ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-10 12:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-09 11:36 [BABEL] Define tables with names in org? Rainer M Krug 2014-01-09 12:30 ` Christian Moe 2014-01-09 13:56 ` Rainer M Krug 2014-01-09 19:25 ` Eric Schulte 2014-01-10 9:20 ` Rainer M Krug 2014-01-10 12:31 ` Christian Moe
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).