(找不到重复)
有谁知道原因:
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#PFormatString
'p'字符串格式为百分比,在用百分号进行格式化之前将值乘以100?
百分比("P")格式说明符
百分比("P")格式说明符将数字乘以100并将其转换为表示百分比的字符串.精度说明符表示所需的小数位数.如果省略精度说明符,则使用当前PercentDecimalDigits属性提供的默认数值精度.
反正是否有格式化之前阻止值乘以100?而不是做:
(value / 100).ToString("p")
Run Code Online (Sandbox Code Playgroud) 我通过从流程中删除一步来进行一些优化...
> library(microbenchmark)
> microbenchmark(paste0("this","and","that"))
Unit: microseconds
expr min lq mean median uq max neval
paste0("this", "and", "that") 2.026 2.027 3.50933 2.431 2.837 34.038 100
> microbenchmark(.Internal(paste0(list("this","and","that"),NULL)))
Unit: microseconds
expr min lq mean median uq max neval
.Internal(paste0(list("this", "and", "that"), NULL)) 1.216 1.621 2.77596 2.026 2.027 43.764 100
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好...
但后来我注意到它list被定义为
function (...) .Primitive("list")
Run Code Online (Sandbox Code Playgroud)
我试图进一步"简化"
> microbenchmark(.Internal(paste0(.Primitive("list")("this","and","that"),NULL)))
Unit: microseconds
expr min lq mean median uq max neval
.Internal(paste0(.Primitive("list")("this", "and", "that"), NULL)) 3.241 3.242 4.66433 3.647 3.648 80.638 100
Run Code Online (Sandbox Code Playgroud)
而且时间增加了! …
有没有办法sliderInput在更改其相应input$变量之前等待几秒钟?我有一个控制图形的条形图,该图形需要在值更改时重新呈现。我知道带有提交按钮的解决方法,我希望避免使用它。
我有一个~2亿行,7列csv文件.我需要删除行2636759.这个文件是7.7GB,超过内存容量.我对R最熟悉,但也可以在python或bash中做到这一点.
我无法在一次操作中读取或写入此文件.在磁盘上以增量方式构建此文件的最佳方法是什么,而不是尝试在内存中执行此操作?
我试图在SO上找到它,但只能找到如何使用足够小的文件来读取/写入内存,或者使用位于文件开头的行.
Creating a plot by adding one column at a time works just fine
exPlot <- plot_ly(data.table(matrix(1:9,ncol = 3)))
theCols <- c("V2","V3")
exPlot <- exPlot %>% add_lines(x = ~V1, y = ~get(theCols[1]), type = "scatter",mode = "lines")
exPlot <- exPlot %>% add_lines(x = ~V1, y = ~get(theCols[2]), type = "scatter",mode = "lines")
exPlot
Run Code Online (Sandbox Code Playgroud)
but if I try to do the same thing in a for loop, it only displays the second trace, overwriting the first one.
exPlot <- plot_ly(data.table(matrix(1:9,ncol = 3))) …Run Code Online (Sandbox Code Playgroud) R中用于将2维矩阵减少到1行的默认行为是实际删除维度.这可以通过在矩阵搜索结束时放置drop = FALSE来"固定".有没有办法使这个默认?我有一个很长的程序,只是意识到我必须在大约100个地方添加它,如果没有...我搜索?选项,?'['和?矩阵无济于事.
我想为类别包装标签。Plotly 正在显示我想要换行的空格。当字符串太长时,它只会以 45 度角显示它们。
plot_ly(x =c("this\nand\nthat\nand\nall\nof\nthe\nthings",
"the\nother\nstring\nthat\nmakes\nthis\nway\ntoo\nlong"),
y = c(1,2), name = "testing",type = "bar")
Run Code Online (Sandbox Code Playgroud)
我正在使用闪亮 / R
我有一个表格,类别标题很长,但我希望它们在悬停时出现.
library(data.table)
library(plotly)
testTable <-
structure(list(ACTUAL_LIFT = c(1.34, 1.21, 1.03, 2.39, 1.49,
1.32, 1.27, 1.32), PROMOTION_TITLE = c("longggggggggggggg title1",
"longggggggggggggg title2", "longggggggggggggg title3", "longggggggggggggg title4",
"longggggggggggggg title5", "longggggggggggggg title6", "longggggggggggggg title7",
"longggggggggggggg title8")), .Names = c("ACTUAL_LIFT", "PROMOTION_TITLE"
), class = c("data.table", "data.frame"), row.names = c(NA, -8L
))
a <- list(
title = "Promo"
)
b <- list(
title = "Lift"
)
p <- plot_ly(
x = testTable[, PROMOTION_TITLE],
y = (testTable[, ACTUAL_LIFT] - 1) * 100,
name = "Lifts",
type …Run Code Online (Sandbox Code Playgroud) 我正在通过Kx技术培训课程,有一条线说
"Enlist适用于所有数据对象;任何数据对象的结果都是单项目列表,其项目是该对象.例如"
enlist(2 5;3.5 10 12)
,(2 5;3.5 10 12)
Run Code Online (Sandbox Code Playgroud)
该结果不是浮点数的一维列表.它是一个二维列表,其中唯一的元素是浮点数的一维列表
但是,当我完全按照QI做的例子时,不要那样做.我明白了
enlist(2 5;3.5 10 12)
2 5 3.5 10 12
Run Code Online (Sandbox Code Playgroud)
所以下面的工作,我期望不能工作给出所谓的结构的解释:
enlist(2 5;3.5 10 12)+1
3 6 4.5 11 13
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?
我有一个数字代表一个对象的状态,我想检查其中一个状态.例如,如果数字为"22",则在检查16,4或2时应返回true,对其他任何内容应返回false.我的功能是
containsOrderType <- function(orderType, state) #returns whether the bitmask translates to containing that order type
{
state <- as.numeric(state)
if(orderType>state) return(FALSE)
binState <- as.integer(state)
class(binState) <- "binmode"
binState <- as.character(binState)
dim(binState) <- dim(state)
X<-log2(orderType)+1
if(str_sub(binState,-X,-X)==1) return(TRUE)
return(FALSE)
}
Run Code Online (Sandbox Code Playgroud)
直到今天这个工作正常一个月,我很确定问题是昏暗(状态)正在变暗([整数]),似乎总是"空".这发生在R 2.15.3和R 3.0.1中.我得到它,如果那是一致的,但这个功能完全按照预期工作了一段时间,现在它没有.这是R.Utils中的intToBin函数,它与我的函数的第3-6行相同.
function (x)
{
y <- as.integer(x)
class(y) <- "binmode"
y <- as.character(y)
dim(y) <- dim(x)
y
}
Run Code Online (Sandbox Code Playgroud)
也
>dim
function (x) .Primitive("dim")
> class
function (x) .Primitive("class")
Run Code Online (Sandbox Code Playgroud)
所以那些没有被包裹或任何奇怪的东西覆盖.