如何在数据帧中有条件地将字符值和它上面的值联合起来

  • 本文关键字:起来 字符 数据帧 有条件 r
  • 更新时间 :
  • 英文 :

时间 Compound_Names
2.105 乙醇,2-(乙烯基氧基)---
2.490 甲氧基乙酸,2-甲基丙基---
NA
2.675 十六进制---

假设您的数据帧名为df

for (i in seq_along(df$Time)){
if(is.na(df$Time[[i]])) 
df$Compound_Names[[i-1]] <- paste(df$Compound_Names[[i-1]] ,
df$Compound_Names[[i]] , sep = "---" )
}
df <- na.omit(df)

相关内容

最新更新