将NA替换为某些列的前一个字符,在R

时间:2019-05-22 17:58:36

标签: r zoo

我想根据特定名称的给定变量值将NA转换为特定字符。示例查询

df1 = data.frame(session=c("breakfast","breakfast", "breakfast", "NA","lunch","lunch","lunch","NA","dinner","dinner","dinner","NA"))

在哪里需要这样的结果

df2 = data.frame(session=c("breakfast","breakfast", "breakfast", "breakfast Total","lunch","lunch","lunch","lunch Total","dinner","dinner","dinner","dinner Total"))

0 个答案:

没有答案