rd-to-json-parser

0.1.23 • Public • Published

rd-to-json-parser codecov

This module will transform a Rd file describing the documentation of a R package into a JSON.

Installation

npm install --save rd-to-json-parser

Example:

This Rd file:

% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/A3.R
\name{a3.gen.default}
\alias{a3.gen.autocor}
\alias{a3.gen.bootstrap}
\alias{a3.gen.default}
\alias{a3.gen.normal}
\alias{a3.gen.resample}
\title{Stochastic Data Generators}
\usage{
a3.gen.default(x, n.reps)
}
\arguments{
\item{x}{the original (observed) data series.}
 
\item{n.reps}{the number of stochastic repetitions to generate.}
}
\value{
A list of of length \code{n.reps} of vectors of stochastic noise. There are a number of different methods of generating noise:
\item{a3.gen.default}{The default data generator. Uses \code{a3.gen.bootstrap}.}
\item{a3.gen.resample}{Reorders the original data series.}
\item{a3.gen.bootstrap}{Resamples the original data series with replacement.}
\item{a3.gen.normal}{Calculates the mean and standard deviation of the original series and generates a new series with that distribution.}
\item{a3.gen.autocor}{Assumesa first order autocorrelation of the original series and generates a new series with the same properties.}
}
\description{
The stochastic data generators generate stochastic noise with (if specified correctly) the same properties as the observed data. By replicating the stochastic properties of the original data, we are able to obtain the exact calculation of p values.
}
\details{
Generally these will not be called directly but will instead be passed to the \code{data.generating.fn} argument of \code{\link{a3.base}}.
}
\examples{
\author{
  John Doe <john.doe@email.com>, John Smith \email{john.smith@email.com}
}
\donttest{
 # Calculate the A3 results assuming an auto-correlated set of observations.
 # In usage p.acc should be <=0.01 in order to obtain more accurate p values.
 
 a3.lm(rating ~ ., attitude, p.acc = 0.1,
   data.generating.fn = replicate(ncol(attitude), a3.gen.autocor))
 }
 
 ## A general illustration:
 
 # Take x as a sample set of observations for a feature
 x <- c(0.349, 1.845, 2.287, 1.921, 0.803, 0.855, 2.368, 3.023, 2.102, 4.648)
 
 # Generate three stochastic data series with the same autocorrelation properties as x
 rand.x <- a3.gen.autocor(x, 3)
 
 plot(x, type="l")
 for(i in 1:3) lines(rand.x[[i]], lwd = 0.2)
}

will give the following json:

{
   "name":"a3.gen.default",
   "alias":[
      "a3.gen.autocor",
      "a3.gen.bootstrap",
      "a3.gen.default",
      "a3.gen.normal",
      "a3.gen.resample"
   ],
   "title":"Stochastic Data Generators",
   "usage":"a3.gen.default(x, n.reps)",
   "arguments":[
      {
         "name":"x",
         "description":"the original (observed) data series."
      },
      {
         "name":"n.reps",
         "description":"the number of stochastic repetitions to generate."
      }
   ],
   "value":[
      "A list of of length <code>n.reps</code> of vectors of stochastic noise. There are a number of different methods of generating noise:",
      {
         "name":"a3.gen.default",
         "description":"The default data generator. Uses <code>a3.gen.bootstrap</code>."
      },
      {
         "name":"a3.gen.resample",
         "description":"Reorders the original data series."
      },
      {
         "name":"a3.gen.bootstrap",
         "description":"Resamples the original data series with replacement."
      },
      {
         "name":"a3.gen.normal",
         "description":"Calculates the mean and standard deviation of the original series and generates a new series with that distribution."
      },
      {
         "name":"a3.gen.autocor",
         "description":"Assumesa first order autocorrelation of the original series and generates a new series with the same properties."
      }
   ],
   "description":"The stochastic data generators generate stochastic noise with (if specified correctly) the same properties as the observed data. By replicating the stochastic properties of the original data, we are able to obtain the exact calculation of p values.",
   "details":"Generally these will not be called directly but will instead be passed to the <code>data.generating.fn</code> argument of <code><a href=\"a3.base\" rd-options=\"\">a3.base</a></code>.",
   "author": [ 
      { 
         "name": "John Doe", 
         "email": "john.doe@email.com" 
      },
      { 
         "name": "John Smith", 
         "email": "john.smith@email.com" 
       } 
    ],
   "examples":"# Calculate the A3 results assuming an auto-correlated set of observations.\n # In usage p.acc should be <=0.01 in order to obtain more accurate p values.\n\n a3.lm(rating ~ ., attitude, p.acc = 0.1,\n   data.generating.fn = replicate(ncol(attitude), a3.gen.autocor))\n\n ## A general illustration:\n\n # Take x as a sample set of observations for a feature\n x <- c(0.349, 1.845, 2.287, 1.921, 0.803, 0.855, 2.368, 3.023, 2.102, 4.648)\n\n # Generate three stochastic data series with the same autocorrelation properties as x\n rand.x <- a3.gen.autocor(x, 3)\n\n plot(x, type=\"l\")\n for(i in 1:3) lines(rand.x[[i]], lwd = 0.2)"
}

Readme

Keywords

none

Package Sidebar

Install

npm i rd-to-json-parser

Weekly Downloads

0

Version

0.1.23

License

MIT

Last publish

Collaborators

  • ludov