My apologize if the question is confusing. This is due to my English language. Thanks to Jim Lemon who has helped me. I must to learn R harder, like how to use "unlist" and "list".
On Wed, May 20, 2015 at 1:36 PM, Jim Lemon <drjimle...@gmail.com> wrote: > Hi Xiyan, > I have to admit that your puzzle very nearly stumped me. At first I > thought the question was: > > "What are the numbers of rows with changed and unchanged class values?" > > That doesn't work as there are at most four rows and your answer sums > to five. I then tried: > > "How many times does at least one value of class change between > successive data frames?" > > Nope, four have at least one change. Could it have been: > > "Using unique combinations of the values of Netto and Bruto, how many > changes have occurred?" > > Wrong again, there are 12 combinations, not five. Surely you don't mean: > > "In how many data frames does ta least one value of class equal 'no'?" > > df1<-data.frame(Netto=c(10,100),Bruto=c(1000,20),class=c("yes","yes")) > df2<-data.frame(Netto=c(101,100),Bruto=c(1000,210),class=c("yes","no")) > > df3<-data.frame(Netto=c(10,12,100),Bruto=c(10,28,20),class=c("yes","yes","yes")) > df4<-data.frame(Netto=c(120,400),Bruto=c(200,20),class=c("no","yes")) > df5<-data.frame(Netto=c(110,1100,120,1140),Bruto=c(12000,120,100,125), > class=c("yes","yes","yes","yes")) > sxdat<-list(df1,df2,df3,df4,df5) > table(ifelse(unlist(lapply(sxdat,function(x) > return(any(x$class=="no")))),"changed","unchanged")) > > Jim > > On Wed, May 20, 2015 at 1:04 PM, Bert Gunter <gunter.ber...@gene.com> > wrote: > > Probably "or what." > > > > This demonstrates a fundamental conundrum: many users or prospective > users > > of R have had little exposure to data structures in their formal > education > > and therefore can be flummoxed by R's fussiness -- as any programming > > language must necessarily be. Consider: data frames, matrices, lists, > > "classes", objects with attributes (e.g. factors),... > > > > Excel, which is basically structureless, of course, exacerbates the > > problem. Those accustomed to its tolerance (and the confusion that > results) > > expect R to behave the same way. Education is the only recourse, either > in > > formal courses or through R tutorials that strongly emphasize this aspect > > of interacting with R and especially writing effective code. But that > > demands effort and, to some extent, aptitude... both of which seem to be > in > > increasingly short supply amidst the worldwide explosion in R's usage. > > > > Of course, feel free to disagree... Just my $.02 > > > > Cheers, > > Bert > > > > > > Bert Gunter > > Genentech Nonclinical Biostatistics > > (650) 467-7374 > > > > "Data is not information. Information is not knowledge. And knowledge is > > certainly not wisdom." > > Clifford Stoll > > > > > > > > On Tue, May 19, 2015 at 7:02 PM, John Kane <jrkrid...@inbox.com> wrote: > > > >> Is this a list of data.frames or what? > >> > >> Please have a look at one or both of these for some ideas of how to ask > a > >> question and provide information on the problem. The better you can > >> describe what you have and what you need the better people can help. > >> > >> > http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example > >> and http://adv-r.had.co.nz/Reproducibility.html > >> > >> > >> John Kane > >> Kingston ON Canada > >> > >> > >> > -----Original Message----- > >> > From: soe.xi...@gmail.com > >> > Sent: Tue, 19 May 2015 23:37:13 +0700 > >> > To: r-help@r-project.org > >> > Subject: [R] Count unchanged class attribute > >> > > >> > Maybe someone can help me. > >> > Suppose I have data-set like this: > >> > > >> > Netto Bruto class > >> > 1 10 1000 yes > >> > 2 100 20 yes > >> > > >> > > >> > Netto Bruto class > >> > 1 101 1000 yes > >> > 2 100 210 no > >> > > >> > > >> > Netto Bruto class > >> > 1 10 10 yes > >> > 2 12 28 yes > >> > 3 100 20 yes > >> > > >> > Netto Bruto class > >> > 1 120 200 no > >> > 2 400 20 yes > >> > > >> > > >> > Netto Bruto class > >> > 1 110 12000 yes > >> > 2 1100 120 yes > >> > 3 120 100 yes > >> > 4 1140 125 yes > >> > > >> > How to calculate the number of classes has changed. > >> > The expected result is > >> > - class changed 2 > >> > - class unchanged 3 > >> > > >> > > >> > Thank you so much. > >> > Soe Xiyan > >> > > >> > [[alternative HTML version deleted]] > >> > > >> > ______________________________________________ > >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> > 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. > >> > >> ____________________________________________________________ > >> Can't remember your password? Do you need a strong and secure password? > >> Use Password manager! It stores your passwords & protects your account. > >> > >> ______________________________________________ > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> 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. > >> > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.