[R] sequencial frequency table

2007-01-30 Thread Mauricio Cardeal
Hi.

I have the data frame xyz below and I´d like to perform a sequencial 
frequency table using some unique function instead of making 3 different 
one-by-one table (table x, table y and table z). But I´can´t figure out 
the correct way.

x - c(2,3,2,4)
y - c(3,1,1,1)
z - c(4,2,1,4)
xyz - as.data.frame(cbind(x,y,z))

freq - function(x){
table(x)
}

freq(xyz)

Thank you,
Mauricio

__
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.


[R] filling the area

2007-01-25 Thread Mauricio Cardeal
Please, how to fill the area under the curve?

x - c(1:10)
y - c(rnorm(10))
plot(x,y)
lines(x,y)

Thanks,
Mauricio Cardeal

__
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.


Re: [R] filling the area

2007-01-25 Thread Mauricio Cardeal
Ok. I´ve tried before and all I got was a polygon indeed with the 
extremes points connected. Please where is the error ?

polygon(x,y,col=gray, border = red)

Benilton Carvalho escreveu:
 take a look at:

 ?polygon

 b

 On Jan 25, 2007, at 8:18 AM, Mauricio Cardeal wrote:

 Please, how to fill the area under the curve?

 x - c(1:10)
 y - c(rnorm(10))
 plot(x,y)
 lines(x,y)

 Thanks,
 Mauricio Cardeal

 __ NOD32 1.1752 (20060912) Information __

 This message was checked by NOD32 antivirus system.
 http://www.nod32.com




__
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.


Re: [R] filling the area

2007-01-25 Thread Mauricio Cardeal
Thank you all. One more question about the syntax below: min(y) twice, is it?

polygon(c(min(x), x, max(x)), c(min(y), y, min(y)),  col = blue)

polygon( c(min(x), x, max(x)), c( min(y), y, min(y)), density=100 )

Best whises,
Mauricio



Marc Schwartz escreveu:
 On Thu, 2007-01-25 at 10:18 -0300, Mauricio Cardeal wrote:
   
 Please, how to fill the area under the curve?

 x - c(1:10)
 y - c(rnorm(10))
 plot(x,y)
 lines(x,y)

 Thanks,
 Mauricio Cardeal
 

 See ?polygon

 x - 1:10
 y - rnorm(10)

 plot(x,y, type = o)

 polygon(c(min(x), x, max(x)), c(min(y), y, min(y)),  col = blue)


 HTH,

 Marc Schwartz



 __ NOD32 1.1752 (20060912) Information __

 This message was checked by NOD32 antivirus system.
 http://www.nod32.com





__
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.


[R] clear screen

2006-11-05 Thread Mauricio Cardeal
Hello !

Please, how can I clear the RConsole screen ? Is there any clear command ?

Thanks,
Mauricio

__
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.


Re: [R] multiple lines and plot

2006-09-20 Thread Mauricio Cardeal
Ok. I´ve already tried ?lines. An example:

x - c(1,2,3,4,5,6)
y - c(3,5,2,4,1,4)
z - c(2,3,4,3,2,1)
plot(x,y)
lines(x,y)
lines(x,z)

Here is the point: how to show the points under the second line (x,z) ?

Thanks
Mauricio


David Barron escreveu:
 ?lines

 On 20/09/06, Mauricio Cardeal [EMAIL PROTECTED] wrote:
 Hi. Please, how can I put together 2 or more lines at the same
 scatterplot ? Example: measures of protein intake (quantitative) of 4
 children over 30 days, by day. How to plot all children at same graphic:
 Protein X Time ? Is there any command like overlay ?

 Thank you,
 Mauricio

 __
 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.




__
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.


[R] multiple lines and plot

2006-09-19 Thread Mauricio Cardeal
Hi. Please, how can I put together 2 or more lines at the same 
scatterplot ? Example: measures of protein intake (quantitative) of 4 
children over 30 days, by day. How to plot all children at same graphic: 
Protein X Time ? Is there any command like overlay ?

Thank you,
Mauricio

__
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.


[R] missing value

2006-08-02 Thread Mauricio Cardeal
Hi all

# I have this data set and how can I assign NA´s in just one command ? 
And why the summary(dat) function preserves the value 9 as real. ?

