phenance.com
Stock Data Pages | TCA League Tables | About

Analyzing Bitcoin in R - Part 2 - Reading the data

Pub: 04.12.17

| By Anonymous

In Finance.

Tags: coding r bitcoin analysis .

Reading the bitcoin data in to R

Locate the file you donwloaded and unzipped.

In R, change the working directory location so that it is easier to run the read command.

setwd('C:/MyFileLocation/')
rawdata <- read.csv('bitstampUSD.csv', sep = ',', dec = '.', head=FALSE)

If you wish to only load a part of the data, you can add parameters like, skip = 10000, nrows = 10000 to your read.csv command. The example options will skip the first 10,000 rows and read only 10,000 rows respectively.

You can take a look at the data using:

head(rawdata)

It will output something like so:

          V1   V2      V3
1 1315922016 5.80  1.0000
2 1315922024 5.83  3.0000
3 1315922029 5.90  1.0000
4 1315922034 6.00 20.0000
5 1315924373 5.95 12.4521
6 1315924504 5.88  7.4580

Because the data file has no headers, we can give the columns names by typing:

colnames(rawdata) <- c('timesec', 'USD', 'Volume')

Now we are ready to manipulate the data in memory so that it is more usable: Using the xts package and dates

You can also jump to each section directly from here: