Re: [R] Need help putting histograms on the diagonal of a splom plot

2007-08-31 Thread Deepayan Sarkar
On 8/30/07, Marc Paterno [EMAIL PROTECTED] wrote:
 Hello,

 I am in need of help in putting histograms on the diagonal of a plot
 produced with splom().

 The plot matrix I am trying to produce is to have standard scatterplots
 in the upper-left triangle, contour plots in the lower-right triangle,
 and histograms on the diagonal. I have a function that does the first
 two, but the histograms on the diagonal has been beyond my ability.

 Here is my function:

 require(lattice)
 require(MASS)
 my.plot = function(data)
 {
splom( ~data
 , lower.panel=function(x,y, ...)
   {
 xy=kde2d(x,y)
 xy.tr=con2tr(xy)
 panel.contourplot( xy.tr$x
  , xy.tr$y
  , xy.tr$z
  , subscripts=seq(nrow(xy.tr))
  , contour=TRUE
  , region=TRUE
  , labels = FALSE
  , col.regions = terrain.colors
  )
   }
  , upper.panel=function(x,y, ...)
   {
 panel.grid(-1,-1)
 panel.xyplot(x,y, cex=0.5)
   }
 #, diag.panel=function(x, ...)
 #  {
 #panel.histogram(x, ...)
 #  }
 )
 }

 It can be called, for example, with:

my.plot(subset(iris, select = Sepal.Length:Petal.Width))

 (the subset is necessary to get rid of a variable that is a factor; my
 function can not deal with factors).

 I have commented out my best guess at the code needed to produce the
 histograms along the diagonal, which fails.

Well, basically the y-axis range of the diagonal panels are not right.
What you want is simpler if you are happy with a density estimate:


my.plot = function(data)
{
  splom( ~data
   #, lower.panel=...
   #, upper.panel=...
   , diag.panel = function(x, ...)
 {
 yrng - current.panel.limits()$ylim
 d - density(x)
 d$y - with(d, yrng[1] + 0.95 * diff(yrng) * y / max(y) )
 panel.lines(d)
 })
}

my.plot(iris[1:4])

For a histogram, things are a bit more complicated, but still easy enough:

my.plot = function(data)
{
  splom( ~data
   #, lower.panel=...
   #, upper.panel=...
   , diag.panel = function(x, ...)
 {
 yrng - current.panel.limits()$ylim
 d - density(x)
 d$y - with(d, yrng[1] + 0.95 * diff(yrng) * y / max(y) )
 panel.lines(d)
 })
}

-Deepayan

__
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] Need help putting histograms on the diagonal of a splom plot

2007-08-30 Thread Marc Paterno
Hello,

I am in need of help in putting histograms on the diagonal of a plot 
produced with splom().

The plot matrix I am trying to produce is to have standard scatterplots 
in the upper-left triangle, contour plots in the lower-right triangle, 
and histograms on the diagonal. I have a function that does the first 
two, but the histograms on the diagonal has been beyond my ability.

Here is my function:

require(lattice)
require(MASS)
my.plot = function(data)
{
   splom( ~data
, lower.panel=function(x,y, ...)
  {
xy=kde2d(x,y)
xy.tr=con2tr(xy)
panel.contourplot( xy.tr$x
 , xy.tr$y
 , xy.tr$z
 , subscripts=seq(nrow(xy.tr))
 , contour=TRUE
 , region=TRUE
 , labels = FALSE
 , col.regions = terrain.colors
 )
  }
 , upper.panel=function(x,y, ...)
  {
panel.grid(-1,-1)
panel.xyplot(x,y, cex=0.5)
  }
#, diag.panel=function(x, ...)
#  {
#panel.histogram(x, ...)
#  }
)
}

It can be called, for example, with:

   my.plot(subset(iris, select = Sepal.Length:Petal.Width))

(the subset is necessary to get rid of a variable that is a factor; my 
function can not deal with factors).

I have commented out my best guess at the code needed to produce the 
histograms along the diagonal, which fails.

Any guidance would be greatly appreciated.

best regards,
Marc

__
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] need help with pdf-plot

2007-08-13 Thread Antje
Thank you both!
The hint with the pty=s was very useful. I did not know it before.

Ciao,
Antje


Ivar Herfindal schrieb:
 Dear Antje
 
 I cannot see that you have got any replies yet, so I will make and 
 attempt. However, I am sure other have more formally correct solutions.
 
 When you call the pdf(), you can set paper=a4 (or a4r for 
 landscape). However, the width and the height of your plot should then 
 not exceed the size of the paper (which is approximately 8.27*11.69 
 inches for a4). Try (I have only tested on windows XP, R 2.5.0):
 
 pdf(test1.pdf, width=10, heigh=5, paper=a4r)
 par(mfrow=c(1,3), pty=s) #pty=s gives square plotting regions
 plot(rnorm(100))
 plot(rnorm(100))
 plot(rnorm(100))
 dev.off()
 
 Hope this helps
 
 Ivar
 
 
 Antje skrev:
 I still have this problem. Does anybody know any solution?

 Antje

 Antje schrieb:
  
 Hello,

 I'm trying to plot a set of barplots like a matrix (2 rows, 10 
 columns fromreduced_mat) to a pdf. It works with the following 
 parameters:

 pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, 
 pointsize = 12)

 par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
 lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)

 The I get a long narrow page format with the quadratic barplots.

 But I would like to have a A4 format in the end and the plots not 
 filling the whole page (they should stay somehow quadratic and not be 
 stretched...).

 What shall I look for to achieve this?

 Antje

 __
 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-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] need help to manipulate function and time interval

2007-08-13 Thread KOITA Lassana - STAC/ACE
Hi,
data are extracted from MS Access with the format: (%d/%m%Y %H%M%S); ex: 
16/09/2006 03:38:37
I still have error messneger

Thank you for your help. 

Lassana KOITA 
Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
Project Engineer Airport Safety Studies  Statistical analysis
Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical 
Department 
Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation 
Headquarters
Tel: 01 49 56 80 60
Fax: 01 49 56 82 14
E-mail: [EMAIL PROTECTED]
http://www.stac.aviation-civile.gouv.fr/



Uwe Ligges [EMAIL PROTECTED] 
12/08/2007 15:24

A
Matthew Walker [EMAIL PROTECTED]
cc
Henrique Dallazuanna [EMAIL PROTECTED], r-help@stat.math.ethz.ch, KOITA 
Lassana - STAC/ACE [EMAIL PROTECTED]
Objet
Re: [R] need help to manipulate function and time interval








Matthew Walker wrote:
 Uwe Ligges wrote:
 Henrique Dallazuanna wrote:
 
 Hi,

 Try whit:

 if(time[j] = 18:00:00   23:59:59)
 

 This code is obviously wrong and does not help for the next few lines 
 in the questioner's message, please do not post unsensible stuff.

 Uwe Ligges

 
 
 Actually, I would have said that was quite an interesting solution.  If 
 the time is guaranteed to be in this 8 character format, then that 
 idea's quite easily implemented:
 
 # Returns true if time is between 18:00:00 and 23:59:59
 check_time - function(time_string) {
  if (nchar(time_string)!=8) stop (Incorrect format)
  time_string = 18:00:00  time_string = 23:59:59
 }
 
 
   check_time(19:59:00)
 [1] TRUE
   check_time(16:59:00)
 [1] FALSE
  
   check_time(18:00:00)
 [1] TRUE
   check_time(23:59:59)
 [1] TRUE
   check_time(24:00:00)
 [1] FALSE
  
   check_time(18:05)
 Error in check_time(18:05) : Incorrect format
 
 
 Perhaps there is an issue if the locale does not sort character-based 
 numbers in the same way as ASCII?  But Otherwise, I can't see why this 
 solution wouldn't do the job.
 
 A more robust solution solution would parse the strings (?strptime) and 
 then check their days/hours/mins/seconds (?DateTimeClasses).  But 
 perhaps the above is sufficient?

Well, the interesting part of the original question that everynody seems 
to omit now was the second part:

if (time[j] is between 22:00:00 and 05:59:59)

hence the answer is still not sufficient (even if the syntax error has 
been corrected) - and hence I asked for the format the time is 
originally in.

Uwe Ligges




 Cheers,
 
 Matthew


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help to manipulate function and time interval

2007-08-13 Thread Uwe Ligges


KOITA Lassana - STAC/ACE wrote:
 Hi,
 data are extracted from MS Access with the format: (%d/%m%Y %H%M%S); ex: 
 16/09/2006 03:38:37


1. the example you gave in your first message is still not reproducible, 
you gave the following:

myfunc - function(mytab, Time, Level)
{
vect - rep(0, length(mytab))
for(i in 1:length(vect))
{
 for(j in 1:length(Time))
 if(time[j] is between 18:00:00 and 23:59:59)
 L[i] - L[j]+5
 vect[i] - 10^((L[i])/10
 if (time[j] is between 22:00:00 and 05:59:59)
 L[i] - L[j]+10
 vect[i] - 10^((L[i])/10
 else
 L[i] = L[j]
 vect[i] - 10^((L[i])/10
  }
}


a) Please check the parentheses  (some closing ) are missing, you also 
probably want to group some code {} that is executed in some of the 
if conditions rather than executing the (syntactically erroneous) line
   vect[i] - 10^((L[i])/10
three times for each inner loop. Particularly, the else is 
syntactically incorrect with not preceding if.

So my guess is you want something like


myfunc - function(mytab, Time, Level)
{
vect - rep(0, length(mytab))
for(i in 1:length(vect))
{
 for(j in 1:length(Time))
 {
 if(time[j] is between 18:00:00 and 23:59:59){
 L[i] - L[j]+5
 vect[i] - 10^(L[i]/10)
 }
 if (time[j] is between 22:00:00 and 05:59:59){
 L[i] - L[j]+10
 vect[i] - 10^(L[i]/10)
 } else {
 L[i] - L[j]
 vect[i] - 10^(L[i]/10)
 }
 }
}

But I am really not sure about that and why you subsitute L[i] so many 
times...!


b) What are mytab, Time and Level?


2. Which is the format do you have?
(%d/%m%Y %H%M%S)
*or*
16/09/2006 03:38:37
If the latter, you can use
dat - strptime(16/09/2006 03:38:37, %d/%m/%Y %H:%M:%S)
in order to get some POSIXlt object for later calculations.


3. What do you mean with
time[j] is between 22:00:00 and 05:59:59
Is the day of the date important or not for this comparison?

Uwe Ligges












 I still have error messneger
 
 Thank you for your help. 
 
 Lassana KOITA 
 Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
 Project Engineer Airport Safety Studies  Statistical analysis
 Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical 
 Department 
 Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation 
 Headquarters
 Tel: 01 49 56 80 60
 Fax: 01 49 56 82 14
 E-mail: [EMAIL PROTECTED]
 http://www.stac.aviation-civile.gouv.fr/
 
 
 
 Uwe Ligges [EMAIL PROTECTED] 
 12/08/2007 15:24
 
 A
 Matthew Walker [EMAIL PROTECTED]
 cc
 Henrique Dallazuanna [EMAIL PROTECTED], r-help@stat.math.ethz.ch, KOITA 
 Lassana - STAC/ACE [EMAIL PROTECTED]
 Objet
 Re: [R] need help to manipulate function and time interval
 
 
 
 
 
 
 
 
 Matthew Walker wrote:
 Uwe Ligges wrote:
 Henrique Dallazuanna wrote:

 Hi,

 Try whit:

 if(time[j] = 18:00:00   23:59:59)

 This code is obviously wrong and does not help for the next few lines 
 in the questioner's message, please do not post unsensible stuff.

 Uwe Ligges


 Actually, I would have said that was quite an interesting solution.  If 
 the time is guaranteed to be in this 8 character format, then that 
 idea's quite easily implemented:

 # Returns true if time is between 18:00:00 and 23:59:59
 check_time - function(time_string) {
  if (nchar(time_string)!=8) stop (Incorrect format)
  time_string = 18:00:00  time_string = 23:59:59
 }


   check_time(19:59:00)
 [1] TRUE
   check_time(16:59:00)
 [1] FALSE
  
   check_time(18:00:00)
 [1] TRUE
   check_time(23:59:59)
 [1] TRUE
   check_time(24:00:00)
 [1] FALSE
  
   check_time(18:05)
 Error in check_time(18:05) : Incorrect format


 Perhaps there is an issue if the locale does not sort character-based 
 numbers in the same way as ASCII?  But Otherwise, I can't see why this 
 solution wouldn't do the job.
  
 A more robust solution solution would parse the strings (?strptime) and 
 then check their days/hours/mins/seconds (?DateTimeClasses).  But 
 perhaps the above is sufficient?
 
 Well, the interesting part of the original question that everynody seems 
 to omit now was the second part:
 
 if (time[j] is between 22:00:00 and 05:59:59)
 
 hence the answer is still not sufficient (even if the syntax error has 
 been corrected) - and hence I asked for the format the time is 
 originally in.
 
 Uwe Ligges
 
 
 
 
 Cheers,

 Matthew
 
 
   [[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
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] need help to manipulate function and time interval

2007-08-13 Thread KOITA Lassana - STAC/ACE
a) I agreed with your suggestion about the condition else. L = Level of 
noise fluctuates during the various moments of the day (i.e L= L+5 between 
18:00:00 and 21:59:59; L=L+10 between 22:00:00 and 05:59:59 and L = L 
else).
b)
mytab is a data table including Time column, Level column,  ,
Time - Table[,time] and Level - Table[, Levele]
c) Time format is 16/09/2006 03:38:37
 d)
the time interval [ 18:00:00 ; 21:59:59 ]and  [ 22:00:00 ; 05:59:59] is 
very important for me.

Best regards 
 


Lassana KOITA 
Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
Project Engineer Airport Safety Studies  Statistical analysis
Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical 
Department 
Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation 
Headquarters
Tel: 01 49 56 80 60
Fax: 01 49 56 82 14
E-mail: [EMAIL PROTECTED]
http://www.stac.aviation-civile.gouv.fr/



Uwe Ligges [EMAIL PROTECTED] 
Envoyé par : [EMAIL PROTECTED]
13/08/2007 10:39

A
KOITA Lassana - STAC/ACE [EMAIL PROTECTED]
cc
r-help@stat.math.ethz.ch
Objet
Re: [R] need help to manipulate function and time interval








KOITA Lassana - STAC/ACE wrote:
 Hi,
 data are extracted from MS Access with the format: (%d/%m%Y %H%M%S); 
ex: 
 16/09/2006 03:38:37


1. the example you gave in your first message is still not reproducible, 
you gave the following:

myfunc - function(mytab, Time, Level)
{
vect - rep(0, length(mytab))
for(i in 1:length(vect))
{
 for(j in 1:length(Time))
 if(time[j] is between 18:00:00 and 23:59:59)
 L[i] - L[j]+5
 vect[i] - 10^((L[i])/10
 if (time[j] is between 22:00:00 and 05:59:59)
 L[i] - L[j]+10
 vect[i] - 10^((L[i])/10
 else
 L[i] = L[j]
 vect[i] - 10^((L[i])/10
  }
}


a) Please check the parentheses  (some closing ) are missing, you also 
probably want to group some code {} that is executed in some of the 
if conditions rather than executing the (syntactically erroneous) line
   vect[i] - 10^((L[i])/10
three times for each inner loop. Particularly, the else is 
syntactically incorrect with not preceding if.

So my guess is you want something like


myfunc - function(mytab, Time, Level)
{
vect - rep(0, length(mytab))
for(i in 1:length(vect))
{
 for(j in 1:length(Time))
 {
 if(time[j] is between 18:00:00 and 23:59:59){
 L[i] - L[j]+5
 vect[i] - 10^(L[i]/10)
 }
 if (time[j] is between 22:00:00 and 05:59:59){
 L[i] - L[j]+10
 vect[i] - 10^(L[i]/10)
 } else {
 L[i] - L[j]
 vect[i] - 10^(L[i]/10)
 }
 }
}

But I am really not sure about that and why you subsitute L[i] so many 
times...!


b) What are mytab, Time and Level?


2. Which is the format do you have?
(%d/%m%Y %H%M%S)
*or*
16/09/2006 03:38:37
If the latter, you can use
dat - strptime(16/09/2006 03:38:37, %d/%m/%Y %H:%M:%S)
in order to get some POSIXlt object for later calculations.


3. What do you mean with
time[j] is between 22:00:00 and 05:59:59
Is the day of the date important or not for this comparison?

Uwe Ligges












 I still have error messneger
 
 Thank you for your help. 
 
 Lassana KOITA 
 Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
 Project Engineer Airport Safety Studies  Statistical analysis
 Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical 

 Department 
 Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation 
 Headquarters
 Tel: 01 49 56 80 60
 Fax: 01 49 56 82 14
 E-mail: [EMAIL PROTECTED]
 http://www.stac.aviation-civile.gouv.fr/
 
 
 
 Uwe Ligges [EMAIL PROTECTED] 
 12/08/2007 15:24
 
 A
 Matthew Walker [EMAIL PROTECTED]
 cc
 Henrique Dallazuanna [EMAIL PROTECTED], r-help@stat.math.ethz.ch, KOITA 

 Lassana - STAC/ACE [EMAIL PROTECTED]
 Objet
 Re: [R] need help to manipulate function and time interval
 
 
 
 
 
 
 
 
 Matthew Walker wrote:
 Uwe Ligges wrote:
 Henrique Dallazuanna wrote:

 Hi,

 Try whit:

 if(time[j] = 18:00:00   23:59:59)

 This code is obviously wrong and does not help for the next few lines 
 in the questioner's message, please do not post unsensible stuff.

 Uwe Ligges


 Actually, I would have said that was quite an interesting solution.  If 

 the time is guaranteed to be in this 8 character format, then that 
 idea's quite easily implemented:

 # Returns true if time is between 18:00:00 and 23:59:59
 check_time - function(time_string) {
  if (nchar(time_string)!=8) stop (Incorrect format)
  time_string = 18:00:00  time_string = 23:59:59
 }


   check_time(19:59:00)
 [1] TRUE
   check_time(16:59:00)
 [1] FALSE
  
   check_time(18:00:00)
 [1] TRUE
   check_time(23:59:59)
 [1] TRUE
   check_time(24:00:00)
 [1] FALSE
  
   check_time(18:05)
 Error in check_time(18:05) : Incorrect format


 Perhaps there is an issue if the locale does not sort character-based 
 numbers in the same

Re: [R] need help to manipulate function and time interval

2007-08-12 Thread Uwe Ligges


Matthew Walker wrote:
 Uwe Ligges wrote:
 Henrique Dallazuanna wrote:
  
 Hi,

 Try whit:

 if(time[j] = 18:00:00   23:59:59)
 

 This code is obviously wrong and does not help for the next few lines 
 in the questioner's message, please do not post unsensible stuff.

 Uwe Ligges

   
 
 Actually, I would have said that was quite an interesting solution.  If 
 the time is guaranteed to be in this 8 character format, then that 
 idea's quite easily implemented:
 
 # Returns true if time is between 18:00:00 and 23:59:59
 check_time - function(time_string) {
  if (nchar(time_string)!=8) stop (Incorrect format)
  time_string = 18:00:00  time_string = 23:59:59
 }
 
 
   check_time(19:59:00)
 [1] TRUE
   check_time(16:59:00)
 [1] FALSE
  
   check_time(18:00:00)
 [1] TRUE
   check_time(23:59:59)
 [1] TRUE
   check_time(24:00:00)
 [1] FALSE
  
   check_time(18:05)
 Error in check_time(18:05) : Incorrect format
 
 
 Perhaps there is an issue if the locale does not sort character-based 
 numbers in the same way as ASCII?  But Otherwise, I can't see why this 
 solution wouldn't do the job.
 
 A more robust solution solution would parse the strings (?strptime) and 
 then check their days/hours/mins/seconds (?DateTimeClasses).  But 
 perhaps the above is sufficient?

Well, the interesting part of the original question that everynody seems 
to omit now was the second part:

if (time[j] is between 22:00:00 and 05:59:59)

hence the answer is still not sufficient (even if the syntax error has 
been corrected) - and hence I asked for the format the time is 
originally in.

Uwe Ligges




 Cheers,
 
 Matthew

__
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] need help to manipulate function and time interval

2007-08-11 Thread Matthew Walker
Uwe Ligges wrote:
 Henrique Dallazuanna wrote:
   
 Hi,

 Try whit:

 if(time[j] = 18:00:00   23:59:59)
 

 This code is obviously wrong and does not help for the next few lines in 
 the questioner's message, please do not post unsensible stuff.

 Uwe Ligges

   

Actually, I would have said that was quite an interesting solution.  If 
the time is guaranteed to be in this 8 character format, then that 
idea's quite easily implemented:

# Returns true if time is between 18:00:00 and 23:59:59
check_time - function(time_string) {
  if (nchar(time_string)!=8) stop (Incorrect format)
  time_string = 18:00:00  time_string = 23:59:59
}


  check_time(19:59:00)
[1] TRUE
  check_time(16:59:00)
[1] FALSE
 
  check_time(18:00:00)
[1] TRUE
  check_time(23:59:59)
[1] TRUE
  check_time(24:00:00)
[1] FALSE
 
  check_time(18:05)
Error in check_time(18:05) : Incorrect format


Perhaps there is an issue if the locale does not sort character-based 
numbers in the same way as ASCII?  But Otherwise, I can't see why this 
solution wouldn't do the job.

A more robust solution solution would parse the strings (?strptime) and 
then check their days/hours/mins/seconds (?DateTimeClasses).  But 
perhaps the above is sufficient?

Cheers,

Matthew

__
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] need help with pdf-plot

2007-08-10 Thread Antje
I still have this problem. Does anybody know any solution?

Antje

Antje schrieb:
 Hello,
 
 I'm trying to plot a set of barplots like a matrix (2 rows, 10 columns 
 fromreduced_mat) to a pdf. It works with the following parameters:
 
 pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, 
 pointsize 
 = 12)
 
 par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
 lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)
 
 The I get a long narrow page format with the quadratic barplots.
 
 But I would like to have a A4 format in the end and the plots not filling the 
 whole page (they should stay somehow quadratic and not be stretched...).
 
 What shall I look for to achieve this?
 
 Antje
 
 __
 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] need help to manipulate function and time interval

2007-08-10 Thread KOITA Lassana - STAC/ACE
Hi R-users,

I have to define a noise level function L and its energy in the various 
moment of the day by:

 if time is between 18:00:00 and 23:59:59 then  L[j] - L[j]+5 and W - 
10^((L+5)/10) 

if time is between 22:00:00 and 05:59:59 == L - L+10  and W - 
10^((L+10)/10)
else
L=L and W = W

Could someone help me to realize this function please? You will find my 
following proposal  code, but my main problem is to handle the time 
interval.

Best regard

