我在r中加载了一个这样的csv表
<表类="年代桌子">方法 SOC SOC2 tbody><WB 1.5 <Com/td> 2.5 法则3.1 表>
试试这个:
library(dplyr)
df <- data.frame(method = c("WB", "Com", "LOI"), SOC = c(1.5, 2.5, 3.1))
df %>% mutate(SOC2 = case_when(
method == "WB" ~ SOC * 10,
method == "Com" ~ SOC * 20,
method == "LOI" ~ SOC * 30
))
method SOC SOC2
1 WB 1.5 15
2 Com 2.5 50
3 LOI 3.1 93
你可以这样做:
wbIndices <- df$method == "WB"
ComIndices <- df$method == "Com"
LOIIndices <- df$method == "LOI"
df$SOC2 <- df$SOC[wbIndices]*10
df$SOC2 <- df$SOC[ComIndices]*20
df$SOC2 <- df$SOC[LOIIndices]*30
相关内容
- 使用PySpark或pandas_on_spark计算新列
- 计算新列上的重复和写入
- 通过对float和datetime和timestamp索引执行操作计算新列
- Multiple Columns使用等式计算新列
- 将行转置为列,并计算新列值为另一列的和
- 根据现有列中的值计算新列
- 如何在自定义函数中使用Dictionary从大型数据帧计算新列
- python根据循环中的另外两列计算新列值
- Spotfire-向下采样时间序列数据-计算新列
- 根据条件计算新列的最快方法是什么
- 如果不存在新列,Panda数据透视表将计算新列的错误
- 放入公式来计算新列的值
- 将lambda与panda结合使用,可以根据现有列计算新列
- 计算新列Pandas中的行数总和
- 在R中,根据行之间的差异计算新列
- Pandas-使用可变列输入计算新列
- R数据.能够在特定条件下根据现有的列基数计算新列
- 对SQL中的两个独立列使用GroupBy来计算新列
- Python根据现有列的条件计算新列
- 如何根据多个先前值的熊猫条件计算新列
最新更新
- Python记录器没有从根记录器继承level
- 是什么导致了python的f字符串中"f "{a}""与"f "{a=}""之间的差异?
- 标题库使用介子
- 打印偶数的"count",而循环使用 if
- 为什么我要将数组转换为对象
- 通过共享操作符将可连接的Flux转换为Hot不工作
- 从演示文稿中删除所有空的/未使用的形状
- 破坏错误取决于变量的顺序
- c -试图编写一个MIPS汇编程序
- 消息队列推送通知/邮件应用程序?
- 如何在根目录下安装gitignore
- 我应该如何测试一个API调用拒绝是在一个上下文中?
- 百分比值到绝对值,反之亦然,由于整数四舍五入,转换导致不匹配
- 由于 NBM 的原因,我无法在 NetBeans 中下载代号一插件
- 如何组织项目与多个Go模块和使用Docker撰写?
- 蓝牙BLE设备配对后未绑定
- 为什么我在 Django 中显示用户配置文件的代码不起作用?
- 使用api平台图形查询读取空间点类型
- 如何处理嵌套角色中超出范围的变量
- std::vector and move semantics
- ImageMagick多个命令,带有不同的源和目标文件夹和文件
- 是否有一个特定的键进入一个字符和退出插入模式在vim vscode扩展?
- c - NULL值在运行时被重新分配给垃圾
- 我如何将这个python函数转换为c++?
- 我可以用pybliometrics找到论文的通讯作者是谁,以及他们的电子邮件地址吗?
- 了解如何在Ruby on Rails中使用Turbo
- 解码mediaRecorder音频文件在Python中
- 节点/反应:我无法使用 multer 上传带有我的帖子的图像
- Texture.loadFromFile 无法按预期工作
- 如何使用Url_Launcher的inAppWebView作为小部件
热门标签:
javascript python java c# php android html jquery c++ css ios sql mysql arrays asp.net json python-3.x ruby-on-rails .net sql-server django objective-c excel regex ruby linux ajax iphone xml vba spring asp.net-mvc database wordpress string postgresql wpf windows xcode bash git oracle list vb.net multithreading eclipse algorithm macos powershell visual-studio image forms numpy scala function api selenium