x - c(1,2,3,9,4)
y - c(3,6,9,2,3)
z - c(9,9,2,2,8)
w - c(6,5,3,0,9)

dat - cbind(x,y,z,w)
summary(dat)

x[x==9] - NA
y[y==9] - NA
z[z==9] - NA
w[w==9] - NA

summary(dat)
summary(x)
summary(y)
summary(z)
summary(w)

Thank you all,
Mauricio

__
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.


[R] the first and last case

2006-07-26 Thread Mauricio Cardeal
Hi all

Sometime ago I asked for a solution about how to aggregate data and the 
help was wonderful. Now, I´d like to know how to extract for each 
individual case below the first and the last observation to obtain this:

ind  y
18
19
27
2   11
39
3   10
4   8
4   5

# Below the example:

ind - c(1,1,1,2,2,3,3,3,4,4,4,4)
y - c(8,10,9,7,11,9,9,10,8,7,6,5)
dat - as.data.frame(cbind(ind,y))
dat
attach(dat)
mean.ind - aggregate(dat$y, by=list(dat$ind), mean)
mean.ind

Thanks
Mauricio

__
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.


[R] new object

2006-07-11 Thread Mauricio Cardeal
Hi !

Please, how can I extract n.event and n.risk as a new object from 
example below ?  Thanks in advance.
Mauricio

require(survival)
fit - survfit(Surv(time, status) ~ x, data=aml)

summary(fit)

Call: survfit(formula = Surv(time, status) ~ x, data = aml)

x=Maintained
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
9 11   10.909  0.0867   0.75411.000
   13 10   10.818  0.1163   0.61921.000
   18  8   10.716  0.1397   0.48841.000
   23  7   10.614  0.1526   0.37690.999
   31  5   10.491  0.1642   0.25490.946
   34  4   10.368  0.1627   0.15490.875
   48  2   10.184  0.1535   0.03590.944

x=Nonmaintained
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
5 12   2   0.8333  0.1076   0.64701.000
8 10   2   0.6667  0.1361   0.44680.995
   12  8   1   0.5833  0.1423   0.36160.941
   23  6   1   0.4861  0.1481   0.26750.883
   27  5   1   0.3889  0.1470   0.18540.816
   30  4   1   0.2917  0.1387   0.11480.741
   33  3   1   0.1944  0.1219   0.05690.664
   43  2   1   0.0972  0.0919   0.01530.620
   45  1   1   0.  NA   NA   NA

[[alternative HTML version deleted]]

__
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


[R] help

2006-07-11 Thread Carlos Mauricio Cardeal Mendes
Please, is there any R-list about survival package ?

Thanks
Mauricio

__
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


[R] mca id numbers

2006-05-03 Thread Carlos Mauricio Cardeal Mendes
Is it possible to make disappear the id numbers from scatter.dudi (mc 
analysis)  ?

a - as.factor(c(1, 2, 3, 2, 1))
b - as.factor(c(3, 2, 3, 1, 1))
x - as.factor(c(1, 2, 2, 1, 3))
y - as.factor(c(2, 2, 3, 1, 1))

dat - data.frame(a=a, b=b,x=x,y=y)
summary(dat)
dat
require(ade4)
dat.acm - dudi.acm(dat, scann = FALSE, nf = 2)
scatter.dudi(dat.acm)

Thank you very much !
Mauricio

__
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


[R] factors and mca

2006-05-02 Thread Carlos Mauricio Cardeal Mendes
Hi ! Wonder if I have this code below:

a - c(1, 2, 3, 2, 1)
b - c(3, 2, 3, 1, 1)
d -as.factor(a)
e -as.factor(b)
table(d,e)
is.factor(a)
is.factor(b)
is.factor(d)
is.factor(e)
de - factor(c(d,e))
is.factor(de)
require(MASS)
mca(de)

I'd like to perform a correspondence analysis, but I can't understand why the 
message error after mca.

Aren't those (d and e) factors as is.factors shows ?

  Erro em mca(de) : all variables must be factors

I'm running R 2.3.0 under windows XP


Thank you !
Mauricio

__
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


[R] sample matrix

2005-12-13 Thread Carlos Mauricio Cardeal Mendes
Please, I´d like to store this sample matrix as a new object. How can I 
do this ?

