【发布时间】:2016-05-15 12:48:12
【问题描述】:
我正在尝试将一些数据帧动态传递给一个函数,该函数将为每个数据帧返回一些统计结果。目的是将统计结果并排绘制。我遇到的问题是我将数据框分配给函数导致传递数据框的名称而不是实际的数据框本身。
例如,我的数据框称为construct 1,但代码并未传递代表此构造的实际数据框,而是传递了名称construct 1
谁能看看如何解决这个问题
# Get a list of all the dataframes in the workspace
my.dfs <- names(which(sapply(.GlobalEnv, is.data.frame)))
# Filter to just the Alpha DataFrames
my.dfs <- as.data.frame(my.dfs) %>%
filter(grepl('Alpha_', my.dfs)) %>%
mutate(my.table = as.character(my.dfs))
# Loop Through Each Table and get the Alpha Statistics
for (i in 1:nrow(my.dfs)){
construct = my.dfs$my.table[i]
construct_name = as.character(my.dfs$my.table[i])
create_cronbach_summ(construct, construct_name)
}
最终结果会是这样的
Construct Name
Statistic 1
Statistic 2
Statistic 3....
我收到的错误信息是:
Error in UseMethod("select_") :
no applicable method for 'select_' applied to an object of class "character
【问题讨论】: