An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100421/6e8bbb10/attachment.pl>
median Q?
7 messages · Joshua Wiley, Vlatka Matkovic Puljic, Mohamed Lajnef
Hello, summary() removes NAs by default. You can get the same results using median(year, na.rm=TRUE) see ?median HTH, Josh On Wed, Apr 21, 2010 at 6:40 AM, Vlatka Matkovic Puljic
<v.matkovic.puljic at gmail.com> wrote:
Hi, I have dataset n1 and v1 (years). when i ask median(year) [1] NA but if i put summary of dataset n1: summary(n1) R produces median (together with min/max/mean....) why it is so? -- ************************** Vlatka Matkovic Puljic 095/8618 171 ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100421/0bb14202/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100421/8ead0628/attachment.pl>
Hi, Try this median(v2[v1==1]) Mohamed Regards Vlatka Matkovic Puljic a ?crit :
I have additional Q:
v1 is gender (M=1 and F=2)
v2 is age
I want R to calculate median only for M (1),
but my comand is not good :)
while(v1=1){median(v2,na.rm=TRUE)}
Error: unexpected '=' in "while(Q2="
2010/4/21 Vlatka Matkovic Puljic <v.matkovic.puljic at gmail.com>
Thank you!
2010/4/21 Joshua Wiley <jwiley.psych at gmail.com>
Hello,
summary() removes NAs by default. You can get the same results using
median(year, na.rm=TRUE)
see ?median
HTH,
Josh
On Wed, Apr 21, 2010 at 6:40 AM, Vlatka Matkovic Puljic
<v.matkovic.puljic at gmail.com> wrote:
Hi,
I have dataset n1 and v1 (years).
when i ask
median(year)
[1] NA
but if i put summary of dataset n1:
summary(n1)
R produces median (together with min/max/mean....)
why it is so?
--
**************************
Vlatka Matkovic Puljic
095/8618 171
[[alternative HTML version deleted]]
______________________________________________ R-help at 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. -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/
--
**************************
Vlatka Matkovic Puljic
095/8618 171
Mohamed Lajnef,IE INSERM U955 eq 15 P?le de Psychiatrie H?pital CHENEVIER 40, rue Mesly 94010 CRETEIL Cedex FRANCE Mohamed.lajnef at inserm.fr tel : 01 49 81 31 31 (poste 18470) Sec : 01 49 81 32 90 fax : 01 49 81 30 99
Look at ?by for example by(data=v2, INDICES=v1, FUN=median, na.rm=TRUE) This will calculate the median of v2 (age) for each level of the indices v1 (in your case M and F). If you are only interested the median for a single level, Mohamed's solution is simpler. Josh On Wed, Apr 21, 2010 at 8:10 AM, Vlatka Matkovic Puljic
<v.matkovic.puljic at gmail.com> wrote:
I have additional Q:
v1 is gender (M=1 and F=2)
v2 is age
I want R to calculate median only for M (1),
but my comand is not good :)
while(v1=1){median(v2,na.rm=TRUE)}
Error: unexpected '=' in "while(Q2="
2010/4/21 Vlatka Matkovic Puljic <v.matkovic.puljic at gmail.com>
Thank you! 2010/4/21 Joshua Wiley <jwiley.psych at gmail.com>
Hello, summary() removes NAs by default. ?You can get the same results using median(year, na.rm=TRUE) see ?median HTH, Josh On Wed, Apr 21, 2010 at 6:40 AM, Vlatka Matkovic Puljic <v.matkovic.puljic at gmail.com> wrote:
Hi, I have dataset n1 and v1 (years). when i ask median(year) [1] NA but if i put summary of dataset n1: summary(n1) R produces median (together with min/max/mean....) why it is so? -- ************************** Vlatka Matkovic Puljic 095/8618 171 ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
-- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/
-- ************************** Vlatka Matkovic Puljic 095/8618 171
-- ************************** Vlatka Matkovic Puljic 095/8618 171
Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100421/e9709d31/attachment.pl>