Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created March 16, 2012 16:08

Revisions

  1. ramnathv revised this gist Mar 16, 2012. No changes.
  2. ramnathv revised this gist Mar 16, 2012. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions temp.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    | A | B | C |
    |-------------- | ---------------- | ------------------|
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    |
  3. ramnathv revised this gist Mar 16, 2012. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions temp.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    | | | |
    |-------------- | ---------------- | ------------------ |
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    |-------------- | ---------------- | ------------------ |
    | A | B | C |
    |-------------- | ---------------- | ------------------|
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    |
  4. ramnathv revised this gist Mar 16, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions temp.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    | | | |
    +-------------- + ---------------- + ------------------ +
    |-------------- | ---------------- | ------------------ |
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    +-------------- + ---------------- + ------------------ +
    |-------------- | ---------------- | ------------------ |
  5. ramnathv revised this gist Mar 16, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion temp.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    | | | |
    |-------------- | ---------------- | ------------------ |
    +-------------- + ---------------- + ------------------ +
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    +-------------- + ---------------- + ------------------ +
  6. ramnathv revised this gist Mar 16, 2012. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions temp.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@

    | | | |
    |--------------|----------------|------------------|
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    | | | |
    |-------------- | ---------------- | ------------------ |
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
  7. ramnathv revised this gist Mar 16, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion temp.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@

    | | | |
    |--------------|----------------|------------------|
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    |--------------|----------------|------------------|
  8. ramnathv revised this gist Mar 16, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions temp.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,4 @@
    |--------------|----------------|------------------|
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
    |--------------|----------------|------------------|
  9. ramnathv revised this gist Mar 16, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions temp.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    | asn_trans() | atanh_trans() | boxcox_trans() |
    | date trans() | exp trans() | identity trans() |
  10. ramnathv revised this gist Mar 16, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gfm-table_knit_.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    Here is how you can make a table in GFM format using knitr + ascii

    ```
    <!-- begin.rcode
    render_gfm()
    gfm_table <- function(x, ...){
    @@ -11,8 +12,11 @@ gfm_table <- function(x, ...){
    return(writeLines(y))
    }
    end.rcode -->
    ```

    ```
    <!-- begin.rcode results = 'asis'
    x <- head(mtcars[,1:3])
    gfm_table(x)
    end.rcode -->
    end.rcode -->
    ```
  11. ramnathv revised this gist Mar 16, 2012. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion gfm-table_knit_.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,18 @@
    #
    Here is how you can make a table in GFM format using knitr + ascii

    <!-- begin.rcode
    render_gfm()
    gfm_table <- function(x, ...){
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = 'org'))
    # substitute + with | for table markup
    # TODO: modify regex so that only + signs in markup, like -+- are substituted
    y <- gsub('[+]', '|', y)
    return(writeLines(y))
    }
    end.rcode -->

    <!-- begin.rcode results = 'asis'
    x <- head(mtcars[,1:3])
    gfm_table(x)
    end.rcode -->
  12. ramnathv revised this gist Mar 16, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gfm-table.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Here is how you can make a table in GFM format using knitr + ascii
    Here is how you can make a table in GFM format using knitr + ascii



  13. ramnathv revised this gist Mar 16, 2012. 1 changed file with 17 additions and 13 deletions.
    30 changes: 17 additions & 13 deletions gfm-table.md
    Original file line number Diff line number Diff line change
    @@ -2,19 +2,23 @@



    render_markdown()
    gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
    # substitute + with | for table markup
    # TODO: modify regex so that only + signs in markup,
    # like -+- are substituted
    y <- gsub("[+]", "|", y)
    return(writeLines(y))
    }
    ```r
    render_gfm()
    gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
    # substitute + with | for table markup
    # TODO: modify regex so that only + signs in markup,
    # like -+- are substituted
    y <- gsub("[+]", "|", y)
    return(writeLines(y))
    }
    ```

    x <- head(mtcars[, 1:3])
    gfm_table(x)
    ```r
    x <- head(mtcars[, 1:3])
    gfm_table(x)
    ```

    | | mpg | cyl | disp |
    |-------------------|-------|------|--------|
    @@ -23,4 +27,4 @@
    | Datsun 710 | 22.80 | 4.00 | 108.00 |
    | Hornet 4 Drive | 21.40 | 6.00 | 258.00 |
    | Hornet Sportabout | 18.70 | 8.00 | 360.00 |
    | Valiant | 18.10 | 6.00 | 225.00 |
    | Valiant | 18.10 | 6.00 | 225.00 |
  14. ramnathv revised this gist Mar 16, 2012. 1 changed file with 12 additions and 16 deletions.
    28 changes: 12 additions & 16 deletions gfm-table.md
    Original file line number Diff line number Diff line change
    @@ -2,23 +2,19 @@



    ```r
    gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
    # substitute + with | for table markup
    # TODO: modify regex so that only + signs in markup,
    # like -+- are substituted
    y <- gsub("[+]", "|", y)
    return(writeLines(y))
    }
    ```
    render_markdown()
    gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
    # substitute + with | for table markup
    # TODO: modify regex so that only + signs in markup,
    # like -+- are substituted
    y <- gsub("[+]", "|", y)
    return(writeLines(y))
    }


    {% highlight r %}
    x <- head(mtcars[, 1:3])
    gfm_table(x)
    {% endhighlight %}
    x <- head(mtcars[, 1:3])
    gfm_table(x)

    | | mpg | cyl | disp |
    |-------------------|-------|------|--------|
  15. ramnathv revised this gist Mar 16, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gfm-table.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@



    {% highlight r %}
    ```r
    gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
    @@ -12,7 +12,7 @@ gfm_table <- function(x, ...) {
    y <- gsub("[+]", "|", y)
    return(writeLines(y))
    }
    {% endhighlight %}
    ```


    {% highlight r %}
  16. ramnathv created this gist Mar 16, 2012.
    30 changes: 30 additions & 0 deletions gfm-table.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    # Here is how you can make a table in GFM format using knitr + ascii



    {% highlight r %}
    gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
    # substitute + with | for table markup
    # TODO: modify regex so that only + signs in markup,
    # like -+- are substituted
    y <- gsub("[+]", "|", y)
    return(writeLines(y))
    }
    {% endhighlight %}


    {% highlight r %}
    x <- head(mtcars[, 1:3])
    gfm_table(x)
    {% endhighlight %}

    | | mpg | cyl | disp |
    |-------------------|-------|------|--------|
    | Mazda RX4 | 21.00 | 6.00 | 160.00 |
    | Mazda RX4 Wag | 21.00 | 6.00 | 160.00 |
    | Datsun 710 | 22.80 | 4.00 | 108.00 |
    | Hornet 4 Drive | 21.40 | 6.00 | 258.00 |
    | Hornet Sportabout | 18.70 | 8.00 | 360.00 |
    | Valiant | 18.10 | 6.00 | 225.00 |
    1 change: 1 addition & 0 deletions gfm-table_knit_.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    #