pulse - c(67, 67, 68, 68, 68, 69, 69, 69, 69, 69, 70, 70, 70, 70, 71, 
71, 72, 72, 73, 74)
m - NULL
x - 0
for (i in 1:5)
{
x - sample(pulse,3)
m - mean(x)
cat(x,m,\n)
}

Thanks,
Mauricio

__
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


[R] sample matrix as a new object

2005-12-13 Thread Carlos Mauricio Cardeal Mendes
Please, I´d like to store this sample matrix as a new object. How can I 
do this ?

pulse - c(67, 67, 68, 68, 68, 69, 69, 69, 69, 69, 70, 70, 70, 70, 71, 
71, 72, 72, 73, 74)
m - NULL
x - 0
for (i in 1:5)
{
x - sample(pulse,3)
m - mean(x)
cat(x,m,\n)
}

Thanks,
Mauricio

__
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


[R] correct rate

2005-10-26 Thread Carlos Mauricio Cardeal Mendes
Hi everone !

I know its not a epidemiologic or statistic list, but since I´m using R 
to solve related problems ... here it goes:

This is a code to solve the rate problem, but the real question is: 
what´s the correct way to calculate the period rate (3 years period put 
together)
The third option is quite different (middle period).
Any suggestions ?

Thanks
Mauricio, Brazil

# Example from Field epidemiology basics computer lab 1

# annual period rates (1989, 1990, 1991)

years - 1989:1991
deaths - c(125, 130, 131)
pop - c(361975, 361401, 366613)

# rates and rates per 10.000 per year
rates - deaths/pop
ratesf - round(rates*1,digits=2)
rates
ratesf

# to calculate the period rate we have 3 possibilities:

# 1) sum of deaths by sum of populations:

rates89_91_1 - sum(deaths)/sum(pop)
rates89_91f_1 - round(rates89_91_1*1,digits=2)
rates89_91_1
rates89_91f_1

# 2) mean rates:

rates89_91_2 - (rates[1]+rates[2]+rates[3])/3
rates89_91f_2 - round(rates89_91_2*1,digits=2)
rates89_91_2
rates89_91f_2

# 3) sum of deahts by middle population (1990):

rates89_91_3 - (deaths[1]+deaths[2]+deaths[3])/pop[2]
rates89_91f_3 - round(rates89_91_3*1,digits=2)
rates89_91_3
rates89_91f_3

__
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


[R] npmc package

2005-10-19 Thread Carlos Mauricio Cardeal Mendes
Hi

Does anyone know where is the package: npmc (Nonparametric Multiple 
Comparisons).

I found the reference on R Site Search, but not the package itself on 
CRAN as suggested.

Thanks

Mauricio

__
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


Re: [R] npmc package

2005-10-19 Thread Carlos Mauricio Cardeal Mendes
So, is there another package to substitute those functions described on 
ORPHANED npmc package ?

Regards,
Mauricio
Brazil

Uwe Ligges escreveu:

 Carlos Mauricio Cardeal Mendes wrote:

 Hi

 Does anyone know where is the package: npmc (Nonparametric Multiple 
 Comparisons).

 I found the reference on R Site Search, but not the package itself on 
 CRAN as suggested.


 The packages is ORPHANED and removed from the CRAN main repository. 
 You can get older versions from the archives, though:

 your-CRAN-mirror/src/contrib/Archive/N/npmc_1.0-1.tar.gz

 Uwe Ligges

 Thanks

 Mauricio

 __
 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






__
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


Re: [R] if() command

