#install.packages("plotly")
library(plotly)
packageVersion('plotly')
[1] 4.5.6
Sys.setenv("plotly_username"="bigdatagal")
Sys.setenv("plotly_api_key"="hvginfgvwe")
x <- c(1:36)
set.seed(25)
y = runif(36, 0, 1)
data <- data.frame(x, y)
line_chart_1 <- plot_ly(data, x = ~x, y = ~y, type = 'scatter', mode = 'lines')
#line_chart_1
web_link = plotly_POST(line_chart_1, filename="line-chart-1")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/143
web_link
x = c(1,2,3,4,5,6,7,8,9)
y = c(1,2,3,4,0,4,3,2,1)
z = c(10,9,8,7,6,5,4,3,2)
data <- data.frame(x, y, z)
line_chart_2 <- plot_ly(data, x = ~x) %>%
add_trace(y = ~y, name = 'trace 1', mode = 'line') %>%
add_trace(y = ~z, name = 'trace 2', mode = 'line')
#line_chart_2
web_link = plotly_POST(line_chart_2, filename="line-chart-2")
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
A line object has been specified, but lines is not in the mode
Adding lines to the mode...
A line object has been specified, but lines is not in the mode
Adding lines to the mode...
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/145
web_link
Puromycin
library(plyr)
package <U+393C><U+3E31>plyr<U+393C><U+3E32> was built under R version 3.2.5
Attaching package: <U+393C><U+3E31>plyr<U+393C><U+3E32>
The following objects are masked from <U+393C><U+3E31>package:plotly<U+393C><U+3E32>:
arrange, mutate, rename, summarise
summary_table <- ddply(Puromycin, c("state", "conc"), summarise, rxn_rate=mean(rate))
summary_table
line_chart_3 <- plot_ly(summary_table, x = ~conc, y = ~rxn_rate, type = 'scatter', mode = 'lines', linetype = ~state, color = I('grey'), line = list(width = 5)) %>%
layout(title = 'Reaction Velocity of an Enzymatic Reaction', xaxis = list(title = 'Substrate Concentrations (ppm)'),
yaxis = list (title = 'Average Instantaneous Reaction Rates (counts/min/min)'))
#line_chart_3
web_link = plotly_POST(line_chart_3, filename="line-chart-3")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/147
web_link
setwd('C:/RClass')
The working directory was changed to C:/RClass inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the the working directory for notebook chunks.
usdat<-read.csv("usdat.csv", header=TRUE)
summary_table <- ddply(usdat, c("occupation"), summarise, salary=mean(msalary))
summary_table
bar_chart_1 <- plot_ly(summary_table, x=~occupation, y= ~salary, name = "Bar Chart of Monthly Salary", type="bar", color = I('pink'))
#bar_chart_1
web_link = plotly_POST(bar_chart_1, filename="bar-chart-1")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/149
web_link
bar_chart_2 <- plot_ly(x = c("Banker", "Business Man", "Doctor", "Engineer", "Police", "Professor"), y = c(3775, 8000, 7150, 7400, 3100, 4850),
name = "Average Salaries", type = "bar", color = I('tan'))
#bar_chart_2
web_link = plotly_POST(bar_chart_2, filename="bar-chart-2")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/151
web_link
x = c("Banker", "Business Man", "Doctor", "Engineer", "Police", "Professor")
y = c(3775, 8000, 7150, 7400, 3100, 4850)
data <- data.frame(x, y)
bar_chart_3 <- plot_ly(data, x = ~x, y = ~y, type="bar", marker = list(color = c('rgb(56,55,53)', 'rgb(249,216,214)', 'rgb(56,55,53)', 'rgb(56,55,53)', 'rgb(56,55,53)')))%>%
layout(title = "Average Salaries", xaxis = list(title = "Postition Title"), yaxis = list(title = "Average Salary"))
#bar_chart_3
web_link = plotly_POST(bar_chart_3, filename="bar-chart-3")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/153
web_link
summary_table <- ddply(Puromycin, c("state"), summarise, rxn_rate=mean(rate))
summary_table
pie_chart_1 <- plot_ly(summary_table, labels = ~state, values = ~rxn_rate, type = 'pie')
#pie_chart_1
web_link = plotly_POST(pie_chart_1, filename="pie-chart-1")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/155
web_link
colors <- c('rgb(56,55,53)', 'tan')
pie_chart_2 <- plot_ly(summary_table, labels = ~state, values = ~rxn_rate, type = 'pie',
textposition = 'inside',
textinfo = 'label+percent',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 5)),
showlegend = TRUE) %>%
layout(title = 'Reaction Velocity of an Enzymatic Reaction', xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
#pie_chart_2
web_link = plotly_POST(pie_chart_2, filename="pie-chart-2")
No encoding supplied: defaulting to UTF-8.
Success! Modified your plotly here -> https://plot.ly/~bigdatagal/157
web_link
Want access to the instructional videos that teach you how to make these for yourself? The course is closed at the moment, but will reopen REAL soon. Sign-up on the waitlist and I will let you know when they’ve been released publicly. The waitlist Google doc is here: https://goo.gl/forms/aJLQBoeHwmOxDS4t2
All Rights Reserved (c), Data-Mania, LLC - 2017