###
myfunc - function(mytab, Time, Level)
{
vect - rep(0, length(mytab))
for(i in 1:length(vect))
   {
  for(j in 1:length(Time))

if(time[j] is between 18:00:00 and 23:59:59) 

L[i] - L[j]+5 
 
   vect[i] - 10^((L[i])/10

if (time[j] is between 22:00:00 and 05:59:59)

L[i] - L[j]+10 
 
 vect[i] - 10^((L[i])/10

else 
 
   L[i] = L[j]
 
  vect[i] - 10^((L[i])/10
 } 
} 

###

Lassana KOITA 
Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
Project Engineer Airport Safety Studies  Statistical analysis
Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical 
Department 
Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation 
Headquarters
Tel: 01 49 56 80 60
Fax: 01 49 56 82 14
E-mail: [EMAIL PROTECTED]
http://www.stac.aviation-civile.gouv.fr/
[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help to manipulate function and time interval

2007-08-10 Thread Henrique Dallazuanna
Hi,

Try whit:

if(time[j] = 18:00:00   23:59:59)
...
...

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

On 10/08/07, KOITA Lassana - STAC/ACE [EMAIL PROTECTED]
wrote:

 Hi R-users,

 I have to define a noise level function L and its energy in the various
 moment of the day by:

 if time is between 18:00:00 and 23:59:59 then  L[j] - L[j]+5 and W -
 10^((L+5)/10)

 if time is between 22:00:00 and 05:59:59 == L - L+10  and W -
 10^((L+10)/10)
 else
 L=L and W = W

 Could someone help me to realize this function please? You will find my
 following proposal  code, but my main problem is to handle the time
 interval.

 Best regard

 ###
 myfunc - function(mytab, Time, Level)
 {
 vect - rep(0, length(mytab))
 for(i in 1:length(vect))
{
   for(j in 1:length(Time))

 if(time[j] is between 18:00:00 and 23:59:59)

 L[i] - L[j]+5

vect[i] - 10^((L[i])/10

 if (time[j] is between 22:00:00 and 05:59:59)

 L[i] - L[j]+10

  vect[i] - 10^((L[i])/10

 else

L[i] = L[j]

   vect[i] - 10^((L[i])/10
  }
 }

 ###

 Lassana KOITA
 Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  /
 Project Engineer Airport Safety Studies  Statistical analysis
 Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical
 Department
 Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation
 Headquarters
 Tel: 01 49 56 80 60
 Fax: 01 49 56 82 14
 E-mail: [EMAIL PROTECTED]
 http://www.stac.aviation-civile.gouv.fr/
 [[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
 and provide commented, minimal, self-contained, reproducible code.



[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help to manipulate function and time interval

2007-08-10 Thread Uwe Ligges


Henrique Dallazuanna wrote:
 Hi,
 
 Try whit:
 
 if(time[j] = 18:00:00   23:59:59)

This code is obviously wrong and does not help for the next few lines in 
the questioner's message, please do not post unsensible stuff.

Uwe Ligges


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


Re: [R] need help to manipulate function and time interval

2007-08-10 Thread Uwe Ligges


KOITA Lassana - STAC/ACE wrote:
 Hi R-users,
 
 I have to define a noise level function L and its energy in the various 
 moment of the day by:
 
  if time is between 18:00:00 and 23:59:59 then  L[j] - L[j]+5 and W - 
 10^((L+5)/10) 


What kind of object is time? Just a character or some Time/Date format?
Do you know the day?

If time is between 18:00:00 and 23:59:59, should the next point (time is 
between 22:00:00 and 05:59:59) be executed additionally if time is, 
e.g., 23:00:00 or is there any other condition I cannot see?

All the information is quite essential in order to help...

BTW: I don't think the rest of your code is sensible (at least, some 
braces are missing).

Uwe Ligges



 if time is between 22:00:00 and 05:59:59 == L - L+10  and W - 
 10^((L+10)/10)
 else
 L=L and W = W
 
 Could someone help me to realize this function please? You will find my 
 following proposal  code, but my main problem is to handle the time 
 interval.
 
 Best regard
 
 ###
 myfunc - function(mytab, Time, Level)
 {
 vect - rep(0, length(mytab))
 for(i in 1:length(vect))
{
   for(j in 1:length(Time))
 
 if(time[j] is between 18:00:00 and 23:59:59) 
 
 L[i] - L[j]+5 
  
vect[i] - 10^((L[i])/10
 
 if (time[j] is between 22:00:00 and 05:59:59)
 
 L[i] - L[j]+10 
  
  vect[i] - 10^((L[i])/10
 
 else 
  
L[i] = L[j]
  
   vect[i] - 10^((L[i])/10
  } 
 } 
 
 ###
 
 Lassana KOITA 
 Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
 Project Engineer Airport Safety Studies  Statistical analysis
 Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical 
 Department 
 Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation 
 Headquarters
 Tel: 01 49 56 80 60
 Fax: 01 49 56 82 14
 E-mail: [EMAIL PROTECTED]
 http://www.stac.aviation-civile.gouv.fr/
   [[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
 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.


Re: [R] need help with pdf-plot

2007-08-10 Thread Ivar Herfindal
Dear Antje

I cannot see that you have got any replies yet, so I will make and 
attempt. However, I am sure other have more formally correct solutions.

When you call the pdf(), you can set paper=a4 (or a4r for 
landscape). However, the width and the height of your plot should then 
not exceed the size of the paper (which is approximately 8.27*11.69 
inches for a4). Try (I have only tested on windows XP, R 2.5.0):

pdf(test1.pdf, width=10, heigh=5, paper=a4r)
par(mfrow=c(1,3), pty=s) #pty=s gives square plotting regions
plot(rnorm(100))
plot(rnorm(100))
plot(rnorm(100))
dev.off()

Hope this helps

Ivar


Antje skrev:
 I still have this problem. Does anybody know any solution?

 Antje

 Antje schrieb:
   
 Hello,

 I'm trying to plot a set of barplots like a matrix (2 rows, 10 columns 
 fromreduced_mat) to a pdf. It works with the following parameters:

 pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, 
 pointsize 
 = 12)

 par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
 lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)

 The I get a long narrow page format with the quadratic barplots.

 But I would like to have a A4 format in the end and the plots not filling 
 the 
 whole page (they should stay somehow quadratic and not be stretched...).

 What shall I look for to achieve this?

 Antje

 __
 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-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] Need Help: Installing/Using xtable package

2007-08-09 Thread M. Jankowski
Hi all,

Let me know if I need to ask this question of the bioconductor group.
I used the bioconductor utility to install this package and also the
CRAN package.install function.

My computer crashed a week ago. Today I reinstalled all my
bioconductor/R packages. One of my scripts is giving me the following
error:

in my script I set:
library(xtable)
print.xtable(

and receive this error:
Error : could not find function print.xtable

This is a new error and I cannot find the source.

I reinstalled xtable with the messages below(which are the same
whether I use CRAN or bioconductor):

Any help is appreciated! Thanks!
Matt


 biocLite(xtable)
Running biocinstall version 2.0.8 with R version 2.5.1
Your version of R requires version 2.0 of Bioconductor.
Warning in install.packages(pkgs = pkgs, repos = repos, dependencies = dependenc
ies,  :
 argument 'lib' is missing: using '/home/mdj/R/i486-pc-linux-gnu-library
/2.5'
trying URL 'http://cran.fhcrc.org/src/contrib/xtable_1.5-1.tar.gz'
Content type 'application/x-gzip' length 134758 bytes
opened URL
==
downloaded 131Kb

* Installing *source* package 'xtable' ...
** R
** data
** inst
** preparing package for lazy loading
** help
  Building/Updating help pages for package 'xtable'
 Formats: text html latex example
  print.xtable  texthtmllatex
  stringtexthtmllatex
  table.attributes  texthtmllatex
  tli   texthtmllatex
  xtabletexthtmllatex   example
** building package indices ...
* DONE (xtable)

The downloaded packages are in
/tmp/RtmpGThCuI/downloaded_packages


__
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] Need Help: Installing/Using xtable package

2007-08-09 Thread Peter Dalgaard
M. Jankowski wrote:
 Hi all,

 Let me know if I need to ask this question of the bioconductor group.
 I used the bioconductor utility to install this package and also the
 CRAN package.install function.

 My computer crashed a week ago. Today I reinstalled all my
 bioconductor/R packages. One of my scripts is giving me the following
 error:

 in my script I set:
 library(xtable)
 print.xtable(

 and receive this error:
 Error : could not find function print.xtable

 This is a new error and I cannot find the source.
   
Looks like the current xtable is no longer exporting its print methods. 
Why were you calling print.xtable explicitly in the first place?

__
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] Need Help: Installing/Using xtable package

2007-08-09 Thread Seth Falcon
Peter Dalgaard [EMAIL PROTECTED] writes:

 M. Jankowski wrote:
 Hi all,

 Let me know if I need to ask this question of the bioconductor group.
 I used the bioconductor utility to install this package and also the
 CRAN package.install function.

 My computer crashed a week ago. Today I reinstalled all my
 bioconductor/R packages. One of my scripts is giving me the following
 error:

 in my script I set:
 library(xtable)
 print.xtable(

 and receive this error:
 Error : could not find function print.xtable

 This is a new error and I cannot find the source.
   
 Looks like the current xtable is no longer exporting its print methods. 
 Why were you calling print.xtable explicitly in the first place?

Indeed, xtable now has a namespace.  The S3 methods are not exported
because they should not be called directly; rather, the generic
function (in this case print) should be called.

The addition of the namespace is really a good.  Yes, it will cause
some hicups for folks who were calling the methods directory (tsk
tsk).  But the addition fixes breakage that was occuring due to
internal xtable helper functions being masked.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
BioC: http://bioconductor.org/
Blog: http://userprimary.net/user/

__
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] Need Help: Installing/Using xtable package

2007-08-09 Thread M. Jankowski
Ok, I got it now.

Just: print(xtable(...),)

Thanks!
Matt

On 8/9/07, Seth Falcon [EMAIL PROTECTED] wrote:
 Peter Dalgaard [EMAIL PROTECTED] writes:

  M. Jankowski wrote:
  Hi all,
 
  Let me know if I need to ask this question of the bioconductor group.
  I used the bioconductor utility to install this package and also the
  CRAN package.install function.
 
  My computer crashed a week ago. Today I reinstalled all my
  bioconductor/R packages. One of my scripts is giving me the following
  error:
 
  in my script I set:
  library(xtable)
  print.xtable(
 
  and receive this error:
  Error : could not find function print.xtable
 
  This is a new error and I cannot find the source.
 
  Looks like the current xtable is no longer exporting its print methods.
  Why were you calling print.xtable explicitly in the first place?

 Indeed, xtable now has a namespace.  The S3 methods are not exported
 because they should not be called directly; rather, the generic
 function (in this case print) should be called.

 The addition of the namespace is really a good.  Yes, it will cause
 some hicups for folks who were calling the methods directory (tsk
 tsk).  But the addition fixes breakage that was occuring due to
 internal xtable helper functions being masked.

 + seth

 --
 Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
 BioC: http://bioconductor.org/
 Blog: http://userprimary.net/user/


__
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] need help with pdf-plot

2007-08-01 Thread Antje
Hello,

I'm trying to plot a set of barplots like a matrix (2 rows, 10 columns 
fromreduced_mat) to a pdf. It works with the following parameters:

pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, pointsize 
= 12)

par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)

The I get a long narrow page format with the quadratic barplots.

But I would like to have a A4 format in the end and the plots not filling the 
whole page (they should stay somehow quadratic and not be stretched...).

What shall I look for to achieve this?

Antje

__
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] Need Help: User Defined R Functions in Sweave/Latex

2007-06-21 Thread Marc Schwartz
On Wed, 2007-06-20 at 22:50 -0500, M. Jankowski wrote:
 Dear all,
 
 I want to start my post by expressing my sincere gratitude for all the
 help this group has given me in Sweave/Latex/R. The tools are
 excellent and so is the community!
 
 On to the question.
 
 My Sweave code is intended to make lots of plots and create a *.pdf
 document. Sweave is perfect for this. The only problem is that  I find
 myself using the same R code, within my Sweave input file over an
 over. I know about Latex macros and I can even get R functions,
 essentially used as subroutines, to sort of work. \Sexpr{} will not
 work because the R code I want to use over and over is in the R
 environment. I've tried numerous ways to tackle this process and could
 really use some help. If there is some easier way to do this please
 let me know!
 
 This is the R function:
 basicplot - function(x, nplots, sectionname){
 # Begin to make figure here
 file = paste(scatter,nplots, .pdf, sep=)
 pdf(file = file,paper=special, width=6, height = 6)
 plot(x)
 dev.off()
 cat(\\begin{figure}\n)
 cat(\\includegraphics{,file,}\n, sep=)
 cat(\\caption{, sectionname,}\n, sep = )
 cat(\\end{figure}\n)
 #End figure making
 }
 
 The aim is to generate Latex code which will have some basic
 information as part of the caption. The trouble seems to be that the
 output from the function appears to latex as if it is protected R code
 when I really want to create output that pdflatex will act on.
 Essentially, the resulting *.pdf contains the lines output by the cat
 function in basicplot. Or:
 \begin{figure}
 \includegraphics{scatter1.pdf}
 \caption{myname}
 \end{figure}
 These lines are not in the environment acted by Latex. I tried a
 variant of the function where results=tex,echo=FALSE and received
 the same result. Below are the files *.Snw - *.tex - *.pdf and the
 output I received while compiling. If there is anything else I can
 give to help you help me just let me know. Thanks!
 
 Matt


Matt,

I don't know if you have reviewed the Sweave manual, but section 3.4
provides insight into reusing named code chunks, as an alternative to
looping or creating LaTeX macros as proposed by Dieter. These can be
nested within other named code chunks and/or R code.

If you don't yet have the manual, it is available here from Fritz' site:

http://www.ci.tuwien.ac.at/~leisch/Sweave/Sweave-manual-20060104.pdf

You could consider using a figure chunk, if the sole output is the plot
and not text. That way you don't have to worry about explicitly cat()ing
the figure related LaTeX markup as you are doing above. Thus, the LaTeX
markup for things like captions will be in LaTeX sections of the .Rnw
file and you can use \Sexpr{}'s to include derived scalar values.

The preferred approach may be to an extent dependent upon whether your
final document will simply have several plots on one or more pages in
sequence, or whether you will need to have text between the plots, such
that you really need LaTeX sections between the figure/code chunks.

Back to Dieter's solution for a moment, take note of the Sweave FAQ
(also in the above manual), specifically FAQ A.9, which covers the issue
of figure chunks and multiple plots, proposing a looping approach
consistent with Dieter's.

I hope that this might give you some other insights into alternative
approaches.

HTH,

Marc Schwartz

__
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] Need Help: User Defined R Functions in Sweave/Latex

2007-06-21 Thread M. Jankowski
 Back to Dieter's solution for a moment, take note of the Sweave FAQ
 (also in the above manual), specifically FAQ A.9, which covers the issue
 of figure chunks and multiple plots, proposing a looping approach
 consistent with Dieter's.

 I hope that this might give you some other insights into alternative
 approaches.

 HTH,

 Marc Schwartz


Marc,

You sure did help me. I reviewed A.9 and found that I simply needed to set:

 results=tex, echo=false =

in the initial function call. Then the route I was pursuing worked smashingly.

The rest of your post has me thinking about my approach. I have more
than enough data, in my mind at least, to justify the extra effort
(and possible confusion) of including captions. I'll need to look at
the options for the pdf function to see if it already has the
functionality I am looking for.

Thank you very much for the nice reply to my post!

Matt

__
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] Need Help: User Defined R Functions in Sweave/Latex

2007-06-20 Thread M. Jankowski
Dear all,

I want to start my post by expressing my sincere gratitude for all the
help this group has given me in Sweave/Latex/R. The tools are
excellent and so is the community!

On to the question.

My Sweave code is intended to make lots of plots and create a *.pdf
document. Sweave is perfect for this. The only problem is that  I find
myself using the same R code, within my Sweave input file over an
over. I know about Latex macros and I can even get R functions,
essentially used as subroutines, to sort of work. \Sexpr{} will not
work because the R code I want to use over and over is in the R
environment. I've tried numerous ways to tackle this process and could
really use some help. If there is some easier way to do this please
let me know!

This is the R function:
basicplot - function(x, nplots, sectionname){
# Begin to make figure here
file = paste(scatter,nplots, .pdf, sep=)
pdf(file = file,paper=special, width=6, height = 6)
plot(x)
dev.off()
cat(\\begin{figure}\n)
cat(\\includegraphics{,file,}\n, sep=)
cat(\\caption{, sectionname,}\n, sep = )
cat(\\end{figure}\n)
#End figure making
}

The aim is to generate Latex code which will have some basic
information as part of the caption. The trouble seems to be that the
output from the function appears to latex as if it is protected R code
when I really want to create output that pdflatex will act on.
Essentially, the resulting *.pdf contains the lines output by the cat
function in basicplot. Or:
\begin{figure}
\includegraphics{scatter1.pdf}
\caption{myname}
\end{figure}
These lines are not in the environment acted by Latex. I tried a
variant of the function where results=tex,echo=FALSE and received
the same result. Below are the files *.Snw - *.tex - *.pdf and the
output I received while compiling. If there is anything else I can
give to help you help me just let me know. Thanks!

Matt

My system:
T41 IBM Thinkpad
Ubuntu Feisty (7.04)
R version 2.5

testmacro3.Snw:
[EMAIL PROTECTED]:~/mydocs/R$ more testmacro3.Snw
\documentclass[a4paper]{article}
\usepackage{fullpage}
echo=f=
basicplot - function(x, nplots, sectionname){
# Begin to make figure here
file = paste(scatter,nplots, .pdf, sep=)
pdf(file = file,paper=special, width=6, height = 6)
plot(x)
dev.off()
cat(\\begin{figure}\n)
cat(\\includegraphics{,file,}\n, sep=)
cat(\\caption{, sectionname,}\n, sep = )
cat(\\end{figure}\n)
#End figure making
}
@

\begin{document}
Filler text here.\\
=
library(flowCore)
x - read.FCS(/home/mdj/data/yifacs2/NL7_PHA03_1.fcs, transformation = FALSE,
alter.names = TRUE);
basicplot(x, nplots = 1, sectionname=myname)
@
End text here \\
\end{document}

testmacro3.tex
\usepackage{/usr/share/R/share/texmf/Sweave}
\begin{document}
Filler text here.\\
\begin{Schunk}
\begin{Sinput}
 library(flowCore)
\end{Sinput}
\begin{Soutput}
Scalable Robust Estimators with High Breakdown Point (version 0.3-05)
\end{Soutput}
\begin{Sinput}
 x - read.FCS(/home/mdj/data/yifacs2/NL7_PHA03_1.fcs, transformation = FALSE
,
+ alter.names = TRUE)
 basicplot(x, nplots = 1, sectionname = myname)
\end{Sinput}
\begin{Soutput}
\begin{figure}
\includegraphics{scatter1.pdf}
\caption{myname}
\end{figure}
\end{Soutput}
\end{Schunk}
End text here \\
\end{document}

testmacro3.pdf:
Filler text here.
 library(flowCore)
Scalable Robust Estimators with High Breakdown Point (version 0.3-05)
 x - read.FCS(/home/mdj/data/yifacs2/NL7_PHA03_1.fcs, transformation = 
 FALSE,
+ alter.names = TRUE)
 basicplot(x, nplots = 1, sectionname = myname)
\begin{figure}
\includegraphics{scatter1.pdf}
\caption{myname}
\end{figure}
End text here



Output:
[EMAIL PROTECTED]:~/mydocs/R$ R CMD Sweave testmacro3.Snw
[1] Welcome to my custom R eenvironment!
 library(utils); Sweave(testmacro3.Snw)
Writing to file testmacro3.tex
Processing code chunks ...
 1 : term verbatim
 2 : echo term verbatim
Loading required package: Biobase
Loading required package: tools

Welcome to Bioconductor

Vignettes contain introductory material. To view, type
'openVignette()' or start with 'help(Biobase)'. For details
on reading vignettes, see the openVignette help page.

Loading required package: rrcov
KernSmooth 2.22 installed
Copyright M. P. Wand 1997

You can now run LaTeX on 'testmacro3.tex'
 [EMAIL PROTECTED]:~/mydocs/Rpdflatex testmacro3.tex
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(./testmacro3.tex
LaTeX2e 2003/12/01
Babel v3.8d and hyphenation patterns for american, french, german, ngerman, b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto, e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk, polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish, tur
kish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf-tetex/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-tetex/tex/latex/base/size10.clo))

[R] Need Help with Dendrogram and DataFrame Leaf names

2007-06-15 Thread ngottlieb
I having problem with dendrogram leaf names when I read a tab delimited
file into dataframe;

I have a text file, tab delimited, using read.table into a data frame as
follows:
  test1-read.table(c:\\R\\data\\Tremont4.txt, header=TRUE, sep=\t)

When I do this the test1 data frame is picking up my first column
names as
part of the data and not the case names, the leafs are the numbers on
the left 1-13
As opposed to the text names to the right. 

Example Output from displaying dataframe:
 test1
 row.names X1.31.2004 X2.29.2004 X3.31.2004 X4.30.2004
X5.31.2004 X6.30.2004 X7.31.2004 X8.31.2004 X9.30.2004 X10.31.2004
1 ConvertibleArbitrage  0.014  0.003  0.004  0.005
-0.013 -0.008 -0.002  0.003 -0.001  -0.003
2   DedicatedShortBias -0.017  0.003 -0.026  0.042
0.008 -0.013  0.081  0.013 -0.019  -0.018
3  EmergingMarkets  0.025  0.014  0.018 -0.033
-0.018  0.009 -0.001  0.018  0.023   0.024
4MarketNeutral  0.008  0.008 -0.001 -0.003
0.002  0.008  0.003  0.021  0.005   0.000
5  EventDriven  0.022  0.010  0.005  0.005
0.001  0.010  0.000  0.005  0.013   0.012
6   Distressed  0.024  0.009  0.006  0.007
0.003  0.011  0.005  0.006  0.012   0.019
7  EventdriveMultiStrategy  0.020  0.011  0.003  0.005
-0.001  0.009 -0.003  0.004  0.014   0.007
8RiskArbitrage  0.008  0.005  0.007 -0.006
0.004  0.003 -0.015  0.002  0.006   0.009
9 FixedIncomeArbitrage  0.012  0.009 -0.005  0.013
0.006  0.007  0.007 -0.004 -0.008   0.011
10 GlobalMacro  0.015  0.012  0.010  0.001
0.001  0.005  0.008 -0.008 -0.005   0.012
11 LongShortEquity  0.020  0.018  0.002 -0.014
-0.004  0.007 -0.014  0.001  0.024   0.014
12  ManagedFutures  0.011  0.069 -0.009 -0.065
-0.011 -0.028 -0.020 -0.015  0.020   0.048
13  Multi-Strategy  0.016  0.004  0.004  0.003
-0.001  0.001 -0.003  0.004  0.006   0.006

Input file looks like this:
row.names   1/31/2004 2/29/2004 3/31/2004
4/30/2004   5/31/2004   6/30/2004   7/31/2004
8/31/2004
ConvertibleArbitrage0.0140.003  0.004  0.005-0.013
-0.008  -0.002  0.003
DedicatedShortBias  -0.017   0.003  -0.026  0.042  0.008
-0.013  0.081 0.013
EmergingMarkets   0.0250.0140.018-0.033
-0.0180.009  -0.001   0.018
MarketNeutral 0.0080.008-0.001  -0.003  0.002
0.008 0.003   0.021
Etc...

Would appreciate why the read.table into dataframe sees the text as part
of the data oand
Not the observation names and is making the numbers the leaf names and
observation names.


Thanks for any help,
Neil Gottlieb


 
 
This information is being sent at the recipient's request or...{{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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need Help with robustbase package: fitnorm2 and plotnorm2

2007-06-08 Thread Prof Brian Ripley
On Fri, 8 Jun 2007, M. Jankowski wrote:

 This is my first post requesting help to this mailing list. I am new
 to R. My apologies for any breach in posting etiquette.

For future reference, telling us your version of R and exact OS would have 
helped here.  The R posting guide suggests showing the output of 
sessionInfo().

Also, to help the readers, fitNorm2 (R is case-sensitive) is in 'prada', 
and the missing package is rrcov not robustbase.

 I am new to
 this language and just learning my way around. I am attempting to run
 some sample code and  and am confused by the error message:
 Loading required package: rrcov
 Error in fitNorm2(fdat[, FSC-H], fdat[, SSC-H], scalefac = ScaleFactor) :
Required package rrcov could not be found.
 In addition: Warning message:
 there is no package called 'rrcov' in: library(package, lib.loc =
 lib.loc, character.only = TRUE, logical = TRUE,

 that I get when I attempt to run the following sample snippet of code.
 The error above is taken from the code below. I am running Ubuntu
 Linux with all the r packages listed in the Synaptic package manager
 (universa). I loaded the prada bioconductor package as instructed in
 the comments and the robustbase was downloaded and installed with the
 command: sudo R CMD INSTALL robustbase_0.2- 7.tar.gz, the robustbase
 folder is in /usr/local/lib/R/site-library/ When I type in
 'library(robustbase)' no error appears; I believe robustbase is
 installed correctly. The sample code was taken from FCS-prada.pdf. The
 sample code was written in 2005, I understand that rrcov was made part
 of the robustbase package sometime in the past year. This may be the
 cause of the problem, but, if it is, I have no idea how to fix it.

That is not the case: rrcov is a separate package, and one prada depends 
on.  So somehow you have managed to install prada without an essential 
dependency 'rrcov'.  That looks like a problem in the Debian/Ubuntu 
packaging of prada.  (There is a list R-sig-debian for such issues.)

Running install.packages(rrcov) inside R should fix this for you: if 
your R is not current (i.e.  2.5.0) you may need to run R as root for 
that session.  (There may be a Debian package for rrcov for your OS and R 
version, but without further details I cannot check.)

In the current version of prada (1.12.0 for BioC-2.0 for R 2.5.0) rrcov is 
in Imports, so probably your version of BioC is not current either.

[...]

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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] Need Help with robustbase package: fitnorm2 and plotnorm2

2007-06-07 Thread M. Jankowski
This is my first post requesting help to this mailing list. I am new
to R. My apologies for any breach in posting etiquette. I am new to
this language and just learning my way around. I am attempting to run
some sample code and  and am confused by the error message:
Loading required package: rrcov
Error in fitNorm2(fdat[, FSC-H], fdat[, SSC-H], scalefac = ScaleFactor) :
Required package rrcov could not be found.
In addition: Warning message:
there is no package called 'rrcov' in: library(package, lib.loc =
lib.loc, character.only = TRUE, logical = TRUE,


that I get when I attempt to run the following sample snippet of code.
The error above is taken from the code below. I am running Ubuntu
Linux with all the r packages listed in the Synaptic package manager
(universa). I loaded the prada bioconductor package as instructed in
the comments and the robustbase was downloaded and installed with the
command: sudo R CMD INSTALL robustbase_0.2- 7.tar.gz, the robustbase
folder is in /usr/local/lib/R/site-library/ When I type in
'library(robustbase)' no error appears; I believe robustbase is
installed correctly. The sample code was taken from FCS-prada.pdf. The
sample code was written in 2005, I understand that rrcov was made part
of the robustbase package sometime in the past year. This may be the
cause of the problem, but, if it is, I have no idea how to fix it.
Thank you in advance for helping out!

Below you will find the code that generates the error and the complete
output of the code. Let me know what I can do to get up and running!

Matt


#prada Bioconductor package
#http://www.bioconductor.org/repository/devel/vignette/norm2.pdf
# To install prada
#source(http://www.bioconductor.org/biocLite.R;)
#biocLite(prada)

library(prada)
filepath - system.file(extdata, fas-Bcl2-plate323-04-04.A01, package = pra
da)
print(filepath)
sampdat - readFCS(filepath)
fdat - exprs(sampdat)
print(dim(fdat))
print(colnames(fdat))

plot(fdat[, FSC-H], fdat[, SSC-H], pch = 20, col = #303030, xlab = FSC,
ylab = SSC,  main = Scatter plot FSC vs SSC)
#All of this goes as the help documentation suggests it should

# 2. Show selections for various scale factors
savepar - par(mfrow=c(2,2))

for (Scalefactor in c(1.0, 1.5, 2.0, 2.5) )
  {
# The next line gives the error I've included below.
nfit - fitNorm2 (fdat[, FSC-H], fdat[, SSC-H], scalefac = ScaleFactor)
plotnorm2(nfit, selection = TRUE, ellipse = TRUE,
  xlab=FSC-H, ylab=SSC-H,
  main=paste(SSC-H vs. FSC-H (ScaleFactor=,ScaleFactor,), sep=
))
  }
par(savepar)



Loading required package: Biobase
Loading required package: tools

Welcome to Bioconductor

Vignettes contain introductory material. To view, type
'openVignette()' or start with 'help(Biobase)'. For details
on reading vignettes, see the openVignette help page.

Loading required package: RColorBrewer
Loading required package: grid
Loading required package: geneplotter
Loading required package: annotate
KernSmooth 2.22 installed
Copyright M. P. Wand 1997
[1] /usr/local/lib/R/site-library/prada/extdata/fas-Bcl2-plate323-04-04.A01
[1] 21158
   $P1N$P2N$P3N$P4N$P5N$P6N$P7N$P8N
FSC-H SSC-H FL1-H FL2-H FL3-H FL2-A FL4-H  Time
Loading required package: rrcov
Error in fitNorm2(fdat[, FSC-H], fdat[, SSC-H], scalefac = ScaleFactor) :
Required package rrcov could not be found.
In addition: Warning message:
there is no package called 'rrcov' in: library(package, lib.loc =
lib.loc, character.only = TRUE, logical = TRUE,


__
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] Need Help

2007-05-28 Thread CHANDRAMOULI BANERJEE
Hi,

I have 2 text files the first one is in the following format:

CC:  Some statements
...
this is continued for 11-12 lines of variable length.
then a line containing the variable names used in the file and then the 
variable fields with their  observations...there are in all 684 observations.

The next  file is a text file containing 3 variables and 684 observations but 
are not numbered , I mean 1 to 684. Only th variable values are there along 
with thew column headers.

My target is to merge these 2 text files and create a  new text file preserving 
the format of the first one becos the subsequent steps of the main program uses 
the format of the first file. I have to create an id variable that numbers the 
observations from 1 to 684 and then merge th 2 files with that id, because the 
first one has the id variable numbered from 1 to 684.

Please help me to achieve this in R.

Regards
Chandramouli Banerjee


-

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] Need Help on Joining 2 text files in R

2007-05-23 Thread CHANDRAMOULI BANERJEE
Hi,
   
  I have  2 text files , the first one looks like this :
   
  CC:  some statements
  this is followed by 10-12 lines in the similar pattern and then the next line 
is a comment and from the 14th line all the columns are aligned and the 
variable values are filled in 
   
  The next file is a text file with 3 columns with column names and the 2 files 
have the same number of rows in both.
   
  I want to concatanate these 2 files side by side to make a complete file, 
keeping the structure of the first file same..
   
  More explicitly the first file looks like:
   
  CC:some statement.
  CC:same as above...
   
  .this pattern is followed upto say 10-12 lines 
and then some variables , I mean columns used in the file is listed as a string 
like nuclear_intensity; cell_intensity ;and so on ...
   
  and then in the next row onwards the column headers start with column names 
and then the variable values are plugged in ...I wish I could have sent you 
the file but it is in the intranet system and can't be sent over in email...
   
   
  The second file looks simple with column headers and field values.The 2 
files are both in the text format.
   
  What I really need to know is how to join the 2 text files and make it into 
one keeping the structure of the first one intact...I need to join the 
columns with the column names from the second file to the first one.
   
  I will wait for any help of how to achieve this is R.
   
  Thanks and Regards
  Chandramouli Banerjee
  23rd May 2007
   


-

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need Help on Joining 2 text files in R

2007-05-23 Thread Prasenjit Kapat
On Wednesday 23 May 2007 07:31:47 am CHANDRAMOULI BANERJEE wrote:
 Hi,

   I have  2 text files , the first one looks like this :

   CC:  some statements
   this is followed by 10-12 lines in the similar pattern and then the next
 line is a comment and from the 14th line all the columns are aligned and
 the variable values are filled in 

   The next file is a text file with 3 columns with column names and the 2
 files have the same number of rows in both.

   I want to concatanate these 2 files side by side to make a complete file,
 keeping the structure of the first file same..

   More explicitly the first file looks like:

   CC:some statement.
   CC:same as above...

   .this pattern is followed upto say 10-12
 lines and then some variables , I mean columns used in the file is listed
 as a string like nuclear_intensity; cell_intensity ;and so on ...

   and then in the next row onwards the column headers start with column
 names and then the variable values are plugged in ...I wish I could
 have sent you the file but it is in the intranet system and can't be sent
 over in email...

If the file has read access, then it can always be copied and attached, unless 
you are prohibited from distributing the file in public domain.



   The second file looks simple with column headers and field values.The
 2 files are both in the text format.

   What I really need to know is how to join the 2 text files and make it
 into one keeping the structure of the first one intact...I need to join
 the columns with the column names from the second file to the first
 one.

   I will wait for any help of how to achieve this is R.

The cheapest way (if possible) is to use an editor that supports block 
selection (like, kate, emacs) then block select the 3 columns from the second 
file and paste them beside the last column in the first one. Done.

Now, if the merging has to be done in R, one way is to read.table the first 
file with 'skip=13' that way you will get only the data. Then read.table from 
the second file and cbind the two data.frames. Finally write.table into a new 
file. By this the data will merged but to add the comments, I think you will 
have to do it manually, copy from the first file and paste into the new file, 
using whatever text editor you use. (I assume the file is a text file)

HTH,
PK

__
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] Need help imputing missing data using mice and outputting them

2007-05-10 Thread John Smith
Hello!
I am trying to impute missing data and output the results of the imputation.

My data set is called: MyData.
I have a bunch of variables all of which start with Q20_ - and some of them 
have missing values.
Here is what I've been doing:

imputationmodel-mice( MyData[ c (grep(Q20_, names(MyData)) ) ] )

multipledataset-complete(imputationmodel,action=long)

write.table(as.data.frame(lapply(multipledataset,function(x) 
{as.numeric(is.element(x,5))} )), sep=\t,file=multiset.txt,row.names=F)

The last line (write.table) makes it so that all the values get changed into 0s 
and 1s. How could I output the original imputed values (in my case, they should 
be 1s or 2s or 3s or 4s or 5s) rather than 0s and 1s?

Thank you very much!
Dimitri

__



[[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
and provide commented, minimal, self-contained, reproducible code.


[R] need help in reading TOMS observed ASCII data file

2007-02-19 Thread Yogesh Tiwari
Hello R Users,

I am new to R.

I have two data sets i) TOMS aerosol optical depth(AOD) and ii) TOMS
ozone(O3).


 AOD data is on 1x1 grid and O3 data is on 5x5 grid.

 First I want to read AOD and O3 as it is and then I want to regrid AOD on
 5x5 grid as O3.

 Reading is first problem.

 FIRST PROBLEM READING AOD:

 AOD data is in following format:

 #
 Latitute: 89.5
 167 0 0 0 0 0 182 0 0 0 0 0 0 0 0 0 0 0 0 200 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 155 0 0 0 0 0 156  0 0 0 0 0 0
 
 ...

 Latitude: 88.5
 .
 

 Lat.
 .
 ...
 ..
 Latitude: -88.5
  180 0 0 0 0 0 182 0 0 0 0 0 0 0 0 0 0 0 0 500 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 655 0 0 0 0 0 156  0 0 0 0 0 0
 ..
 .
 ##

 After each latitude header there is 360 AOD values (1x1 grid). This is
 monthly mean data. I have many years of data file.

 So the first problem is how to read the data by omiting latitude header,
 also data is written along row not along column ?



  SECOND PROBLEM READING O3:

 O3 data is in following format:

 ozone(72,12,324)

 72: Longitude -177.5,-172.5,...,177.5'

 12: Latitude -27.5,-22.5,...,27.5'

 324: Month Jan79,Feb79,,Dec05'

 ###

Month index:0
   20.8  22.1  20.0  19.0  16.3  20.0  24.4  23.5  27.9  23.7   0.0  32.4
   21.6  23.8  20.4  17.9  16.0  22.2  25.3  25.1  31.1  27.4   0.0  30.3
   23.2  23.9  20.7  17.3  16.5  23.1  25.9   25.4  30.4  29.3   0.0  29.9
   26.1  24.7  21.3  15.9  16.8  22.8  25.3  25.8  29.8  30.1   0.0  31.6

 --

 



   Month index:  323
0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
0.0   0.0   0.0   0.0   0.0   0.0   0.00.0   0.0   0.0   0.0   0.0
0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0

 -

 -

 #

 12 columns and 72 rows (latitudexlongitude)





 THIRD PROBLEM regriding AOD:
 How to regrid 1x1 AOD data on 5x5 grid  as O3.


 Many thanks for yours help.

 Regards,
 Yogesh

 --
 Dr. Yogesh K. Tiwari,
 Scientist,
 Indian Institute of Tropical Meteorology,
 Homi Bhabha Road,
 Pashan,
 Pune-411008
 INDIA

 Phone: 0091-99 2273 9513 (Cell)
  : 0091-20-258 93 600 (O) ( Ext.250)
 Fax: 0091-20-258 93 825




-- 
Dr. Yogesh K. Tiwari,
Scientist 'B',
Indian Institute of Tropical Meteorology,
Homi Bhabha Road,
Pashan,
Pune-411008
INDIA

Phone: 0091-99 2273 9513 (Cell)
 : 0091-20-258 93 600 (O) (Ext.250)
Fax: 0091-20-258 93 825

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help in reading TOMS observed ASCII data file

2007-02-19 Thread jim holtman
Here is a script that will read in you O3 data.  It assumes that the data is
perfect.  You will have to either prescan the data for errors, or add code
to catch them.

 # setup to read your file
 # this procedure works if the data is 'perfect'; it does not catch errors
 # 'result' is a list of matrices of the data
 f.1 - file(/jph/r-help/TOMS_O3.txt, r)
 result - list()
 while(length(month - readLines(f.1, n=1))){
+ # read in 12*72 real numbers from the file after reading the 'month'
header
+ data.in - matrix(scan(f.1, what=0, n=12*72), ncol=12, byrow=TRUE)
+ # extract just the number and use it as the index into the list to
save the matrix
+ result[[gsub(.*(\\d file://d/+), \\1 file://0.0.0.1/, month,
perl=TRUE)]] - data.in
+ }
Read 864 items
Read 864 items
Read 864 items
Read 864 items
 str(result)
List of 4
 $ 0: num [1:72, 1:12] 20.8 21.6 23.2 26.1 26.2 29 22.2 18.5 19 20.5 ...
 $ 1: num [1:72, 1:12] 22.7 22.4 20.4 19.7 16.9 20.8 24 25.1 24.7 24.7 ...
 $ 2: num [1:72, 1:12] 25.4 24.6 27 28 29.9 33.3 32.4 28.2 24.5 21.6 ...
 $ 3: num [1:72, 1:12] 31 31 31 30 30.1 27.4 20.5 19 18.8 19.2 ...





On 2/19/07, Yogesh Tiwari [EMAIL PROTECTED] wrote:

 Hello R Users,

 I am new to R.

 I have two data sets i) TOMS aerosol optical depth(AOD) and ii) TOMS
 ozone(O3).

 
  AOD data is on 1x1 grid and O3 data is on 5x5 grid.
 
  First I want to read AOD and O3 as it is and then I want to regrid AOD
 on
  5x5 grid as O3.
 
  Reading is first problem.
 
  FIRST PROBLEM READING AOD:
 
  AOD data is in following format:
 
  #
  Latitute: 89.5
  167 0 0 0 0 0 182 0 0 0 0 0 0 0 0 0 0 0 0 200 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 155 0 0 0 0 0 156  0 0 0 0 0 0
  
  ...
 
  Latitude: 88.5
  .
  
 
  Lat.
  .
  ...
  ..
  Latitude: -88.5
   180 0 0 0 0 0 182 0 0 0 0 0 0 0 0 0 0 0 0 500 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 655 0 0 0 0 0 156  0 0 0 0 0 0
  ..
  .
  ##
 
  After each latitude header there is 360 AOD values (1x1 grid). This is
  monthly mean data. I have many years of data file.
 
  So the first problem is how to read the data by omiting latitude header,
  also data is written along row not along column ?
 
 
 
   SECOND PROBLEM READING O3:
 
  O3 data is in following format:
 
  ozone(72,12,324)
 
  72: Longitude -177.5,-172.5,...,177.5'
 
  12: Latitude -27.5,-22.5,...,27.5'
 
  324: Month Jan79,Feb79,,Dec05'
 
  ###
 
 Month index:0
20.8  22.1  20.0  19.0  16.3  20.0  24.4  23.5  27.9  23.7   0.0  32.4
21.6  23.8  20.4  17.9  16.0  22.2  25.3  25.1  31.1  27.4   0.0  30.3
23.2  23.9  20.7  17.3  16.5  23.1  25.9   25.4  30.4  29.3   0.0
 29.9
26.1  24.7  21.3  15.9  16.8  22.8  25.3  25.8  29.8  30.1   0.0  31.6
 
  --
 
  
 
 
 
Month index:  323
 0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
 0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
 0.0   0.0   0.0   0.0   0.0   0.0   0.00.0   0.0   0.0   0.0
 0.0
 0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
 0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0
 
  -
 
  -
 
  #
 
  12 columns and 72 rows (latitudexlongitude)
 
 
 
 
 
  THIRD PROBLEM regriding AOD:
  How to regrid 1x1 AOD data on 5x5 grid  as O3.
 
 
  Many thanks for yours help.
 
  Regards,
  Yogesh
 
  --
  Dr. Yogesh K. Tiwari,
  Scientist,
  Indian Institute of Tropical Meteorology,
  Homi Bhabha Road,
  Pashan,
  Pune-411008
  INDIA
 
  Phone: 0091-99 2273 9513 (Cell)
   : 0091-20-258 93 600 (O) ( Ext.250)
  Fax: 0091-20-258 93 825
 



 --
 Dr. Yogesh K. Tiwari,
 Scientist 'B',
 Indian Institute of Tropical Meteorology,
 Homi Bhabha Road,
 Pashan,
 Pune-411008
 INDIA

 Phone: 0091-99 2273 9513 (Cell)
 : 0091-20-258 93 600 (O) (Ext.250)
 Fax: 0091-20-258 93 825

[[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
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] Need help writing a faster code

2007-02-01 Thread Ravi Varadhan
Hi,

 

I apologize for this repeat posting, which I first posted yesterday. I would
appreciate any hints on solving this problem:

 

I have two matrices A (m x 2) and B (n x 2), where m and n are large
integers (on the order of 10^4).  I am looking for an efficient way to
create another matrix, W (m x n), which can be defined as follows:

 

for (i in 1:m){

for (j in 1:n) {

W[i,j] - g(A[i,], B[j,])

} }

where g(x,y) is a function that takes two vectors and returns a scalar.

 

The following works okay, but is not fast enough for my purpose.  I am sure
that I can do better:

 

for (i in 1:m) {

W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x)) 

}

 

How can I do this in a faster manner? I attempted outer, kronecker,
expand.grid, etc, but with no success.

 

Here is an example:

 

m - 2000

n - 5000

A - matrix(rnorm(2*m),ncol=2)

B - matrix(rnorm(2*n),ncol=2)

W - matrix(NA, m, n)

 

for (i in 1:m) {

W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x)) 

}

 

