Thursday, 16 June 2016

List of Packages:

the following packages are useful for Data Analytics more easier:

To load data

RODBCRMySQLRPostgresSQLRSQLite - If you'd like to read in data from a database, these packages are a good place to start. Choose the package that fits your type of database.
XLConnectxlsx - These packages help you read and write Micorsoft Excel files from R. You can also just export your spreadsheets from Excel as .csv's.
foreign - Want to read a SAS data set into R? Or an SPSS data set? Foreign provides functions that help you load data files from other programs into R.
R can handle plain text files – no package required. Just use the functions read.csv, read.table, and read.fwf. If you have even more exotic data, consult the CRAN guide to data import and export.

To manipulate data

dplyr - Essential shortcuts for subsetting, summarizing, rearranging, and joining together data sets. dplyr is our go to package for fast data manipulation.
tidyr - Tools for changing the layout of your data sets. Use the gather and spread functions to convert your data into the tidy format, the layout R likes best.
stringr - Easy to learn tools for regular expressions and character strings.
lubridate - Tools that make working with dates and times easier.

To visualize data

ggplot2 - R's famous package for making beautiful graphics. ggplot2 lets you use thegrammar of graphics to build layered, customizable plots.
ggvis - Interactive, web based graphics built with the grammar of graphics.
rgl - Interactive 3D visualizations with R
htmlwidgets - A fast way to build interactive (javascript based) visualizations with R. Packages that implement htmlwidgets include:

googleVis - Let's you use Google Chart tools to visualize data in R. Google Chart tools used to be called Gapminder, the graphing software Hans Rosling made famous in hie TED talk.

To model data

car - car's Anova function is popular for making type II and type III Anova tables.
mgcv - Generalized Additive Models
lme4/nlme - Linear and Non-linear mixed effects models
randomForest - Random forest methods from machine learning
multcomp - Tools for multiple comparison testing
vcd - Visualization tools and tests for categorical data
glmnet - Lasso and elastic-net regression methods with cross validation
survival - Tools for survival analysis
caret - Tools for training regression and classification models

To report results

shiny - Easily make interactive, web apps with R. A perfect way to explore data and share findings with non-programmers.
R Markdown - The perfect workflow for reproducible reporting. Write R code in yourmarkdown reports. When you run render, R Markdown will replace the code with its results and then export your report as an HTML, pdf, or MS Word document, or a HTML or pdf slideshow. The result? Automated reporting. R Markdown is integrated straight into RStudio.
xtable - The xtable function takes an R object (like a data frame) and returns the latex or HTML code you need to paste a pretty version of the object into your documents. Copy and paste, or pair up with R Markdown.

For Spatial data

spmaptools - Tools for loading and using spatial data including shapefiles.
maps - Easy to use map polygons for plots.
ggmap - Download street maps straight from Google maps and use them as a background in your ggplots.

For Time Series and Financial data

zoo - Provides the most popular format for saving time series objects in R.
xts - Very flexible tools for manipulating time series data sets.
quantmod - Tools for downloading financial data, plotting common charts, and doing technical analysis.

To write high performance R code

Rcpp - Write R functions that call C++ code for lightning fast speed.
data.table - An alternative way to organize data sets for very, very fast operations. Useful for big data.
parallel - Use parallel processing in R to speed up your code or to crunch large data sets.

To work with the web

XML - Read and create XML documents with R
jsonlite - Read and create JSON data tables with R
httr - A set of useful tools for working with http connections

To write your own R packages

devtools - An essential suite of tools for turning your code into an R package.
testthat - testthat provides an easy way to write unit tests for your code projects.
roxygen2 - A quick way to document your R packages. roxygen2 turns inline code comments into documentation pages and builds a package namespace.

Tuesday, 19 April 2016

Matrices

Matrices:

Here matrices are two dimensions arrays. 

> matrixone = matrix(c(1,2,3,4,5,6,7,8), nrow=2, ncol = 4, byrow=TRUE)