2005-09-14 Thread Carlos Mauricio Cardeal Mendes
Ok Petr, I run your suggestion and I got this message:

  age-sample(seq(10,50,10), 20, replace=T)
 
  if (age =10) {group - 1} else if (age  10  age = 20) {group - 
2} else {group - 3}
Warning message:
the condition has length  1 and only the first element will be used in: 
if (age = 10) {

What does it means ?

And when I look to the database I have no new classification !

Could you help please ?

Mauricio

Petr Pikal escreveu:

 Hallo


 On 13 Sep 2005 at 10:29, Carlos Maurício Cardeal Mende wrote:

 Hi everyone !

 Could you please help me with this problem ?

 I´ve trying to write a code that assign to a variable the content from
 another, but all I´ve got is a message error. For example:

 if (age =10) {group == 1}
 else if (age  10  age = 20) {group == 2}
 else {group == 3}

 if you put your statement on one line it works (at least it does not 
 give you syntax error) but the result is hardly what you really expect

 age-sample(seq(10,50,10), 20, replace=T)

 if (age =10) {group - 1} else if (age  10  age = 20) {group - 2} 
 else {group - 3}
 if (age =10) {group == 1} else if (age  10  age = 20) {group == 2} 
 else {group == 3}

 Maybe you want something like

 group-as.numeric(cut(age,c(0,10,20,100)))

 but it is only guess

 HTH
 Petr


 Syntax error

 Or

 if (age =10) {group == 1}
 else (age  10  age = 20) {group == 2}
 else {group == 3}

 Syntax error

 I know that is possible to find the solution by ifelse command or even
 recode command, but I´d like to use this way, because I can add
 another variable as a new condition and I believe to expand the
 possibilites.

 Thanks,
 Mauricio

 __
 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


 Petr Pikal
 [EMAIL PROTECTED]



No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.21/96 - Release Date: 10/9/2005
  


__
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


Re: [R] if() command

2005-09-14 Thread Carlos Mauricio Cardeal Mendes
Hello reid ! About your third explanation, could you please write the 
complete code including that option: a loop ?

Forgiveme,  I'm trying to learn R and my mind is full of  other 
statistical program syntax. And I'd like very very much to improve my 
knowledge using R and maybe contribute to someone, someday, somehow.

Thanks, again

Mauricio

Huntsinger, Reid escreveu:

First, == is logical comparison, so if you want to create a variable based
on both age and group you can do that. However, it looks like you want
to define the variable group, so you want to use - or = for that. 

Second, if you're typing this at a command prompt, you need to make sure you
tell R you're not finished when it looks like you could be. There are
several ways to do this. One is to put everything inside braces; another is
to deliberately leave lines incomplete, like

if (age = 10) {
   group - 1
} else {
   if (age = 20) {
  group - 2
   } else group - 3
}

Third, this will work for a vector of length 1. If you want to take a vector
age and produce a corresponding vector group, you'll need to put this in
a loop, or use lapply, or some iteration.

Fourth, you can also write the above as 

  

group - if (age = 10) 1 else if (age = 20) 2 else 3



that is, if() returns a value you can assign.

Finally, besides ifelse you can use cut for this particular task.

Reid Huntsinger


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Carlos Maurício
Cardeal Mendes
Sent: Tuesday, September 13, 2005 9:29 AM
To: r-help@stat.math.ethz.ch
Subject: [R] if() command


Hi everyone !

Could you please help me with this problem ?

I´ve trying to write a code that assign to a variable the content from 
another, but all I´ve got is a message error. For example:

if (age =10) {group == 1}
else if (age  10  age = 20) {group == 2}
else {group == 3}

Syntax error

Or

if (age =10) {group == 1}
else (age  10  age = 20) {group == 2}
else {group == 3}

Syntax error

I know that is possible to find the solution by ifelse command or even 
recode command, but I´d like to use this way, because I can add another 
variable as a new condition and I believe to expand the possibilites.

Thanks,
Mauricio

__
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





--
Notice:  This e-mail message, together with any attachments...{{dropped}}

__
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


[R] Proportions again

2004-02-29 Thread Carlos Mauricio Cardeal Mendes
Hello.

I asked before and it was great, cause as a beginner I learned a lot. But, if I have 
this in R (1 and 2 are codes for sex):

 sex-c(1,2,2,1,1,2,2,2)
 sex
[1] 1 2 2 1 1 2 2 2

I´d like to obtain the proportion according to sex.So I type:

 prop.table(sex)
[1] 0.07692308 0.15384615 0.15384615 0.07692308 0.07692308 0.15384615 0.15384615
[8] 0.15384615

The result is OK, but I expected to see a simple frequency table or something like 
that:

1   0.375
2   0.625
 1.0

How can I get this ? 

Thank you very much
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] proportions

2004-02-11 Thread Mauricio Cardeal
Hi all:

Please be patient with my silly question:

How can I get proportions if I have a contingency table ? 

I tried the table command, but I almost sure I made my usual mistakes.

Thaks

Mauricio

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html