g - function(x,y){

theta - atan((y[2]-x[2]) / (y[1] - x[1]))

theta + 2*pi*(theta  0)

}

 

Thanks for any suggestions.

 

Best,

Ravi.

 

 

 


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




 


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help writing a faster code

2007-02-01 Thread Dimitris Rizopoulos
the following seems to be a first improvement:

m - 2000
n - 5000
A - matrix(rnorm(2*m), ncol=2)
B - matrix(rnorm(2*n), ncol=2)
W1 - W2 - matrix(0, m, n)

##
##

g1 - function(x, y){
theta - atan((y[2] - x[2]) / (y[1] - x[1]))
theta + 2*pi*(theta  0)
}

invisible({gc(); gc()})
system.time(for (i in 1:m) {
W1[i, ] - apply(B, 1, y = A[i,], function(x, y) g1(y, x))
})

##

g2 - function(x){
out - tB - x
theta - atan(out[2, ] / out[1, ])
theta + 2*pi*(theta  0)
}

tB - t(B)
invisible({gc(); gc()})
system.time(for (i in 1:m) {
W2[i, ] - g2(A[i, ])
})

## or

invisible({gc(); gc()})
system.time(W3 - t(apply(A, 1, g2)))

all.equal(W1, W2)
all.equal(W1, W3)


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Ravi Varadhan [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, February 01, 2007 4:10 PM
Subject: [R] Need help writing a faster code


 Hi,



 I apologize for this repeat posting, which I first posted yesterday. 
 I would
 appreciate any hints on solving this problem:



 I have two matrices A (m x 2) and B (n x 2), where m and n are large
 integers (on the order of 10^4).  I am looking for an efficient way 
 to
 create another matrix, W (m x n), which can be defined as follows:



 for (i in 1:m){

 for (j in 1:n) {

 W[i,j] - g(A[i,], B[j,])

 } }

 where g(x,y) is a function that takes two vectors and returns a 
 scalar.



 The following works okay, but is not fast enough for my purpose.  I 
 am sure
 that I can do better:



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 How can I do this in a faster manner? I attempted outer, 
 kronecker,
 expand.grid, etc, but with no success.



 Here is an example:



 m - 2000

 n - 5000

 A - matrix(rnorm(2*m),ncol=2)

 B - matrix(rnorm(2*n),ncol=2)

 W - matrix(NA, m, n)



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 g - function(x,y){

 theta - atan((y[2]-x[2]) / (y[1] - x[1]))

 theta + 2*pi*(theta  0)

 }



 Thanks for any suggestions.



 Best,

 Ravi.







 
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage: 
 http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



 
 




 [[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
 and provide commented, minimal, self-contained, reproducible code.
 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
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] Need help writing a faster code

2007-02-01 Thread Robin Hankin
Hi



  A - matrix(runif(10),ncol=2)
  B - matrix(runif(10),ncol=2)
  g - function(i4){theta - atan2( (i4[4]-i4[2]),(i4[3]-i4[1]))
+ return(theta + 2*pi*(theta0))}
  apply(A,1,function(x){apply(B,1,function(y){g(c(x,y))})})
   [,1]  [,2] [,3][,4]  [,5]
[1,] 1.1709326 2.6521457 3.857477 0.219274562 1.2948374
[2,] 1.1770919 4.2109056 4.057313 4.918552967 1.9733967
[3,] 0.9171661 0.6721475 4.193675 0.434253839 0.9781060
[4,] 0.9181475 0.6911804 4.213295 0.455127422 0.9771797
[5,] 1.0467449 4.9263243 3.983248 0.004371504 1.1693707
 



HTH

rksh


On 1 Feb 2007, at 15:10, Ravi Varadhan wrote:

 Hi,



 I apologize for this repeat posting, which I first posted  
 yesterday. I would
 appreciate any hints on solving this problem:



 I have two matrices A (m x 2) and B (n x 2), where m and n are large
 integers (on the order of 10^4).  I am looking for an efficient way to
 create another matrix, W (m x n), which can be defined as follows:



 for (i in 1:m){

 for (j in 1:n) {

 W[i,j] - g(A[i,], B[j,])

 } }

 where g(x,y) is a function that takes two vectors and returns a  
 scalar.



 The following works okay, but is not fast enough for my purpose.  I  
 am sure
 that I can do better:



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 How can I do this in a faster manner? I attempted outer,  
 kronecker,
 expand.grid, etc, but with no success.



 Here is an example:



 m - 2000

 n - 5000

 A - matrix(rnorm(2*m),ncol=2)

 B - matrix(rnorm(2*n),ncol=2)

 W - matrix(NA, m, n)



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 g - function(x,y){

 theta - atan((y[2]-x[2]) / (y[1] - x[1]))

 theta + 2*pi*(theta  0)

 }



 Thanks for any suggestions.



 Best,

 Ravi.







 -- 
 --
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/ 
 Varadhan.html



 -- 
 --
 




   [[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
 and provide commented, minimal, self-contained, reproducible code.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743


-- 
This e-mail (and any attachments) is confidential and intend...{{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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help writing a faster code

2007-02-01 Thread Ravi Varadhan
Thank you, Dimitris and Robin.  

Dimitris - your solution(s) works very well.  Although my g function is a
lot more complicated than that in the simple example that I gave, I think
that I can use your idea of taking the whole matrix inside the function and
working directly with it.

Robin - using two applys doesn't make the code any faster, it just produces
a compact one-liner.

Best,
Ravi.

---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




-Original Message-
From: Dimitris Rizopoulos [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 01, 2007 10:33 AM
To: Ravi Varadhan
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Need help writing a faster code

the following seems to be a first improvement:

m - 2000
n - 5000
A - matrix(rnorm(2*m), ncol=2)
B - matrix(rnorm(2*n), ncol=2)
W1 - W2 - matrix(0, m, n)

##
##

g1 - function(x, y){
theta - atan((y[2] - x[2]) / (y[1] - x[1]))
theta + 2*pi*(theta  0)
}

invisible({gc(); gc()})
system.time(for (i in 1:m) {
W1[i, ] - apply(B, 1, y = A[i,], function(x, y) g1(y, x))
})

##

g2 - function(x){
out - tB - x
theta - atan(out[2, ] / out[1, ])
theta + 2*pi*(theta  0)
}

tB - t(B)
invisible({gc(); gc()})
system.time(for (i in 1:m) {
W2[i, ] - g2(A[i, ])
})

## or

invisible({gc(); gc()})
system.time(W3 - t(apply(A, 1, g2)))

all.equal(W1, W2)
all.equal(W1, W3)


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Ravi Varadhan [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, February 01, 2007 4:10 PM
Subject: [R] Need help writing a faster code


 Hi,



 I apologize for this repeat posting, which I first posted yesterday. 
 I would
 appreciate any hints on solving this problem:



 I have two matrices A (m x 2) and B (n x 2), where m and n are large
 integers (on the order of 10^4).  I am looking for an efficient way 
 to
 create another matrix, W (m x n), which can be defined as follows:



 for (i in 1:m){

 for (j in 1:n) {

 W[i,j] - g(A[i,], B[j,])

 } }

 where g(x,y) is a function that takes two vectors and returns a 
 scalar.



 The following works okay, but is not fast enough for my purpose.  I 
 am sure
 that I can do better:



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 How can I do this in a faster manner? I attempted outer, 
 kronecker,
 expand.grid, etc, but with no success.



 Here is an example:



 m - 2000

 n - 5000

 A - matrix(rnorm(2*m),ncol=2)

 B - matrix(rnorm(2*n),ncol=2)

 W - matrix(NA, m, n)



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 g - function(x,y){

 theta - atan((y[2]-x[2]) / (y[1] - x[1]))

 theta + 2*pi*(theta  0)

 }



 Thanks for any suggestions.



 Best,

 Ravi.









 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage: 
 http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html





 




 [[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
 and provide commented, minimal, self-contained, reproducible code.
 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
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] Need help writing a faster code

2007-02-01 Thread Ravi Varadhan
Dear Dimitris,

I implemented your solution on my actual problem.  I was able to generate my
large transition matrix in 56 seconds, compared to the previous time of
around 27 minutes.  Wow!!!

I thank you very much for the help.  R and the R-user group are truly
amazing!

Best regards,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: Dimitris Rizopoulos [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 01, 2007 10:33 AM
To: Ravi Varadhan
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Need help writing a faster code

the following seems to be a first improvement:

m - 2000
n - 5000
A - matrix(rnorm(2*m), ncol=2)
B - matrix(rnorm(2*n), ncol=2)
W1 - W2 - matrix(0, m, n)

##
##

g1 - function(x, y){
theta - atan((y[2] - x[2]) / (y[1] - x[1]))
theta + 2*pi*(theta  0)
}

invisible({gc(); gc()})
system.time(for (i in 1:m) {
W1[i, ] - apply(B, 1, y = A[i,], function(x, y) g1(y, x))
})

##

g2 - function(x){
out - tB - x
theta - atan(out[2, ] / out[1, ])
theta + 2*pi*(theta  0)
}

tB - t(B)
invisible({gc(); gc()})
system.time(for (i in 1:m) {
W2[i, ] - g2(A[i, ])
})

## or

invisible({gc(); gc()})
system.time(W3 - t(apply(A, 1, g2)))

all.equal(W1, W2)
all.equal(W1, W3)


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Ravi Varadhan [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, February 01, 2007 4:10 PM
Subject: [R] Need help writing a faster code


 Hi,



 I apologize for this repeat posting, which I first posted yesterday. 
 I would
 appreciate any hints on solving this problem:



 I have two matrices A (m x 2) and B (n x 2), where m and n are large
 integers (on the order of 10^4).  I am looking for an efficient way 
 to
 create another matrix, W (m x n), which can be defined as follows:



 for (i in 1:m){

 for (j in 1:n) {

 W[i,j] - g(A[i,], B[j,])

 } }

 where g(x,y) is a function that takes two vectors and returns a 
 scalar.



 The following works okay, but is not fast enough for my purpose.  I 
 am sure
 that I can do better:



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 How can I do this in a faster manner? I attempted outer, 
 kronecker,
 expand.grid, etc, but with no success.



 Here is an example:



 m - 2000

 n - 5000

 A - matrix(rnorm(2*m),ncol=2)

 B - matrix(rnorm(2*n),ncol=2)

 W - matrix(NA, m, n)



 for (i in 1:m) {

 W[i,] - apply(B, 1, y=A[i,], function(x,y) g(y,x))

 }



 g - function(x,y){

 theta - atan((y[2]-x[2]) / (y[1] - x[1]))

 theta + 2*pi*(theta  0)

 }



 Thanks for any suggestions.



 Best,

 Ravi.









 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage: 
 http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html





 




 [[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
 and provide commented, minimal, self-contained, reproducible code.
 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
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] need help with debug package

2007-01-04 Thread Tong Wang
I think I have figured out part of the answer,  when I entered a debugger, the 
calling environment (parent frame) 
refers to the debugger program, instead of the mainfun( ).   But is there 
anyway to solve this problem ? 

thanks 

- Original Message -
From: Tong Wang [EMAIL PROTECTED]
Date: Wednesday, January 3, 2007 9:30 pm
Subject: need help with debug package
To: R help r-help@stat.math.ethz.ch

 Hi all, 
  I met a problem while using the debug package,  I have the 
 following program: 
 
 mainfun- function(){
   beta-1
   result-subfun(beta+x)
 }
 
 subfun-function(expr){
   y - eval(expr, envir=list(x=c(1,2)),enclos = 
 parent.frame())  return(y)
 }
 
 I have no problem using this program without calling the debug 
 package.   but once 
 I mtrace(subfun),  the debugger can't find all the beta after 
 entering subfun , and give 
 the message : Error in beta : non-numeric argument to binary 
 operator
 Is there anyway to get around ?
 
 thanks a lot 
 happy new year


__
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] need help with debug package

2007-01-03 Thread Tong Wang
Hi all, 
  I met a problem while using the debug package,  I have the following 
program: 

mainfun- function(){
   beta-1
   result-subfun(beta+x)
}
 
subfun-function(expr){
   y - eval(expr, envir=list(x=c(1,2)),enclos = parent.frame())
  return(y)
}

I have no problem using this program without calling the debug package.   but 
once 
I mtrace(subfun),  the debugger can't find all the beta after entering subfun , 
and give 
the message : Error in beta : non-numeric argument to binary operator

Is there anyway to get around ?

thanks a lot 
happy new year

__
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] need help with barplot

2006-11-29 Thread Robertas Kavaliūnas
Hello,
I do this
a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)
b=matrix(a,nrow=4)
rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002)
colnames(b)=c(p1,p2,p3)
barplot(b,beside=T,col=(c(red,orange,yellow)))

then I have 
http://www.mif.vu.lt/~roka5178/barplot1.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot1.JPG
but I need to have
http://www.mif.vu.lt/~roka5178/barplot.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot.JPG
how can i do this?
i need to  to change axis x whit y

--
Robertas

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help with barplot

2006-11-29 Thread David Barron
You need the transpose of the matrix (or create it differently in the
first place!).  Changing the last line to

 barplot(t(b),beside=T,col=(c(red,orange,yellow)))

should do the trick.

On 29/11/06, Robertas Kavaliūnas [EMAIL PROTECTED] wrote:
 Hello,
 I do this
 a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)
 b=matrix(a,nrow=4)
 rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002)
 colnames(b)=c(p1,p2,p3)
 barplot(b,beside=T,col=(c(red,orange,yellow)))

 then I have 
 http://www.mif.vu.lt/~roka5178/barplot1.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot1.JPG
 but I need to have
 http://www.mif.vu.lt/~roka5178/barplot.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot.JPG
 how can i do this?
 i need to  to change axis x whit y

 --
 Robertas

 [[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
 and provide commented, minimal, self-contained, reproducible code.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
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] need help with barplot

2006-11-29 Thread John Kane
--- Robertas Kavaliûnas
[EMAIL PROTECTED] wrote:

 Hello,
 I do this

a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)
 b=matrix(a,nrow=4)

rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002)
 colnames(b)=c(p1,p2,p3)
 barplot(b,beside=T,col=(c(red,orange,yellow)))
 
 then I have

http://www.mif.vu.lt/~roka5178/barplot1.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot1.JPG
 but I need to have

http://www.mif.vu.lt/~roka5178/barplot.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot.JPG
 how can i do this?
 i need to  to change axis x whit y

 Robertas


This is dirty code but it works. Just transpose the
matrix before you plot it.

a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)
b= matrix(a,nrow=4)
rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002)
colnames(b)=c(p1,p2,p3)
b1 - t(b)#  Transpose of 'b'
barplot(b1,beside=T,col=(c(red,orange,yellow)))

__
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] Need help in nlmeODE

2006-11-19 Thread Spencer Graves
  I've never used nlmeODE, but this post is almost 3 days old, so 
I'll offer some comments.  I didn't see an example in the 'nlmeODE' help 
file, but I did find a reference to 'PKPDmodels', and the help file for 
'PKPDmodels' includes several examples.  Have you worked through those?  
If you have and you still would like some help, please submit another 
post with a copy to the 'nlmeODE' maintainer [identified, e.g., via 
help(package='nlmeODE')].  In that post, please include minimal, 
self-contained, reproducible code showing something you tried and 
explaining why it doesn't meet your needs (as suggested in the posting 
guide www.R-project.org/posting-guide.html). 

  Hope this helps. 
  Spencer Graves

Ron Fisher wrote:
 I am trying to use nlmeODE. But I don't know what is ObsEq. How you can get 
 it from your ODEs system? Could someone help me out?

 Best,

 Ron

 __
 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] Need help in nlmeODE

