Stock Data Pages | TCA League Tables | About

Analyzing Bitcoin in R - Part 4 - Manipulating the data frequency

Pub: 04.12.17

| By Anonymous

In Finance.

Tags: coding r bitcoin analysis .

We can summarize the Bitcoin transaction level data using xts functionality:

This code generates a new variable called rawdaily which contains the mean USD value each day in the dataset.

rawdaily <- period.apply(rawdata$USD, INDEX = endpoints(rawdata, "days"), FUN = mean)
indexClass(rawdaily) <- "Date"

We change the indexClass of the resulting variable to Date because it is supposed to be at the daily level.

It looks like this:

2011-09-13 5.874167
2011-09-14 5.582143
2011-09-15 5.120000
2011-09-16 4.835000
2011-09-17 4.870000
2011-09-18 4.840000

Plot it to see what it looks like.


It looks like this:

Daily Bitcoin Price

We can also sum up the daily volume in Bitcoins and plot it:

rawdailyvol <- period.apply(rawdata$Volume, INDEX = endpoints(rawdata, "days"), FUN = sum)
indexClass(rawdailyvol) <- "Date"

It looks like this:

Daily Bitcoin Volume

Next, we can set up a typical OHLC (Open, High, Low, Close, Volume) data set for further analysis: Setting up Bitcoin data in OHLC format

You can also jump to each section directly from here: