问题描述
我得到了以下代码
为(我在c(1:(ncol(dcol_df_multi_paths_cols)-1)中) ){
df_cache<-df_multi_paths_cols%>%
select(num_range( ord_,c(i,i + 1)))%>%
#在具有前缀且在特定范围内i和i + 1的数据集列中进行选择。
na.omit()%>%
#na.omit R函数删除数据对象$ b $的所有不完整情况b#(通常是数据帧,矩阵或向量)。
group_by(.dots = c(paste0( ord_,c(i,i + 1)))))%>%
#paste =连接字符串且不使用分隔符
#group_by( )将现有的tbl转换为分组的tbl,其中
#操作是按组执行的。 ungroup()删除分组。
summarise(number = n())%>%
#summarise()通常用于由group_by()创建的分组数据。输出
#每一组有一行。
#n()=组中的编号抢夺
ungroup()
colnames(df_cache)[c(1、2)]<-c('channel_from', 'channel_to')
df_res [[i]]<-df_cache
}
以下错误:
错误:仅在数据上下文中调用n()
在网络上,但似乎没有描述与该特定错误相关的解决方案。
数据帧df_multi_path_cols像这样:
p>
> df_multi_paths_cols
ord_1 ord_2 ord_3 ord_4
1(开始)MANAGER_SASWP MANAGER_SRSLT MANAGER_3RDWP
2(开始)GROUPDIRECTOR / CXO_LIVEWEBEXR GROUPDIRECTOR / CXO_SASWEB GROUPDIRECTORC(b)(3) )< NA>
4(开始)GROUPDIRECTOR / CXO_SUG GROUPDIRECTOR / CXO_3RDWP GROUPDIRECTOR / CXO_SASLIVE
5(开始)GROUPDIRECTOR / CXO_SUG GROUPDIRECTOR / CXO_SUG(空)
6(开始)DIRECTOR_3RDLIVES DIRECTOR_BIN 7 (开始)DIRECTOR_DMCR DIRECTOR_SUG(空)
8(开始)DIRECTOR_3RDLIVE DIRECTOR_SUG GROUPDIRECTOR / CXO_SASWP
9(开始)DIRECTOR_SUG DIRECTOR_EPCR DIRECTOR_EPCR
10(开始)DIRECTOR_SUG $ REC $ S_A(11) )MANAGER_SUG(空)< NA>
ord_5 ord_6 ord_7 ord_8
1 MANAGER_SASWP MANAGER_EBOOK MANAGER_3RDWP MANAGER_ONASOFF
2(转换)< NA> < NA> < NA>
3< NA> < NA> < NA> < NA>
4 GROUPDIRECTOR / CXO_WBR GROUPDIRECTOR / CXO_SUG GROUPDIRECTOR / CXO_WDLR GROUPDIRECTOR / CXO_WDLR
5< NA> < NA> < NA> < NA>
6 DIRECTOR_ONASOFF DIRECTOR_WPR MANAGER_SUG(转换)
更新04/07/2019
dput(df_multi_paths_cols)
structure(list(ord_1 = c((开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),( start),(start),(start),(start),(start),
(start),(start),(start), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),( start),(start),(start),(start),(start),
(start),(start),(start), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),( start),(start),(start),(start),
(start),(start),(start),(start), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),( start),(start),(start),(start),
(start),(start),(start),(start), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),( start),(start),(start),(start),
(start),(start),(start),(start), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(sta rt),(开始),(开始),(开始),(开始),
(开始),(开始),(开始), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),( start),(start),(start),(start),(start),
(start),(start),(start), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),( start),(start),(start),(start),(start),
(start),(start),(start), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),( start),(start),(start),(start),
(start),(start),(start),(start), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),( start),(start),(start),(start),
(start),(start),(start),(start), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),( start),(start),(start),(start),
(start),(start),(start),(start), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始), (开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始) ,
(开始),(开始),(开始),(开始),(开始),(开始),
(开始) ,(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始), (开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),( ),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(st art),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始), (开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始) ,(开始),(开始),(开始),
(开始),(开始),(开始),(开始),( start),(start),
(start),(start),(start),(start),(start),(start),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始), (开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始) ,(开始),(开始),(开始),
(开始),(开始),(开始),(开始),( start),(start),
(start),(start),(start),(start),(start),(start),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始), (开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始) ,(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始), (开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始) ,(开始), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始),(开始),
(开始),( start),(start),(start),(start),(start),
(start),(start),(start), (开始),(开始),(开始),
(开始),(开始),(开始),(开始),(开始) ,(开始),
(开始),(开始),(开始),(开始),(开始),(开始)
),ord_2 = c( MANAGER_SASWP, GROUPDIRECTOR / CXO_LIVEWEBEXR,
GROUPDIRECTOR / CXO_SUG, GROUPDIRECTOR / CXO_SUG, GROUPDIRECTOR / CXO_SUG,
DIRC , DIRECTOR_3RDLIVE, DIRECTOR_SUG,
DIRECTOR_SUG, MANAGER_SUG, TEAMMEMBER_3RDLIVE, TEAMMEMBER_3RDLIVE,
TEAMMEMBER_OTHR, TEAMMEMBER_SASLIVE, DIRECTOR_ $ bRDLIVE DIRECTOR_SASWP, DIRECTOR_WBR, TEAMMEMBER_EBOOK, TEACHER_DMCR,
TEACH ER_DMCR, TEACHER_OTHR, TEACHER_RMCHR, TEACHER_SUG,
TEACHER_WBR, DIRECTOR_DMCR, DIRECTOR_DMCR, DIRECTOR_DMCR,
DIRECTOR_SASEXEC, DIRECTOR_SASLIVE , DIRECTOR_SUG,
DIRECTOR_SUG, TEAMMEMBER_3RDWEBIN, _ SASLIVE, DIRECTOR_SUG,
TEAMMEMBER_3RDLIVE, DIRECTOR_SASEXEC, DIRECTOR_SUG, MANAGER_TEL,
DIRECTOR_SUG, DIRECTOR_3RDLIVE, DIRECTOR_DMCR, DIRECTOR_SASLIVE,
DIRECTOR_SASLIVE, DIRECTOR_SUG, DIRECTOR_WBR, MANAGER_3RDLIVE,
MANAGER_SASLIVE, MANAGER_S , DIRECTOR_SASLIVE,
DIRECTOR_3RDLIVE, DIRECTOR_3RDLIVE, TEAMMEMBER_SASLIVE,
DIRECTOR_SUG, DIRECTOR_TEL, MANAGER_3RDLIVE, MANAGER_IKR,
MANAGER_SASEXEC MANAGER_SASLIVE, MANAGER_SEFR, MANAGER_TEL,
_CR, _ AR, _ WPR, DIRECTOR_SASLIVE, TEAMMEMBER_DMR, TEAMMEMBER_ID,
TEAMMEMBER_IKR, TEAMMEMBER_SASEXEC , TEAMMEMBER_SASLIVE,
TEAMMEMBER_SEFR, TEAMMEMBER_SRSLT, TEAMM EMBER_TEL, MANAGER_EBOOK,
MANAGER_SEFR, DIRECTOR_COMR, DIRECTOR_CR, DIRECTOR_DMR,
DIRECTOR_TEL, TEAMMEMBER_TEL, DIRECTOR_DMR, DIRECTOR_SASLIVE,$ b DIRECTOR_SASLIVE, DIRECTOR_SRSLT, DIRECTOR_TEL, DIRECTOR_TEL,
MANAGER_SASLIVE, MANAGER_WPR, MANAGER_WPR, TEAMMEMBER_3RDLIVE,
TEAMMEMBER_Lead GenerationR, TEAMMEMBER_Lead GenerationR, TEAMMEMBER_COMR,
TEAMMEMBER_CR, TEAMMEMBER_DMR, TEAMMEMBER_IKR, TEAMMEMBER_TEL,
DIRECTOR_IKR, DIRECTOR_SASLIVE, DIRECTOR_SASLIVE, DIRECTOR_SASEXECMAN,
, DIRECTOR_3RDLIVE, DIRECTOR_RMCHR, DIRECTOR_SASEXEC,
DIRECTOR_3RDLIVE, DIRECTOR_SASWP, MANAGER_CR, DIRECTOR_IKR,
DIRECTOR_SASLIVE, TEAMMEMBER_SASLIVE, MANAGER_OTHR,
TEAMMEMBER_CR, MANAGER_SRSLT, DIRECTOR_DMR, DIRECTOR_IKR,
MANAGER_COMR, MANAGER_DMR, MANAGER_IKR, MANAGER_TEL,
DIRECTOR , MANAGER_3RDWP, TEAMMEMBER_WS, DI RECTOR_3RDLIVE,
DIRECTOR_SASLIVE, _ SASLIVE, DIRECTOR_3RDLIVE, TEAMMEMBER_3RDLIVE,
TEAMMEMBER_COMR, TEAMMEMBER_WPR, TEAMMEMBER_CR, TEAMMEMBER_ARCHWEB,
, TEAMMEMBER_SASLIVE, TEAMMEMBER_SASLIVE,
TEAMMEMBER_SASLIVE, TEAMMEMBER_SASLIVE, TEAMMEMBER_WS,
GROUPDIRECTOR / CXO_SASLIVE, MANAGER_SASLIVE, GROUPDIRECTOR / CXb_DMCR GROUPDIRECTOR / CXO_SASLIVE, GROUPDIRECTOR / CXO_SEFR, MANAGER_3RDLIVE,
通过为每个功能指定dplyr打包了相对的来源包:
for(在c(i:(ncol(dcol_df_multi_paths_cols)-1))中) {
df_cache<-df_multi_paths_cols%>%
select(num_range( ord_,c(i,i + 1)))%>%
na。 omit()%>%
dplyr :: group_by(.dots = c(paste0( ord_,c(i,i + 1)))))%> %%
dplyr :: summarise (number = dplyr :: n())%>%
ungroup()
colnames(df_cache)[c(1,2)]<-c('channel_from','channel_to')
df_res [[i]]<-df_cache
}
现在我认为这与具有相同功能名称 summarise的其他软件包有些冲突,
>冲突()
[1]预测变量%>%紧凑提升 cols%&%;%
[7]%>% shift take移调%>% add_row
[13]安排 as_data_frame as_tibble之间 coalesce计数
[19] data_frame data_frame_ desc failwith第一个 frame_data
[25]瞥见 id last lst lst_变异
[31] n 重命名摘要摘要 tbl_sum tibble
[37] tribble trunc_mat type_sum matches%>%%>%
[43] expand expm t%>% enexpr enexprs
[49] enquo enquos ensym ensyms expr quo
[55] quo_name quos sym syms vars dcast
[61] melt smiths coerce情节 print显示
[67]摘要 t cov cov2cor df过滤器
[73]滞后 lowess预测平滑 toeplitz更新
[79] var image plot? 数据头
[85]尾巴 Arith cbind2胁迫比较 kronecker
[91]逻辑数学 Math2运算 rbind2显示
[97]摘要 all.equal as.array as.matrix body<- chol
[103] chol2inv colMeans colSums crossprod det行列式
[109] diag diag<- diff drop format相交
[115] isSymmetric kronecker平均范数位置打印
[121] qr qr.coef qr.fitted qr.Q qr.qty qr.qy
[127] qr.R qr.resid rcond rowMeans行名 rowSums
[133] setdiff setequal解决摘要 t tcrossprod
[139] union unname url which zapsmall
I got for the following code
for (i in c(1:(ncol(df_multi_paths_cols) - 1))) {
df_cache <- df_multi_paths_cols %>%
select(num_range("ord_", c(i, i+1))) %>%
#select within dataset columns with prefix and within specific range i and i+1
na.omit() %>%
# The na.omit R function removes all incomplete cases of a data object
# (typically of a data frame, matrix or vector).
group_by(.dots = c(paste0("ord_", c(i, i+1)))) %>%
#paste=concatenate strings without separator
# group_by() takes an existing tbl and converts it into a grouped tbl where
# operations are performed "by group". ungroup() removes grouping.
summarise(number = n()) %>%
# summarise() is typically used on grouped data created by group_by(). The output will
# have one row for each group.
#n()=numbe robservation in the group
ungroup()
colnames(df_cache)[c(1, 2)] <- c('channel_from', 'channel_to')
df_res[[i]] <- df_cache
}
The below error:
Error: n() should only be called in a data context
Searched on the web but seems no solution has been described related to this specific error. Any hints more than appreciated as I'm not able to figure out why the n() function is not working within summarise.
The dataframe df_multi_path_cols is like this:
> df_multi_paths_cols
ord_1 ord_2 ord_3 ord_4
1 (start) MANAGER_SASWP MANAGER_SRSLT MANAGER_3RDWP
2 (start) GROUPDIRECTOR/CXO_LIVEWEBEXR GROUPDIRECTOR/CXO_SASWEB GROUPDIRECTOR/CXO_WPR
3 (start) GROUPDIRECTOR/CXO_SUG (null) <NA>
4 (start) GROUPDIRECTOR/CXO_SUG GROUPDIRECTOR/CXO_3RDWP GROUPDIRECTOR/CXO_SASLIVE
5 (start) GROUPDIRECTOR/CXO_SUG GROUPDIRECTOR/CXO_SUG (null)
6 (start) DIRECTOR_3RDLIVE DIRECTOR_ODSASWEBIN DIRECTOR_SUG
7 (start) DIRECTOR_DMCR DIRECTOR_SUG (null)
8 (start) DIRECTOR_3RDLIVE DIRECTOR_SUG GROUPDIRECTOR/CXO_SASWP
9 (start) DIRECTOR_SUG DIRECTOR_EPCR DIRECTOR_EPCR
10 (start) DIRECTOR_SUG DIRECTOR_SUG MANAGER_SASWP
11 (start) MANAGER_SUG (null) <NA>
ord_5 ord_6 ord_7 ord_8
1 MANAGER_SASWP MANAGER_EBOOK MANAGER_3RDWP MANAGER_ONASOFF
2 (conversion) <NA> <NA> <NA>
3 <NA> <NA> <NA> <NA>
4 GROUPDIRECTOR/CXO_WBR GROUPDIRECTOR/CXO_SUG GROUPDIRECTOR/CXO_WDLR GROUPDIRECTOR/CXO_WDLR
5 <NA> <NA> <NA> <NA>
6 DIRECTOR_ONASOFF DIRECTOR_WPR MANAGER_SUG (conversion)
Update 04/07/2019
dput(df_multi_paths_cols)
structure(list(ord_1 = c("(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)", "(start)"), ord_2 = c("MANAGER_SASWP", "GROUPDIRECTOR/CXO_LIVEWEBEXR", "GROUPDIRECTOR/CXO_SUG", "GROUPDIRECTOR/CXO_SUG", "GROUPDIRECTOR/CXO_SUG", "DIRECTOR_3RDLIVE", "DIRECTOR_DMCR", "DIRECTOR_3RDLIVE", "DIRECTOR_SUG", "DIRECTOR_SUG", "MANAGER_SUG", "TEAMMEMBER_3RDLIVE", "TEAMMEMBER_3RDLIVE", "TEAMMEMBER_OTHR", "TEAMMEMBER_SASLIVE", "DIRECTOR_3RDLIVE", "DIRECTOR_SASWP", "DIRECTOR_WBR", "TEAMMEMBER_EBOOK", "TEACHER_DMCR", "TEACHER_DMCR", "TEACHER_OTHR", "TEACHER_RMCHR", "TEACHER_SUG", "TEACHER_WBR", "DIRECTOR_DMCR", "DIRECTOR_DMCR", "DIRECTOR_DMCR", "DIRECTOR_SASEXEC", "DIRECTOR_SASLIVE", "DIRECTOR_SUG", "DIRECTOR_SUG", "DIRECTOR_SUG", "TEAMMEMBER_3RDWEBIN", "_SASLIVE", "DIRECTOR_SUG", "TEAMMEMBER_3RDLIVE", "DIRECTOR_SASEXEC", "DIRECTOR_SUG", "MANAGER_TEL", "DIRECTOR_SUG", "DIRECTOR_3RDLIVE", "DIRECTOR_DMCR", "DIRECTOR_SASLIVE", "DIRECTOR_SASLIVE", "DIRECTOR_SUG", "DIRECTOR_WBR", "MANAGER_3RDLIVE", "MANAGER_SASLIVE", "MANAGER_SUG", "_CR", "DIRECTOR_SASLIVE", "DIRECTOR_3RDLIVE", "DIRECTOR_3RDLIVE", "TEAMMEMBER_SASLIVE", "DIRECTOR_SUG", "DIRECTOR_TEL", "MANAGER_3RDLIVE", "MANAGER_IKR", "MANAGER_SASEXEC", "MANAGER_SASLIVE", "MANAGER_SEFR", "MANAGER_TEL", "_CR", "_AR", "_WPR", "DIRECTOR_SASLIVE", "TEAMMEMBER_DMR", "TEAMMEMBER_ID", "TEAMMEMBER_IKR", "TEAMMEMBER_SASEXEC", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_SEFR", "TEAMMEMBER_SRSLT", "TEAMMEMBER_TEL", "MANAGER_EBOOK", "MANAGER_SEFR", "DIRECTOR_COMR", "DIRECTOR_CR", "DIRECTOR_DMR", "DIRECTOR_TEL", "TEAMMEMBER_TEL", "DIRECTOR_DMR", "DIRECTOR_SASLIVE", "DIRECTOR_SASLIVE", "DIRECTOR_SRSLT", "DIRECTOR_TEL", "DIRECTOR_TEL", "MANAGER_SASLIVE", "MANAGER_WPR", "MANAGER_WPR", "TEAMMEMBER_3RDLIVE", "TEAMMEMBER_Lead GenerationR", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_COMR", "TEAMMEMBER_CR", "TEAMMEMBER_DMR", "TEAMMEMBER_IKR", "TEAMMEMBER_TEL", "DIRECTOR_IKR", "DIRECTOR_SASLIVE", "DIRECTOR_SASLIVE", "DIRECTOR_SASEXEC", "MANAGER_CS", "DIRECTOR_3RDLIVE", "DIRECTOR_RMCHR", "DIRECTOR_SASEXEC", "DIRECTOR_3RDLIVE", "DIRECTOR_SASWP", "MANAGER_CR", "DIRECTOR_IKR", "DIRECTOR_SASLIVE", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_CR", "MANAGER_OTHR", "TEAMMEMBER_CR", "MANAGER_SRSLT", "DIRECTOR_DMR", "DIRECTOR_IKR", "MANAGER_COMR", "MANAGER_DMR", "MANAGER_IKR", "MANAGER_TEL", "DIRECTOR_SASLIVE", "MANAGER_3RDWP", "TEAMMEMBER_WS", "DIRECTOR_3RDLIVE", "DIRECTOR_SASLIVE", "_SASLIVE", "DIRECTOR_3RDLIVE", "TEAMMEMBER_3RDLIVE", "TEAMMEMBER_COMR", "TEAMMEMBER_WPR", "TEAMMEMBER_CR", "TEAMMEMBER_ARCHWEB", "TEAMMEMBER_ASKOD", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_SASLIVE", "TEAMMEMBER_WS", "GROUPDIRECTOR/CXO_SASLIVE", "MANAGER_SASLIVE", "GROUPDIRECTOR/CXO_DMCR", "GROUPDIRECTOR/CXO_SASLIVE", "GROUPDIRECTOR/CXO_SEFR", "MANAGER_3RDLIVE",
The error disappeared by specifying for each function of the dplyr package the relative package of provenience:
for (i in c(1:(ncol(df_multi_paths_cols) - 1))) {
df_cache <- df_multi_paths_cols %>%
select(num_range("ord_", c(i, i+1))) %>%
na.omit() %>%
dplyr::group_by(.dots = c(paste0("ord_", c(i, i+1)))) %>%
dplyr::summarise(number=dplyr::n()) %>%
ungroup()
colnames(df_cache)[c(1, 2)] <- c('channel_from', 'channel_to')
df_res[[i]] <- df_cache
}
Pretty much now I think it was some kind of conflict with other packages with the same function name "summarise", as proved by
> conflicts()
[1] "predictors" "%>%" "compact" "lift" "cols" "%>%"
[7] "%>%" "shift" "take" "transpose" "%>%" "add_row"
[13] "arrange" "as_data_frame" "as_tibble" "between" "coalesce" "count"
[19] "data_frame" "data_frame_" "desc" "failwith" "first" "frame_data"
[25] "glimpse" "id" "last" "lst" "lst_" "mutate"
[31] "n" "rename" "summarise" "summarize" "tbl_sum" "tibble"
[37] "tribble" "trunc_mat" "type_sum" "matches" "%>%" "%>%"
[43] "expand" "expm" "t" "%>%" "enexpr" "enexprs"
[49] "enquo" "enquos" "ensym" "ensyms" "expr" "quo"
[55] "quo_name" "quos" "sym" "syms" "vars" "dcast"
[61] "melt" "smiths" "coerce" "plot" "print" "show"
[67] "summary" "t" "cov" "cov2cor" "df" "filter"
[73] "lag" "lowess" "predict" "smooth" "toeplitz" "update"
[79] "var" "image" "plot" "?" "data" "head"
[85] "tail" "Arith" "cbind2" "coerce" "Compare" "kronecker"
[91] "Logic" "Math" "Math2" "Ops" "rbind2" "show"
[97] "Summary" "all.equal" "as.array" "as.matrix" "body<-" "chol"
[103] "chol2inv" "colMeans" "colSums" "crossprod" "det" "determinant"
[109] "diag" "diag<-" "diff" "drop" "format" "intersect"
[115] "isSymmetric" "kronecker" "mean" "norm" "Position" "print"
[121] "qr" "qr.coef" "qr.fitted" "qr.Q" "qr.qty" "qr.qy"
[127] "qr.R" "qr.resid" "rcond" "rowMeans" "rownames" "rowSums"
[133] "setdiff" "setequal" "solve" "summary" "t" "tcrossprod"
[139] "union" "unname" "url" "which" "zapsmall"
这篇关于dplyr :: n()返回“错误:错误:n()仅应在数据上下文中调用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!