I'm looking for a tables / dataframes implementation for Racket. I see tabular-asa, and a quick reading of the docs suggests that it's more or less exactly what I'm looking for. I do see a number of what appear to be documentation bugs. Have other people used this package? I have to say I'm quite pleased with it so far!
I'm currently stuck on "appending" two frames. That is, given two frames, return a new frame containing the rows of the first followed by the rows of the second. It looks to me like I can construct an efficient implementation of this using only the built-in functionality, but I think I need to iterate over the columns of the table, and it seems a bit like something that should be built-in?
Well, it wasn't too bad, after I made the enormous simplifying assumption that all tables have the same set of columns. Let me know if there's a nicer way to do this?
(define (transpose lol)
(apply map list lol))
;; hmm... shouldn't this be built-in?
;; given a list of tables with identical column names, return a new one
;; containing all of the rows of all of the tables
(define (append-tables tables)
(define headers
(map table-header tables))
(unless (= 1 (length (remove-duplicates headers)))
(error 'headers "unimplemented, headers not equal"))
;; things get much easier if the columns are all the same:
(define column-lists (transpose (map table-columns tables)))
(for/fold ([t empty-table])
([column-list (in-list column-lists)])
(table-with-column t (apply sequence-append column-list) #:as
(column-name (first column-list)))))
Hmm... also seems like maybe table equality is not defined as I would expect? Specifically,
(equal?
(table-read/sequence '((a 1) (b 2) (c 3)) '(name number))
(table-read/sequence '((a 1) (b 2) (c 3)) '(name number)))
returns false?
I will also mention the data-frame
package, which I have used and liked.
Interesting and useful-looking package.
But http://docs.racket-lang.org/data-frame/index.html , the link
to the reference documentation, seems to lead to a Page not found message.
-- hendrik