0
require(curl) 
require(RCurl) 
require(downloader) 
temp <- tempfile()
sURL <- "http://www.nseindia.com/archives/equities/bhavcopy/pr/PR240915.zip"

download(sURL,dest="C:/Users/sayantan/Documents/Data",mode="wb")

con <- unzip(temp, extdir="C:/Data") 
data <- matrix(scan(con),ncol=4,byrow=TRUE) 
unlink(temp)

But this code is not working. Any hints would be appreciated.

nTuple
  • 1
  • 2
  • 2
    What is not working? Do you get error messages? At which line? – Stibu Oct 02 '15 at 09:06
  • I unzipped your zipped file and it contained many files. You should choose one. – Miha Trošt Oct 02 '15 at 09:19
  • @nTuple - You may want to check [this](http://stackoverflow.com/questions/3053833/using-r-to-download-zipped-data-file-extract-and-import-data) SO post. – Sandeep Chatterjee Oct 02 '15 at 12:58
  • ` library(RCurl) sURL <- "http://www.nseindia.com/content/equities/block.csv" options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))) x <- getURL(sURL) ## Or ## x <- getURL(sURL, ssl.verifypeer = FALSE) out <- read.csv(textConnection(x)) head(out) ` – nTuple Oct 02 '15 at 13:56
  • @Stibu error is "403 access denied" – nTuple Oct 02 '15 at 14:08
  • I can not reproduce that error. Downloading the file works for me. – Stibu Oct 02 '15 at 16:37

2 Answers2

1

You can use nser package.

library(nser)
bhav("12082020")
Nad Pat
  • 3,129
  • 3
  • 10
  • 20
0

Use Quantmod or Quandl to download data from NSE. I prefer Quandl over Quantmod, as Quandl directly downloads from NSE whereas Quantmod uses Yahoo to get data for Indian equities.

In Quandl simple use NSE's Ticker to get data For example type data <- Quandl("NSE/SBIN", start_date="2005-01-01", end_date="2015-12-31") to get SBI's daily data.