【发布时间】:2020-01-07 14:55:52
【问题描述】:
我有几行代码希望使用管道更简洁,这样我就不必一遍又一遍地定义列名:
my_fields <- c(1,2,4)
timeline_data_1 <- timeline_data[,my_fields]
timeline_data_1 <- timeline_data_1[order(timeline_data_1$avi_date),] #order the field
timeline_data_1$avi_date <- timeline_data_1 $avi_date/30 #divide the field by 30
当我尝试使用管道时,我最终会在这里遇到各种错误。如何使用管道使此语句更简洁?通常这是我尝试过的方法,但运气不佳:
my_fields <- c(1,2,4)
timeline_data_1 <- timeline_data[,my_fields] %>%
timeline_data_1[order(timeline_data_1$avi_date),] #order the field
timeline_data_1 $avi_date/30 #divide the field by 30
我收到一条错误消息:
undefined columns selected
【问题讨论】:
-
问答没有列出运行提供的代码所需的库。