Thank you, David! Here is the code to read my file: > data <- read.table("data.txt", header=TRUE, sep=";", na.strings="NA", > dec=".", strip.white=TRUE)
Jorge Ivan Velez gave me a working solution, but I am ready to learn yours to. Iurie 2010/4/9 David Winsemius <dwinsem...@comcast.net>: > OK, we have the data, now ... where is the code that you used to read that > data? It is labeled as a csv file but does not have commas as separators. > Post any follow-ups to the r-help list. I do not offered offlist consulting. > > When you post data to the list it needs to have a file extension of ".txt" > > -- > David > > On Apr 9, 2010, at 10:08 AM, Iurie Malai wrote: > >> I attached a file with data and corrected in the working commands >> grouping factor name: >> >>> data.n<-names(data) # put names into a vector called data.n >>> by(eval(parse(text=(paste("data",data.n[3],sep="$")))), data$groupFactor, >>> shapiro.test) # run shapiro.test >> >> and not working: >> >>> for (r in 3:18) { >>> by(eval(parse(text=(paste("data",data.n[3],sep="$")))), data$groupFactor, >>> shapiro.test) >>> } >> >> >> 2010/4/9 David Winsemius <dwinsem...@comcast.net>: >>> >>> On Apr 9, 2010, at 8:16 AM, Iurie Malai wrote: >>> >>>> I want to run Shapiro-Wilk test for each variable in my dataset, each >>>> grouped by variable groupFactor. >>>> I have these working commands: >>>> >>>>> data.n<-names(data) # put names into a vector called data.n >>>>> by(eval(parse(text=(paste("data",data.n[3],sep="$")))), data$factor, >>>>> shapiro.test) #run shapiro.test >>>> >>>> but I must to change the variable number manualy. How to automate this? >>>> >>>> I tried this: >>>> >>>>> for (r in 3:18) { >>>>> by(eval(parse(text=(paste("data",data.n[3],sep="$")))), >>>>> data$groupFactor, >>>>> shapiro.test) >>>>> } >>> >>> Not able to test since you have provided code that works with data that >>> is >>> not available. Inside for loops one needs either to make an assignment or >>> print the results. Had the data been available I would have wrapped >>> print() >>> around the full by expression to see if my hypothesis could be tested. >>> >>> -- >>> David. >>>> >>>> but not working and no errors. Why? >>>> >>>> Please help. >>>> >>>> -- >>>> Regards, >>>> Iurie Malai, Senior Lecturer >>>> Department of Psychology >>>> Faculty of Psychology and Special Education >>>> Ion Creanga Moldova Pedagogical State University - www.upsm.md >>>> >>>> http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_University >>>> >>>> ______________________________________________ >>>> R-help@r-project.org 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. >>> >>> David Winsemius, MD >>> West Hartford, CT >>> >>> >> <data.csv> > > David Winsemius, MD > West Hartford, CT > > -- Regards, Iurie Malai, Senior Lecturer Department of Psychology Faculty of Psychology and Special Education Ion Creanga Moldova Pedagogical State University - www.upsm.md http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_University
"groupFactor";"x1";"x2";"x3";"x4";"x5";"x6";"x7";"x8";"x9";"x10";"x11";"x12";"x13";"x14";"x15";"x16" "int";9;2;2;2;6;14;9;3;2;3;2;5;3;6;22;97 "int";8;4;3;4;6;11;4;4;4;4;5;9;6;6;17;89 "int";10;0;0;1;0;20;17;5;4;7;8;8;7;10;24;85 "int";9;0;2;4;2;18;16;4;8;8;10;10;10;10;29;107 "int";10;4;0;6;2;9;12;5;6;9;9;9;7;10;12;73 "int";8;5;5;4;6;20;12;2;3;5;5;5;4;10;28;113 "int";8;0;0;1;1;11;3;3;5;5;5;5;3;2;18;91 "int";8;0;0;1;1;13;13;5;6;7;8;9;8;10;24;100 "int";9;0;0;1;0;11;9;2;4;6;6;8;5;6;14;73 "int";8;1;0;1;1;14;12;5;6;5;5;6;4;10;18;91 "int";9;4;1;2;3;16;15;5;7;6;8;7;5;10;15;86 "int";9;4;1;1;5;17;18;3;3;5;6;6;6;10;26;103 "int";8;0;0;0;1;16;8;4;5;5;8;7;4;10;5;79 "int";10;0;0;0;1;15;14;3;4;1;6;5;4;2;41;108 "int";9;3;3;1;1;14;11;2;6;2;2;4;3;10;28;106 "int";9;3;2;3;2;17;17;1;3;6;9;8;6;10;29;99 "int";9;0;0;1;0;18;14;4;6;5;8;7;8;10;11;88 "int";10;0;0;1;0;17;10;4;4;4;7;7;6;6;12;73 "int";10;1;1;1;1;14;14;3;4;4;5;6;4;10;22;82 "int";9;0;1;2;2;16;17;6;4;5;9;8;8;10;10;79 "int";11;3;4;3;4;11;15;6;3;8;7;9;9;2;16;73 "int";9;4;0;3;0;22;12;4;4;6;5;6;3;10;31;102 "int";10;0;0;1;1;17;18;2;6;8;8;7;6;6;37;110 "int";9;1;1;3;4;11;12;3;4;4;5;3;6;10;20;94 "int";9;3;2;4;2;17;15;2;4;5;6;8;6;6;42;127 "int";9;0;1;1;1;14;15;4;8;9;8;9;10;10;20;94 "int";10;3;2;3;3;11;3;0;3;4;4;6;5;6;18;82 "int";11;6;2;2;4;15;9;5;6;7;8;8;7;6;15;67 "int";10;2;1;1;2;13;18;5;4;6;6;7;4;10;16;73 "int";8;0;0;0;0;7;15;1;2;2;7;7;4;6;21;104 "int";8;5;4;4;6;16;17;3;4;5;6;7;7;6;16;97 "int";8;6;3;3;4;9;13;3;4;4;3;4;3;10;8;84 "int";11;4;5;2;3;14;6;5;5;7;8;6;7;10;34;87 "int";10;4;4;1;5;20;15;5;7;8;9;9;7;10;33;104 "int";9;6;3;3;6;19;10;3;4;7;6;6;6;10;36;113 "int";9;6;2;1;3;19;18;3;5;7;7;9;5;10;36;113 "int";10;2;2;5;4;14;4;3;7;8;8;9;8;10;21;80 "int";11;3;2;1;6;18;16;4;5;5;6;7;5;10;22;82 "int";8;0;1;1;0;10;6;2;6;6;5;5;3;2;4;77 "int";11;5;3;4;6;18;5;1;5;6;7;8;5;10;26;87 "int";8;3;5;2;4;17;10;4;4;6;6;7;5;6;53;143 "int";13;5;2;4;5;19;14;3;6;7;9;7;6;10;34;87 "int";10;5;2;3;2;7;1;4;1;1;5;6;3;2;12;73 "int";8;4;0;0;3;17;6;3;3;4;5;6;4;6;21;104 "int";9;0;1;1;1;19;11;5;5;8;9;10;9;6;22;97 "int";8;5;4;3;6;17;1;2;3;4;2;5;7;2;11;89 "int";9;1;2;3;3;16;14;5;7;5;9;7;8;10;16;88 "int";11;1;2;2;4;4;4;2;4;5;5;5;1;2;19;78 "int";9;4;3;2;5;9;4;2;3;6;7;7;6;2;9;77 "int";11;3;2;4;1;19;12;5;5;2;7;7;5;10;20;73 "gen";8;0;2;1;2;35;18;5;7;4;7;9;9;10;27;108 "gen";8;4;2;4;4;36;10;6;6;7;7;7;9;10;25;109 "gen";8;6;6;6;6;20;16;4;9;6;7;8;7;6;29;111 "gen";8;4;1;4;2;36;18;3;5;8;7;7;10;6;22;97 "gen";8;2;1;2;1;36;17;3;6;9;7;8;8;6;22;101 "gen";9;5;6;6;6;21;10;4;5;2;2;5;6;10;24;104 "gen";8;1;2;1;3;34;18;4;8;8;10;7;8;10;26;107 "gen";9;2;2;3;5;37;15;5;8;10;10;10;10;10;22;97 "gen";8;4;5;0;6;34;10;4;7;6;9;9;10;6;26;109 "gen";9;4;2;5;1;21;15;3;6;8;9;9;9;10;25;101 "gen";9;4;0;4;1;39;10;4;2;3;1;7;8;10;13;83 "gen";8;2;0;3;2;34;20;6;6;7;5;6;7;10;29;111 "gen";8;5;1;4;1;34;11;7;6;8;8;9;9;2;23;103 "gen";9;1;2;2;2;30;16;3;6;5;7;8;7;6;29;107 "gen";8;3;2;2;5;30;14;1;4;6;7;9;5;2;18;95 "gen";9;3;2;2;1;33;15;4;7;8;8;10;9;10;30;113 "gen";8;0;0;2;3;39;11;4;8;8;9;10;7;6;24;104 "gen";8;4;3;3;4;36;9;2;4;6;4;6;6;2;14;79 "gen";8;6;0;4;1;20;15;4;6;7;7;7;8;6;18;81 "gen";9;1;1;4;2;19;14;5;7;8;7;8;8;6;19;92 "gen";8;3;1;1;0;32;19;3;5;2;9;10;9;10;28;110 "gen";8;5;6;6;6;28;10;10;10;10;10;10;10;10;14;79 "gen";9;3;2;2;2;33;9;6;8;8;9;9;8;2;30;109 "gen";8;5;3;4;6;34;8;4;3;2;6;7;6;10;18;81 "gen";9;2;1;0;4;10;10;4;4;4;3;4;3;10;13;83 "gen";8;3;2;1;4;14;13;5;5;4;3;4;4;10;29;114 "gen";9;4;2;4;3;9;13;4;1;4;3;4;4;6;24;108 "gen";8;5;3;3;5;20;17;5;5;4;2;4;4;10;29;114 "gen";9;4;3;1;3;16;10;6;6;8;9;8;8;6;14;79 "gen";9;2;3;6;3;19;8;3;3;5;6;7;4;10;20;94 "gen";8;3;3;4;3;17;8;4;5;6;5;8;5;6;19;101 "gen";8;0;1;0;1;25;6;6;5;8;8;8;8;10;21;100 "gen";8;0;1;0;1;16;2;5;6;5;7;6;5;2;19;101 "gen";8;2;0;1;2;8;1;3;6;7;7;7;5;2;14;79 "gen";9;3;2;3;3;23;13;5;4;5;7;8;6;10;13;83 "gen";8;5;2;2;3;10;11;5;7;9;9;9;6;2;6;81 "gen";8;1;0;0;1;19;6;3;5;4;4;3;3;2;11;89 "gen";8;3;1;3;1;18;7;3;3;4;7;7;6;6;8;76 "gen";9;4;3;5;5;17;10;3;5;4;7;6;5;6;16;88 "gen";8;6;3;3;4;9;14;4;4;5;4;5;4;2;14;79 "gen";9;5;6;3;5;13;11;5;3;2;4;5;6;10;15;86 "gen";8;4;3;3;5;10;16;5;5;4;3;6;5;6;19;101 "gen";9;3;2;3;2;24;9;6;7;5;6;6;7;6;9;77 "gen";9;4;3;4;5;11;13;3;3;4;3;4;4;2;17;89 "gen";9;2;2;3;4;9;15;5;5;6;7;5;8;6;27;104 "gen";9;5;4;3;4;20;10;3;3;3;2;4;5;10;32;112 "gen";8;2;1;0;1;10;8;3;4;4;4;5;5;6;16;97 "gen";9;4;5;2;5;25;12;4;4;5;5;6;6;10;13;83 "gen";9;5;4;3;4;11;13;6;5;6;6;7;7;2;10;79 "gen";8;4;5;4;4;10;9;4;4;5;5;6;6;2;4;77
______________________________________________ R-help@r-project.org 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.