% mutate( model = row.names(mtcars) ) You can see I’m selecting 2 columns from mtcars in the first line, then adding a model column with mutate. 3) OK, ready to graph. This sets my data source: tauchart(mtcars) %>% Next line of code says I want a scatter plot, or graph with points, with weight on the x axis and mpg on my y axis: tau_point("wt", "mpg") %>% If you're familiar with ggplot2, note a difference here - you need the column names inside quotation marks with taucharts. I want to add a tootip: tau_tooltip() %>% And I want to add trend line options tau_trendline() Run the code; then open results in a browser window, and voilà. Here’s an interactive scatterplot. You can mouse over points to see underlying data. The tau_tooltip() command added all the columns in the graph's data set to the tooltip. That's why I wanted Models to be in a column. tau_trendline() shows a linear regression line by default. But you can see there are several other options included. That's how easy it is to create an interactive scatterplot with multiple trendline options in R! As promised, here's information about installing taucharts. The package was written by security data scientist Bob Rudis. It's on his GitHub, at his hrbrmstr account. You can install it with the devtools package. But another compelling option if you're lazy and don't want to have to type out the author’s GitHub account name is the githubinstall package. Install it with install.packages("githubinstall") and then run githubinstall::githubinstall("taucharts") It asks you if that's the one you want! Type capital Y for yes and off you go. That’s it for this episode, thanks for watching! For more R tips, follow me on Twitter at @sharon000. So long! ">
关闭字幕 隐藏式字幕可在我们的YouTube频道
你可能会喜欢

[R提示:如何创建taucharts易互动散点图

InfoWorld的|2018年5月14日

在做多有R的这首插曲,莎朗·马克利斯,编辑数据和在IDG通信分析总监,证明它是多么容易使用R语言来创建具有多个趋势线选择一个互动的散点图

版权所有©2018Raybet2

嗨,这是莎朗·马克利斯,编辑数据和分析总监IDG通信。
在做这首插曲更具有R,我们要看看它是多么容易创建具有多个趋势线选择一个互动的散点图。
我将使用taucharts包。而且,对于数据的mtcars数据集熟悉到几乎所有的R用户。它有一些汽车模型的几个数据点。
我会告诉你如何安装taucharts的一点,因为它不是在CRAN呢。包括凉爽的包从GitHub安装,你可能不知道的。但首先,让我告诉你什么taucharts呢,所以你要* *进行安装。
1)我会加载taucharts,mtcars和dplyr。为什么dplyr?因为我总是最后想利用dplyr,当我在R.我工作
库(taucharts)
数据( “mtcars”)
库(dplyr)

2)其次,我会调整mtcars给它我想要的格式。我将创建出由汽车重量每加仑英里的散点图,所以我就保持MPG和重量列。我也想增加一列的车型名称。默认mtcars数据帧模型名称作为列名,但没有自己的专栏。这里是所有的代码:
mtcars < - 选择(mtcars,重量,MPG)%>%
发生变异(
模型= row.names(mtcars)

你可以看到,我选择2列从mtcars在第一线,然后用添加发生变异的模型列。
3)好了,可以画图了。这设置我的数据源:
tauchart(mtcars)%>%
下一行代码说我想要一个散点图,或点图,具有重量上的x轴和MPG在我的Y轴:
tau_point( “重量”, “MPG”)%>%
如果你熟悉GGPLOT2,这里需要注意的一个区别 - 你需要引号内列名与taucharts。
我想添加一个tootip:
tau_tooltip()%>%
我要添加趋势线的选项
tau_trendline()

运行代码;然后打开导致浏览器窗口中,就万事大吉了。下面是一个互动的散点图。
你可以鼠标点看到基础数据。所述tau_tooltip()命令添加所有列在图的数据集的工具提示。这就是为什么我想待的机型,一列。
tau_trendline()示出了通过默认的线性回归线。但是你可以看到有包括几个其他的选择。
这是多么容易创建与r多个趋势线选项的交互式散点图!
如所承诺的,下面介绍了安装taucharts信息。该软件包由安全数据科学家鲍勃Rudis。这是对他GitHub上,在他的hrbrmstr帐户。您可以使用devtools包安装。
但是,如果你懒惰,不希望有型出作者的GitHub的帐户名称的另一个引人注目的选项是githubinstall包。与安装
install.packages( “githubinstall”)
然后运行
githubinstall :: githubinstall( “taucharts”)

它要求你,如果这就是你想要的!
输入大写Y(是)和您去。
这是它为这个情节,感谢收看!对于以上R提示,跟着我在Twitter上@ sharon000。太长!
流行
IDG.tv的精选视频