Natalie O'Toole napsal(a): > Does anyone know why it is giving me this error? Any help would be greatly > appreciated!! > > Thanks, > > Nat > > > > myfile<-("c:/test2.txt") > mysubset<-myfile > mysubset$Y_Q02 <-mysubset$DVSELF <-NULL > mysubset2<-mysubset > mysubset2$Y_Q10B <-mysubset2$GP2_07 <-NULL > > myVariableNames<-c("PUMFID=rnorm(10)","PROV=rnorm(10)","REGION=rnorm(10)","GRADE=rnorm(10)","Y_Q10A=rnorm(10)","WTPP=rnorm(10)") >> df<-mysubset2[, 2:5] * mysubset2[, 6]
HERE it has to stop with the error message you provided, not below. The code might run for a few more lines, but the problem is here. Your mysubset2, btw. we have no idea what that might be, aparently does not have 2 dimensions. Besides, your code is very dirty and it is indeed very easy to make a mistake in such code. You really should start reading some introductory manual as someone suggested before. You are not likely to recieve more (different) answers to questions of this kind. Petr > myVariableWidths<-c(5,2,1,2,1,12.4) > df<-read.fwf( > file=myfile, > width=myVariableWidths, > col.names=myVariableNames, > row.names="PUMFID", > fill=TRUE, > strip.white=TRUE) > > happyguys<-subset(df, PROV==48 & GRADE == 7 & Y_Q10A < 9) > print(happyguys) > > > where it is bolded, i'm getting the following error: Error in mysubset2[, > 2:5] : incorrect number of dimensions <snip> -- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.