I would like to mix data.table pipelining with magrittr pipelining. I can go from data.table to %>% but I can't figure out how to get back to [][] data.table style pipelining. Here's an example: > tbl = data.table(grp=c(1,1,1,2,2,2,3,3,3,4,4), y=rnorm(11)) > tbl grp y 1: 1 0.08150 2: 1 1.51330 3: 1 -0.26154 4: 2 -0.12746 5: 2 0.10747 6: 2 0.16
我想将data.table流水线与magrittr流水线混合。 我可以从data.table去%>%,但我不知道如何回到[] [] data.table样式流水线。 这是一个例子: > tbl = data.table(grp=c(1,1,1,2,2,2,3,3,3,4,4), y=rnorm(11)) > tbl grp y 1: 1 0.08150 2: 1 1.51330 3: 1 -0.26154 4: 2 -0.12746 5: 2 0.10747 6: 2 0.16502 7: 3 0.54139 8: 3 -0.04194 9: 3 0.02373 10: 4 2.007
When running the code of this example I'm getting the following error in the last line: Error in matrix(mean(range), ncol = ncol(x), nrow = nrow(x), dimnames = dimnames(x)) : non-numeric matrix extent However, I remember having seen other cases some months ago where the library arulesViz worked whit categorical data type. landing.data=read.csv2("http://archive.ics.uci.edu/ml/machine-lear
在运行这个例子的代码时,在最后一行中出现以下错误: 矩阵中的错误(平均值(范围),ncol = ncol(x),nrow = nrow(x),dimnames = dimnames(x)):非数值矩阵范围 但是,我记得几个月前看过其他案例,arulesViz是白皮书的分类数据类型。 landing.data=read.csv2("http://archive.ics.uci.edu/ml/machine-learning-databases/shuttle-landing-control/shuttle-landing-control.data", se
I want to find the location of the script .R files which are used for computation in R. I know that by typing the object function, I will get the code which is running and then I can copy and edit and save it as a new script file and use that. The reason for asking to find the foo.R file is Curiosity Know what is the algorithm used in the numerical computations More immedietly, the func
我想找到用于R中计算的脚本.R文件的位置。 我知道通过输入对象函数,我将得到正在运行的代码,然后我可以复制并编辑它并将其另存为新的脚本文件并使用它。 要求查找foo.R文件的原因是 好奇心 知道数值计算中使用的算法是什么 更直接地,我使用的stats包中的函数正在运行两个参数的结果,而不是其他参数,并且必须弄清楚如何使其工作。 R显示的错误意味着脚本文件中可能需要进行一些修改。 如果可能的话,我正在寻找
Neither of these show the source code of pnorm function, stats:::pnorm getAnywhere(pnorm) How can i see the source code of pnorm ? sum (..., na.rm = FALSE) .Primitive("sum") .Primitive("sum") function (..., na.rm = FALSE) .Primitive("sum") methods(sum) no methods were found and, how can I see source code of the sum function? The R source code of pnorm is: function (q, mean = 0, sd = 1
这些都没有显示pnorm函数的源代码, stats:::pnorm getAnywhere(pnorm) 我怎样才能看到pnorm的源代码? sum (..., na.rm = FALSE) .Primitive("sum") .Primitive("sum") function (..., na.rm = FALSE) .Primitive("sum") methods(sum) no methods were found 并且,如何查看sum函数的源代码? pnorm的R源代码是: function (q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) .Call(C_pnorm, q, mean, sd, l
I like using the R package qcc. This is a great package for the quality control professional. The package generates a lot of cool graphics. I know how to modify basic graphs in R with the par() command. The graphics in the qcc package are somewhat unique and I don't always know what elements make up the graphics. How do I determine what elements make up the graphics so I can modify them
我喜欢使用R包qcc。 这是质量控制专业人员的一个很好的包装。 该软件包生成很多很酷的图形。 我知道如何用par()命令修改R中的基本图形。 qcc软件包中的图形有点独特,我并不总是知道构成图形的元素。 如何确定组成图形的元素,以便我可以使用par()命令和参数对其进行修改。 在下面的代码中使用这个简单的因果图。 我将如何去修改线条颜色,线条粗细,字体等? 我不知道作者在开发软件包时是如何构建这个的。 librar
I've made a couple of simple plots with ggplot2 and grouped them with grid.arrange() (from package grid.extra) to join the plots in one single figure. I'm creating the title via the grid.arrange() function with argument top , as below: library(ggplot2) library(gridExtra) ... tiff("Figure5.tiff", height = 20, width = 16, units = "cm", compression = "lzw", res = 300) Fig5 <
我用ggplot2创建了几个简单的图,并将它们与grid.arrange() (来自package grid.extra)分组在一起,以便将这些图添加到一个图中。 我通过带参数top的grid.arrange()函数创建标题,如下所示: library(ggplot2) library(gridExtra) ... tiff("Figure5.tiff", height = 20, width = 16, units = "cm", compression = "lzw", res = 300) Fig5 <- grid.arrange(plot5, plot5Ran, ncol = 2, t
I want to create the graph, like at the link for the previous topic, but receive error: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Font family not found in Windows font database Though fonts() shows "Humor Sans" and "xksd" are installed. I use Windows 7 64bit, R 2.15.2 RStudio 0.96.331. Any suggestions how to fix it? I think I had the same probl
我想创建图表,就像在上一个主题的链接中一样,但收到错误: 在grid.Call(L_textBounds,as.graphicsAnnot(x $ label),x $ x,x $ y,:在Windows字体数据库中找不到字体系列 虽然fonts()显示“幽默Sans”和“xksd”被安装。 我使用Windows 7 64bit,R 2.15.2 RStudio 0.96.331。 任何建议如何解决它? 我想前一段时间我也有同样的问题。 这是我所做的: 将Humor-Sans字体文件放入您的项目文件夹中,并确保您的工作
I wonder how to add regression line equation and R^2 on the ggplot . My code is library(ggplot2) df <- data.frame(x = c(1:100)) df$y <- 2 + 3 * df$x + rnorm(100, sd = 40) p <- ggplot(data = df, aes(x = x, y = y)) + geom_smooth(method = "lm", se=FALSE, color="black", formula = y ~ x) + geom_point() p Any help will be highly appreciated. Here is one solution #
我想知道如何在ggplot上添加回归直线方程和R ^ 2。 我的代码是 library(ggplot2) df <- data.frame(x = c(1:100)) df$y <- 2 + 3 * df$x + rnorm(100, sd = 40) p <- ggplot(data = df, aes(x = x, y = y)) + geom_smooth(method = "lm", se=FALSE, color="black", formula = y ~ x) + geom_point() p 任何帮助将不胜感激。 这是一个解决方案 # GET EQUATION AND R-SQUARED AS STRING # S
I am trying to make a bar graph where the largest bar would be nearest to the y axis and the shortest bar would be furthest. So this is kind of like the Table I have Name Position 1 James Goalkeeper 2 Frank Goalkeeper 3 Jean Defense 4 Steve Defense 5 John Defense 6 Tim Striker So I am trying to build a bar graph that would show the number of players according to pos
我正在试图制作一个条形图,其中最大的酒吧最接近y轴,最短的酒吧最远。 所以这就像我的桌子一样 Name Position 1 James Goalkeeper 2 Frank Goalkeeper 3 Jean Defense 4 Steve Defense 5 John Defense 6 Tim Striker 所以我正在试图建立一个条形图,根据位置显示球员的数量 p <- ggplot(theTable, aes(x = Position)) + geom_bar(binwidth = 1) 但是图上显示了守门员先防守吧,最后是前锋
A very newbish question, but say I have data like this: test_data <- data.frame( var0 = 100 + c(0, cumsum(runif(49, -20, 20))), var1 = 150 + c(0, cumsum(runif(49, -10, 10))), date = seq(as.Date("2002-01-01"), by="1 month", length.out=100) ) How can I plot both time series var0 and var1 on the same graph, with date on the x-axis, using ggplot2 ? Bonus points if you make var0
一个非常新鲜的问题,但说我有这样的数据: test_data <- data.frame( var0 = 100 + c(0, cumsum(runif(49, -20, 20))), var1 = 150 + c(0, cumsum(runif(49, -10, 10))), date = seq(as.Date("2002-01-01"), by="1 month", length.out=100) ) 如何使用ggplot2在同一图表上绘制时间序列var0和var1 ,并在x轴上绘制date ? 如果您制作var0和var1不同的颜色,并且可以包含图例,则var0奖励积分! 我确信这