> 
> ### Solution 1
> 
> You could use an elisp function to clear the nil. It is not automatic
> and you would have to write a formula for every column but it might
> still be better changing them manually.
> 
> I don't know how to implement it automatically though. 
> 
> #+BEGIN_SRC_elisp
> (defun removenil (x)
> (interactive)
> (replace-regexp-in-string "nil" "" x))
> #+END_SRC
> 


I created this export filter which uses something similar but automatically 
replaces nil with --- on all my documents:

(defun org-export-blanks-filter-latex (row backend info)
  "Replace nil in table with --- in LaTeX export."
  (when (org-export-derived-backend-p backend 'latex)
    (replace-regexp-in-string "nil" "---" row)))

(add-to-list 'org-export-filter-table-row-functions
             'org-export-blanks-filter-latex)


> #+NAME: test2
> #+BEGIN_SRC R :results value  :exports results :colnames yes :hline yes :dir 
> /tmp  :session R-test1
> NA_rep <- function(dt,rep="") {
> dt[is.na(dt)] <- rep
> return(dt)
> }
> NA_rep(data.frame(a=c(1,2,NA),b=c("john","dan","marco")))
> #+END_SRC
> 

This gets more painful if I want to use something like “—“ in numeric columns.

The first approach/export filter is less painful than this.

Thanks,

Vikas


Reply via email to