Question: Using markdown for two or more programming languages
gravatar for Deepak Tanwar
5.6 years ago by
Deepak Tanwar4.0k
ETH Zürich, Switzerland
Deepak Tanwar4.0k wrote:

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):

        key = mylist[2]
        value = mylist[3]
        if (mydict.has_key(key) == False):
            mydict[key] = [value]

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

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

tab<- data.frame(table)

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?

R knitr shell scripting python perl • 2.3k views
ADD COMMENTlink modified 5.1 years ago • written 5.6 years ago by Deepak Tanwar4.0k
gravatar for Jeremy Leipzig
5.6 years ago by
Philadelphia, PA
Jeremy Leipzig19k wrote:
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 COMMENTlink written 5.6 years ago by Jeremy Leipzig19k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1776 users visited in the last hour