2006-11-17 Thread Ron Fisher
I am trying to use nlmeODE. But I don't know what is ObsEq. How you can get it 
from your ODEs system? Could someone help me out?

Best,

Ron

__
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] Need help in waveslim package: imodwt and universal.thresh.modwt

2006-11-13 Thread Airon Yiu
Hi:
  I have encountered problems with imodwt and universal.thresh.modwt and cannot 
find any reference in R Search.   Hope someone can give me some ideas:
   
  Starting with 
  modwt.la8 - modwt(xdata, la8, n.level=6)  -- this seems to work fine 
   
  (1)  ydata - imodwt(modwt.la8)
  will always give ydata as numeric(0) (no values) instead of being a time 
series data with the same lenght as xdata.  
   
  (2)   thred.la8 - universal.thresh.modwt(modwt.la8, max.level=4, hard=F) 
will give me error at:
  abs(wc.fine)  - cannot contain non-numeric field.
   
  Any help is much appreciated.
   
  Regards

 ___
 YM - Â÷½u°T®§
 
´Nºâ§A¨S¦³¤Wºô¡A§AªºªB¤Í¤´¥i¥H¯d¤U°T®§µ¹§A¡A·í§A¤Wºô®É´N¯à¥ß§Y¬Ý¨ì¡A¥ô¦ó»¡¸Ü³£ÉN¨«¥¢¡C

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in waveslim package: imodwt and universal.thresh.modwt

2006-11-13 Thread rdporto1
The first two commands worked fine to me. I used
xdata = rnorm(128).

To let us help you more, specify your R version,
some data, OS etc, as usually asked.

Rogerio Porto.

-- Cabeçalho original ---

De: [EMAIL PROTECTED]
Para: r-help@stat.math.ethz.ch
Cópia: 
Data: Sun, 12 Nov 2006 16:02:45 +0800 (CST)
Assunto: [R] Need help in waveslim package: imodwt and universal.thresh.modwt

 Hi:
   I have encountered problems with imodwt and universal.thresh.modwt and 
 cannot find any reference in R Search.   Hope someone can give me some ideas:

   Starting with 
   modwt.la8 - modwt(xdata, la8, n.level=6)  -- this seems to work fine 

   (1)  ydata - imodwt(modwt.la8)
   will always give ydata as numeric(0) (no values) instead of being a time 
 series data with the same lenght as xdata.  

   (2)   thred.la8 - universal.thresh.modwt(modwt.la8, max.level=4, hard=F) 
 will give me error at:
   abs(wc.fine)  - cannot contain non-numeric field.

   Any help is much appreciated.

   Regards
 
  ___
  YM - Â÷½u°T®§
  
 ´Nºâ§A¨S¦³¤Wºô¡A§AªºªB¤Í¤´¥i¥H¯d¤U°T®§µ¹§A¡A·í§A¤Wºô®É´N¯à¥ß§Y¬Ý¨ì¡A¥ô¦ó»¡¸Ü³£ÉN¨«¥¢¡C
 
   [[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with barplots

2006-10-15 Thread Henric Nilsson
On 2006-10-13 10:55, David Barron wrote:

 First, produce two barplots for comparison:
 
 par(mfrow=c(2,1) )
 barplot(VADeaths,beside=TRUE)
 barplot(VADeaths)
 
 The same information is in both plots; in the top, it is displayed as
 5 separate bars for each group, and in the stacked plot it is shown as
 5 separate regions in each of the four bars.  The hight of each of
 these regions is the same as the hight of the corresponding bar in the
 side-by-side plot.  The stacked plot enables you to see overall
 differences more easily (easier to see that the death rate is highest
 for Urban Males), but it is harder to compare the sizes of the
 categories.

Take a look at ?spineplot.


HTH,
Henric



 
 On 13/10/06, laba diena [EMAIL PROTECTED] wrote:
 I`ve read all the manuals and still couln`t find what is the difference
 between the stacked and side-by-side barplots ? Could you explain me ?

 [[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
 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] Need help with barplots

2006-10-13 Thread laba diena
I`ve read all the manuals and still couln`t find what is the difference
between the stacked and side-by-side barplots ? Could you explain me ?

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with barplots

2006-10-13 Thread Peter Dalgaard
laba diena [EMAIL PROTECTED] writes:

 I`ve read all the manuals and still couln`t find what is the difference
 between the stacked and side-by-side barplots ? Could you explain me ?

Did you try

par(ask=TRUE)
example(barplot)  

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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] Need help with barplots

2006-10-13 Thread David Barron
First, produce two barplots for comparison:

 par(mfrow=c(2,1) )
 barplot(VADeaths,beside=TRUE)
 barplot(VADeaths)

The same information is in both plots; in the top, it is displayed as
5 separate bars for each group, and in the stacked plot it is shown as
5 separate regions in each of the four bars.  The hight of each of
these regions is the same as the hight of the corresponding bar in the
side-by-side plot.  The stacked plot enables you to see overall
differences more easily (easier to see that the death rate is highest
for Urban Males), but it is harder to compare the sizes of the
categories.

On 13/10/06, laba diena [EMAIL PROTECTED] wrote:
 I`ve read all the manuals and still couln`t find what is the difference
 between the stacked and side-by-side barplots ? Could you explain me ?

 [[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
 and provide commented, minimal, self-contained, reproducible code.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
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] Need help with tables

2006-10-13 Thread laba diena
I have a data file with 3 columns and I need to take only 2, how to do that
?

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with tables

2006-10-13 Thread David Barron
I'm not quite sure what you mean, but if you are wanting to select
columns of a data frame, have a look at

 help([)

David

On 13/10/06, laba diena [EMAIL PROTECTED] wrote:
 I have a data file with 3 columns and I need to take only 2, how to do that
 ?

 [[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
 and provide commented, minimal, self-contained, reproducible code.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
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] Need help with tables

2006-10-13 Thread Stefan Grosse
I suggest you look at one of the guides:
http://cran.r-project.org/other-docs.html
before answering questions like this to the mailing list... please read
the posting guide!

laba diena schrieb:
 I have a data file with 3 columns and I need to take only 2, how to do that
 ?

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


Re: [R] Need help with tables

2006-10-13 Thread John Kane

--- laba diena [EMAIL PROTECTED] wrote:

 I have a data file with 3 columns and I need to take
 only 2, how to do that

Have a look at the manual?
An Introduction to R
2.7 Index vectors; selecting and modifying subsets of
a data set

__
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] Need help to estimate the Coef matrices in mAr

2006-09-30 Thread Spencer Graves
  I'm sorry, but I can't follow what you are asking.  If you'd like 
more help, please provide commented, minimal, self-contained, 
reproducible code, as suggested in the posting guide 
www.R-project.org/posting-guide.html. 
http://www.R-project.org/posting-guide.html  Please include a minimal 
data set, e.g., 10 simulated observations on 2 variables, with comments 
describing what you tried and what you don't understand about it. 

  Hope this helps. 
  Spencer Graves

Arun Kumar Saha wrote:

 Dear Spencer,

  

 Thank you very much for your attention on my problem. According to 
 your advice I did some home work on this problem, but unfortunately I 
 could not solve my problem.

  

  

 Suppose I have a dataset of length 300 with 2 variables. And I want to 
 fit a VAR model on this of order 2.

  

 I went through the function mAr.est and got understand that, here 'K' 
 is a matrix with (300-2) rows and 7 columns. the first col. consists 
 only 1, next two columns consist of lagged values of two variables 
 with lag-length 2, next two col. consist of lagged value with lag 
 length-1, and next two cols are for lag-length-0.

  

 Next, they add additional a 7-7 matrix to K. For this matrix diagonal 
 elements are the square root of sum of square of elements of K (col. 
 wise) and rest of the elements are 0.

  

 I feel that this matrix, that is added to K, is the key matrix for any 
 type of modification that you prescribed. Therefore for experimental 
 purpose I put NA against one of its off-diagonal elements. But I got 
 error.

  

 However I cannot understand why they put such figures for diagonal and 
 off-diagonal elements of that matrix.

  

 Can you suggest me any solution more specifically?

  

  

 Thanks and regards,

 Arun



 On 9/4/06, *Spencer Graves* [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:

   Have you tried 'RSiteSearch(multivariate autoregression,
 functions)'?  This produced 14 hits for me just now, the first of
 which mentions a package 'MSBVAR'.  Have you looked at that?

   If that failed, I don't think it would be too hard to modify
 'mAr.est' to do what you want.  If it were my problem, I might a local
 copy of the function, then add an argument accepting a 2 or
 3-dimensional array with numbers for AR coefficients to be fixed
 and NAs
 for the coefficients.  Then I'd use 'debug' to walk through the
 function
 line by line until I figured out how to modify the function to do
 what I
 wanted.  I haven't checked all the details, so I don't know for
 sure if
 this would work, but the function contains a line 'R =
 qr.R(qr((rbind(K,
 diag(scale, complete = TRUE)' which I would start by decomposing,
 possibly starting as follows:

   Z - rbind(K, diag(scale)

 I'd figure out how the different columns of Z relate to my
 problem, then
 modify it appropriately to get what I wanted.

   Another alternative would be to program it from scratch using
 something like 'optim' to minimize the sum of squares of residuals
 over
 the free parameters in my AR matrices.   I'm confident I could
 make this
 work, even if the I somehow could not get it with either of the
 other two.

   There may be something else  better, e.g., a Kalman filter
 representation, but I can't think how to do that off the top if my
 head.

   Hope this helps.
   Spencer Graves

 Arun Kumar Saha wrote:
  Dear R users,
 
  I am using mAr package to fit a Vector autoregressive model to
 my data. But
  here I want to put some predetermined values for some elements in
  coefficient matrix that mAr.est going to estimate. For example
 if p=3 then I
  want to put A3[1,3] = 0 and keep rest of the elements of
 coefficient
  matrices to be determined by mAr.est.
 
  Can anyone please tell me how can I do that?
 
  Sincerely yours,
  Arun
 
[[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch
 mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
 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.
 




 -- 
 Arun Kumar Saha, M.Sc.[C.U.]
 S T A T I S T I C I A N[Analyst]
 RISK  MANAGEMENT  DIVISION
 Transgraph Consulting [ www.transgraph.com http://www.transgraph.com]
 Hyderabad, INDIA
 Contact #  Home: (91-033) 25558038
 Office: (91-040) 30685012 Ext. 17
   FAX: (91-040) 55755003
Mobile: 919989122010
 E-Mail: [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED]
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Re: [R] Need help with boxplots

2006-09-26 Thread Gabor Grothendieck
To prevent confusion you might want to use a red dot rather than
a line:

   points(1:2, c(mean(a), mean(b)), col = red)

and perhaps label it since its non-standard:

   text(1:2, c(mean(a), mean(b)), Mean, pos = 4)

On 9/26/06, laba diena [EMAIL PROTECTED] wrote:
 How to add a mean line in the boxplot keeping the median line ?
 For example in this:


 set.seed(1)

 a - rnorm(10)

 b - rnorm(10)

 boxplot(a, b)

[[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
 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] Need help with boxplots

2006-09-26 Thread laba diena
How to add a mean line in the boxplot keeping the median line ?
For example in this:


set.seed(1)

a - rnorm(10)

b - rnorm(10)

boxplot(a, b)

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] Need help with boxplots

2006-09-26 Thread laba diena
 How to add a mean *line* in the boxplot keeping the median line ?
Maybe it is possible to do using the *segments* function ?
For example in this:

set.seed(1)

a - rnorm(10)

b - rnorm(10)

boxplot(a, b)

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with boxplots

2006-09-26 Thread David Barron
The problem with a line, I think, would be that the width of the boxes
can vary depending on the number of boxes in the plot, etc.  No doubt
it could be done, but you'd probably have to look into the bxp
function to see how the widths are calculated.

On 26/09/06, laba diena [EMAIL PROTECTED] wrote:
  How to add a mean *line* in the boxplot keeping the median line ?
 Maybe it is possible to do using the *segments* function ?
 For example in this:

 set.seed(1)

 a - rnorm(10)

 b - rnorm(10)

 boxplot(a, b)

 [[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
 and provide commented, minimal, self-contained, reproducible code.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
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] Need help with boxplots

2006-09-26 Thread Gabor Grothendieck
And if you really do want a line segment try this:

M - c(mean(a), mean(b))
segments(1:2-0.4, M, 1:2+0.4, M, col = red)


On 9/26/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 To prevent confusion you might want to use a red dot rather than
 a line:

   points(1:2, c(mean(a), mean(b)), col = red)

 and perhaps label it since its non-standard:

   text(1:2, c(mean(a), mean(b)), Mean, pos = 4)

 On 9/26/06, laba diena [EMAIL PROTECTED] wrote:
  How to add a mean line in the boxplot keeping the median line ?
  For example in this:
 
 
  set.seed(1)
 
  a - rnorm(10)
 
  b - rnorm(10)
 
  boxplot(a, b)
 
 [[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
  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.


Re: [R] Need help to estimate the Coef matrices in mAr

2006-09-20 Thread Arun Kumar Saha
Dear Spencer,



Thank you very much for your attention on my problem. According to your
advice I did some home work on this problem, but unfortunately I could not
solve my problem.





Suppose I have a dataset of length 300 with 2 variables. And I want to fit a
VAR model on this of order 2.



I went through the function mAr.est and got understand that, here 'K' is a
matrix with (300-2) rows and 7 columns. the first col. consists only 1, next
two columns consist of lagged values of two variables with lag-length 2,
next two col. consist of lagged value with lag length-1, and next two cols
are for lag-length-0.



Next, they add additional a 7-7 matrix to K. For this matrix diagonal
elements are the square root of sum of square of elements of K (col. wise)
and rest of the elements are 0.



I feel that this matrix, that is added to K, is the key matrix for any type
of modification that you prescribed. Therefore for experimental purpose I
put NA against one of its off-diagonal elements. But I got error.



However I cannot understand why they put such figures for diagonal and
off-diagonal elements of that matrix.



Can you suggest me any solution more specifically?





Thanks and regards,

Arun


On 9/4/06, Spencer Graves [EMAIL PROTECTED] wrote:

   Have you tried 'RSiteSearch(multivariate autoregression,
 functions)'?  This produced 14 hits for me just now, the first of
 which mentions a package 'MSBVAR'.  Have you looked at that?

   If that failed, I don't think it would be too hard to modify
 'mAr.est' to do what you want.  If it were my problem, I might a local
 copy of the function, then add an argument accepting a 2 or
 3-dimensional array with numbers for AR coefficients to be fixed and NAs
 for the coefficients.  Then I'd use 'debug' to walk through the function
 line by line until I figured out how to modify the function to do what I
 wanted.  I haven't checked all the details, so I don't know for sure if
 this would work, but the function contains a line 'R = qr.R(qr((rbind(K,
 diag(scale, complete = TRUE)' which I would start by decomposing,
 possibly starting as follows:

   Z - rbind(K, diag(scale)

 I'd figure out how the different columns of Z relate to my problem, then
 modify it appropriately to get what I wanted.

   Another alternative would be to program it from scratch using
 something like 'optim' to minimize the sum of squares of residuals over
 the free parameters in my AR matrices.   I'm confident I could make this
 work, even if the I somehow could not get it with either of the other two.

   There may be something else  better, e.g., a Kalman filter
 representation, but I can't think how to do that off the top if my head.

   Hope this helps.
   Spencer Graves

 Arun Kumar Saha wrote:
  Dear R users,
 
  I am using mAr package to fit a Vector autoregressive model to my data.
 But
  here I want to put some predetermined values for some elements in
  coefficient matrix that mAr.est going to estimate. For example if p=3
 then I
  want to put A3[1,3] = 0 and keep rest of the elements of coefficient
  matrices to be determined by mAr.est.
 
  Can anyone please tell me how can I do that?
 
  Sincerely yours,
  Arun
 
[[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
  and provide commented, minimal, self-contained, reproducible code.
 




-- 
Arun Kumar Saha, M.Sc.[C.U.]
S T A T I S T I C I A N[Analyst]
RISK  MANAGEMENT  DIVISION
Transgraph Consulting [www.transgraph.com]
Hyderabad, INDIA
Contact #  Home: (91-033) 25558038
Office: (91-040) 30685012 Ext. 17
  FAX: (91-040) 55755003
   Mobile: 919989122010
E-Mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] -Need help with function

2006-09-19 Thread Guenther, Cameron
Hello everyone,

I have a function here that I wrote but doesn't seem to work quite
right.  Attached is the code.  In the calib funcion under the for loop
Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i+1] returns NA's for everything
after years 1983 and 1984.  However the code works when it reads
Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i].  I don't quite understand why
since it should be calculating all of the necessary inputs prior to
calculating Bt[i+2].  Any help would be greatly appreciated.

Thanks

#Model parameters
B0-7500
m-0.3
R0-B0*m
z-0.8
a-B0/R0*(1-(z-0.2)/(0.8*z))
b-(z-0.2)/(0.8*z*R0)
dat-data.frame(years=seq(1983,2004),cobs=c(19032324,19032324,17531618,2
0533029,20298099,20793744,23519369,23131780,19922247,17274513,17034419,1
2448318,4551585,4226451,7183688,7407924,7538366,7336039,8869193,7902341,
6369089,6211886))
stdr-runif(100,0,0.5)
stdc-runif(100,0,0.5)
BC-runif(1000,0,100)


#model calibration

calib-function(x){
 v-sample(stdr,1)
 cr-sample(stdc,1)
 N-rnorm(1)
 Bq-sample(BC,1)
 Rerr-exp(N*v-(v^2/2))
 Cerr-exp(N*cr-(cr^2/2))
 Bt-vector();Bt[1]=B0;Bt[2]=B0
 Rt-vector()
 Ct-vector()
 for (i in 1:length(x$years)){
  Ct[i]-1/Bq*Bt[i]*Cerr
  Rt[i]-Bt[i]/(a+b*Bt[i])
  Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i+1]
 }
  out-new.env()
  out$yr-x$years[1:length(x$years)]
  out$Bt-Bt[1:length(x$years)]
  out$Rt-Rt[1:length(x$years)]
  out$Ct-Ct[1:length(x$years)]
  out$stdr-v
  out$stdc-cr
  out$Bq-Bq
  out$Rerr-Rerr
  out$Cerr-Cerr
  return(as.list(out))
 }
 test-calib(dat)



Cameron Guenther, Ph.D.
Associate Research Scientist
FWC/FWRI, Marine Fisheries Research
100 8th Avenue S.E.
St. Petersburg, FL 33701
(727)896-8626 Ext. 4305
[EMAIL PROTECTED] 


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] -Need help with function

2006-09-19 Thread jim holtman
You are referencing Ct[i+1] in the loop and it is not defined.  From
then on everything is NA.

On 9/19/06, Guenther, Cameron [EMAIL PROTECTED] wrote:
 Hello everyone,

 I have a function here that I wrote but doesn't seem to work quite
 right.  Attached is the code.  In the calib funcion under the for loop
 Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i+1] returns NA's for everything
 after years 1983 and 1984.  However the code works when it reads
 Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i].  I don't quite understand why
 since it should be calculating all of the necessary inputs prior to
 calculating Bt[i+2].  Any help would be greatly appreciated.

 Thanks

 #Model parameters
 B0-7500
 m-0.3
 R0-B0*m
 z-0.8
 a-B0/R0*(1-(z-0.2)/(0.8*z))
 b-(z-0.2)/(0.8*z*R0)
 dat-data.frame(years=seq(1983,2004),cobs=c(19032324,19032324,17531618,2
 0533029,20298099,20793744,23519369,23131780,19922247,17274513,17034419,1
 2448318,4551585,4226451,7183688,7407924,7538366,7336039,8869193,7902341,
 6369089,6211886))
 stdr-runif(100,0,0.5)
 stdc-runif(100,0,0.5)
 BC-runif(1000,0,100)


 #model calibration

 calib-function(x){
  v-sample(stdr,1)
  cr-sample(stdc,1)
  N-rnorm(1)
  Bq-sample(BC,1)
  Rerr-exp(N*v-(v^2/2))
  Cerr-exp(N*cr-(cr^2/2))
  Bt-vector();Bt[1]=B0;Bt[2]=B0
  Rt-vector()
  Ct-vector()
  for (i in 1:length(x$years)){
  Ct[i]-1/Bq*Bt[i]*Cerr
  Rt[i]-Bt[i]/(a+b*Bt[i])
  Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i+1]
  }
  out-new.env()
  out$yr-x$years[1:length(x$years)]
  out$Bt-Bt[1:length(x$years)]
  out$Rt-Rt[1:length(x$years)]
  out$Ct-Ct[1:length(x$years)]
  out$stdr-v
  out$stdc-cr
  out$Bq-Bq
  out$Rerr-Rerr
  out$Cerr-Cerr
  return(as.list(out))
  }
  test-calib(dat)



 Cameron Guenther, Ph.D.
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]


[[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
 and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
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] Need help with dataset formation problem

2006-09-19 Thread Uwe Ligges
Tong Wang wrote:

 Hi, I have a data set , say, X  :  [1][2] mean  0  .8
  sd1   3
 
 I need to use it in do.call() ,   so when I refer to the first col of
 X, I need it to be a list with members mean, sd. thus I constructed X
 as a list of list :  X[[1]]- list(mean=0, sd=1),   X[[2]]-.
 .  But this dataset is useless in other cases, for example, I can't
 pull out all the means as a vector. Can I get some suggestions on

You can:

sapply(X, [[, 1)

Uwe Ligges

 what's the best way to handle it? (except preparing two copies of
 this data with different formats)
 
 Thanks a lot in advance.
 
 best
 
 __ 
 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.


Re: [R] Need help to estimate the Coef matrices in mAr

2006-09-04 Thread Spencer Graves
  Have you tried 'RSiteSearch(multivariate autoregression, 
functions)'?  This produced 14 hits for me just now, the first of 
which mentions a package 'MSBVAR'.  Have you looked at that? 

  If that failed, I don't think it would be too hard to modify 
'mAr.est' to do what you want.  If it were my problem, I might a local 
copy of the function, then add an argument accepting a 2 or 
3-dimensional array with numbers for AR coefficients to be fixed and NAs 
for the coefficients.  Then I'd use 'debug' to walk through the function 
line by line until I figured out how to modify the function to do what I 
wanted.  I haven't checked all the details, so I don't know for sure if 
this would work, but the function contains a line 'R = qr.R(qr((rbind(K, 
diag(scale, complete = TRUE)' which I would start by decomposing, 
possibly starting as follows: 

  Z - rbind(K, diag(scale)

I'd figure out how the different columns of Z relate to my problem, then 
modify it appropriately to get what I wanted. 

  Another alternative would be to program it from scratch using 
something like 'optim' to minimize the sum of squares of residuals over 
the free parameters in my AR matrices.   I'm confident I could make this 
work, even if the I somehow could not get it with either of the other two. 

  There may be something else  better, e.g., a Kalman filter 
representation, but I can't think how to do that off the top if my head. 

  Hope this helps. 
  Spencer Graves

Arun Kumar Saha wrote:
 Dear R users,

 I am using mAr package to fit a Vector autoregressive model to my data. But
 here I want to put some predetermined values for some elements in
 coefficient matrix that mAr.est going to estimate. For example if p=3 then I
 want to put A3[1,3] = 0 and keep rest of the elements of coefficient
 matrices to be determined by mAr.est.

 Can anyone please tell me how can I do that?

 Sincerely yours,
 Arun

   [[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
 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] need help with an interaction term

2006-08-31 Thread Christian Jones
Hello!
IŽm fitting a model with glm(family binomial). The best model counts 9 
Variables and includes an interaction term that was generated by the product of 
to continuous variables (a*b). All variables are correlated under a value of 
0.7 (Spearman rank order) While the estimates of both main effects are negativ, 
the resulting interaction term is positiv. This change of sign makes it 
difficult to interpret the model and above all, is this perhaps due to a bad 
variable choice ?
Thanks a lot for helping
Christian

___
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=02

__
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] need help with an interaction term

2006-08-31 Thread Chuck Cleland
Christian Jones wrote:
 Hello!
 I�m fitting a model with glm(family binomial). The best model counts 9 
 Variables and includes an interaction term that was generated by the product 
 of to continuous variables (a*b). All variables are correlated under a value 
 of 0.7 (Spearman rank order) While the estimates of both main effects are 
 negativ, the resulting interaction term is positiv. This change of sign makes 
 it difficult to interpret the model and above all, is this perhaps due to a 
 bad variable choice ?
 Thanks a lot for helping

  Rather than trying to interpret the model coefficients directly, you
might visualize the a*b interaction effect.  The effects package by John
Fox is very useful for this:

http://cran.r-project.org/doc/packages/effects.pdf

 Christian
 
 ___
 Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
 Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=02
 
 __
 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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] need help with an interaction term

2006-08-31 Thread Christian Jones
Hello Chuck,
many thanks for your advice.
IŽll go through the package and see if IŽll manage to visualize the interaction 
effect this time as I already tried it with a special tool for displaying 
models with interaction terms in 3D. 
http://www.uni-oldenburg.de/landeco/Download/Software/LR_Mesh/LR_Mesh.htm
but could not yield any plausible results. Hopefully this time...
best regards
Christian

 -Ursprüngliche Nachricht-
 Von: Chuck Cleland [EMAIL PROTECTED]
 Gesendet: 31.08.06 14:16:12
 An: Christian Jones [EMAIL PROTECTED]
 CC: r-help@stat.math.ethz.ch
 Betreff: Re: [R] need help with an interaction term


 Christian Jones wrote:
  Hello!
  Iï¿œm fitting a model with glm(family binomial). The best model counts 9 
  Variables and includes an interaction term that was generated by the 
  product of to continuous variables (a*b). All variables are correlated 
  under a value of 0.7 (Spearman rank order) While the estimates of both main 
  effects are negativ, the resulting interaction term is positiv. This change 
  of sign makes it difficult to interpret the model and above all, is this 
  perhaps due to a bad variable choice ?
  Thanks a lot for helping
 
   Rather than trying to interpret the model coefficients directly, you
 might visualize the a*b interaction effect.  The effects package by John
 Fox is very useful for this:
 
 http://cran.r-project.org/doc/packages/effects.pdf
 
  Christian
  
  ___
  Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
  Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=02
  
  __
  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.
 
 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894


__
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] Need help to estimate the Coef matrices in mAr

2006-08-29 Thread Arun Kumar Saha
Dear R users,

I am using mAr package to fit a Vector autoregressive model to my data. But
here I want to put some predetermined values for some elements in
coefficient matrix that mAr.est going to estimate. For example if p=3 then I
want to put A3[1,3] = 0 and keep rest of the elements of coefficient
matrices to be determined by mAr.est.

Can anyone please tell me how can I do that?

Sincerely yours,
Arun

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with difficulty loading page www.bioconductor.org

2006-08-25 Thread Martin Morgan
I didn't see a response to this, and am not an expert, but wanted to
point you in the right direction.

You should ask this question on the bioconductor mailing list.

The site is very much alive at this end (though I'm very close to it,
physically), so you'll need to provide some more information about the
problems you're experiencing. At a minimum it would help to include
the output of the R command

sessionInfo()

If you're using Windows you might also look at mailing list threads
dealing with server proxies. Searchable archives are at

http://dir.gmane.org/gmane.science.biology.informatics.conductor

this link

http://article.gmane.org/gmane.science.biology.informatics.conductor/2152/match=internet2

and searching for internet2 might be a good start.

Martin


Debashis Bhattacharya [EMAIL PROTECTED] writes:

 The page is either too busy, or there is something seriously wrong with 
 access to this page.

 Most of the time, trying to reach www.bioconductor.org results in 
 failure. Only once in a
 blue moon, do I get through.

 In fact, thus far, I have not been able to install bioconductor, since 
 the first source(...)
 command from the R command window -- following instruction on 
 www.bioconductor.org
 page, that I did manage to reach, one time -- has failed, every time.

 Please help.



 Debashis Bhattacharya.

 __
 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] Need help with difficulty loading page www.bioconductor.org

2006-08-24 Thread Debashis Bhattacharya
The page is either too busy, or there is something seriously wrong with 
access to this page.

Most of the time, trying to reach www.bioconductor.org results in 
failure. Only once in a
blue moon, do I get through.

In fact, thus far, I have not been able to install bioconductor, since 
the first source(...)
command from the R command window -- following instruction on 
www.bioconductor.org
page, that I did manage to reach, one time -- has failed, every time.

Please help.



Debashis Bhattacharya.

__
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] need help in building an R package with Fortran source

2006-05-05 Thread Meinhard Ploner
Hello all!

Can someone give me instructions how to build on PC/Win an R package 
with some embedded Fortran functions (preferable source, not dll!). The 
package should then be compilable and work on PC/Win as well as on Unix 
derivatives.

Thanks a lot

Meinhard Ploner

__
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] need help in building an R package with Fortran source

2006-05-05 Thread Uwe Ligges
Meinhard Ploner wrote:

 Hello all!
 
 Can someone give me instructions how to build on PC/Win an R package 
 with some embedded Fortran functions (preferable source, not dll!). The 
 package should then be compilable and work on PC/Win as well as on Unix 
 derivatives.

How to build source packages is described in the manual Writing R 
Extensions.

Uwe Ligges


 
 Thanks a lot
 
 Meinhard Ploner
 
 __
 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] need help in building an R package with Fortran source

2006-05-05 Thread Meinhard Ploner
Uwe recommended the reading of help desk in Rnews 2005/2
 http://cran.r-project.org/doc/Rnews/Rnews_2005-2.pdf

Thanks, it looks good, as my problems were mainly due to Perl and some 
compilers!!
Meinhard

__
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] need help for superpc package

2006-04-19 Thread Rossana Dell'Anna
Hi,

I am using the superpc package.
By 
superpc.train (data, type=regression) 
I calculated the standardized regression coefficients for measuring the
univariate effect of each feature on a continuous response y.

By 
superpc.cv(compute.fullcv=TRUE, compute.preval=FALSE, n.components=3,
n.fold=10)  
I used cross validation to estimate the optimal feature threshold and
choose only those features whose univariate coefficient exceeds the
threshold.

To choose the best threshold I plotted the cross-validation curves by 
superpc.plotcv(cv.type=full').

I work with 55 features and 43 samples.
I noticed that by repeating the call of superpc.cv  (with the same
argument values) and then plotting the curves by  superpc.plotcv, the
curves change and sometimes the best threshold changes value. Please
note that I chose compute.fullcv =TRUE, therefore full cross-validation
is done.
Moreover, if n.fold=10 the result is not significant for any threshold
value (the three curves are under the three horizontal lines -likelihood
ratio test). However with n.fold10 there are significant results.

I tested also the example provided by the user manual for the
explanation of the superpc.plotcv routine. In this case, by repeating
the call of superpc.cv (with the same argument values) the three curves
change, but they always remain under the three horizontal lines. So it
seems that the result is always not significant (likelihood ratio).

Is my interpretation of the likelihood ratio test correct? 
As the curves change, has someone any explanation or solution for the
correct choice of the best threshold value? 

I also noticed that by following the instructions of the superpc
tutorial (http://www-stat.stanford.edu/~tibs/superpc/tutorial.html) the
obtained cv.plot is not similar to the one provided in the tutorial as
pdf version. I use R 2.2.1 version. Is it possible that the rnorm()
function (seed=4648) did not generate the same set of numbers as that
used by R. Tibshirani?

Thank You in advance

Rossana

---
Rossana Dell'Anna, PhD
ITC-irst Centre for Scientific and Technological Research 
Via Sommarive, 18 - 38050 Trento, ITALY
ph:  +39 0461 314 486
e-mail:  [EMAIL PROTECTED]

__
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] need help in tune.nnet

2006-03-14 Thread Tuszynski, Jaroslaw W.
You use tune function to find optimal parameters needed for particular
classification algorithm. I had more experience with tune.svm but, I
would try first to put parameters covering the whole possible range of
each variable (in which algorithm do not crash), for example c(4^-2,
4^-1, 4^0, 4^1, 4^2) look at the results and than narrow down the search
in the best ranges. For allowed ranges of parameters you will need to
experiment or study documentation of your chosen classifier (nnet).

Jarek Tuszynski

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of madhurima
bhattacharjee
Sent: Friday, March 10, 2006 5:38 AM
To: r-help@stat.math.ethz.ch; Bioconductor
Subject: [R] need help in tune.nnet

Dear R people,

I want to use the tune.nnet function of e1071 package to tune nnet .
I am unable to understand the parameters of tune.nnet from the e1071 pdf

document.
I have performed nnet on a traindata and want to test it for class 
prediction with a testdata.
I want to know the values of size,decay,range etc. parameters for which 
the prediction of testdata is best.
Can anyone please tell me how to do this with the tune.nnet function.

Anticipating quick response.

Thanks and Regards,
Madhurima.

__
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


[R] need help in tune.nnet

2006-03-10 Thread madhurima bhattacharjee
Dear R people,

I want to use the tune.nnet function of e1071 package to tune nnet .
I am unable to understand the parameters of tune.nnet from the e1071 pdf 
document.
I have performed nnet on a traindata and want to test it for class 
prediction with a testdata.
I want to know the values of size,decay,range etc. parameters for which 
the prediction of testdata is best.
Can anyone please tell me how to do this with the tune.nnet function.

Anticipating quick response.

Thanks and Regards,
Madhurima.

__
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] Need help on Coxph

2006-03-09 Thread Gao Zhang
Hi all,




I have a dataset which includes 84 rows and 4313 columns. Starting from the
2nd row, each row represents
a patient. The 1st column is for arrayID
 2nd column is for time
 3rd column is for cancer
 4th column is for patientID
 Starting for the 5th columns, each column's ID is like
CTC_232B23, RP11_181G12, RP11_62M23...

I extract first 5 rows and 7 columns and get the data in below:

 arrayID   time cancer patientID CTC_232B23 RP11_181G12 RP11_62M23
X1747_4224 37.633  0 30635   -0.02665-0.02665  -0.038025
X1750_4214 89.300  0 22158   -0.02665-0.02665  -0.038025
X1751_4208 53.333  0 31669   -0.02665-0.02665  -0.038025
X1754_4194 39.467  0 32849   -0.02665-0.02665  -0.038025
X1775_4497 84.900  0 33563   -0.02665-0.02665  -0.038025

Finally I would like to build the cox model for each column (starting from
the 5th column). The code would be like:

mod.allison -  coxph( Surv(time, cancer) ~ CTC_232B23 , data=Rossi2)
mod.allison -  coxph( Surv(time, cancer) ~ RP11_181G12 , data=Rossi2)
mod.allison -  coxph( Surv(time, cancer) ~ RP11_62M23 , data=Rossi2)

I have no problem getting the result. However, since there are 4309 columns
(counted begining at the 5th column), I decide to make a 4309*1 matrix
(called BACs) to store the name of each column. Then run a loop like:

for (i in 1:4309){

mod.allison -  coxph( Surv(time, cancer) ~ BAC[i,1], data=Rossi2)
}

mod.allison


However, I got the error. Would you like to give me some suggestions about
this?


Many thanks in advance!

[[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] need help in nnet

2005-12-20 Thread madhurima bhattacharjee
Hello Everybody,

I would like to know how to interpret the result of nnet function of R.
My result looks like this:

# weights:  24
initial  value 6.533893
iter  10 value 4.616299
iter  20 value 4.616120
iter  30 value 4.616109
iter  30 value 4.616109
final  value 4.616109
converged
cres
true  1
   1 10
   2  3

Can anyone please help me asap?

Thanks and Regards,
Madhurima.

__
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] Need help for a statistical problem (See the posting guide)

2005-12-16 Thread Brett Magill
In response to a thread where a statistical question
unrelated to R was asked, Uwe Ligges wrote:

 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 Please ask a local statistical consultant for help.
 
 Uwe Ligges

Perhaps Uwe's admonition to do read the posting
guide was just a knee jerk reaction to an
unrecognized poster's name.  Of course, if the poster
did read the posting guide, they would have learned
that : 

Questions about statistics: The R mailing lists are
primarily intended for questions and discussion about
the R software. However, questions about statistical
methodology are sometimes posted. If the question is
well-asked and of interest to someone on the list, it
may elicit an informative up-to-date answer. See also
the Usenet groups sci.stat.consult (applied statistics
and consulting) and sci.stat.math (mathematical stat
and probability).

The language here is so equivocal!  OK, it is really
for R, but statistical questions are asked and you
might get an informative and up-to-date answer if
you do it well.  Sounds good to me!  I might start
using r-help for my statistical questions.  Thanks for
referring me to the posting guide Uwe (though I am not
sure why it was relevant the the original post).

My point: If r-help does not want statistical
questions, and people who ask statistical questions
are referred to the posting guide, shouldn't the
posting guide *actually* say no statistical questions!

Brett

__
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] Need help for a statistical problem

2005-12-14 Thread james brown
Hello Dear
I need to select among 700 objects  a good
representative sample. These
objects
could be residential houses, commercial buildings,
trucks, etc.
How to get a good sample size and select a set of
objects that is very
representative.

The second part of my question is to find a
statistical model in R that
detects objects that are most
likely used as their owners told the municipality. For
example, if a
restaurant is suppose
to have 5 tables, we want to know that it doesn't have
more. The goal
is to have a model that
flags such restaurant for inspection.

Cheers, Dan

__
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] Need help for a statistical problem

2005-12-14 Thread Uwe Ligges
james brown wrote:
 Hello Dear
 I need to select among 700 objects  a good
 representative sample. These
 objects
 could be residential houses, commercial buildings,
 trucks, etc.
 How to get a good sample size and select a set of
 objects that is very
 representative.
 
 The second part of my question is to find a
 statistical model in R that
 detects objects that are most
 likely used as their owners told the municipality. For
 example, if a
 restaurant is suppose
 to have 5 tables, we want to know that it doesn't have
 more. The goal
 is to have a model that
 flags such restaurant for inspection.
 
 Cheers, Dan
 
 __
 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

PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

Please ask a local statistical consultant for help.

Uwe Ligges

__
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] need help with matrix manipulation

