Error: n() should only be called in a data context
Call `rlang::last_error()` to see a backtrace
- library(dplyr)
- library(plyr)
- load("D:/R整理数据/newzonghe.RData")
- newzonghe<-data.frame(zonghe$groupRebalancingStockSymbol,zonghe$chigubianhua,zonghe$newdatatime)
- newzonghe<-newzonghe[which(newzonghe$zonghe.chigubianhua!=0),]
- bijiao<-newzonghe
- colnames(bijiao)=c("Stockid","bili","dttime")
- ds<-tbl_df(bijiao)
- newds<-filter(ds,abs(bili)>=10)
- newds<- newds %>% mutate(postitive=ifelse(bili>0,1,0))
- gp1<- newds%>% group_by(Stockid) %>% summarise(countt=n())
- gp2<-newds %>% group_by(Stockid,dttime,postitive) %>% summarise(count=n())
- df1<-gp1 %>% as.data.frame()
- df2<-gp2 %>% as.data.frame()
- save(df1,file = "D:\\df1")
- save(df2,file = "D:\\df2")
| Stockid | bili | dttime |
| SH601318 | 15.09 | 2014-11-04 |
| SH601318 | 50 | 2014-11-04 |
| SH601318 | 10 | 2014-11-06 |
| SH601318 | 10 | 2014-11-10 |
| SH601318 | 23 | 2014-11-11 |
| SH601318 | 21 | 2014-11-12 |
| SH601318 | -50 | 2014-11-13 |
| SH601318 | 21 | 2014-11-13 |
| SH601318 | 21 | 2014-11-13 |
| SH601318 | 20 | 2014-11-13 |
| SH601318 | 20 | 2014-11-14 |
| SH601318 | 21 | 2014-11-17z |


雷达卡




京公网安备 11010802022788号







