The attached code file provides an easy basic interface to the Wolfram Alpha API. Inspired by the wolframalpha module available for Python.
source("wa_lib.R")
This requires an app ID. Sign into your wolfram account to generate one.
app_id <- ""
wa <- WolframClient(app_id)
result <- wa$query("pi")
## Querying wolfram alpha...
library(knitr)
kable(result$get_plaintext(), format = "html")
pod | id | plaintext |
---|---|---|
Input | Input | pi |
Decimal approximation | DecimalApproximation | 3.1415926535897932384626433832795028841971693993751058... |
Property | Property | pi is a transcendental number |
Number line | NumberLine | |
Continued fraction | ContinuedFraction | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, ...] |
Alternative representations | AlternativeRepresentations:MathematicalFunctionIdentityData | pi = 180 ° |
Alternative representations | AlternativeRepresentations:MathematicalFunctionIdentityData | pi = -i log(-1) |
Alternative representations | AlternativeRepresentations:MathematicalFunctionIdentityData | pi = cos^(-1)(-1) |
Series representations | SeriesRepresentations:MathematicalFunctionIdentityData | pi = 4 sum_(k=0)^infinity (-1)^k/(2 k+1) |
Series representations | SeriesRepresentations:MathematicalFunctionIdentityData | pi = -2+2 sum_(k=1)^infinity 2^k/(binomial(2 k, k)) |
Series representations | SeriesRepresentations:MathematicalFunctionIdentityData | pi = sum_(k=0)^infinity (50 k-6)/(2^k binomial(3 k, k)) |
Integral representations | IntegralRepresentations:MathematicalFunctionIdentityData | pi = 2 integral_0^infinity 1/(t^2+1) dt |
Integral representations | IntegralRepresentations:MathematicalFunctionIdentityData | pi = 4 integral_0^1 sqrt(1-t^2) dt |
Integral representations | IntegralRepresentations:MathematicalFunctionIdentityData | pi = 2 integral_0^infinity (sin(t))/t dt |
result <- wa$query("ion equivalents of zinc chloride")
## Querying wolfram alpha...
kable(result$get_plaintext(), format = "html")
pod | id | plaintext |
---|---|---|
Input interpretation | Input | zinc chloride | ion equivalents |
Result | IonProperties:ChemicalData | Zn^(2+) (zinc) | 1 Cl^(-) (chloride) | 2 |
Hey, that's a super useful bridge between WA and R. I thought this would be great to package up and upload on CRAN for convenience. Here, I changed it slightly and pushed a packaged version of this script on Git.
It would be great if you could upload this either to CRAN or your Git, so that people can just
install_github()
orinstall()
! Here: https://github.com/ArtificialBreeze/wolfRamalpha (tested, works as is)