emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* syntax for remote table/cell references
@ 2015-11-30 16:36 Matt Price
  2015-11-30 19:45 ` Thierry Banel
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Price @ 2015-11-30 16:36 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 1603 bytes --]

Hello everyone,

I'm trying to simulate a simple "COUNT" spreadsheet function with the
following two tables:

 #+TBLNAME: grades
| Student               | Precis  | POV PAPER |
|-----------------------+---------+-----------|
| | A-      | A-        |
| | A       | A-/B+     |
| | A-      | A         |
| | B       | B+        |
| | A-      | B+        |
| | A       | A         |
| | A       | A-        |
| | A-      | B+        |
| | A-      | A-        |
| | A       | A         |
| | A       | A         |
| | B+? A-? | A-        |
| | A-      | B+        |
| | B       | B+        |
| | B+      | A-        |
| | A-      | A-        |
| | A       | B+        |
| | B+      | B         |
| | B+      | B+        |
| | B+      | B         |
| | A       | A-        |


| Grade | Count in Precis | Percent |
|-------+--------+---------|
| A+    | #ERROR |         |
| A     | #ERROR |         |
| A-    | #ERROR |         |
| B+    | #ERROR |         |
| B     | #ERROR |         |
| B-    | #ERROR |         |
| C+    | #ERROR |         |
| C     | #ERROR |         |
| C-    | #ERROR |         |
| F     | #ERROR |         |
 #+TBLFM: $2='(length (org-lookup-all $1 '(remote(grades,$2))));E

Sorry for the ugly formatting.
I want to just count the number of As, A-'s, etc, so I can see how badly
I've messed up my distribution, and how much regrading I need to do.  I
don't understand the syntax for referencing cell ranges in org-lookup-all,
nor do I quite get how "remote" works (doesn't seem to be a normal
function?).  Am trying to follow worg tutorials but not having much luck.

Thanks,
Matt

[-- Attachment #2: Type: text/html, Size: 2278 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: syntax for remote table/cell references
  2015-11-30 16:36 syntax for remote table/cell references Matt Price
@ 2015-11-30 19:45 ` Thierry Banel
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry Banel @ 2015-11-30 19:45 UTC (permalink / raw)
  To: emacs-orgmode

You may want to give the orgtbl-aggregate package a try.
  (Available on http://melpa.org,
   documentation here: https://github.com/tbanel/orgaggregate)

It creates the following table:

#+BEGIN: aggregate :table "grades" :cols "Precis count()"
| Precis  | count() |
|---------+---------|
| A-      |       7 |
| A       |       7 |
| B       |       2 |
| B+? A-? |       1 |
| B+      |       4 |
#+END:

Read it as:
 - the "aggregate" function
 - uses the "grades" table,
 - groups rows with the same "Precis" value
 - and "counts()" rows in each group.

There is a wizard to create it:
 - M-x org-insert-dblock:aggregate
 - C-c C-x i aggregate

You may add an ASCII-art plot by hitting:
  C-c " a

#+BEGIN: aggregate :table "grades" :cols "Precis count()"
| Precis  | count() |         |
|---------+---------+---------|
| A-      |       7 | WWWWWWW |
| A       |       7 | WWWWWWW |
| B       |       2 | WW      |
| B+? A-? |       1 | W       |
| B+      |       4 | WWWW    |
#+TBLFM: $3='(orgtbl-ascii-draw $2 0 7 7)
#+END:


Have fun
Thierry


Le 30/11/2015 17:36, Matt Price a écrit :
> Hello everyone,
>
> I'm trying to simulate a simple "COUNT" spreadsheet function with the
> following two tables:
>
>  #+TBLNAME: grades
> | Student               | Precis  | POV PAPER |
> |-----------------------+---------+-----------|
> | | A-      | A-        |
> | | A       | A-/B+     |
> | | A-      | A         |
> | | B       | B+        |
> | | A-      | B+        |
> | | A       | A         |
> | | A       | A-        |
> | | A-      | B+        |
> | | A-      | A-        |
> | | A       | A         |
> | | A       | A         |
> | | B+? A-? | A-        |
> | | A-      | B+        |
> | | B       | B+        |
> | | B+      | A-        |
> | | A-      | A-        |
> | | A       | B+        |
> | | B+      | B         |
> | | B+      | B+        |
> | | B+      | B         |
> | | A       | A-        |
>
>
> | Grade | Count in Precis | Percent |
> |-------+--------+---------|
> | A+    | #ERROR |         |
> | A     | #ERROR |         |
> | A-    | #ERROR |         |
> | B+    | #ERROR |         |
> | B     | #ERROR |         |
> | B-    | #ERROR |         |
> | C+    | #ERROR |         |
> | C     | #ERROR |         |
> | C-    | #ERROR |         |
> | F     | #ERROR |         |
>  #+TBLFM: $2='(length (org-lookup-all $1 '(remote(grades,$2))));E
>
> Sorry for the ugly formatting. 
> I want to just count the number of As, A-'s, etc, so I can see how
> badly I've messed up my distribution, and how much regrading I need to
> do.  I don't understand the syntax for referencing cell ranges in
> org-lookup-all, nor do I quite get how "remote" works (doesn't seem to
> be a normal function?).  Am trying to follow worg tutorials but not
> having much luck. 
>
> Thanks,
> Matt
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-30 19:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-30 16:36 syntax for remote table/cell references Matt Price
2015-11-30 19:45 ` Thierry Banel

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).