AI News, DataScience+


The package xplain is designed to help users interpret the results of their statistical analyses.

The basic idea behind xplain is simple: Package authors or other people interested in explaining statistics provide interpretation information for a statistical method (i.e.

Providing xplain interpretation information can be interesting for: xplain offers support for interpretation information in different languages and on different levels of difficulty.

It looks like this: This simple example assume we are providing interpretation information for the lm() function (for linear regression models) included in the stats package.

The language of each XML element can be defined with the lang attribute, like in the follwing example: The value of the lang attribute is the ISO country code of the language.

The numbering is cumulative in the sense that if you call xplain with difficulty level 2 it will show you both the text entries for level 1 and for level 2.

If no language is specified when xplain is called then xplain tries to find the language of the user's work environment and uses this language;

Now have a look at the following extract from an xplain XML file: In this example, we access the return object of the lm function, more specifically, the vector df.residual that holds the residual degrees of freedom of the estimated linear model.

If, for example, the user works with the Anscombe dataset from the car package and runs the regression then the expression @$df.residual from the XML file would translate to my.model$df.residual.

element (which refers to a specific object within the return object of the explained function) then you can easily access this result object with the ## symbol.

Here, we refer to the current object within the return object of the lm function (and this current object is df.residual because we are in the XML element <result name="df.residual">), so ##=my.model$df.residual.

This way, you can even include more complex R structures like in the following example that works with an if construct: Here, the message is only shown if the \(R^2\) of the regression does not exceed 0.15.

Look at the following example: Instead of writing which is complex and hard to read, you can start by defining some reusable code sections with define: With the name attribute of the define tag you assign a name to the R code expression.

in fact, the apostrophes in the indep_vars and the dep_vars definitions above are normal text than has been inserted to make sure all the variables are enclosed in apostrophes when they are printed).

The above XML produces the following output (don't worry too much about the call of xplain(), we will discuss later on in more detail how to work with the xplain() function): When you look at the XML code, you'll see that we use a mix of plain text and R code.

For the Notepad++ editor I have developed a syntax highlighting scheme that considers the specifics of xplain XML files, for example the definition of placeholders with <define>

Arguments and return values The function xplain() has the following arguments: Let us have a closer look at each of them: While xplain has quite some arguments, the only obligatory argument is call, the function call that you want to have explained.

So, a very simple call of xplain() for a linear regression would look like this: If we wanted to incldue the result of another function, let's say summary() we would use the addfun argument.

In this example we don't want to hand over any additional arguments (apart from our lm object, the result of the linear regression) to summary() but we want to have a nice header above the output.

To achieve this, we could run the following call of xplain(): Since addfun, addfun.args and adfun.title are all vectors, we could include multiple functions here.

There are basically two main ways to work with xplain(): Look at the following example of such a wrapper function: The function lm.xplain() has the same interface as the explained function lm(), so the user can call it exactly as he calls lm().

Its call looks like this: The arguments of xplain.overview() are the following ones: xplain.overview() returns a data frame that contains the summary information on the xplain XML file.

each of these elements it provides some standard information like the package of the explained function, the function's name, the language and complexity level of the element, and also the element of the explained functions'

If the Result object column is empty this means that the respective title or text element is not related to any particular element of the return object of the explained function but directly belongs to the return object or the function as such.

Aport from this standard information, the data frame returned by xplain.overview() also shows If you use xplain.overview() with show.text=TRUE then the resulting data frame has an additional column containg the text of the <title>...</title>

XML DOM Tutorial

The DOM defines a standard for accessing and manipulating documents: The HTML DOM defines a standard way for accessing and manipulating HTML documents.

This example changes the value of an HTML element with id="demo": This example changes the value of the first <h1>

element you still have to specify the array index [0], because the getElementsByTagName() method always returns an array.

element in an XML document: The XML file used in the examples below is books.xml.

element in books.xml: This example loads a text string into an XML DOM object, and extracts the info from it with JavaScript: The DOM models XML as a set of node objects.

XML Elements

An XML element is everything from (including) the element's start tag to (including) the element's end tag.

In XML, you can indicate an empty element like this: You can also use a so called self-closing tag: The two forms produce identical results in XML software (Readers, Parsers, Browsers).

XML elements must follow these naming rules: Any name can be used, no words are reserved (except xml).

Look at the following XML example: Let's imagine that we created an application that extracted the <to>, <from>, and <body>

elements from the XML document to produce this output: Imagine that the author of the XML document added some extra information to it: Should the application break or crash?

Web data tutorial: Retrieving and displaying XML data |

This tutorial explains how to retrieve and display XML data using a client-side jQuery solution, as well as how to use that data to show four paintings in an online ...

Part 8 XML validation against XSD

Link for all dot net and sql server video tutorial playlists Link for slides, code samples and text version of the ..

XML and XSLT Transformation Explained

Explaining the technical details of transforming XML to HTML using XSLT. Digital literacy and source literacy for technical communicators.

Dynamic XPath in Selenium using Different Approaches

Do you know how to write Dynamic xpath in Selenium Webdriver? In this video, we will mainly discuss XPath different methods which will help us to write ...

Python and XML Training | How to Create XML with Python and ElementTree

This Python training tutorial located at from Firebox Training demonstrates how to create a simple XML file using Python ..

Part 20 Element Operators in LINQ

Link for all dot net and sql server video tutorial playlists Link for slides, code samples and text version of the ..

Part 18 GroupBy in LINQ

Link for all dot net and sql server video tutorial playlists Link for slides, code samples and text version of the ..

Sql server query plan cache

Text version of the video Slides ..

REGEX Tutorial Regular Expressions

Best Regular Expressions Book : Here I explain how Regular Expressions are used. I cover all of the codes and what they are used for

LINQ-05-What is LINQ to XML or XLINQ

In this Video we have covered the following Interview Question and answer related to LINQ What is LINQ to XML (XLINQ) ? How to Read XML using LINQ to ...