You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于历史GE值补全vm=18/24的status变量的R技术需求

现有数据
id = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
vm = c("13", "14", "15", "16", "17", "19", "20", "21", "22", "23")
GE = c("0", "0", "0", "0", "0", "0", "1", "0", "1", "0")
fichier <- data.frame(id, vm, GE)
已实现的R代码
library(tidyverse)
fichier <- fichier %>%
  mutate(statut = case_when(
    fichier$vm == 13 & fichier$GE == 1 ~ "infection",
    fichier$vm == 14 & fichier$GE == 1 ~ "infection",
    fichier$vm == 15 & fichier$GE == 1 ~ "infection",
    fichier$vm == 16 & fichier$GE == 1 ~ "infection",
    fichier$vm == 17 & fichier$GE == 1 ~ "infection",
    fichier$vm == 19 & fichier$GE == 1 ~ "infection",
    fichier$vm == 20 & fichier$GE == 1 ~ "infection",
    fichier$vm == 21 & fichier$GE == 1 ~ "infection",
    fichier$vm == 22 & fichier$GE == 1 ~ "infection",
    fichier$vm == 23 & fichier$GE == 1 ~ "infection",
    TRUE ~ "noinfection")
  )
当前运行结果
id = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
vm = c("13", "14", "15", "16", "17", "19", "20", "21", "22", "23"), 
GE = c("0", "0", "0", "0", "0", "0", "1", "0", "1", "0"), 
statut = c("noinfection", "noinfection", "noinfection", "noinfection", "noinfection", "noinfection", "infection", "noinfection", "infecton", "noinfection")
fichier <- data.frame(id, vm, GE, status)
需求
  • a) 为vm=18的status变量赋值:若13至17访视的GE值均为0,则赋值0;若13至17访视中存在GE=1,则赋值1。
  • b) 为vm=24的status变量赋值:若19至23访视的GE值均为0,则赋值0;若19至23访视中存在GE=1,则赋值1。

内容的提问来源于stack exchange,提问作者Pipas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 17:38:11