This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Using markdown for two or more programming languages

I know that we could use markdown for the compilation of documents within Rstudio. We could use it for shell programming, python, perl, R, etc.

My question is:

I have python code, that will generate a table for the input file. Please also tell me, how can I import python packages (while generating the markdown documentation) that are not within python and need to be downloaded and installed separately. I tried to import the tabulate package here, but I was not able to do that. Here is the markdown format:

from sys import argv
file = open("DAS217.txt", 'r')

mydict = {}

for line in file.readlines():
    if (line[0] != '#'):
        mylist = line.rstrip().split()
        if  (len(mylist) < 4):
            continue

        key = mylist[2]
        value = mylist[3]

        if (mydict.has_key(key) == False):
            mydict[key] = [value]
        else:
            mydict[key].append(value)

from tabulate import tabulate
table<- tabulate({"synonymous_variant":mydict["synonymous_variant"],"missense_variant": mydict["missense_variant"]}, headers="keys")
</pre>

What I want is, to import the "table" object in the R in a single markdown documentation:

tab<- data.frame(table)
head(tab)

Basic idea is: use multiple programming languages and compile one document out of it and importing the output of one to another, within one markdown script. I want to compile this pdf. Is it possible?

perl shell-scripting python knitr r

1 answer

sudo easy_install tabulate

should install this package into the same python (e.g. /usr/bin/python) that knitr is using. Third-party modules are not "within python", they are just located in Python's search path

Log in to answer this question.