Using markdown for two or more programming languages
1
5
Entering edit mode
9.4 years ago
Deepak Tanwar ★ 4.2k

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 • 3.2k views
ADD COMMENT
2
Entering edit mode
9.4 years ago
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

ADD COMMENT

Login before adding your answer.

Traffic: 1861 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6