here we assigning a matrix 
> print(matrixone)
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8

Lists

Lists

A container of different elements or different data types.

> listone <- list(c(1,2,3),"your name",TRUE,2L,1+2i,2.36)
Assigning different type of values in a container called listone which is of type list

Printing the listone
> print(listone)

Output
[[1]]
[1] 1 2 3

[[2]]
[1] "your name"

[[3]]
[1] TRUE

[[4]]
[1] 2

[[5]]
[1] 1+2i

[[6]]
[1] 2.36


Vectors

Vectors:

--------------------------------------------------------------------------------------------------------------------------
there are six types in the Vectors:
--------------------------------------------------------------------------------------------------------------------------

Logical -- when  a value is true or false, then it shoes the class of the value:
for example:

> vectorone <- TRUE

assigning TRUE to the vectorone variable 

> print(vectorone)
printing thevariable

Output
[1] TRUE


> print(class(vectorone))
printing the class of the vectorone
 
Output:
[1] "logical"

--------------------------------------------------------------------------------------------------------------------------
> vectorone <- 26.5

assigning the numerical value for variable vectorone

> print(vectorone)
printing the vectorone

Output
[1] 26.5

> print(class(vectorone)) 
printing the class of the vector

Output:
[1] "numeric"


> vectorone <- 23

assigning the value for the vectorone

> print(vectorone)
printing the value

Output:
[1] 23

> print(class(vectorone))
printing the class of the variable
 Output
[1] "numeric"
------------------------------------------------------------------------------------------------------------------------- 
> vectortwo<-"your name"

Assigning the value for vectortwo

> print(vectortwo)
printing the value of the variable

Output
[1] "your name"

printing the class of the variable

Output
> print(class(vectortwo))
[1] "character"
--------------------------------------------------------------------------------------------------------------------------
 vector3 <- 1L
Assigning the value for the vector3

printing the vector3
> print(vector3)

Output:
[1] 1

printing the class of the vector3 
> print(class(vector3))

Output:
[1] "integer"

--------------------------------------------------------------------------------------------------------------------------
> vector4 <- 1+2i
assigning the complex value for the vector4

> print(vector4)
printing the vector4

Output
[1] 1+2i

printing the class of the vector3

> print(class(vector4))

Output
[1] "complex"
--------------------------------------------------------------------------------------------------------------------------
To create vector more than one value , we use c() it is a combiner function then the syntax ill be in the following format, 

> vector5 <- c("firstname",2L,23.6,2+3i,TRUE)
assigning multiple values to the vector5

> print(vector5)
printing vector5

Output
[1] "firstname" "2"         "23.6"      "2+3i"      "TRUE" 

Printing the class of the vector5:

Output    
> print(class(vector5))
[1] "character"




Data Types:



We don't declare the data types in front of the variables. the Data type of the R language will become the Data type of the Variable 

Some of the Data type Objects in the R language are:
1. Vectors.
2.Matrices.
3. Data Frames.
4. Lists.
5. Arrays.
6. Factors.


Lets have go further for the vectors.

Strings:

In script write commands:

#writing the strings in R language
myname <- "your name"
print (myname)

Output:
[1] "your name"

Explanation:
In the first line # is defining the comment. R supports only the single line comment.

Here myname is a variable which stores the the string literal "your name"
and when a print command issued on the myname then it prints the string literal.

Here you can use single quotes or double quotes . the output will be same:

myname <- 'your name'
print(myname)

Output:
[1] "your name"

Explanation:
In the output the string literal will be in the double quotes in the two cases.

--------------------------------------------------------------------------------------------------------------------------
> vectortwo<-"your name"

Assigning the value for vectortwo

> print(vectortwo)
printing the value of the variable

Output
[1] "your name"

printing the class of the variable

Output
> print(class(vectortwo))
[1] "character"

First R Script:

Create a new Script and Write the following:
 print('Hai world welcome to R language tutorials')

the Output will be:
[1] "Hai world welcome to R language tutorials"