Friday, July 1, 2016

How to parse a XML document in R?

This post shows how to parse a XML document in R. I often use the following simple xml file for my posts and examples.


MyStudentsXMLDoc

If your xml doccument is not on the local server, you can easily place it on the server by copying and pasting the xml document(file) to the local server root (inetpub/wwwroot).

The steps to parse use the xml function xmlTreeParse as shown by the following:
The program uses the readLines() function to read the document as shown and you code these after launching R Studio or R Gui.


MyStudnetsXMLDoc_2

You immediately get the following response as shown here:

$doc
$file
[1] ""

$version
[1

$children
$children$wclass

 
  Linda Jones
  Access, VB5.0
 

 
  Adam Davidson
  Cobol, Mainframe
 

 
  Charles Boyer
  HTML, Photoshop
 

 
  Charles Amos
  Cobol, Mainframe
 


attr(,"class")
[1] "XMLDocumentContent"

$dtd
$external
NULL

$internal
NULL

attr(,"class")
[1] "DTDList"


Thursday, June 30, 2016

How do you install the XML library for R programming?

If you try to run the program to install the library for XML you would get an error as the library is not installed by default.
==
> library(XML)
Error in library(XML) : there is no package called ‘XML’

===
From Main menu Packages click Install package(s)...


You will get at list of Internet sites from where you can install.



Pick a site and the packages available there are displayed (USA[TN] was picked.



Pick XML from the drop-down and you will get the following response:


Once you have the package you can start programming.



What is hierarchical data?

Hierarchical data is a set of data related to each other by hierarchical relationships. Here are some examples:

•Parent ->Children->Grand children
•File system
•Projects tasks
•Links between web pages
•Organizational Structures

You create table in SQL Server with hierarchyID data type to describe data with hierarchical data structure.
Hierarchical data in SQL Servers was first introduced in SQL Server 2008 by providing the hierarchy data type. This data type allows you to store and query hierarchical data.

Here us a screen shot of a table being created with hierarchical data type:



Hierarchical Data           Level in Hierarchy
-----------------------------------------------------
John/Mary Parents             /
Their children                    /1/
Their grand children          /1/2/

A slash separates a parents from their children schematically shown for a family relationship:

Saturday, June 11, 2016

What is the difference between MOUNT and BURN as related to ISO files?

Mount operation creates a directory on the computer which you can treat it as a drive on your computer and access the files therein.

If you want a quick check the contents of the ISO file you would use MOUNT. If you want to create a copy to keep use BURN. A mounted ISO file can be 'unmounted' by choosing to eject as you would eject a regular DVD Drive.


Unmount.png

Burn operation requires you to transfer contents in the .ISO file to be transferred to a DVD which you can then use to install or otherwise, use programs on the DVD. This DVD is for you to Keep.

Windows 10 has the both options to work with an .ISO image file. To find what they are right click the image file to show a drop-down menu.

BurnImageOption.png

What R language items are installed when you install SQL Server 2016?

R langugage support featured in SQL Server the  first time in SQL Server 2016. There were items  at isntallation time that explicitly shows the items.


Ritems_00 in help

The following items (RServer and R Services) were installed according to the above choice.

When you install SQL Server 2016 Developer you will be able to use the following:



SQL@2K16_defaultInstall


Also in the SQL Server Installation Center you can install a stand-alone Microsoft R Server by clicking the link in the installation center, if for some reason you do not find the Microsoft R Server in your search.

RServer_00

After installing SQL Server 2016 Developer edition you should be able to find the R Server related folders/files here:

R_Folder

R is Power full.
 
R is supposed to be the most powerful language when it comes to statistical processing of a large amount of data; machine learning and graphics. It is open, that means world is the player. Microsoft got into R for these strengths but still there were challenges when it comes to volume of data and deployment scenarios. The open software was further tuned for SQL Server to include in Microsoft R Server.

The Microsoft R product consists of the following:
  • Microsoft R Server
  • Microsoft R Client
  • Microsoft R Open
  • SQL Server R Services
You should jump into R if you are going to work with databases and specially analytics. Analytics is the future! believe me.

Sunday, June 5, 2016

Can you install SQL Server 2016 on Windows 10?

Yes, you can.

SQL Server 2016 Developer can only be installed on x64 bit machines.

There are two types of SQL Server 2016 Editions.

Principal Editions
  • Enterprise
  • Standard
  • Web
 Breadth Editions
  • Developer
  • Express

On Windows 10 Pro as well as Home you can install the following:
Standard, Developer and Express

For step-by-step procedure to install SQL Server 2016 visit the following link:
http://hodentekmsss.blogspot.com/2016/06/installing-sql-server-2016-developer.html

Friday, June 3, 2016

How do you convert from Hexadecimal to decimal and decimal to hexadecimal in R?


In R programming, Integer creates an integer vector
as.integer coerces(forces) its argument to integer type

This information is from R documentation:

Character strings containing optional whitespace followed by either a decimal representation or a hexadecimal representation (starting with 0x or 0X) can be converted, as well as any allowed by the platform for real number

Hexadecimal to Decimal Conversion:

Let us take a decimal number 78 and its hexadecimal value is 4E (or 4e)

This is how you code it in R. You have to use the string representation by appending 0x. Note that the function is case sensitive.
---
> as.integer("0x4E")
[1] 78
---

Decimal to Hexadecimal Conversion:

You need to use the sprintf(fmt,...) function as in converting the decimal 78 to hexadecimal. sprintf() is a wrapper for the C-library function.
-----
 > sprintf("%x",78)
[1] "4e"

or

> sprintf("%X",78)

[1] "4E"
-----