在Python3和Python2.6中,我注意到我可以分割两个整数并得到一个浮点数.你如何得到Python2.6的行为?是否有不同的方法来获取int/int = int?
我试图理解R中的反引号.
据我所知,这在?QuotesR. 的文档页面中没有解释.
例如,在R控制台:
"[["
# [1] "[["
`[[`
# .Primitive("[[")
Run Code Online (Sandbox Code Playgroud)
它似乎返回相当于:
get("[[")
Run Code Online (Sandbox Code Playgroud) .以下dplyr代码中的句点引用了什么?:
(df <- as.data.frame(matrix(rep(1:5, 5), ncol=5)))
# V1 V2 V3 V4 V5
# 1 1 1 1 1 1
# 2 2 2 2 2 2
# 3 3 3 3 3 3
# 4 4 4 4 4 4
# 5 5 5 5 5 5
dplyr::mutate_each(df, funs(. == 5))
# V1 V2 V3 V4 V5
# 1 FALSE FALSE FALSE FALSE FALSE
# 2 FALSE FALSE FALSE FALSE FALSE
# 3 FALSE FALSE FALSE FALSE FALSE
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个包,但是当我运行document()它时,我NAMESPACE not generated by roxygen2. Skipped.试图ggplot2,XML, R6在我的函数中使用包.我按以下方式导入它们:
#' @rdname visualization
#' @param hist_data A table of weather variables with PWS created by hist_data function
#' @param variable A character string of variable name
#' @examples
#' table <- getWeather(city = "San Francisco", state="CA")
#' please <- getConditionsTable(table, "2015-03-09")
#' tab <- hist_data(table, please)
#' head(tab)
#' plot_variable_across_all_pws(hist_data=tab, variable="tempi")
#' @import ggplot2
#' @import XML
#' @import R6
Run Code Online (Sandbox Code Playgroud)
我想知道是什么原因造成了这个错误,Namespace除了我之外什么也没有exportPattern("^[^\\.]")
另外,我正在浏览Hadley的r包书http://r-pkgs.had.co.nz/namespace.html 并且对此行感到困惑: …
如何在OSX Mavericks上清除NetBeans 8.0中的缓存?
以前的帖子建议我删除下的文件
/home/{user}/.netbeans/7.4/var/filehistory 和/home/{user}/.netbeans/7.4/var/log但隐藏文件夹.netbeans似乎在我的电脑上不存在.它移动了吗?
以下Rmarkdown以HTML格式呈现3D图形,但不是PDF格式.
Testing plotly
```{r}
library(plotly)
p <- plot_ly(data=iris, x=~Sepal.Length, y=~Sepal.Width, z=~Petal.Length,
color=~Species, symbols=c(0,1), type="scatter3d", mode="markers")
p
```
Run Code Online (Sandbox Code Playgroud)
图表的快照如下所示:
根据情节帮助页面:
如果您使用带有HTML输出的rmarkdown,则在代码块中打印绘图对象将生成交互式HTML图形.当使用带有非HTML输出的rmarkdown时,打印一个绘图对象将导致图形的png屏幕截图.
有没有办法在PDF中呈现图形图?
注意:错误来自rmarkdown::render():
Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: yes
Note however that the HTML output will …Run Code Online (Sandbox Code Playgroud) 是否有一种方法可以source()将R中的脚本附加为全局环境(.GlobalEnv)的父级?
目前,当我获取脚本时,该脚本的所有变量和函数都出现在我的全局(交互)环境中.我想在搜索路径中包含这些变量和函数,但不包括在内.GlobalEnv.也就是说,我希望源脚本的行为类似于附加的包,它附加在全局环境和基础环境之间(参见高级R 环境中的图)
当R中有重复的列表名称时,这里发生了什么?
l <- list()
l[["A"]] <- 5
l[["B"]] <- 7
l[["C"]] <- 9
names(l) <- c("B", "B", "C")
Run Code Online (Sandbox Code Playgroud)
打字l[["B"]]返回
$B
[1] 5
Run Code Online (Sandbox Code Playgroud)
打字l返回
$B
[1] 5
$B
[1] 7
$C
[1] 9
Run Code Online (Sandbox Code Playgroud)
是否有标准方法来检索"键""B"的所有值?
我想删除在矢量中出现多次的所有项目.具体来说,这包括字符,数字和整数向量.目前,我正在使用duplicated()向前和向后(使用fromLast参数).
是否有更高计算效率(更快)的方法在R中执行此操作?下面的解决方案很简单,可以写入/读取,但执行重复搜索两次似乎效率低下.也许使用额外数据结构的基于计数的方法会更好?
例:
d <- c(1,2,3,4,1,5,6,4,2,1)
d[!(duplicated(d) | duplicated(d, fromLast=TRUE))]
#[1] 3 5 6
Run Code Online (Sandbox Code Playgroud)
如何在此热图中将色标上的0点设置为白色?它是否使用breaks参数?
在以下代码中,white设置为3(或在比例附近):
test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Name", 1:20, sep = "")
pheatmap(test, color = colorRampPalette(c("yellow", "white", "blue"))(50))
Run Code Online (Sandbox Code Playgroud)
r ×8
syntax ×2
3d ×1
arguments ×1
backticks ×1
devtools ×1
dictionary ×1
division ×1
dplyr ×1
duplicates ×1
ggplot2 ×1
key ×1
knitr ×1
list ×1
namespaces ×1
netbeans ×1
netbeans-8 ×1
packages ×1
performance ×1
pheatmap ×1
plotly ×1
python ×1
python-3.x ×1
r-markdown ×1
unique ×1