- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有一个data.table dt
,我在其中使用cut
做了一些分类:
require(data.table)
set.seed(1)
dt <- data.table(x = rnorm(10))
dt[, y := cut(x, breaks = c(-Inf, 0, Inf), labels = 1:2)]
如果我将结果因子 y
转换为数值(使用基于 ?factor
的函数 as.Numeric
),二分查找不再起作用,尽管 z
是数字。
as.Numeric <- function(f){
as.numeric(levels(f))[f]
}
dt[, z := as.Numeric(y)] # as.numeric(as.character(y))
# is working ...
dt
## x y z
## 1: -0.6264538 1 1
## 2: 0.1836433 2 2
## 3: -0.8356286 1 1
## 4: 1.5952808 2 2
## 5: 0.3295078 2 2
## 6: -0.8204684 1 1
## 7: 0.4874291 2 2
## 8: 0.7383247 2 2
## 9: 0.5757814 2 2
## 10: -0.3053884 1 1
setkey(dt, z)
dt
## x y z
## 1: 0.1836433 2 2
## 2: 1.5952808 2 2
## 3: 0.3295078 2 2
## 4: 0.4874291 2 2
## 5: 0.7383247 2 2
## 6: 0.5757814 2 2
## 7: -0.6264538 1 1
## 8: -0.8356286 1 1
## 9: -0.8204684 1 1
## 10: -0.3053884 1 1
dt[J(1)] # doesn't work
## x y z
## 1: NA NA 1
dt[y == 1, ] # works fine
## x y z
## 1: -0.6264538 1 1
## 2: -0.8356286 1 1
## 3: -0.8204684 1 1
## 4: -0.3053884 1 1
str(dt)
## Classes ‘data.table’ and 'data.frame': 10 obs. of 3 variables:
## $ x: num 0.184 1.595 0.33 0.487 0.738 ...
## $ y: Factor w/ 2 levels "1","2": 2 2 2 2 2 2 1 1 1 1
## $ z: num 2 2 2 2 2 2 1 1 1 1
## - attr(*, ".internal.selfref")=<externalptr>
## - attr(*, "sorted")= chr "z"
尝试再次设置 key ,没有帮助:
setkey(dt, z)
## Warning message:
## In setkeyv(x, cols, verbose = verbose) :
## Already keyed by this key but had invalid row order, key rebuilt. If you didn't go under the hood please let datatable-help know so the root cause can be fixed.
dt
## x y z
## 1: 0.1836433 2 2
## 2: 1.5952808 2 2
## 3: 0.3295078 2 2
## 4: 0.4874291 2 2
## 5: 0.7383247 2 2
## 6: 0.5757814 2 2
## 7: -0.6264538 1 1
## 8: -0.8356286 1 1
## 9: -0.8204684 1 1
## 10: -0.3053884 1 1
dt[J(1)] # doesn't work
## x y z
## 1: NA NA 1
矢量扫描 正在运行,因为不需要 key 。使用 as.numeric(as.character(y))
也可以。也许 [
-operator in as.Numeric
是个问题?使用与 dt 1.8.10 相同的代码,一切都像预期的那样。要找出代码在 1.9.3 中不再工作的原因并不是那么容易...
这是一个错误吗?
附:
sessionInfo()
## R version 3.1.0 (2014-04-10)
## Platform: powerpc64-unknown-linux-gnu (64-bit)
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
## attached base packages:
## [1] splines grid stats graphics grDevices utils datasets
## [8] methods base
## other attached packages:
## [1] plyr_1.8.1 reshape2_1.4 lubridate_1.3.3 HP14int_0.1-15
## [5] Hmisc_3.14-4 Formula_1.1-1 survival_2.37-7 lattice_0.20-29
## [9] HP14unidata_1.1-1 data.table_1.9.3
## loaded via a namespace (and not attached):
## [1] cluster_1.15.2 digest_0.6.4 latticeExtra_0.6-26
## [4] memoise_0.2.1 RColorBrewer_1.0-5 Rcpp_0.11.1
## [7] stringr_0.6.2 tools_3.1.0
writeLines(paste("Endianess:", .Platform$endian))
## Endianess: big
最佳答案
现已修复 v1.9.5 on GitHub .感谢您的报告。
Compatibility with big endian machines (e.g., SPARC and PowerPC) is restored. Most Windows, Linux and Mac systems are little endian; type
.Platform$endian
to confirm. Thanks to Gerhard Nachtmann for reporting and the QEMU project for their PowerPC emulator.
关于r - PowerPC 和 SPARC(均为大端)上的 data.table 不正确行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23805911/
有没有办法将在 SPARC 上运行的 Solaris 设置为在小端模式下运行? 我一直在读到 v9 架构芯片是双端芯片,但默认情况下,系统以大端运行。如何切换到小端? 谢谢! 最佳答案 不,小端模式几
在过去的几个月里,我一直很好奇尝试为 SPARC 处理器(V8 或 V9)进行一些组装。我的问题是,我无法访问 SPARC 机器,有没有办法可以在我的 x86 机器上运行 SPARC 二进制文件?我看
我安装了 CentOS 7.6,然后在我的机器上安装了所有 QEMU。我有一个 SPARC 镜像,需要在 VM 中调出。我一直在使用 qemu-system-sparc . $ qemu-system
我很少有符合 SPARC V8 32 位架构的基准测试应用程序。我将它们用于 SPARC 32 位处理器的性能评估。然而,很少有应用程序在性能上达不到要求。我想测试 64 位 SPARC V9 架构(
我很少有符合 SPARC V8 32 位架构的基准测试应用程序。我将它们用于 SPARC 32 位处理器的性能评估。然而,很少有应用程序在性能上达不到要求。我想测试 64 位 SPARC V9 架构(
我正在学习 SPARC 程序集,我必须创建一个从寄存器中提取字段的脚本。该脚本接受 3 个值,初始编号、字段开始位置、字段长度。 它不能使用任何移位函数,但可以使用乘法和除法。 我目前患有呼吸道病毒,
我目前正在使用 Sparc 处理器系列的一些汇编代码,但我在处理一段代码时遇到了一些麻烦。我认为代码和输出解释了更多,但简而言之,这是我的问题: 当我调用函数时 println()我写入 %fp -
是否有与 x86 的单步模式等效的 SPARC?我想要的是在每条指令之后停止执行并将控制流移动到陷阱处理程序或类似的东西。 我考虑过在延迟执行槽中使用 ta 指令,但是当前一条指令是设置了 annul
我的 gcc 交叉编译器不支持Built-in functions for atomic memory access 。我如何使用 Sparc V8 架构的内联汇编来实现以下功能: long __sy
我希望我的程序让二进制文件中的每个函数在结束后都留有一些空间。这样一来,如果以后需要进行一些小的更改,则只需更改该功能,而额外的空间将作为解释小更改的空间。 -falign-function 可以完成
java -version 2>&1 |gawk 'NR==1{ gsub(/"/," "); print $3}' 这适用于 Linux 和 Solaris,它将返回该计算机中安装的 Java 版本
我想在我的 C 程序中编写一个什么都不做的非常简单的内联汇编例程否则然后将本地寄存器 %l0 - %l7 设置为不同的值。我尝试了以下直接的方法: asm volatile ( ".text\
我想在 Sparc 中进行一些“内联”汇编编程,我想知道如何通过寄存器传递来做到这一点。 最好用一个小例子来解释我的问题 int main() { int a = 5; int b = 6
我目前正在学习计算机科学,我的必修类(class)之一是“计算机组织和体系结构”——或者换句话说,是汇编语言的介绍。这个特定的类(class)使用 SPARC 语言,因为部门机器只与 SPARC 兼容
我正在开发一个跨平台应用程序,我希望为其提供 Solaris/SPARC 支持,但我无法再访问服务器。我在 VirtualBox 上有一个 OpenSolaris VM,但我不知道有任何可以用来编译和
我有安装了Solaris 10 SPARC的Sun服务器。 我已经使用tarball源代码成功安装了libevent和openssl。我正在尝试使用gnu gmake编译tor-0.2.5.16。我在
所以;在符合 v9 的 64 位 SPARC CPU 上,存在我知道的 cas 指令。这对单个字长值进行操作。 我还在网络上看到了对 casx 指令的引用 - 但我找不到更多关于它的信息。 我想知道
我正在尝试以正确的方式优化此代码。我所说的正确的意思是......我想有一种通用的方法来执行这些优化,如果其他人查看代码,他们将能够删除优化。 可读性的 C 代码示例... int a = 1; //
我想了解为什么使用此代码会出现总线错误。 int main() { int p=34; int *pp= (int *) ((char *)&p+1); cout<<*pp<<"\n"; return
我正在确定函数中的数字是否为零。如果它为零,我需要将一些字符串(如“Is Zero”)传递到我声明为 B 的变量中。我确定它是否为零的函数有效,但是当我尝试使用我的 SPARC 源代码将字符串传递到变
我是一名优秀的程序员,十分优秀!