user1357015
user1357015

Reputation: 11696

rChart gives a blank screen

Here is my data:

    rawData <- structure(list(Date = c("4/30/2015", "5/1/2015", "5/2/2015", 
"5/3/2015", "5/4/2015", "5/5/2015"), Amount = c(23L, 43L, 32L, 
43L, 43L, 32L)), .Names = c("Date", "Amount"), class = "data.frame", row.names = c(NA, 
-6L))

The following comes out blank:

rPlot(Amount~Date, data = rawData, type = 'bar')

I have no idea why -- I'm new to rCharts though -- I usually use ggplot2.

Thanks for your help

Upvotes: 3

Views: 103

Answers (1)

LyzandeR
LyzandeR

Reputation: 37889

I 've seen as many tutorials or blogs as I could find about rCharts and there is no example of rPlot being used with a bar type anywhere with a data set similar to yours (there is only one here but it is being used as a histogram with binned variables and counts which is not the same).

The rPlot function works fine if you change the bar type to line, which makes me think that you cannot use rPlot in this case.

#this works
p1 <- rPlot(x='Date', y='Amount', data = rawData, type = 'line')
p1

It seems to me that if you want to plot a barchart the best thing is to use the vPlot (or hPlot for a horizontal bar) function which works fine:

p1 <- vPlot(x='Date', y='Amount', data = rawData, type = 'bar')
p1

enter image description here

And actually as per @Shiva 's message below you can also do (type = 'column' will print it vertically):

hPlot(x='Date', y='Amount', data = rawData, type = 'column')

Which actually looks even better:

enter image description here

Upvotes: 2

Related Questions