This text will appear as bold!
This text will also appear bold!
This text will appear in italics!
This text will also appear italics!
This text will appear as bold! This text will also appear bold!
This text will appear in italics! This text will also appear italics!
This text will appear as bold!
This text will also appear bold!
This text will appear in italics!
This text will also appear italics!
Ordered Lists
Unordered Lists - 1
Image
Comment using backticks

Image
Insert Table
| aaa | bbbbbbbb | cccc | ddddddddddddd |
|---|---|---|---|
| 1 | 2 | 3 | 4 |
| 11 | 22 | 33 | 44 |
| 111 | 222 | 333 | 444 |
Make tables alligned
| Tables | Are | Cool |
|---|---|---|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
# for development
knitr::opts_chunk$set(echo=TRUE, eval=TRUE, error=TRUE, warning=TRUE, message=TRUE, cache=FALSE, tidy=FALSE, fig.path='figures/')
# for production
#knitr::opts_chunk$set(echo=TRUE, eval=TRUE, error=FALSE, warning=FALSE, message=FALSE, cache=FALSE, tidy=FALSE, fig.path='figures/')
** Load Libraries**
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
Read Nifty
dfrNifty <- read.csv("C:\\Program Files\\R\\R-3.4.1\\nifty-data.csv",header = T,stringsAsFactors = FALSE)
head(dfrNifty)
## RecDate Mkt Series Sector Symbol NameOfTheSecurityInNse
## 1 2014-12-01 N EQ Cement ACC ACC LIMITED
## 2 2014-12-01 N EQ Cement AMBUJACEM AMBUJA CEMENTS LTD
## 3 2014-12-01 N EQ FMCG ASIANPAINT ASIAN PAINTS LIMITED
## 4 2014-12-01 N EQ FinSrvc AXISBANK AXIS BANK LIMITED
## 5 2014-12-01 N EQ Auto BAJAJ-AUTO BAJAJ AUTO LIMITED
## 6 2014-12-01 N EQ FinSrvc BANKBARODA BANK OF BARODA
## PrevClose OpenPrice HighPrice LowPrice ClosePrice TradeValue TradeQty
## 1 1475.35 1476.00 1479.7 1461.15 1470.95 202553784 137735
## 2 229.90 229.25 233.5 228.55 230.35 348745207 1512068
## 3 744.70 753.95 802.2 753.10 797.05 2576774020 3291847
## 4 481.20 484.40 493.2 481.15 489.15 2267475272 4634567
## 5 2640.80 2642.50 2660.8 2613.05 2636.30 527142941 199683
## 6 1087.20 1091.00 1104.7 1074.35 1082.65 1447645708 1328730
## IndSec CoprInd Trades X52W_High X52W_Low
## 1 Y 6422 1564.65 970.15
## 2 Y 19712 243.80 150.10
## 3 Y 68366 802.20 460.20
## 4 Y 53177 2043.05 369.05
## 5 Y 10121 2695.00 1793.20
## 6 Y 29489 1104.70 511.15
Filter Nifty
dfrNifty.filt <- filter(dfrNifty,grepl("^TATA",dfrNifty$NameOfTheSecurityInNse))
head(dfrNifty.filt)
## RecDate Mkt Series Sector Symbol NameOfTheSecurityInNse
## 1 2014-12-01 N EQ Auto TATAMOTORS TATA MOTORS LIMITED
## 2 2014-12-01 N EQ Power TATAPOWER TATA POWER CO LTD
## 3 2014-12-01 N EQ Metals TATASTEEL TATA STEEL LIMITED
## 4 2014-12-01 N EQ InfoTech TCS TATA CONSULTANCY SERV LT
## 5 2014-12-02 N EQ Auto TATAMOTORS TATA MOTORS LIMITED
## 6 2014-12-02 N EQ Power TATAPOWER TATA POWER CO LTD
## PrevClose OpenPrice HighPrice LowPrice ClosePrice TradeValue TradeQty
## 1 533.50 539.85 539.85 530.10 536.00 2722536582 5093458
## 2 93.00 92.50 93.25 90.00 90.45 220499479 2416386
## 3 473.35 475.00 475.00 459.15 461.15 1429327906 3075179
## 4 2643.00 2650.50 2700.00 2645.25 2692.95 2545619658 948177
## 5 536.00 535.70 535.80 528.10 528.95 1886210374 3555543
## 6 90.45 90.45 91.70 90.05 90.65 174722314 1923777
## IndSec CoprInd Trades X52W_High X52W_Low
## 1 Y 134346 550.7 332.10
## 2 Y 9698 115.6 71.40
## 3 Y 47384 579.9 332.00
## 4 Y 50222 2839.7 1983.05
## 5 Y 42325 550.7 332.10
## 6 Y 9930 115.6 71.40
show summary
summary(dfrNifty)
## RecDate Mkt Series
## Length:2100 Length:2100 Length:2100
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
## Sector Symbol NameOfTheSecurityInNse
## Length:2100 Length:2100 Length:2100
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
## PrevClose OpenPrice HighPrice LowPrice
## Min. : 78.25 Min. : 78.8 Min. : 79.5 Min. : 76.55
## 1st Qu.: 274.12 1st Qu.: 273.5 1st Qu.: 278.3 1st Qu.: 269.95
## Median : 629.25 Median : 626.0 Median : 632.2 Median : 619.00
## Mean :1012.49 Mean :1011.5 Mean :1022.9 Mean : 999.07
## 3rd Qu.:1425.33 3rd Qu.:1424.9 3rd Qu.:1435.2 3rd Qu.:1399.78
## Max. :4359.85 Max. :4387.0 Max. :4402.2 Max. :4292.60
## ClosePrice TradeValue TradeQty
## Min. : 78.25 Min. :4.755e+07 Min. : 23606
## 1st Qu.: 273.74 1st Qu.:5.790e+08 1st Qu.: 795035
## Median : 625.17 Median :1.038e+09 Median : 1904322
## Mean :1010.47 Mean :1.518e+09 Mean : 3087293
## 3rd Qu.:1423.83 3rd Qu.:1.798e+09 3rd Qu.: 4067533
## Max. :4349.85 Max. :8.269e+10 Max. :41580102
## IndSec CoprInd Trades X52W_High
## Length:2100 Length:2100 Min. : 2010 Min. : 115.6
## Class :character Class :character 1st Qu.: 20160 1st Qu.: 400.3
## Mode :character Mode :character Median : 34954 Median : 829.8
## Mean : 44814 Mean :1278.3
## 3rd Qu.: 60083 3rd Qu.:1776.6
## Max. :283121 Max. :4402.2
## X52W_Low
## Min. : 71.4
## 1st Qu.: 228.1
## Median : 369.1
## Mean : 670.5
## 3rd Qu.: 855.4
## Max. :2880.0
include Plots You can also embed plots, for example:
plot(pressure)