本文介绍了`* tmp *`[[j]]:下标超出范围时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! for(i in 1:dim(dataset)[1]){ hitlist = trainmy2 [trainmy2 $ VisitNumber == dataset [i,2],] dayofweek =姓名(hitlist)[3:9] [hitlist [1,3:9]> 0] 数据集[i,dayofweek] = 1 hitlist2 = Copy_Walmart [Copy_Walmart $ VisitNumber == dataset [ i,2],] agg = aggregate(ScanCount~DepartmentDescription,data = hitlist2,sum) sub1< -gsub(,。,paste0(names(agg)[1], 。,agg [,1])) sub2< -gsub( - ,。,sub1) sub3< -gsub(&,。,sub2) sub4< -gsub(/,。,sub3) sub5< -gsub(,,。,sub4) dataset [i,sub5] = agg [,2] 打印(i)} 我的尝试: 我真的不明白这有什么问题。请帮我理解解决方案 VisitNumber == dataset [i,2],] dayofweek = names(hitlist)[3:9] [hitlist [1,3:9]> 0] dataset [i,dayofweek ] = 1 hitlist2 = Copy_Walmart [Copy_Walmart VisitNum ber == dataset [i,2],] agg = aggregate(ScanCount~DepartmentDescription,data = hitlist2,sum) sub1< -gsub(,。,paste0(names(agg) )[1],。,agg [,1])) sub2< -gsub( - ,。,sub1) sub3< -gsub(&, 。,,sub2) sub4< -gsub(/,。,sub3) sub5< -gsub(,,。,sub4) dataset [i ,sub5] = agg [,2] 打印(i)} 我是什么尝试过: 我真的不明白这有什么问题。请帮我理解 for(i in 1:dim(dataset)[1]){ hitlist=trainmy2[trainmy2$VisitNumber==dataset[i,2],] dayofweek=names(hitlist)[3:9][hitlist[1,3:9]>0] dataset[i,dayofweek]=1 hitlist2=Copy_Walmart[Copy_Walmart$VisitNumber==dataset[i,2],] agg=aggregate(ScanCount~DepartmentDescription,data=hitlist2,sum) sub1<-gsub("",".",paste0(names(agg)[1],".",agg[,1])) sub2<-gsub("-",".",sub1) sub3<-gsub("&",".",sub2) sub4<-gsub("/",".",sub3) sub5<-gsub(",",".",sub4) dataset[i,sub5]=agg[,2] print(i)}What I have tried:I not really able to understand what is wrong with this.Please help me to understand 解决方案 VisitNumber==dataset[i,2],] dayofweek=names(hitlist)[3:9][hitlist[1,3:9]>0] dataset[i,dayofweek]=1 hitlist2=Copy_Walmart[Copy_WalmartVisitNumber==dataset[i,2],] agg=aggregate(ScanCount~DepartmentDescription,data=hitlist2,sum) sub1<-gsub("",".",paste0(names(agg)[1],".",agg[,1])) sub2<-gsub("-",".",sub1) sub3<-gsub("&",".",sub2) sub4<-gsub("/",".",sub3) sub5<-gsub(",",".",sub4) dataset[i,sub5]=agg[,2] print(i)}What I have tried:I not really able to understand what is wrong with this.Please help me to understand 这篇关于`* tmp *`[[j]]:下标超出范围时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-16 03:40