Question: Using markdown for two or more programming languages
5
gravatar for Deepak Tanwar
4.7 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):
            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")

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?

R knitr shell scripting python perl • 2.0k views
ADD COMMENTlink modified 4.1 years ago • written 4.7 years ago by Deepak Tanwar4.0k
2
gravatar for Jeremy Leipzig
4.7 years ago by
Philadelphia, PA
Jeremy Leipzig18k 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 4.7 years ago by Jeremy Leipzig18k
Please log in to add an answer.

Help
Access

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