2005-12-05 Thread Jaramillo, Renee
I hope my problem is not too basic to post here.  I am a beginner having
problems with some matrix manipulation.  The data I am working with are
sites with hourly ozone readings and is in a matrix where each row is a site
and each column is an hourly reading.  So for 10 sites, one day's worth of
data is a 10x24 matrix - column 1 is the ozone measurement for midnight GMT,
column 2 is ozone at 1:00am GMT, etc.

 

My challenge is that I want to create a new matrix with the same sites, BUT
I want the first column to be the hourly ozone reading at midnight LOCAL
time.  If all the sites were in the same time zone this would be easy - for
the US Eastern time zone I could do something like:

oz.est[, 1:19] - oz.gmt[, 6:24]  

 

The problem is the sites are in different time zones, and I have a separate
vector that indicates which site belongs to which time zone.  So sites in
the Eastern time zone I want to extract columns 6-24 from the GMT matrix,
sites in the Central time zone I want to extract columns 7-24 from the GMT
matrix, etc.  

 

Is there a clever way to use matrix indices on my GMT matrix to extract the
columns I need for the sites in the different time zones?  I have been
trying different things like this: 

 

# VECTOR WITH HOUR TIME DIFFERENCE BETWEEN SITE AND GMT 

start.hr - c(6,7,6,8,7,5,7,6,5,6)  

 

# THIS DOESN'T WORK

oz.local[ , 1: (24-start.hr) ]  -  oz.gmt [, (start.hr+1) : 24 ]

 

# THIS DOESN'T WORK EITHER

oz.local[ , rep(1,nrow(oz.gmt)) : (24-start.hr) ]  -  oz.gmt [,
(start.hr+1) : rep(24,nrow(oz.gmt)) ]

 

Ultimately I will be working with over 10,000 sites and hourly data over 3
months so my data matrix will be something like 10,220 x 2208 

 

 

I'd appreciate any suggestions.  Thanks!

Renee Jaramillo

 

 

 

 

 


