Thank you very very much David
________________________________ De : David Winsemius <dwinsem...@comcast.net> à : David Winsemius <dwinsem...@comcast.net> Envoyé le : Mardi, 25 Août 2009, 23h32mn 53s Objet : Re: [R] Re : Odp: Re : Odp: Re : table function On Aug 25, 2009, at 9:23 AM, David Winsemius wrote: > > On Aug 25, 2009, at 6:25 AM, Inchallah Yarab wrote: > [[elided Yahoo spam]] >> [[elided Yahoo spam]] >> [[elided Yahoo spam]] > > ?table > ?xtab I read this incorrectly. Try instead; > by(z, z.c, sum) z.c: 0 - 1000 [1] 1010 ------------------------------------------------------------------------ z.c: >1000 - 3000 [1] 6400 ------------------------------------------------------------------------ z.c: >3000 [1] 14200 > >> ________________________________ >> De : Petr PIKAL <petr.pi...@precheza.cz> >> >> Cc : r-help@r-project.org >> Envoyé le : Mardi, 25 Août 2009, 11h53mn 21s >> Objet : Odp: [R] Re : Odp: Re : table function >> >> Hi >> >> r-help-boun...@r-project.org napsal dne 25.08.2009 11:28:31: >> >>> à >>> Thank you Peter, >>> in my vector Z i have missing value ""NA" and i want to count its >>> number >> in the vector >>> i had did alla this i know the difference between a numeirc and a >>> factor >> >> >> OK. If you know difference between factor and numeric you probably >> have >> seen >> ?factor >> where is note about how to make NA an extra level >> >> #Here is z >> z<-c(10,100, 1000, 1200, 2000, 2200, 3000, 3200, 5000, 6000) >> #let's put some NA values into it >> z[c(2,5)] <-NA >> #let's make a cut >> z.c<-cut(z, breaks = c(-Inf, 1000, 3000, Inf), labels = c("0 - 1000", >> ">1000 - 3000", ">3000")) >> #as you see there are NA values but they are not extra level >> z.c >> [1] 0 - 1000  <NA>    0 - 1000  >1000 - 3000 <NA> >> [6] >1000 - 3000 >1000 - 3000 >3000    >3000    >3000 >> Levels: 0 - 1000 >1000 - 3000 >3000 >> is.na(z.c) >> [1] FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE >> >> # so let's try what help page says >>> factor(z.c, exclude=NULL) >> [1] 0 - 1000  <NA>    0 - 1000  >1000 - 3000 <NA> >> [6] >1000 - 3000 >1000 - 3000 >3000    >3000    >3000 >> Levels: 0 - 1000 >1000 - 3000 >3000 <NA> >> # wow we have NA as extra level, let's do table >> table(factor(z.c, exclude=NULL)) >> >>  0 - 1000 >1000 - 3000    >3000    <NA> >>     2      3      3      2 >> >> Regards >> Petr >> >> >>> the goal of this exercice that to count the number of missing value, >> number >>> betwwen 0-1000 , 1000-3000, >3000. >>> >>> Thank you again for your help >>> >>> >>> >>> >>> ________________________________ >>> De : Petr PIKAL <petr.pi...@precheza.cz> >>> >>> Cc : r-help@r-project.org >>> EnvoyÄ© le : Mardi, 25 AoÄ»t 2009, 11h15mn 23s >>> Objetà : Odp: [R] Re : table function >>> >>> Hi >>> >>> r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36: >>> >>>> Hi Mark, >>>> >>>> >>>> Thank you for your answer !! it works but if i have "NA" in the >>>> vector >> z >>> what >>>> i shoud do to count its number in Z? >>> >>> You do not have NA in z, you manage to convert it somehow to factor. >>> Please try to read about data types and its behaviour. Start with >>> this >>> chapter >>> 2.8 Other types of objects >>> in R intro manual which I suppose you have in doc folder of R >>> program >>> directory. You possibly can convert it back to numeric by >>> >>> e.g. >>> >>> DF$z <- as.numeric(as.character(DF$z)) >>> >>> but I presume you need to check your original data maybe by >>> >>> str(your.data) what mode they are and why they are factor if you >>> expect >>> them numeric. >>> >>> Regards >>> Petr >>> >>>> xàààyààààz >>>>> 1àà0ààà100 >>>>> 5àà1ààà1500 >>>>> 6àà1àààNA >>>>> 2àà2ààà500 >>>>> 1àà1àààNA >>>>> 5àà2àà2000 >>>>> 8àà5àà4500 >>>>> >>>> >>>> i did the same but it gives me this erroràmessage: >>>> à[0 - 1000] [1000 - 3000]àààà>3000 >>>> àààààà0àààààà0àà>>>> àà>>>> àà0 >>>> Warning message: >>>> In inherits(x, "factor") : NAs introduced by coercion >>>> >>>> >>>> Thank you >>>> >>>> >>>> ________________________________ >>>> De : Marc Schwartz <marc_schwa...@me.com> >>>> >>>> Cc : r-help@r-project.org >>>> EnvoyÄ© le : Lundi, 24 Aoűt 2009, 18h33mn 52s >>>> Objet : Re: [R] table function >>>> >>>> On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote: >>>> >>>>> hi, >>>>> >>>>> i want to use the function table to build a table not of frequence >>> (number >>>> of time the vareable is repeated in a list or a data frame!!) but >>>> in >>> function of classes >>>> [[elided Yahoo spam]] >>>>> >>>>> example >>>>> >>>>> xàààyààààz >>>>> 1àà0ààà100 >>>>> 5àà1ààà1500 >>>>> 6àà1ààà1200 >>>>> 2àà2ààà500 >>>>> 1àà1ààà3500 >>>>> 5àà2àà2000 >>>>> 8àà5àà4500 >>>>> >>>>> i want to do a table summerizing the number of variable where z is >> in >>>> [0-1000],],[1000-3000], [> 3000] >>>>> >>>>> thank you very much for your help >>>> >>>> >>>> See ?cut, which bins a continuous variable. >>>> >>>>> DF >>>> àx yààz >>>> 1 1 0à100 >>>> 2 5 1 1500 >>>> 3 6 1 1200 >>>> 4 2 2à500 >>>> 5 1 1 3500 >>>> 6 5 2 2000 >>>> 7 8 5 4500 >>>> >>>> >>>>> table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf), >>>> ààààààlabels = c("0 - 1000", ">1000 - 3000", >>>> ">3000"))) >>>> >>>> àà0 - 1000 >1000 - 3000àààà>3000 >>>> ààààà2àààààà3ààà>>>> àà>>>> à2 >>>> >>>> HTH, >>>> >>>> Marc Schwartz >>>> >>>> >>>> >>>> àà[[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> 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. >>> >>> >>> >>>  [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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. >> >> >> >>    [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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 > Heritage Laboratories > West Hartford, CT > > ______________________________________________ > 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 Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]]
______________________________________________ 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.