GP.
GP.

Reputation: 487

org-babel how to get rid of [1] in the output of an R code that is the input of a shell one

The [#] marker is included by R as a label to the index of each element, but, unfortunately, this is a problem when this output is used as input of another block.

I already tried to get rid of it by using cat but this way I got no result. Any idea about that?

#+name: aux
#+begin_src R :results output
a <- c(-2, 2, 4, 5, 6, 7, -6, -4, 99, 101, -9, 2, 0, 1, 3, 123, 345, 678, 987, 543, 3567)
a
#+end_src

#+begin_src shell :results output :var ls=aux
for l in $ls; do
    echo "processing $l"
done;
#+end_src

#+RESULTS:
#+begin_example
processing [1]
processing -2
processing 2
processing 4
processing 5
processing 6
processing 7
processing -6
processing -4
processing 99
processing 101
processing -9
processing 2
processing 0
processing 1
processing 3
processing [16]
processing 123
processing 345
processing 678
processing 987
processing 543
processing 3567
#+end_example

Upvotes: 1

Views: 84

Answers (1)

Rorschach
Rorschach

Reputation: 32426

cat should work, you just have to print to stdout,

#+begin_src R :results output
a <- c(-2, 2, 4, 5, 6, 7, -6, -4, 99, 101, -9, 2, 0, 1, 3, 123, 345, 678, 987, 543, 3567)
cat(a, file=stdout())
#+end_src

#+RESULTS: aux
: -2 2 4 5 6 7 -6 -4 99 101 -9 2 0 1 3 123 345 678 987 543 3567

Alternatively, using :results value verbatim would work.

Upvotes: 1

Related Questions