[[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


Re: [R] need help with matrix manipulation

2005-12-05 Thread Gabor Grothendieck
This will give a list, one element per row of oz.gmt, which
contains the differently sized vectors as components:

idx - seq(along = start.hr)
f - function(i) oz.gmt[i, start.hr[i]:24]
lapply(idx, f)


On 12/5/05, Jaramillo, Renee [EMAIL PROTECTED] wrote:
 I hope my problem is not too basic to post here.  I am a beginner having
 problems with some matrix manipulation.  The data I am working with are
 sites with hourly ozone readings and is in a matrix where each row is a site
 and each column is an hourly reading.  So for 10 sites, one day's worth of
 data is a 10x24 matrix - column 1 is the ozone measurement for midnight GMT,
 column 2 is ozone at 1:00am GMT, etc.



 My challenge is that I want to create a new matrix with the same sites, BUT
 I want the first column to be the hourly ozone reading at midnight LOCAL
 time.  If all the sites were in the same time zone this would be easy - for
 the US Eastern time zone I could do something like:

 oz.est[, 1:19] - oz.gmt[, 6:24]



 The problem is the sites are in different time zones, and I have a separate
 vector that indicates which site belongs to which time zone.  So sites in
 the Eastern time zone I want to extract columns 6-24 from the GMT matrix,
 sites in the Central time zone I want to extract columns 7-24 from the GMT
 matrix, etc.



 Is there a clever way to use matrix indices on my GMT matrix to extract the
 columns I need for the sites in the different time zones?  I have been
 trying different things like this:



 # VECTOR WITH HOUR TIME DIFFERENCE BETWEEN SITE AND GMT

 start.hr - c(6,7,6,8,7,5,7,6,5,6)



 # THIS DOESN'T WORK

 oz.local[ , 1: (24-start.hr) ]  -  oz.gmt [, (start.hr+1) : 24 ]



 # THIS DOESN'T WORK EITHER

 oz.local[ , rep(1,nrow(oz.gmt)) : (24-start.hr) ]  -  oz.gmt [,
 (start.hr+1) : rep(24,nrow(oz.gmt)) ]



 Ultimately I will be working with over 10,000 sites and hourly data over 3
 months so my data matrix will be something like 10,220 x 2208





 I'd appreciate any suggestions.  Thanks!

 Renee Jaramillo












[[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@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] Need help on ARIMA (time series analysis)

2005-10-16 Thread Spencer Graves
  Have you received a reply to this post?  I have not seen one.  If you 
would still like some suggestions from this group, please provide more 
detail on your question, as requested in the posting guide 
(www.R-project.org/posting-guide.html), including which version of R 
under which operating system.

  If I understand your post, you have two questions:  (1) the error 
message and (2) the need for a loop.

  Regarding the error message, I can not replicate it.  The message 
suggests a series that is nonstationary.  However, I don't get that 
message from 'arima(1:50, order=c(1,0,1))', which is clearly 
nonstationary.  What's in the file C:\\R\\arima.R?  Can you replicate 
the error without using a source command?

  Regarding the need for a loop, I'm sorry, but I don't know enough 
about time series in R to answer your question.  I'm currently studying 
Venables and Ripley (2002) Modern Applied Statistics with S, 4th ed. 
(Springer), ch. 14.  If you are not familiar with this book, I highly 
recommend it.  Ch. 14 is on time series.  If you would like more 
comments on your question regarding a loop, I suggest you rephrase your 
question in terms of a standard example like lh, fitting to, e.g., 
windows of length 30 in this series of 48 observations, explaining also 
very briefly what you are trying to accomplish with the loop.

  spencer graves

park wrote:
 Hi, 
  
 I am so novice in using R. I have some problems in my R script below
 which fits time series data and predict it one-step ahead.  Here is a
 brief explanation on what I try to achieve
  
 Th16k is time series data (500 data points). The size of window for
 fitting and predicting is 50 (data points). As you can easily discover
 from my code,  (fixed) window is moving/sliding to get next one-step
 ahead prediction. The predicted value will be saved in pth.
  
 The problem is,  every time I execute following script, I got error
 saying 
  
 
source(C:\\R\\arima.R)
 
 Error in arima(temp, order = c(1, 0, 1)) : 
 non-stationary AR part from CSS
  
 I think there should be better way to achieve this goal without using
 for loop.  If you can share your knowledge, please advise me!!! :-)
  
 ---
 -
 w - 50
 pth - th16k[1:w]
 limit - length(th16k)-w
 for (i in 1:limit) {
   ws - i
   we - i+w-1
   temp - th16k[ws:we]
   fit - arima(temp, order=c(1, 0, 1))
   pred - predict(fit, n.ahead=1)
   pth[i+w] - pred$pred
 }
 plot(pth)
 ---
 -
  
 
   [[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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
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] Need help on ARIMA (time series analysis)

2005-10-16 Thread Gabor Grothendieck
Regarding the loop, the code below:

   ws - i
   we - i+w-1
   temp - th16k[ws:we]

can be written as:

  temp - th16k[seq(i, length = w)]

or you can get rid of the loop entirely using embed
or  using running in package gtools or rapply in the zoo package.


 park wrote:
  Hi,
 
  I am so novice in using R. I have some problems in my R script below
  which fits time series data and predict it one-step ahead.  Here is a
  brief explanation on what I try to achieve
 
  Th16k is time series data (500 data points). The size of window for
  fitting and predicting is 50 (data points). As you can easily discover
  from my code,  (fixed) window is moving/sliding to get next one-step
  ahead prediction. The predicted value will be saved in pth.
 
  The problem is,  every time I execute following script, I got error
  saying
 
 
 source(C:\\R\\arima.R)
 
  Error in arima(temp, order = c(1, 0, 1)) :
  non-stationary AR part from CSS
 
  I think there should be better way to achieve this goal without using
  for loop.  If you can share your knowledge, please advise me!!! :-)
 
  ---
  -
  w - 50
  pth - th16k[1:w]
  limit - length(th16k)-w
  for (i in 1:limit) {
ws - i
we - i+w-1
temp - th16k[ws:we]
fit - arima(temp, order=c(1, 0, 1))
pred - predict(fit, n.ahead=1)
pth[i+w] - pred$pred
  }
  plot(pth)
  ---
  -
 
 
[[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

 --
 Spencer Graves, PhD
 Senior Development Engineer
 PDF Solutions, Inc.
 333 West San Carlos Street Suite 700
 San Jose, CA 95110, USA

 [EMAIL PROTECTED]
 www.pdf.com http://www.pdf.com
 Tel:  408-938-4420
 Fax: 408-280-7915

 __
 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


[R] Need help write a function

2005-10-11 Thread Jan Sabee
Dear all,
I am still learning R with write a small function for my self.
I was wondering if someone can help me to write a R function formula below:
Z_k (x) = \sum_{i=0}^{i=k} \binom{n}{i} (m-1)^i
Thanks a million in advance,

Sincerely,
Jan Sabee

[[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


Re: [R] Need help write a function

2005-10-11 Thread Sundar Dorai-Raj


Jan Sabee wrote:
 Dear all,
 I am still learning R with write a small function for my self.
 I was wondering if someone can help me to write a R function formula below:
 Z_k (x) = \sum_{i=0}^{i=k} \binom{n}{i} (m-1)^i
 Thanks a million in advance,
 
 Sincerely,
 Jan Sabee
 

(This smells like a homework problem.)

What is m? Your Z_k is a function of x and there is no x on the RHS.

Are you trying to re-write pbinom?

--sundar

__
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] Need help on ARIMA (time series analysis)

2005-10-04 Thread park
Hi, 
 
I am so novice in using R. I have some problems in my R script below
which fits time series data and predict it one-step ahead.  Here is a
brief explanation on what I try to achieve
 
Th16k is time series data (500 data points). The size of window for
fitting and predicting is 50 (data points). As you can easily discover
from my code,  (fixed) window is moving/sliding to get next one-step
ahead prediction. The predicted value will be saved in pth.
 
The problem is,  every time I execute following script, I got error
saying 
 
 source(C:\\R\\arima.R)
Error in arima(temp, order = c(1, 0, 1)) : 
non-stationary AR part from CSS
 
I think there should be better way to achieve this goal without using
for loop.  If you can share your knowledge, please advise me!!! :-)
 
---
-
w - 50
pth - th16k[1:w]
limit - length(th16k)-w
for (i in 1:limit) {
  ws - i
  we - i+w-1
  temp - th16k[ws:we]
  fit - arima(temp, order=c(1, 0, 1))
  pred - predict(fit, n.ahead=1)
  pth[i+w] - pred$pred
}
plot(pth)
---
-
 

[[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] Need help understanding/resolving build error message

2005-09-01 Thread Zajd, John
Can someone provide help to resolve this build failure?
 
Thank you,
John Zajd 
 

C:\ConstellaGroup\EPA\RAGG\packagercmd check RAGG
* checking for working latex ... OK
* using log directory 'C:/ConstellaGroup/EPA/RAGG/package/RAGG.Rcheck'
* using R version 2.1.0, 2005-04-18
* checking for file 'RAGG/DESCRIPTION' ... OK
* this is package 'RAGG' version '1.5'
* checking if this is a source package ... OK
 
installing R.css in C:/ConstellaGroup/EPA/RAGG/package/RAGG.Rcheck
 

-- Making package RAGG 
  adding build stamp to DESCRIPTION
Error in if (regexpr(dep_regexp, dep) == -1) { :
missing value where TRUE/FALSE needed
Execution halted
make[2]: *** [frontmatter] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-RAGG] Error 2
*** Installation of RAGG failed ***
 
Removing 'C:/ConstellaGroup/EPA/RAGG/package/RAGG.Rcheck/RAGG'
 ERROR
Installation failed.

[[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


Re: [R] need help

2005-08-13 Thread Jim Lemon

Weiwei Shi wrote:

Hi, there:
I think i need to re-phrase my question since last time I did not get
any reply but i think the question is not that hard, probably i did
not make the question clear:

I want to find cases like
35, 90, 330, 330, 335

from the rest which look like
3, 3, 3, 3.2, 3.3
4, 4.4, 4.5, 4.6, 4.7


basically there is one (or more) big 'gap' in the case i seek. 


Hi Weiwei,

I think your method of defining a central value for the large proportion 
of values and then setting a criterion for outliers is valid (or at 
least as valid as many other ways of defining outliers). However, here 
is a different method, sorting the vector of values and then looking for 
a gap with a specified multiple (gap.prop) of the mean differences 
between the smaller values. It returns the first value after the gap 
(easily changed to all the values after). To account for vectors that 
have negative values the minimum value is subtracted when calculating 
newx and then added to the result. For your data, a gap.prop of 20 
works, but the default value of 10 doesn't. It also won't work where 
large values are typical and small ones are the outliers (well, it will 
indicate where the gap is).


Jim
find.first.gap-function(x,gap.prop=10) {
 lenx-length(x)
 newx-sort(x)-min(x)
 not.found-1
 gap.pos-2
 # set the 
 mean.diff-newx[2]-newx[1]
 while(not.found  gap.pos = lenx) {
  this.diff-newx[gap.pos]-newx[gap.pos-1]
  print(c(mean.diff,this.diff))
  if(mean.diff != 0) {
   if(this.diff/mean.diff = gap.prop) not.found-0
   else gap.pos-gap.pos+1
  }
  else gap.pos-gap.pos+1
  mean.diff-(this.diff+mean.diff*(gap.pos-1))/gap.pos
 }
 return(newx[gap.pos]+min(x))
}
__
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] need help

2005-08-12 Thread Weiwei Shi
Hi, there:
I think i need to re-phrase my question since last time I did not get
any reply but i think the question is not that hard, probably i did
not make the question clear:

I want to find cases like
35, 90, 330, 330, 335

from the rest which look like
3, 3, 3, 3.2, 3.3
4, 4.4, 4.5, 4.6, 4.7


basically there is one (or more) big 'gap' in the case i seek. 

thanks,

weiwei

-- 
Weiwei Shi, Ph.D

Did you always know?
No, I did not. But I believed...
---Matrix III

__
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] need help

2005-08-12 Thread Daniel Nordlund
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Weiwei Shi
 Sent: Friday, August 12, 2005 2:05 PM
 To: r-help
 Subject: [R] need help
 
 Hi, there:
 I think i need to re-phrase my question since last time I did not get
 any reply but i think the question is not that hard, probably i did
 not make the question clear:
 
 I want to find cases like
 35, 90, 330, 330, 335
 
 from the rest which look like
 3, 3, 3, 3.2, 3.3
 4, 4.4, 4.5, 4.6, 4.7
 
 
 basically there is one (or more) big 'gap' in the case i seek.
 
 thanks,
 
 weiwei
 
 --
 Weiwei Shi, Ph.D

Weiwei,

You will have to specify what you mean by a big gap before anyone can help.  
And I still don't understand what your data look like.  Is

35, 90, 330, 330, 335

supposed to represent a sequence or a row of a matrix (or data frame)?

Dan Nordlund
Bothell, WA

__
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] need help

2005-08-12 Thread Weiwei Shi
Hi, there:
here is some part from my previous email:

  [,1]  [,2]   [,3]   [,4]   [,5]
[1,] 34.216166 96.928587 330.125990 330.183222 330.201215
[2,]  2.819183  8.134491   8.275841   8.525256   8.828448
[3,]  2.819183  7.541680   7.550333   8.374636   8.690998
[4,]  4.672551  5.036353   5.072710   5.152218   5.223204
[5,]  5.470131  5.500513   5.674139   5.689151   5.770423
[6,]  4.480287  4.628300   4.797686   4.814106   4.823345

I want to filter out the first 3 cases from the rest and the criteria
is I am looking for a gap. 

My way is using std(eachrow)/median(each) and set up a threshold,
which is very naive, but fast and good enough. But I want it better
and more academic. Please be advised. I think clustering might help,
but it needs to be quick since t2 has 3 rows.

Thanks,


On 8/12/05, Daniel Nordlund [EMAIL PROTECTED] wrote:
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  On Behalf Of Weiwei Shi
  Sent: Friday, August 12, 2005 2:05 PM
  To: r-help
  Subject: [R] need help
 
  Hi, there:
  I think i need to re-phrase my question since last time I did not get
  any reply but i think the question is not that hard, probably i did
  not make the question clear:
 
  I want to find cases like
  35, 90, 330, 330, 335
 
  from the rest which look like
  3, 3, 3, 3.2, 3.3
  4, 4.4, 4.5, 4.6, 4.7
  
 
  basically there is one (or more) big 'gap' in the case i seek.
 
  thanks,
 
  weiwei
 
  --
  Weiwei Shi, Ph.D
 
 Weiwei,
 
 You will have to specify what you mean by a big gap before anyone can help.  
 And I still don't understand what your data look like.  Is
 
 35, 90, 330, 330, 335
 
 supposed to represent a sequence or a row of a matrix (or data frame)?
 
 Dan Nordlund
 Bothell, WA
 
 
 


-- 
Weiwei Shi, Ph.D

Did you always know?
No, I did not. But I believed...
---Matrix III

__
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] need help on building packages

2005-06-23 Thread Erik Lamontagne
Good day, I have been trying to build packages for R unix, and the check always 
failed around the LaTeX area, altho LaTex was installed. 

I dont know wich test dosent pass check because there are a few test made and 
only one error message for all those test done in 3rd step of the check.

Also could you refer me to a valid format of the package, because I am starting 
to believe the package format(directories+files) might have changed for version 
2.0.0. 

I use R 2.0.1, I am completing a package for R-windows XP, and porting it to R 
for Unix. I need help to complete those tasks cause I have tried all I could to 
debug the package building error I was getting.

Thank you

Éric Lamontagne
Université du Québec à Chicoutimi

__
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] need help on building packages

2005-06-23 Thread Duncan Murdoch
Erik Lamontagne wrote:
 Good day, I have been trying to build packages for R unix, and the check 
 always failed around the LaTeX area, altho LaTex was installed. 
 
 I dont know wich test dosent pass check because there are a few test made and 
 only one error message for all those test done in 3rd step of the check.

Usually there is useful information in the pkg.Rcheck directory that is 
left after the check.  In particular, you'll see the .log file that 
latex produced, and it might be able to help you.

 Also could you refer me to a valid format of the package, because I am 
 starting to believe the package format(directories+files) might have changed 
 for version 2.0.0. 

See the R extensions manual.

 I use R 2.0.1, I am completing a package for R-windows XP, and porting it to 
 R for Unix. I need help to complete those tasks cause I have tried all I 
 could to debug the package building error I was getting.

Does it pass Rcmd check in Windows?

Duncan Murdoch

__
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] need help on computing double summation

2005-06-16 Thread Liaw, Andy
If I understood correctly, the following might be simpler (dat is the data
frame holding the data):

 sum(ave(dat$x, dat$id, FUN=scale, scale=FALSE) * 
+ ave(dat$y, dat$id, FUN=scale, scale=FALSE))
[1] 6.229377

Andy


 From: Huntsinger, Reid
 
 You could do something like
 
 ids - unique(mydata$id)
 ans - vector(length=length(ids), mode=list)
 for (i in ids) {
   g - which(mydata$id == i)
   ans[[i]] - (length(g) - 1)*cov(mydata$x[g], mydata$y[g])
 }
 ans
 
 but cov() returns NA for length 1 vectors, so you'd want an 
 if (length(g) ==
 1) ans[i] - 0 else ans[i] - ... construction.
 
 This is almost brute force; you could also use tapply, as follows:
 
 sx - tapply(mydata$x,INDEX=mydata$id,FUN=sum)
 sy - tapply(mydata$y,INDEX=mydata$id,FUN=sum)
 sxy - tapply(mydata$x*mydata$y, INDEX=mydata$id, FUN=sum)
 n - tapply(mydata$id,INDEX=mydata$id,FUN=length) # or use table()!
 
 and now your inner sum is
 
 sxy - 2*sx*(sy/n) + n*(sx/n)*(sy/n) = sxy - sx*sy/n
 
 so 
 
 sum(sxy - sx*sy/n) should do.
 
 One more approach is to make your dataset into a list of data 
 frames, one
 for each id, then use lapply(). The list can be created by 
 split(). In one
 line,
 
 lapply(split(mydata,f=mydata$id),function(z) (length(z$x) - 
 1)*cov(z$x,z$y))
 
 and take sum(,na.rm=TRUE) to remove the NAs due to single ids 
 that you want
 to be zeros.
 
 Reid Huntsinger
 
 
 
 
 Reid Huntsinger
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Kerry Bush
 Sent: Wednesday, June 15, 2005 11:41 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] need help on computing double summation
 
 
 Dear helpers in this forum,
 
This is a clarified version of my previous
 questions  in this forum. I really need your generous
 help on this issue.
 
  Suppose I have the following data set:
  
  
  ..
  
 
 Now I want to compute the following double summation:
 
 sum_{i=1}^k
 sum_{j=1}^{n_i}(x_{ij}-mean(x_i))*(y_{ij}-mean(y_i))
 
 i is from 1 to k,
 indexing the ith subject id; and j is from 1 to n_i,
 indexing the jth observation for the ith subject.
 
 in the above expression, mean(x_i) is the mean of x
 values for the ith
 subject, mean(y_i) is the mean of y values for the ith
 subject. 
 
 Is there a simple way to do this in R?
 
 __
 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
 
 
 --
 
 Notice:  This e-mail message, together with any attachments, 
 contains information of Merck  Co., Inc. (One Merck Drive, 
 Whitehouse Station, New Jersey, USA 08889), and/or its 
 affiliates (which may be known outside the United States as 
 Merck Frosst, Merck Sharp  Dohme or MSD and in Japan, as 
 Banyu) that may be confidential, proprietary copyrighted 
 and/or legally privileged. It is intended solely for the use 
 of the individual or entity named on this message.  If you 
 are not the intended recipient, and have received this 
 message in error, please notify us immediately by reply 
 e-mail and then delete it from your system.
 --
 
 


__
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] need help on computing double summation

2005-06-15 Thread Kerry Bush
Dear helpers in this forum,

   This is a clarified version of my previous
questions  in this forum. I really need your generous
help on this issue.

 Suppose I have the following data set:
 
 id x y 
 023 1 2
 023 2 5
 023 4 6
 023 5 7
 412 2 5
 412 3 4
 412 4 6
 412 7 9
 220 5 7
 220 4 8
 220 9 8
 ..
 

Now I want to compute the following double summation:

sum_{i=1}^k
sum_{j=1}^{n_i}(x_{ij}-mean(x_i))*(y_{ij}-mean(y_i))

i is from 1 to k,
indexing the ith subject id; and j is from 1 to n_i,
indexing the jth observation for the ith subject.

in the above expression, mean(x_i) is the mean of x
values for the ith
subject, mean(y_i) is the mean of y values for the ith
subject. 

Is there a simple way to do this in R?

__
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] need help on computing double summation

2005-06-15 Thread Huntsinger, Reid
You could do something like

ids - unique(mydata$id)
ans - vector(length=length(ids), mode=list)
for (i in ids) {
  g - which(mydata$id == i)
  ans[[i]] - (length(g) - 1)*cov(mydata$x[g], mydata$y[g])
}
ans

but cov() returns NA for length 1 vectors, so you'd want an if (length(g) ==
1) ans[i] - 0 else ans[i] - ... construction.

This is almost brute force; you could also use tapply, as follows:

sx - tapply(mydata$x,INDEX=mydata$id,FUN=sum)
sy - tapply(mydata$y,INDEX=mydata$id,FUN=sum)
sxy - tapply(mydata$x*mydata$y, INDEX=mydata$id, FUN=sum)
n - tapply(mydata$id,INDEX=mydata$id,FUN=length) # or use table()!

and now your inner sum is

sxy - 2*sx*(sy/n) + n*(sx/n)*(sy/n) = sxy - sx*sy/n

so 

sum(sxy - sx*sy/n) should do.

One more approach is to make your dataset into a list of data frames, one
for each id, then use lapply(). The list can be created by split(). In one
line,

lapply(split(mydata,f=mydata$id),function(z) (length(z$x) - 1)*cov(z$x,z$y))

and take sum(,na.rm=TRUE) to remove the NAs due to single ids that you want
to be zeros.

Reid Huntsinger




Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kerry Bush
Sent: Wednesday, June 15, 2005 11:41 AM
To: r-help@stat.math.ethz.ch
Subject: [R] need help on computing double summation


Dear helpers in this forum,

   This is a clarified version of my previous
questions  in this forum. I really need your generous
help on this issue.

 Suppose I have the following data set:
 
 
 ..
 

Now I want to compute the following double summation:

sum_{i=1}^k
sum_{j=1}^{n_i}(x_{ij}-mean(x_i))*(y_{ij}-mean(y_i))

i is from 1 to k,
indexing the ith subject id; and j is from 1 to n_i,
indexing the jth observation for the ith subject.

in the above expression, mean(x_i) is the mean of x
values for the ith
subject, mean(y_i) is the mean of y values for the ith
subject. 

Is there a simple way to do this in R?

__
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


[R] Need Help - Urgent

2005-06-03 Thread Nivesh Pawar

Hello,
I am a student and some really urgent help.I am using R software and while
creating a grid with eight elements its showing the error and while if i
do it with seven it says that the memory is not sufficient...
here is the line ...with the error

 Z-as.matrix(expand.grid(x,y,x,y,t,s,t,s))

Error in rep.int(rep.int(seq(length = nx), rep.int(rep.fac, nx)), orep) :
cannot allocate vector of length 112896

Is it possible to somehow increase the default size of the matrix?
please help..

THanking you
nivesh pawar

__
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] Need Help - Urgent

2005-06-03 Thread Huntsinger, Reid
You're asking for a matrix with
length(x)^2*length(y)^2*length(s)^2*length(t)^2 rows. What are these
lengths? Is that what you're expecting? Perhaps you want the distinct factor
levels in x,y,s,t rather than x,y,s,t themselves?

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nivesh Pawar
Sent: Friday, June 03, 2005 8:00 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Need Help - Urgent



Hello,
I am a student and some really urgent help.I am using R software and while
creating a grid with eight elements its showing the error and while if i
do it with seven it says that the memory is not sufficient...
here is the line ...with the error

 Z-as.matrix(expand.grid(x,y,x,y,t,s,t,s))

Error in rep.int(rep.int(seq(length = nx), rep.int(rep.fac, nx)), orep) :
cannot allocate vector of length 112896

Is it possible to somehow increase the default size of the matrix?
please help..

THanking you
nivesh pawar

__
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


  1   2   >