# NOT RUN {
# Test data
dframe <- data.frame(
category = factor(c(rep("Sports",50), rep("Home", 150), rep("Fashion", 100))),
season = factor(c(rep(c("Fall","Winter"),150))),
sales = c(runif(100,min=0,max=100), runif(100,min=50,max=200), runif(100,min=50,max=80))
)
dframe$visitors <- dframe$sales * runif(300, min=0.5, max=1.5)
# Bar chart with product category on x-axis and total sales on y-axis
cql_str <- "CHART bar X category Y sales";
cql(dframe, cql_str);
# Bar chart but facet x-axis with both category and season of the year
cql_str <- "CHART bar X category, season Y sales X_label 'Product\\nCategory'";
cql(dframe, cql_str);
# Bar chart with 95% confidence interval error bars
cql_str <- "CHART bar X category, season Y sales ConfInt '.95'";
cql(dframe, cql_str);
# Bar chart but specify the colors for each season
cql_str <- "CHART bar X category, season Y sales Colorset '#FF9900, #990099'";
cql(dframe, cql_str);
# Scatter plot of number of visitors and sales
cql_str <- "CHART scatter X visitors Y sales";
cql(dframe, cql_str);
# Scatter plot but facet by season
cql_str <- "CHART scatter X visitors, season Y sales";
cql(dframe, cql_str);
# Scatter plot with fitted line (no SE curves)
cql_str <- "CHART scatter X visitors, season Y sales Fit 'false'";
cql(dframe, cql_str);
# }
Run the code above in your browser using DataLab