Skip to main content

An extract of the BIU R functionality, without any dependency on biu

Project description

biuR

An extract of the BIU R functionality, without any dependency on biu.

Install

pip install biuR

How to use

import biur.wrapper
import matplotlib.pylab as plt
import pandas as pd
R = biur.wrapper.R()

Push some data

R.push(n=5000, mean=10, var=6, question="How many apples do you eat per day?")

Run some commands

R("""
    dist <- rnorm(n, mean, var)
    print(mean(dist))
""", get=False)
[1] 9.883113

Get some data

dist = R.get("dist")
dist_alt = R("dist", get=True) # the get parameter is True by default
_ = plt.hist(dist, bins=50)

png

Do it all at the same time

dist = R("""rnorm(n, mean, var)""",
         push=dict(n=5000, mean=10, var=6, question="How many apples do you eat per day?"))
_ = plt.hist(dist, bins=50)

png

Dataframes also work as expected

df  = pd.DataFrame(dist.reshape(500,10), columns=["C%d" % (i+1) for i in range(10)])
df2 = R("""df*2""", push=dict(df=df))
df2.describe()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10
count 500.000000 500.000000 500.000000 500.000000 500.000000 500.000000 500.000000 500.000000 500.000000 500.000000
mean 19.664014 19.844730 21.397676 20.316715 19.915327 20.479617 20.606811 20.671680 19.978792 20.363389
std 12.082482 11.829318 11.756079 12.228085 11.878440 12.626452 11.560421 12.360558 12.425381 12.545196
min -28.185781 -11.851668 -14.899577 -15.940758 -23.651277 -17.811376 -13.721199 -17.615716 -18.421257 -22.172515
25% 11.909300 12.042162 13.257103 12.162031 12.214617 11.778717 12.920449 12.178726 11.741882 12.254866
50% 19.316743 19.564965 20.988669 20.498992 19.765990 20.166144 20.278277 20.020587 20.054040 20.275403
75% 27.771991 28.085157 29.174137 28.447980 28.061103 28.312460 28.384447 28.869581 28.670938 29.319559
max 53.658666 59.740534 58.531887 57.402270 55.351012 52.867132 56.286094 55.596513 50.953409 58.989365

Some additional stuff

Dates

from datetime import datetime
R("""print(today)""", push=dict(today=datetime.today()), get=False)
[1] "2021-11-15 14:59:14 EET"

Dictionaries

Note that individual numbers do not exist in R (everything is a vector) so it is impossible to transform this back perfectly.

R.push(mydict={"A":10, "B":20, "C":40})
R("""
    mydict$D <- 60
    mydict""")
{'A': [10], 'B': [20], 'C': [40], 'D': [60.0]}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biur-0.0.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

biur-0.0.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file biur-0.0.1.tar.gz.

File metadata

  • Download URL: biur-0.0.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for biur-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1965a3c2772c34575427702d9a36be375ac30795ae6365476005db091e4b9cef
MD5 4589ae3caad1233ceca190b0d273c506
BLAKE2b-256 081d69f64a1d24395d912b9af902fef1e75748bb041497966fad183a9ea8f7de

See more details on using hashes here.

File details

Details for the file biur-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: biur-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for biur-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d3688bd86fb47a457ed522de6c60c524f31852eb632e97fbe408fba8de9bc47
MD5 85ec9389d5651f1fe7d655166d44f9b8
BLAKE2b-256 ea513166269877a4604605a5f875743664265e587317a385e906a96313795207

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page