- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我偶然发现了一个我无法解决的看似简单的问题。我试图在不包含感兴趣值的 vector
上使用 max
和 which
。理想情况下,我想在该实例中获得数字 0
。但我不断得到负无穷。
ff <- c(2, 4, 6, 8, 10)
my.index <- 1
max(which(ff == my.index))
#[1] -Inf
#Warning message:
#In max(which(ff == my.index)) :
# no non-missing arguments to max; returning -Inf
以下是返回相同结果的其他一些尝试:
max(as.numeric(which(ff == my.index)))
max(which(ff == my.index), na.rm = TRUE)
max(as.numeric(which(ff == my.index)), na.rm = TRUE)
max(numeric(0))
我确实注意到了:
max(0)
[1] 0
所以,我想也许最简单的解决方案是将 -Inf
转换为 0
。有没有比下面的更优雅的 base R
解决方案?单线?理想情况下不会返回 warning
消息?
aaa <- max(which(ff == my.index))
aaa[is.infinite(aaa)] <- 0
aaa
[1] 0
最佳答案
max
在传递给 max(...)
的所有参数中使用 all 值,因此:
max(which(ff == my.index), 0)
#[1] 0
关于r - max 在 R 中返回负无穷大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73496269/
我有一个非常基本的 MySQL 查询,它从数据库表中读取行并将行值添加或减去定义为 $total_balance 的 PHP 字符串。 例如; $statement_details_query = m
我有 following fiddle ,请注意,如果您使输出的宽度变小,图像将被覆盖并且不会出现滚动条 - 完美。 如果我attempt the same effect on the right ,
这个正则表达式将得到 456。我的问题是为什么它不能是 1-234-56 中的 234 ? 56 是否限定 (?!\d)) 模式,因为它不是单个数字。 (?!\d)) 寻找的起始点在哪里? impor
我需要知道两个子结构之间的内存距离 (&my_type.a - &my_tape.b.c) 结果的类型是什么?我需要将它转换为 (signed int),所以显然它是别的东西。 最佳答案 根据 C11
我遇到了一个扩展异常的异常处理程序类,如下所示: public class AppFileReaderException extends Exception { //Explicit seri
如何可视化负 RGB 值? 根据 OpenCV 文档: CV_8S - 8 位有符号整数 (-128..127) 这是否意味着 -128 表示 0 而 127 表示 255? 如果是,那我们为什么需要
我这里有一段代码给我带来了麻烦: idIndex = panoBuffer.indexOf("\"photo_id\":"); System.out.println(idIndex);
我刚刚练习 Java,对此还很陌生。我只是想创建一个随机数生成器程序来跟踪玩家的获胜、失败、获胜百分比和总获胜金额。该程序的逻辑是,玩家每次 session 有 3 次机会,计算机会生成一个随机数,玩
因此,我们被要求创建一个程序,使用户能够从 1-6 个有关矩阵运算的选项中进行选择。在每个用户的输入中,我们需要检查该输入是否适合要完成的操作(程序应该接受整数或 float ,正数或负数)。如果不满
这是我期望的输出 x |x| 1.2 1.2 -2.3 2.3 3.4 3.4 但我一直收到这个: x |x| 1
假设我有这个: $date1=date_create(date('H:I', strtotime('8:00'))); $date2=date_create(date('H:I', strtotime
如何确定负 FixNum 的无符号解释? # unexpected, true (~0b01111011).to_s(2) == ("-" + (~0b01111011).abs.to_s(2)) #
这是一个用于“邀请您的 friend 加入此群组”脚本的快速 SQL 查询。 我有 2 个表:users 和 group_members。我正在尝试执行一个查询,选择我所有的 friend ——由第一
负 ASCII 值有什么意义? int a = '«'; //a = -85 but as in ASCII table '<<' should be 174 最佳答案 没有负数ASCII值。 ASC
我知道用 PHP 可以做到这一点,但是有没有办法只用 MySQL 来做到这一点? 我有这个数据库: --------------------------------------------------
我在变量中有一个时间戳 $data = (float) -2208988800; 是否可以根据这些数据创建正确的日期?date("d.M.Y", $data) 返回“07.02.2036” 最佳答案
你好我如何将括号格式的负值转换为 double 值。目前我有这个。 Payment.Text = Calc_Payment().ToString("#,##0.00;(#,##0.00)"); 将支付
这是一个小程序。这应该打印 0 或 1,还是它有未定义的行为? #include struct S0 { unsigned f1 : 1; }; struct S0 s; int main (v
运行 lgb.cv 时,我有时会从日志中看到“从分数开始训练”后的负数。想知道这个数字到底是什么意思,单位是什么?是根据参数中指定的指标吗?以下是摘录: [LightGBM] [Info] Total
我正在使用变分自动编码器类型模型,我的损失函数的一部分是均值为 0 和方差为 1 的正态分布与另一个均值和方差由我的模型预测的正态分布之间的 KL 散度。 我用以下方式定义了损失: def kl_lo
我是一名优秀的程序员,十分优秀!