Re: [R] documentation of wts object returned by nnet() function

2008-06-11 Thread Prof Brian Ripley

See the summary() method.  It labels the weights for you.

On Tue, 10 Jun 2008, wmg wrote:

In MASS there is a nnet() function which returns, among other things, a wts[] 
vector giving the weights in the neural network. However, in neither the book 
nor in the online documentation for the routine can I find documentation of 
which element of wts[] goes with which link in the network---input unit to 
hidden layer unit, hidden layer unit to output unit, skip layer links, etc. 
Anybody know the answer to that, presumably in form of an algorithm for 
pairing them up? Thanks in advance.


Regards,
Will Grove
U. of Minnesota Psychology Dept.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] computing and showing mean

2008-06-11 Thread Paul Adams
Hello to everyone,
I am trying to compute a mean and show it to the screen and then save to later 
be used
as a boxplot.I have used the following code:
dat-read.table(file=C:\\Documents and Settings\\Owner\\My 
Documents\\Yeast\\Yeast.txt,header=T,row.names=1)
file.show(file=C:\\Documents and Settings\\Owner\\My 
Documents\\Yeast\\Yeast.txt)
x-dat[2,23:46]
y=mean(x,trim=0,na.rm=T)
save(y,file=ydata)
Am I computing the mean correctly and how to I show the value of the mean to 
the screen?



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Polynomial Goal Programming

2008-06-11 Thread Shubha Vishwanath Karanth
Hello R,

 

Is there a package to perform Polynomial goal programming in R?

 

BR, Shubha

Shubha Karanth | Amba Research

Ph +91 80 3980 8031 | Mob +91 94 4886 4510 

Bangalore * Colombo * London * New York * San José * Singapore * 
www.ambaresearch.com

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] samr result

2008-06-11 Thread Eleni Christodoulou
Yes, here it is:
samr.obj-samr(data,resp.type=Two class unpaired, nperms=100,
center.arrays=T)

where *data *is a matrix of microarray gene expressions with genes as rows
and tissues as columns. With putting *center.arrays=T *the *data* matrix is
normalized such as each column has median=0. I would like to retrieve the
new normalized matrix, but it seems that it is not returned by *samr.* If
you have any idea on how I can find this transformed matrix I would be glad
to hear that!

Thanks again,
E.



On Tue, Jun 10, 2008 at 11:30 PM, Richardson, Patrick 
[EMAIL PROTECTED] wrote:

 Could you post your code so we can see what you are trying to do?

 Thanks,

 Patrick

 
 From: [EMAIL PROTECTED] [EMAIL PROTECTED] On
 Behalf Of Eleni Christodoulou [EMAIL PROTECTED]
 Sent: Tuesday, June 10, 2008 11:20 AM
 To: r-help@r-project.org
 Subject: [R] samr result

 Hello list!

 I have a proble trying to perform a SAM analysis using the function samr
 from the samr package. I have put the option *center.arrays=TRUE *in order
 to scale all the experiments to median=0. I would like to retrieved the
 scaled data but it seems that samr does not return it...Does anyone have
 any
 idea on this?

 Thanks a lot!!!
 E.

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 This email message, including any attachments, is for ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparing two groups of proportions

2008-06-11 Thread Yvonnick NOEL

Hi Ivan,

It was not clear from your original post that QA was a repeated factor.

But your problem may be reframed very much like you would do with a 
McNemar chi-square: Just count the number of times both procedure give 
the same result, of each kind, and different results, again of both 
kinds, to get four counts by condition. These events are probably 
independent within your setting.


You should then be able to test various binomial or Poisson models with 
the proper equality constraints.


HTH,

Yvonnick Noel, PhD
University of Brittany at Rennes
France

Re: [R] Comparing two groups of proportions
To: r-help@r-project.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=iso-8859-1

Hi Rolf,

On Monday 09 June 2008 11:16:57 pm Rolf Turner wrote:
  

 Your approach tacitly assumes --- as did the poster's question --- that
 the probability of passing an item by one method is *independent* of
 whether it is passed by the other method.  Which makes the methods
 effectively independent of the nature of the item being assessed!



So it seems I can't just block my primary factor (QA procedure) by nuisance 
one (production line) and run Cochran test to see if effects of primary 
factor are identical for both its levels.


  

 Not much actual quality being assured there!



In fact, I am not interested in quality of QA procedures as much as in how 
different the results are (error component).


Thanks,
Ivan




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: newbie nls question

2008-06-11 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 11.06.2008 00:56:19:

 I'm tyring to fit a relatively simple nls model to some data, but keep 
coming 
 up against the same error (code follows):
 
 Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), 
 data = ages, 
 start = list(Linf=1000, k=0.1, to=0.1), 
 trace = TRUE) 
 
 The error message I keep getting is Error in eval(expr, envir, enclos) 
: 
 could not find function k.  I've used this line of code for other nls 

 models (with different data, parameter estimates, etc.), but have never 
gotten
 this error.  The data is 

Does

 Oto=nls(Otolith ~ Linf*(1-exp(-k*(AGE-to))), 
 data = ages, 
 start = list(Linf=1000, k=0.1, to=0.1), 
 trace = TRUE) 

help?

Regards
Petr

 
 AGE,Otolith,Scale
 1,207.1052632,207.1052632
 2,329.962963,332.7586207
 3,401.9473684,406
 4,422,413.111
 5,452.6785714,458.34375
 6,510.75,533
 7,477,674
 8,643,704
 9,,615
 10,695.5,
 12,615,
 
 Are the missing values (e.g., no value for Otolith, AGE 9) having an 
effect? 
 I am using Tinn-R as an editor 
 
 I'm new to R, trying to get away from Rcmdr (though it has been 
helpful), and 
 still trying to learn the language with the aid of several books on the 
R.  A 
 search of the R Archive did not prove fruitful.
 
 Thanks in advance, 
 
 SR
 
 Steven H. Ranney
 Graduate Research Assistant (Ph.D)
 USGS Montana Cooperative Fishery Research Unit
 Montana State University
 PO Box 173460
 Bozeman, MT 59717-3460
 
 phone: (406) 994-6643
 fax:   (406) 994-7479
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Matrix transformation problem

2008-06-11 Thread stefan . petersson

ng,

I have a matrix (x) with binary content. Each row of the matrix holds exactly 
one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' 
the matrix to one column where each row holds the original column index of the 
1's (y). Sometimes, the matrix is quite large, so I have a perfomance problem.

x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),ncol=3,byrow=T)
x
 [,1] [,2] [,3]
[1,]100
[2,]001
[3,]010
[4,]001
[5,]010
[6,]100

In the matrix above, on the first row, the 1 is in column 1, hence '1' on the 
first row in the matrix below. On the second row in the matrix above, the 1 is 
in column 3, hence the '3' on the second row in the matrix below. And so on... 

y
 [,1]
[1,]1
[2,]3
[3,]2
[4,]3
[5,]2
[6,]1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bayesian Analysis using the BUGS Language

2008-06-11 Thread Uwe Ligges



DrakeGis wrote:

WinBugs doesn't run in LINUX. Neither OpenBugs.


Ah, sorry, haven't read carefully enough.
The only possible thing is to run WinBUGS under wine and use R2WinBUGS, 
which supports the wine/WinBUGS combination.


Best wishes,
Uwe Ligges


DrakeGis wrote:

Hi all,
 I observed that the 'link' between R and BUGS (winBugs/linBugs) has
totally disappeared. I'm wondering what package can be use to run
bayesian models specified using the BUGS language in R (specifically
under Linux). Is there any other option besides JAGS ?
 Thanks


Ther are several package, if you want to use WinBUGS (not recommended),
there is the CRAN package R2WinBUGS, and if you want to use OpenBUGS
(the new version of WinBUGS), use BRugs, which is available from the
CRAN extras repository hosted by Brian Ripley (which is a default
repository for R for Windows, hence install.packages(BRugs) should
work).

Best wishes,
Uwe Ligges






-
Stay ahead of the information curve.
Receive EDA news and jobs on your desktop daily.
Subscribe today to the EDA CafeNews newsletter.
[ http://www10.EDACafe.com/nl/newsletter_subscribe.php ]
It's informative and essential.
This message was sent to you from a machine at 141.211.153.44

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




-
Stay ahead of the information curve.
Receive EDA news and jobs on your desktop daily.
Subscribe today to the EDA CafeNews newsletter.
[ http://www10.EDACafe.com/nl/newsletter_subscribe.php ]
It's informative and essential.
This message was sent to you from a machine at 141.211.153.44


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] difference between nlm and nlminb

2008-06-11 Thread DavidM.UK

I believe nlminb() performs *constrained* optimization, where as nlm() is for
*unconstrained* opimization

So I guess nlm() is for solving min(f[a,b]), and nlminb() min(f[a,b]) given
a+b = c 

FYI I think optim() also does constrained optimization, well I've used for
min(f[a,b]) given a = a* and b = b*.

David
 

ae2356 wrote:
 
 
 Hi, 
  
 I was wondering if someone could give a brief, big picture overview of the
 difference between the two optimization functions nlm and nlminb. I'm not
 familiar with PORT routines, so I was hoping someone could give an
 explanation. 
  
 Thanks,
 Angelo
 _
 Instantly invite friends from Facebook and other social networks to join
 yo
 https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/difference-between-nlm-and-nlminb-tp17769859p17772440.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix transformation problem

2008-06-11 Thread Dimitris Rizopoulos

try this:

x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),
   ncol = 3, byrow = TRUE)
which(x == 1, arr.ind = TRUE)[, col, drop = FALSE]


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
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: [EMAIL PROTECTED]

To: r-help@r-project.org
Sent: Wednesday, June 11, 2008 10:10 AM
Subject: [R] Matrix transformation problem




ng,

I have a matrix (x) with binary content. Each row of the matrix 
holds exactly one 1, and the rest of the row is zeros. The thing is 
that I need to 'collapse' the matrix to one column where each row 
holds the original column index of the 1's (y). Sometimes, the 
matrix is quite large, so I have a perfomance problem.


x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 
1,0,0),ncol=3,byrow=T)

x
[,1] [,2] [,3]
[1,]100
[2,]001
[3,]010
[4,]001
[5,]010
[6,]100

In the matrix above, on the first row, the 1 is in column 1, hence 
'1' on the first row in the matrix below. On the second row in the 
matrix above, the 1 is in column 3, hence the '3' on the second row 
in the matrix below. And so on...


y
[,1]
[1,]1
[2,]3
[3,]2
[4,]3
[5,]2
[6,]1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix transformation problem

2008-06-11 Thread Dimitris Rizopoulos

sorry, my previous answer was not correct; you need:

x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),
   ncol = 3, byrow = TRUE)
which(t(x == 1), arr.ind = TRUE)[, row, drop = FALSE]


Best,
Dimitris


Dimitris Rizopoulos
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: [EMAIL PROTECTED]

To: r-help@r-project.org
Sent: Wednesday, June 11, 2008 10:10 AM
Subject: [R] Matrix transformation problem




ng,

I have a matrix (x) with binary content. Each row of the matrix 
holds exactly one 1, and the rest of the row is zeros. The thing is 
that I need to 'collapse' the matrix to one column where each row 
holds the original column index of the 1's (y). Sometimes, the 
matrix is quite large, so I have a perfomance problem.


x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 
1,0,0),ncol=3,byrow=T)

x
[,1] [,2] [,3]
[1,]100
[2,]001
[3,]010
[4,]001
[5,]010
[6,]100

In the matrix above, on the first row, the 1 is in column 1, hence 
'1' on the first row in the matrix below. On the second row in the 
matrix above, the 1 is in column 3, hence the '3' on the second row 
in the matrix below. And so on...


y
[,1]
[1,]1
[2,]3
[3,]2
[4,]3
[5,]2
[6,]1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix transformation problem

2008-06-11 Thread Eik Vettorazzi

you may try a matrix multiplication, which has a very high performance in R

x%*%1:ncol(x)

hth.


[EMAIL PROTECTED] schrieb:

ng,

I have a matrix (x) with binary content. Each row of the matrix holds exactly 
one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' 
the matrix to one column where each row holds the original column index of the 
1's (y). Sometimes, the matrix is quite large, so I have a perfomance problem.

x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),ncol=3,byrow=T)
x
 [,1] [,2] [,3]
[1,]100
[2,]001
[3,]010
[4,]001
[5,]010
[6,]100

In the matrix above, on the first row, the 1 is in column 1, hence '1' on the first row in the matrix below. On the second row in the matrix above, the 1 is in column 3, hence the '3' on the second row in the matrix below. And so on... 


y
 [,1]
[1,]1
[2,]3
[3,]2
[4,]3
[5,]2
[6,]1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
  


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bayesian Analysis using the BUGS Language

2008-06-11 Thread Prof Brian Ripley

On Wed, 11 Jun 2008, Uwe Ligges wrote:




DrakeGis wrote:

WinBugs doesn't run in LINUX. Neither OpenBugs.


Ah, sorry, haven't read carefully enough.
The only possible thing is to run WinBUGS under wine and use R2WinBUGS, which 
supports the wine/WinBUGS combination.


'Linux' is too vague.  AFAIK none of this runs on Linux on Sparc or PPC 
for example.


Tobias Verbeke referred to a thread which is AFAICS about building an ix86 
Linux bugs executable from the distributed brugs.so in OpenBUGS.  If you 
can get that to run (and like Uwe, I get a trap), you can then communicate 
with that bugs executable via files (in the same way that R2WinBUGS 
communicates with WinBUGS).


It is not clear to me that the Windows classicbugs.exe or winbugs.exe in 
OpenBUGS could not be run under Wine with communication via files, but 
R2WinBUGS is not set up to do so.




Best wishes,
Uwe Ligges


DrakeGis wrote:

Hi all,
 I observed that the 'link' between R and BUGS (winBugs/linBugs) has
totally disappeared. I'm wondering what package can be use to run
bayesian models specified using the BUGS language in R (specifically
under Linux). Is there any other option besides JAGS ?
 Thanks


Ther are several package, if you want to use WinBUGS (not recommended),
there is the CRAN package R2WinBUGS, and if you want to use OpenBUGS
(the new version of WinBUGS), use BRugs, which is available from the
CRAN extras repository hosted by Brian Ripley (which is a default
repository for R for Windows, hence install.packages(BRugs) should
work).

Best wishes,
Uwe Ligges






-
Stay ahead of the information curve.
Receive EDA news and jobs on your desktop daily.
Subscribe today to the EDA CafeNews newsletter.
[ http://www10.EDACafe.com/nl/newsletter_subscribe.php ]
It's informative and essential.
This message was sent to you from a machine at 141.211.153.44

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




-
Stay ahead of the information curve.
Receive EDA news and jobs on your desktop daily.
Subscribe today to the EDA CafeNews newsletter.
[ http://www10.EDACafe.com/nl/newsletter_subscribe.php ]
It's informative and essential.
This message was sent to you from a machine at 141.211.153.44


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: computing and showing mean

2008-06-11 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 11.06.2008 08:41:27:

 Hello to everyone,
 I am trying to compute a mean and show it to the screen and then save to 
later be used
 as a boxplot.I have used the following code:
 dat-read.table(file=C:\\Documents and Settings\\Owner\\My 
Documents\\Yeast\

here you get data frame

 \Yeast.txt,header=T,row.names=1)
 file.show(file=C:\\Documents and Settings\\Owner\\My 
Documents\\Yeast\\Yeast.txt)
 x-dat[2,23:46]

x is data frame consisting from row 2 and columns 23:46 of data frame dat

 y=mean(x,trim=0,na.rm=T)

y is named vector numerically the same as x (you compute mean of one 
value)

if you want to see how your objects look like just print them on your 
console by simply typing

x or y.

If you want to see internal structure do

str(x) or str(y)

 save(y,file=ydata)
 Am I computing the mean correctly and how to I show the value of the 
mean to the screen?

Maybe its time to have a small glimpse into some basic documentation like 
R-intro.

I may guess you want mean of columns 25:46. If this is true, then

colMeans(dat[, 23:46])

prints means for defined columns.
And
boxplot(dat[, 23:46])

gives you boxplots for each column.

But enough of speculation what do you really want.

Regards
Petr



 
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fwd: Hello

2008-06-11 Thread sumit gupta
Hii

The contour plot is somewhat similar to what I want.
I am attaching the data here.

What I want to do is divide all the three variable( Recency, frequency,and
monetory ) in 5 intervals based on their values.That will make
25 rectangle(5(recency)X 5(frequency) boxes on heat plot. and then plot a
heat map with recency on X axis and frquency on Y axis, and also I want to
show the no. of elements in each box( total 25) by heat colours i.e
increasing no. of elements with the darker colour box.
And one more plot with the same variable on XY as mentioned above but this
time box colour depicting the average monetary value of that box.

Hope this clears the problem I am facing.
Thank you.

Regards,
Sumit




On 6/11/08, Petr PIKAL [EMAIL PROTECTED] wrote:

 sumit gupta [EMAIL PROTECTED] napsal dne 11.06.2008 07:53:54:

  Hello
  thanx for the info..
 
  I still have tthe doubt regarding the heat map.
  I am attching a plot of a 70X3 data matrix.In which 3rd variable has
 been
  shown as  colour of different boxes.Could you help me to draw this type
 of graph using R

 Well, as you did not provided some data

 mat-cbind(sample(1:5, 70, replace=T), sample(1:5, 70, replace=T),
 rnorm(70))
 dim(mat)
 [1] 70  3
 library(akima)
 filled.contour(interp(mat[,1], mat[,2], mat[,3], duplicate=mean))
 image(interp(mat[,1], mat[,2], mat[,3], duplicate=mean))


 is this what you want?

 Regards
 Petr

 
  Regards,
  Sumit
 
 
  On 6/10/08, Petr PIKAL [EMAIL PROTECTED] wrote:
  Hi
 
  [EMAIL PROTECTED] napsal dne 10.06.2008 14:49:55:
 
   Hello,
  
   I am facing a problem in drawing heat map using R.
  
   I have a 70X3 matrix and I want to draw a heat map with 1 coloumn on X
  axis
   another on Y axis and want to show the value of 3rd coloumn using heat
   colours.
   Could you please help me with this .
 
  You can use function interp from akima package
 
  Petr
 
   Thank you .
  
   Regards,
   Sumit
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.

 
 
 
  --
  Sumit Kumar Gupta
  4thYear ,Biotechnology
  IIT Madras [příloha rfm.bmp odstraněna uživatelem Petr PIKAL/CTCAP]




-- 
Sumit Kumar Gupta
4thYear ,Biotechnology
IIT Madras



-- 
Sumit Kumar Gupta
4thYear ,Biotechnology
IIT Madras
Recency Frequency   Monetary
562 2   4795.5
570 2   1200
578 3   1719
585 2   728
575 3   2326.
583 1   1822
612 2   9508.9637
578 2   2127.5
581 4   2781.5
562 5   1504.4
563 3   1447
575 1   3163
577 2   995
564 6   1198.
569 2   1740.5
562 6   1294.5
566 8   881.25
587 1   1913
578 2   1553.5
585 13  2472.0769
567 1   3049
560 1   964
568 2   1452
569 2   3370
575 6   1386.
585 3   1643
560 3   4554.2631
559 2   1536.7438
559 1   1319.6811
559 5   3169.5263
560 3   875.5572
561 2   5093.6068
559 8   2394.0242
561 1   4076.4088
559 1   1625.0949
562 5   1775.1878
560 1   1500.597
562 14  1876.4794
563 3   1582.5177
564 3   4268.6134
564 2   3799.6765
567 4   4590.8274
563 1   2140
564 2   1475
569 1   6970
568 1   1500
567 7   2070.2857
568 3   1681.
568 3   697.5219
571 1   2000
571 5   1438
570 4   1393
570 4   2355.25
571 1   756.3875
576 1   1720.8184
571 5   1613
574 3   1903.
577 6   1828.2312
571 2   2087.5
581 3   3456.
582 13  2135.3076
582 1   3876
581 1   2424
576 1   3061
583 1   1534
583 3   2810
577 13  1042.7692
576 4   756.3875
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Hello

2008-06-11 Thread Petr PIKAL
sumit gupta [EMAIL PROTECTED] napsal dne 11.06.2008 07:53:54:

 Hello 
 thanx for the info..
 
 I still have tthe doubt regarding the heat map.
 I am attching a plot of a 70X3 data matrix.In which 3rd variable has 
been 
 shown as  colour of different boxes.Could you help me to draw this type 
of graph using R

Well, as you did not provided some data

 mat-cbind(sample(1:5, 70, replace=T), sample(1:5, 70, replace=T), 
rnorm(70))
dim(mat)
[1] 70  3
library(akima)
filled.contour(interp(mat[,1], mat[,2], mat[,3], duplicate=mean))
image(interp(mat[,1], mat[,2], mat[,3], duplicate=mean))


is this what you want?

Regards
Petr

 
 Regards,
 Sumit
 
 
 On 6/10/08, Petr PIKAL [EMAIL PROTECTED] wrote: 
 Hi
 
 [EMAIL PROTECTED] napsal dne 10.06.2008 14:49:55:
 
  Hello,
 
  I am facing a problem in drawing heat map using R.
 
  I have a 70X3 matrix and I want to draw a heat map with 1 coloumn on X
 axis
  another on Y axis and want to show the value of 3rd coloumn using heat
  colours.
  Could you please help me with this .
 
 You can use function interp from akima package
 
 Petr
 
  Thank you .
 
  Regards,
  Sumit
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 
 
 
 -- 
 Sumit Kumar Gupta
 4thYear ,Biotechnology
 IIT Madras [příloha rfm.bmp odstraněna uživatelem Petr PIKAL/CTCAP] 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix transformation problem

2008-06-11 Thread Ted Harding
For precisely this particular type of question, the
following seems to be the simplest, most direct,
and most transparent solution:

  rowSums(x%*%(1:ncol(x)))
# [1] 1 3 2 3 2 1

Ted.

On 11-Jun-08 09:21:35, Dimitris Rizopoulos wrote:
 sorry, my previous answer was not correct; you need:
 
 x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),
 ncol = 3, byrow = TRUE)
 which(t(x == 1), arr.ind = TRUE)[, row, drop = FALSE]
 
 
 Best,
 Dimitris
 
 
 Dimitris Rizopoulos
 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: [EMAIL PROTECTED]
 To: r-help@r-project.org
 Sent: Wednesday, June 11, 2008 10:10 AM
 Subject: [R] Matrix transformation problem
 
 

 ng,

 I have a matrix (x) with binary content. Each row of the matrix 
 holds exactly one 1, and the rest of the row is zeros. The thing is 
 that I need to 'collapse' the matrix to one column where each row 
 holds the original column index of the 1's (y). Sometimes, the 
 matrix is quite large, so I have a perfomance problem.

 x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 
 1,0,0),ncol=3,byrow=T)
 x
 [,1] [,2] [,3]
 [1,]100
 [2,]001
 [3,]010
 [4,]001
 [5,]010
 [6,]100

 In the matrix above, on the first row, the 1 is in column 1, hence 
 '1' on the first row in the matrix below. On the second row in the 
 matrix above, the 1 is in column 3, hence the '3' on the second row 
 in the matrix below. And so on...

 y
 [,1]
 [1,]1
 [2,]3
 [3,]2
 [4,]3
 [5,]2
 [6,]1

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 11-Jun-08   Time: 10:49:13
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Finding Coordinate of Max/Min Value in a Data Frame

2008-06-11 Thread Gundala Viswanath
Hi,

Suppose I have the following data frame.

__BEGIN__

 library(MASS)
 data(crabs)
 crab.pca - prcomp(crabs[,4:8],retx=TRUE)
 crab.pca$rotation
 PC1PC2PC3PC4PC5
FL 0.2889810  0.3232500 -0.5071698  0.7342907  0.1248816
RW 0.1972824  0.8647159  0.4141356 -0.1483092 -0.1408623
CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656
CW 0.6616550 -0.2879790  0.4913755  0.1256282  0.4712202
BD 0.2837317  0.1598447 -0.5468821 -0.6343657  0.4386868

__END__

Is there a way to identify the coordinate of a max/min value of all the
points above.

For example the coord of maximum value is (RW,PC2) = 0.865,
and coord of min value is (CW,PC2) = - 0.288.

-- 
Gundala Viswanath

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] MCA in R

2008-06-11 Thread John Fox
Dear Kimmo,

MCA is a rather old name (introduced, I think, in the 1960s by Songuist and 
Morgan in the OSIRIS package) for a linear model consisting entirely of factors 
and with only additive effects -- i.e., an ANOVA model will no interactions. 
You can fit such a model with lm() -- e.g., lm(y ~ f1 + f2 + etc.). Typically, 
the results of an MCA are reported using adjusted means. You could compute 
these manually, or via the effects package.

I hope this helps,
 John

--
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
 Behalf Of K. Elo
 Sent: June-11-08 1:07 AM
 To: r-help@r-project.org
 Subject: [R] MCA in R
 
 Hi!
 
 Is there any possibilities to do multiple classification analysis (MCA)
 in R? (MCA examines the relationships between several categorical
 independent variables and a single dependent variable, and determines
 the effects of each predictor before and after adjus­tment for its
 inter-correlations with other predictors in the analysis).
 
 Kind regrads,
 Kimmo Elo
 
 ---
 University of Turku, Finland
 Dep. of political science
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] piper diagram

2008-06-11 Thread Jim Lemon

Jim Lemon wrote:

Dylan Beaudette wrote:


Hi,

Is anyone on the list familiar with an R implementation of Piper 
Diagrams?


Example:
http://faculty.uml.edu/nelson_eby/89.315/IMAGES/Figure%209-78.jpg

I am thinking that two calls to triax.plot (plotrix) along with some 
kind of affine-transformed standard plot would do the trick. Not so 
sure about the final layout, or a nice generalized version for 
something like lattice.


Okay, I've had a look at the Piper diagram and with better labeled ones 
and some explanations, I think I've got the picture. No, triax.plot 
won't do the job, but it's a similar sort of illustration. Give me a few 
days to think about it and I may be able to put one together.


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Peter Dalgaard
ChCh wrote:
 Hello,

 I have consciously avoided using step() for model simplification in favour
 of manually updating the model by removing non-significant terms one at a
 time.  I'm using The R Book by M.J. Crawley as a guide. It comes as no
 surprise that my analysis does proceed as smoothly as does Crawley's and
 being a beginner, I'm struggling with what to do next.  

 I have a model:

 lm(y~A * B * C)

 where A is a categorical variable with three levels and B and C are
 continuous covariates.

 Following Crawley, I execute the model, then use summary.aov() to identify
 non-significant terms.  I begin deleting non-significant interaction terms
 one at a time (using update).  After each update() statement, I use
 anova(modelOld,modelNew) to contrast the previous model with the updated
 one.  After removing all the interaction terms, I'm left with:

 lm(y~ A + B + C)

 again, using summary.aov() I identify A to be non-significant, so I remove
 it, leaving:

 lm(y~B + C) both of which are continuous variables

 Does it still make sense to use summary.aov() or should I use summary.lm()
 instead?  Has the analysis switched from an ANCOVA to a regression?  Both
 give different results so I'm uncertain which summary to accept.

 Any help would be appreciated!


   
Does he really recommend using summary.aov() on an lm object??? I
wouldn't. It _might_ give sensible results, but in general, aov() and
its methods rely on balancedness and orthogonality properties of the
design, to the extent that I'm inclined to say that if you do not know
exactly what is going on, it is probably the wrong thing.

I'd use drop1 throughout.

-- 
   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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Frank E Harrell Jr

ChCh wrote:

Hello,

I have consciously avoided using step() for model simplification in favour
of manually updating the model by removing non-significant terms one at a
time.  I'm using The R Book by M.J. Crawley as a guide. It comes as no
surprise that my analysis does proceed as smoothly as does Crawley's and
being a beginner, I'm struggling with what to do next.  


I have a model:

lm(y~A * B * C)

where A is a categorical variable with three levels and B and C are
continuous covariates.

Following Crawley, I execute the model, then use summary.aov() to identify
non-significant terms.  I begin deleting non-significant interaction terms
one at a time (using update).  After each update() statement, I use
anova(modelOld,modelNew) to contrast the previous model with the updated
one.  After removing all the interaction terms, I'm left with:

lm(y~ A + B + C)

again, using summary.aov() I identify A to be non-significant, so I remove
it, leaving:

lm(y~B + C) both of which are continuous variables

Does it still make sense to use summary.aov() or should I use summary.lm()
instead?  Has the analysis switched from an ANCOVA to a regression?  Both
give different results so I'm uncertain which summary to accept.

Any help would be appreciated!




What is the theoretical basis for removing insignificant terms?  How 
will you compensate for this in the final analysis (e.g., how do you 
unbias your estimate of sigma squared)?


--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Finding Coordinate of Max/Min Value in a Data Frame

2008-06-11 Thread Henrique Dallazuanna
Try this:

which(pca == min(pca), arr.ind = TRUE)
which(pca == max(pca), arr.ind = TRUE)

On Wed, Jun 11, 2008 at 7:34 AM, Gundala Viswanath [EMAIL PROTECTED]
wrote:

 Hi,

 Suppose I have the following data frame.

 __BEGIN__

  library(MASS)
  data(crabs)
  crab.pca - prcomp(crabs[,4:8],retx=TRUE)
  crab.pca$rotation
 PC1PC2PC3PC4PC5
 FL 0.2889810  0.3232500 -0.5071698  0.7342907  0.1248816
 RW 0.1972824  0.8647159  0.4141356 -0.1483092 -0.1408623
 CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656
 CW 0.6616550 -0.2879790  0.4913755  0.1256282  0.4712202
 BD 0.2837317  0.1598447 -0.5468821 -0.6343657  0.4386868

 __END__

 Is there a way to identify the coordinate of a max/min value of all the
 points above.

 For example the coord of maximum value is (RW,PC2) = 0.865,
 and coord of min value is (CW,PC2) = - 0.288.

 --
 Gundala Viswanath

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] searching for specific row in matrix

2008-06-11 Thread Esmail Bonakdarian

Hi,

I have matrix of bits and a target vector. Is there an
efficient way to search the rows of the matrix for the target?
I am interested in the first row index where target is found.

Example:

 source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
 [1,]10110
 [2,]11010
 [3,]00100
 [4,]10011
 [5,]10111
 [6,]11001
 [7,]10011
 [8,]00111
 [9,]01101
[10,]00010

target:  1 1 0 1 1

Should return -1 (or some other indicator) since the
target was not found in any of the rows.



 source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
 [1,]00110
 [2,]10000
 [3,]10000
 [4,]11000
 [5,]11100
 [6,]00110
 [7,]01110
 [8,]00110
 [9,]11011
[10,]10100

target:  1 1 0 1 1

Should return 9 since the target was  found in row 9


If the target is found, it is no longer necessary to keep
searching the rest of the matrix (which may be quite large)

The data/size etc may change of course, but target will
always have the same number of columns as the matrix.

I tried variations of which, and a for loop
comparing pop[i,] to target without much success, nor
did google yield any results. I am hoping someone here
can provide a suggestion.

Thanks,

EB


-

# Here is the code that generates the above data

create_bin_string - function(len)
{
  sample(0:1, len, replace=T)
}

ROWS = 10
COLS =  5
pop = matrix(create_bin_string(ROWS*COLS), ROWS, COLS, byrow=T)



target=c(1, 1, 0, 1, 1)

# my population
print(pop)

# I am looking for the index of this in pop
# if present (else -1?)
cat(\ntarget: , target, \n)



##
## this is NOT working
## plus it would continue to search
## after it found the target
##
for(i in ROWS)
   if (pop[i,] == target)
  cat(\nfound in row: , i, \n\n)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Finding Coordinate of Max/Min Value in a Data Frame

2008-06-11 Thread Gabor Grothendieck
This suggests that one nice to have item would be to support
arr.ind= on which.min and which.max

On Wed, Jun 11, 2008 at 7:57 AM, Henrique Dallazuanna [EMAIL PROTECTED] wrote:
 Try this:

 which(pca == min(pca), arr.ind = TRUE)
 which(pca == max(pca), arr.ind = TRUE)

 On Wed, Jun 11, 2008 at 7:34 AM, Gundala Viswanath [EMAIL PROTECTED]
 wrote:

 Hi,

 Suppose I have the following data frame.

 __BEGIN__

  library(MASS)
  data(crabs)
  crab.pca - prcomp(crabs[,4:8],retx=TRUE)
  crab.pca$rotation
 PC1PC2PC3PC4PC5
 FL 0.2889810  0.3232500 -0.5071698  0.7342907  0.1248816
 RW 0.1972824  0.8647159  0.4141356 -0.1483092 -0.1408623
 CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656
 CW 0.6616550 -0.2879790  0.4913755  0.1256282  0.4712202
 BD 0.2837317  0.1598447 -0.5468821 -0.6343657  0.4386868

 __END__

 Is there a way to identify the coordinate of a max/min value of all the
 points above.

 For example the coord of maximum value is (RW,PC2) = 0.865,
 and coord of min value is (CW,PC2) = - 0.288.

 --
 Gundala Viswanath

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

[[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R idiom list? [was: Matrix transformation problem

2008-06-11 Thread Dietrich Trenkler

Dimitris Rizopoulos schrieb:

sorry, my previous answer was not correct; you need:

x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),
   ncol = 3, byrow = TRUE)
which(t(x == 1), arr.ind = TRUE)[, row, drop = FALSE]


Dear helpeRs,

I would like to use this thread for a proposal which lingered in my head
for quite a while.  Several years ago I was an APL aficionado and I very
much liked the idea of an APL idiom list (see e.g
http://www.pyr.fi/apl/texts/Idiot.htm).

Looking at the solution of Dimitris Rizopoulos wouldn't it be nice not to
have it disappear in the archives?  To be explicit I would like to
propose an R idiom list.  If there does exist one please forgive my 
ignorance.


Best regards

Dietrich


--
Dietrich Trenkler c/o Universitaet Osnabrueck 
Rolandstr. 8; D-49069 Osnabrueck, Germany
email: [EMAIL PROTECTED]


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Finding Coordinate of Max/Min Value in a Data Frame

2008-06-11 Thread DavidM.UK

Firstly surely (CL,PC5) = -0.7416656 is the minima?

I think something like this should work, though I'm not sure

library(MASS) 
data(crabs) 
crab.pca - prcomp(crabs[,4:8],retx=TRUE) 
x- crab.pca$rotation 
c.len = length(x[,1])
r.len = length(x[1,])
maxy = which(x == min(x))
x.co - ceiling(maxy/c.len)
y.co - maxy-(x.co-1)*c.len

Though I'm sure their is a more simple solution to your problem,

Best,

David
U Bristol


Edward Wijaya-2 wrote:
 
 Hi,
 
 Suppose I have the following data frame.
 
 __BEGIN__
 
 library(MASS)
 data(crabs)
 crab.pca - prcomp(crabs[,4:8],retx=TRUE)
 crab.pca$rotation
  PC1PC2PC3PC4PC5
 FL 0.2889810  0.3232500 -0.5071698  0.7342907  0.1248816
 RW 0.1972824  0.8647159  0.4141356 -0.1483092 -0.1408623
 CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656
 CW 0.6616550 -0.2879790  0.4913755  0.1256282  0.4712202
 BD 0.2837317  0.1598447 -0.5468821 -0.6343657  0.4386868
 
 __END__
 
 Is there a way to identify the coordinate of a max/min value of all the
 points above.
 
 For example the coord of maximum value is (RW,PC2) = 0.865,
 and coord of min value is (CW,PC2) = - 0.288.
 
 -- 
 Gundala Viswanath
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Finding-Coordinate-of-Max-Min-Value-in-a-Data-Frame-tp17775656p17776020.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Finding Coordinate of Max/Min Value in a Data Frame

2008-06-11 Thread Gundala Viswanath
Thanks so much both.

- Gundala

On 6/11/08, Henrique Dallazuanna [EMAIL PROTECTED] wrote:
 Try this:

 which(pca == min(pca), arr.ind = TRUE)
 which(pca == max(pca), arr.ind = TRUE)


 On Wed, Jun 11, 2008 at 7:34 AM, Gundala Viswanath [EMAIL PROTECTED]
 wrote:
 
  Hi,
 
  Suppose I have the following data frame.
 
  __BEGIN__
 
   library(MASS)
   data(crabs)
   crab.pca - prcomp(crabs[,4:8],retx=TRUE)
   crab.pca$rotation
  PC1PC2PC3PC4PC5
  FL 0.2889810  0.3232500 -0.5071698  0.7342907  0.1248816
  RW 0.1972824  0.8647159  0.4141356 -0.1483092 -0.1408623
  CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656
  CW 0.6616550 -0.2879790  0.4913755  0.1256282  0.4712202
  BD 0.2837317  0.1598447 -0.5468821 -0.6343657  0.4386868
 
  __END__
 
  Is there a way to identify the coordinate of a max/min value of all the
  points above.
 
  For example the coord of maximum value is (RW,PC2) = 0.865,
  and coord of min value is (CW,PC2) = - 0.288.
 
  --
  Gundala Viswanath
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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


-- 
Gundala Viswanath

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R idiom list? [was: Matrix transformation problem

2008-06-11 Thread Gabor Grothendieck
Google for Rtips.

Also Rwiki

On Wed, Jun 11, 2008 at 6:35 AM, Dietrich Trenkler
[EMAIL PROTECTED] wrote:
 Dimitris Rizopoulos schrieb:

 sorry, my previous answer was not correct; you need:

 x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),
   ncol = 3, byrow = TRUE)
 which(t(x == 1), arr.ind = TRUE)[, row, drop = FALSE]

 Dear helpeRs,

 I would like to use this thread for a proposal which lingered in my head
 for quite a while.  Several years ago I was an APL aficionado and I very
 much liked the idea of an APL idiom list (see e.g
 http://www.pyr.fi/apl/texts/Idiot.htm).

 Looking at the solution of Dimitris Rizopoulos wouldn't it be nice not to
 have it disappear in the archives?  To be explicit I would like to
 propose an R idiom list.  If there does exist one please forgive my
 ignorance.

 Best regards

 Dietrich


 --
 Dietrich Trenkler c/o Universitaet Osnabrueck Rolandstr. 8; D-49069
 Osnabrueck, Germanyemail: [EMAIL PROTECTED]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] searching for specific row in matrix

2008-06-11 Thread jim holtman
This should work for you:

 create_bin_string - function(len)
+ {
+  sample(0:1, len, replace=T)
+ }

 ROWS = 10
 COLS =  5
 set.seed(2)
 pop = matrix(create_bin_string(ROWS*COLS), ROWS, COLS, byrow=T)



 target=c(1, 1, 0, 1, 1)

 # my population
 print(pop)
  [,1] [,2] [,3] [,4] [,5]
 [1,]01101
 [2,]10101
 [3,]10100
 [4,]11000
 [5,]10100
 [6,]00010
 [7,]00111
 [8,]11010
 [9,]10001
[10,]11011

 # determine which data matches
 matches - t(pop) == target  # 't' due to matching in column order

 # colSums equal to COLS will indicate matches
 which(colSums(matches) == COLS)
[1] 10


On Wed, Jun 11, 2008 at 7:58 AM, Esmail Bonakdarian [EMAIL PROTECTED] wrote:
 Hi,

 I have matrix of bits and a target vector. Is there an
 efficient way to search the rows of the matrix for the target?
 I am interested in the first row index where target is found.

 Example:

 source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
  [1,]10110
  [2,]11010
  [3,]00100
  [4,]10011
  [5,]10111
  [6,]11001
  [7,]10011
  [8,]00111
  [9,]01101
 [10,]00010

 target:  1 1 0 1 1

 Should return -1 (or some other indicator) since the
 target was not found in any of the rows.



 source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
  [1,]00110
  [2,]10000
  [3,]10000
  [4,]11000
  [5,]11100
  [6,]00110
  [7,]01110
  [8,]00110
  [9,]11011
 [10,]10100

 target:  1 1 0 1 1

 Should return 9 since the target was  found in row 9


 If the target is found, it is no longer necessary to keep
 searching the rest of the matrix (which may be quite large)

 The data/size etc may change of course, but target will
 always have the same number of columns as the matrix.

 I tried variations of which, and a for loop
 comparing pop[i,] to target without much success, nor
 did google yield any results. I am hoping someone here
 can provide a suggestion.

 Thanks,

 EB


 -

 # Here is the code that generates the above data

 create_bin_string - function(len)
 {
  sample(0:1, len, replace=T)
 }

 ROWS = 10
 COLS =  5
 pop = matrix(create_bin_string(ROWS*COLS), ROWS, COLS, byrow=T)



 target=c(1, 1, 0, 1, 1)

 # my population
 print(pop)

 # I am looking for the index of this in pop
 # if present (else -1?)
 cat(\ntarget: , target, \n)



 ##
 ## this is NOT working
 ## plus it would continue to search
 ## after it found the target
 ##
 for(i in ROWS)
   if (pop[i,] == target)
  cat(\nfound in row: , i, \n\n)

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] searching for specific row in matrix

2008-06-11 Thread Dimitris Rizopoulos

try this:

match.pat - function (mat, target, nomatch = -1) {
   f1 - do.call(paste, c(as.data.frame(mat), sep = \r))
   f2 - paste(target, collapse = \r)
   ind - f1 %in% f2
   if (any(ind)) which(ind)[1] else nomatch
}
##
set.seed(1234)
mat - matrix(sample(0:1, 50, TRUE), 10, 5)

targ1 - mat[2, ]
match.pat(mat, targ1)

targ2 - rep(0, 5)
match.pat(mat, targ2)


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
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: Esmail Bonakdarian [EMAIL PROTECTED]

To: r-help@r-project.org
Sent: Wednesday, June 11, 2008 1:58 PM
Subject: [R] searching for specific row in matrix



Hi,

I have matrix of bits and a target vector. Is there an
efficient way to search the rows of the matrix for the target?
I am interested in the first row index where target is found.

Example:

 source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
 [1,]10110
 [2,]11010
 [3,]00100
 [4,]10011
 [5,]10111
 [6,]11001
 [7,]10011
 [8,]00111
 [9,]01101
[10,]00010

target:  1 1 0 1 1

Should return -1 (or some other indicator) since the
target was not found in any of the rows.



 source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
 [1,]00110
 [2,]10000
 [3,]10000
 [4,]11000
 [5,]11100
 [6,]00110
 [7,]01110
 [8,]00110
 [9,]11011
[10,]10100

target:  1 1 0 1 1

Should return 9 since the target was  found in row 9


If the target is found, it is no longer necessary to keep
searching the rest of the matrix (which may be quite large)

The data/size etc may change of course, but target will
always have the same number of columns as the matrix.

I tried variations of which, and a for loop
comparing pop[i,] to target without much success, nor
did google yield any results. I am hoping someone here
can provide a suggestion.

Thanks,

EB


-

# Here is the code that generates the above data

create_bin_string - function(len)
{
  sample(0:1, len, replace=T)
}

ROWS = 10
COLS =  5
pop = matrix(create_bin_string(ROWS*COLS), ROWS, COLS, byrow=T)



target=c(1, 1, 0, 1, 1)

# my population
print(pop)

# I am looking for the index of this in pop
# if present (else -1?)
cat(\ntarget: , target, \n)



##
## this is NOT working
## plus it would continue to search
## after it found the target
##
for(i in ROWS)
   if (pop[i,] == target)
  cat(\nfound in row: , i, \n\n)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Default Argument Passing in Script

2008-06-11 Thread Gundala Viswanath
Hi all,

Currently I run R script with arguments the following ways

$ R --vanilla  myscript.R  ARGUMENT1

And in my script it is encoded as:

__BEGIN__
args-commandArgs()
do_sth(args[3])


My question is that is there a way to set a default
argument inside the R script?

In Perl analogically would be:

my $param = $ARGV[0] || default_argument;

I am wondering how can this be done in R.

-- 
Gundala Viswanath
Jakarta - Indonesia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] searching for specific row in matrix

2008-06-11 Thread Henrique Dallazuanna
Try this:

which(apply(t(m) == target, 2, all))

On Wed, Jun 11, 2008 at 8:58 AM, Esmail Bonakdarian [EMAIL PROTECTED]
wrote:

 Hi,

 I have matrix of bits and a target vector. Is there an
 efficient way to search the rows of the matrix for the target?
 I am interested in the first row index where target is found.

 Example:

  source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
  [1,]10110
  [2,]11010
  [3,]00100
  [4,]10011
  [5,]10111
  [6,]11001
  [7,]10011
  [8,]00111
  [9,]01101
 [10,]00010

 target:  1 1 0 1 1

 Should return -1 (or some other indicator) since the
 target was not found in any of the rows.



  source(lookup.R)
  [,1] [,2] [,3] [,4] [,5]
  [1,]00110
  [2,]10000
  [3,]10000
  [4,]11000
  [5,]11100
  [6,]00110
  [7,]01110
  [8,]00110
  [9,]11011
 [10,]10100

 target:  1 1 0 1 1

 Should return 9 since the target was  found in row 9


 If the target is found, it is no longer necessary to keep
 searching the rest of the matrix (which may be quite large)

 The data/size etc may change of course, but target will
 always have the same number of columns as the matrix.

 I tried variations of which, and a for loop
 comparing pop[i,] to target without much success, nor
 did google yield any results. I am hoping someone here
 can provide a suggestion.

 Thanks,

 EB


 -

 # Here is the code that generates the above data

 create_bin_string - function(len)
 {
  sample(0:1, len, replace=T)
 }

 ROWS = 10
 COLS =  5
 pop = matrix(create_bin_string(ROWS*COLS), ROWS, COLS, byrow=T)



 target=c(1, 1, 0, 1, 1)

 # my population
 print(pop)

 # I am looking for the index of this in pop
 # if present (else -1?)
 cat(\ntarget: , target, \n)



 ##
 ## this is NOT working
 ## plus it would continue to search
 ## after it found the target
 ##
 for(i in ROWS)
   if (pop[i,] == target)
  cat(\nfound in row: , i, \n\n)

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] searching for specific row in matrix

2008-06-11 Thread Esmail Bonakdarian

Henrique Dallazuanna wrote:

Try this:

which(apply(t(m) == target, 2, all))


Wow! .. talk about concise! Neat! Thanks.

This will return all matches correct? So if I only wanted
the first I'd simply subscript [1] into it.

Do you think the fact that it searches the whole matrix instead
of stopping when it finds a match may slow it down?

This is my own solution I came up with in the meantime,
looks rather pedestrian compared to your one line, but it will
drop out immediately once if finds the target. Yours looks (based
simply on appearance :-) faster. Having no feel for the language
I may just have to time them.


I would assume that your solution would be faster simple since it's
using built-in language constructs which are optimized (and implemented
in C?) instead of my own interpreted way.


# return index of target in pop, else -1
searchPop - function(pop, target)
{
rows = length(pop[1,])
for(i in 1:rows)
{
result = (pop[i,] == target)
if (sum(which(result==FALSE)) == 0)
return(i)
}

return (-1)
}


idx=searchPop(pop, target)

if (idx  0)
{
cat(NOT found\n)
} else
cat(Found at position , idx, \n)



Esmail

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] searching for specific row in matrix

2008-06-11 Thread Esmail Bonakdarian

Dimitris Rizopoulos wrote:

try this:

match.pat - function (mat, target, nomatch = -1) {
   f1 - do.call(paste, c(as.data.frame(mat), sep = \r))
   f2 - paste(target, collapse = \r)
   ind - f1 %in% f2
   if (any(ind)) which(ind)[1] else nomatch
}


Thanks! More R for me to sink my teeth in :-)  My own solution
doesn't seem to work quite correctly as I found out from some
further testing .. so the solutions posted here are much appreciated!

Esmail

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] searching for specific row in matrix

2008-06-11 Thread Esmail Bonakdarian



# determine which data matches
matches - t(pop) == target  # 't' due to matching in column order

# colSums equal to COLS will indicate matches
which(colSums(matches) == COLS)




Neat! .. somewhat similar to the solution I came up with in the
meantime, only yours works :-)

Thanks Jim.

Esmail

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problem with densityplot from the lattice package

2008-06-11 Thread Malte Brockmann

Dear list,

I just experienced some strange behavior of the densityplots provided by the 
lattice package. Depending on the values for from and to that are passed on 
to the function for kernel density estimates, the densityplot excludes the 
jittered stripplot that is routinely included in lattice densityplot.


Example:

library(lattice)
test-runif(100)
densityplot(test) #the standard density plot without problems
densityplot(test, from=0, to=1) #stripplot is excluded 
densityplot(test, from=-1, to=2) #stripplot is again included

Any hints how I could get the stripplot back in the second example?

Tanks in advance
Malte



 sessionInfo()
R version 2.7.0 (2008-04-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

other attached packages:
[1] lattice_0.17-8

loaded via a namespace (and not attached):
[1] grid_2.7.0




sent via xelos.net | the communication and groupware solution

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread hadley wickham
On Wed, Jun 11, 2008 at 6:42 AM, Frank E Harrell Jr
[EMAIL PROTECTED] wrote:
 ChCh wrote:

 Hello,

 I have consciously avoided using step() for model simplification in favour
 of manually updating the model by removing non-significant terms one at a
 time.  I'm using The R Book by M.J. Crawley as a guide. It comes as no
 surprise that my analysis does proceed as smoothly as does Crawley's and
 being a beginner, I'm struggling with what to do next.
 I have a model:

 lm(y~A * B * C)

 where A is a categorical variable with three levels and B and C are
 continuous covariates.

 Following Crawley, I execute the model, then use summary.aov() to identify
 non-significant terms.  I begin deleting non-significant interaction terms
 one at a time (using update).  After each update() statement, I use
 anova(modelOld,modelNew) to contrast the previous model with the updated
 one.  After removing all the interaction terms, I'm left with:

 lm(y~ A + B + C)

 again, using summary.aov() I identify A to be non-significant, so I remove
 it, leaving:

 lm(y~B + C) both of which are continuous variables

 Does it still make sense to use summary.aov() or should I use summary.lm()
 instead?  Has the analysis switched from an ANCOVA to a regression?  Both
 give different results so I'm uncertain which summary to accept.

 Any help would be appreciated!



 What is the theoretical basis for removing insignificant terms?  How will
 you compensate for this in the final analysis (e.g., how do you unbias your
 estimate of sigma squared)?

And in a similar vein, where are your exploratory graphics?  How do
you know that there is a linear relationship between your response and
your predictors?  Are the distributional assumptions you are making
appropriate?

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Goodness of fit tests for copula

2008-06-11 Thread Frankg

How can i calculate the discrete L2 distance between the empirical copula and
the estimated one.
-- 
View this message in context: 
http://www.nabble.com/Goodness-of-fit-tests-for-copula-tp17779318p17779318.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix transformation problem

2008-06-11 Thread Berend Hasselman



stefan.petersson wrote:
 
 
 ng,
 
 I have a matrix (x) with binary content. Each row of the matrix holds
 exactly one 1, and the rest of the row is zeros. The thing is that I need
 to 'collapse' the matrix to one column where each row holds the original
 column index of the 1's (y). Sometimes, the matrix is quite large, so I
 have a perfomance problem.
 
 x - matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0, 1,0,0),ncol=3,byrow=T)
 x
  [,1] [,2] [,3]
 [1,]100
 [2,]001
 [3,]010
 [4,]001
 [5,]010
 [6,]100
 
 In the matrix above, on the first row, the 1 is in column 1, hence '1' on
 the first row in the matrix below. On the second row in the matrix above,
 the 1 is in column 3, hence the '3' on the second row in the matrix below.
 And so on... 
 
 y
  [,1]
 [1,]1
 [2,]3
 [3,]2
 [4,]3
 [5,]2
 [6,]1
 
 

max.col(x)


-- 
View this message in context: 
http://www.nabble.com/Matrix-transformation-problem-tp17773270p17779431.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with densityplot from the lattice package

2008-06-11 Thread Prof Brian Ripley

Look at the y axis ... so try something like

densityplot(test, from=0, to=1, ylim=c(-0.1, 1.5))

The jittered plot is plotted centred on y=0.

On Wed, 11 Jun 2008, Malte Brockmann wrote:



Dear list,

I just experienced some strange behavior of the densityplots provided by the lattice package. 
Depending on the values for from and to that are passed on to the function 
for kernel density estimates, the densityplot excludes the jittered stripplot that is routinely 
included in lattice densityplot.


Example:

library(lattice)
test-runif(100)
densityplot(test) #the standard density plot without problems
densityplot(test, from=0, to=1) #stripplot is excluded
densityplot(test, from=-1, to=2) #stripplot is again included

Any hints how I could get the stripplot back in the second example?

Tanks in advance
Malte




sessionInfo()

R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] lattice_0.17-8

loaded via a namespace (and not attached):
[1] grid_2.7.0




sent via xelos.net | the communication and groupware solution

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Some problem with the OLS

2008-06-11 Thread roberto laforgia
Dear all!!

 I estimated the following OLS model with R 2.5.6:

Output R 2.5.6

Call:

lm(formula = UN ~ log(x) + time2, data = dati)



Residuals:

   Min 1Q Median 3QMax

-5.649 -2.753 -1.015  1.225 16.199



Coefficients:

  Estimate Std. Error t value Pr(|t|)

(Intercept)  7.3036294  0.6871025  10.630   2e-16 ***

log(x)  -0.0028542  0.0270730  -0.1050.916

time2   -0.0002670  0.0003823  -0.6980.487

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



Residual standard error: 4.323 on 87 degrees of freedom

Multiple R-Squared: 0.02933,Adjusted R-squared: 0.007017

F-statistic: 1.314 on 2 and 87 DF,  p-value: 0.2739

is significant only the intercept

After I estimated the same model with R 2.7 and this is the new output:

Output R 2.7

regressione14-lm(UN ~ log(x)+ time2,data=dati)

 summary(regressione14)



Call:

lm(formula = UN ~ log(x) + time2, data = dati)



Residuals:

   Min 1Q Median 3QMax

-8.825 -2.094 -0.861  2.233 12.664



Coefficients:

 Estimate Std. Error t value Pr(|t|)

(Intercept) 22.724208   3.304670   6.876 8.89e-10 ***

log(x)  -7.117981   1.499482  -4.747 8.05e-06 ***

time20.002051   0.000523   3.922 0.000175 ***

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



Residual standard error: 3.853 on 87 degrees of freedom

Multiple R-Squared: 0.2289, Adjusted R-squared: 0.2112

F-statistic: 12.91 on 2 and 87 DF,  p-value: 1.227e-05


Well, how you can see the two outputs are very differents, so i try to
estimated the same model with another package and i show the

output:





*Variabile*

*Coefficiente*

*Errore Std.*

*Statistica t*

*p-value*



const

22,7242

3,30467

6,8764

0,1

***

logx

-7,11798

1,49948

-4,7470

0,1

***

time2

0,00205144

0,000523012

3,9224

0,00017

***



Media della variabile dipendente = 6,47833

Scarto quadratico medio della variabile dipendente = 4,33827

Somma dei quadrati dei residui = 1291,58

Errore standard dei residui = 3,85302

R2 = 0,228922

R2 corretto = 0,211196

Statistica F (2, 87) = 12,9145 (p-value = 1,23e-005)

Log-verosimiglianza = -247,576

Criterio di informazione di Akaike = 501,152

Criterio bayesiano di Schwarz = 508,652

Criterio di Hannan-Quinn = 504,176

  How you can see this package show the same output of the R 2.7

 My question is where is the bug?



 Kind regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newbie nls question

2008-06-11 Thread Ranney, Steven
Worked liked a charm.  Thanks for your help.  

SR

Steven H. Ranney
Graduate Research Assistant (Ph.D)
USGS Montana Cooperative Fishery Research Unit
Montana State University
PO Box 173460
Bozeman, MT 59717-3460

phone: (406) 994-6643
fax:   (406) 994-7479



-Original Message-
From: Michael Manning [mailto:[EMAIL PROTECTED]
Sent: Tue 6/10/2008 5:08 PM
To: Ranney, Steven; r-help@r-project.org
Subject: Re: [R] newbie nls question
 
Hi

On 11/06/2008 at 10:56 a.m., Ranney, Steven [EMAIL PROTECTED]
wrote:
 I'm tyring to fit a relatively simple nls model to some data, but keep coming 
 up against the same error (code follows):
 
 Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), 
 data = ages, 
 start = list(Linf=1000, k=0.1, to=0.1), 
 trace = TRUE) 
 
 The error message I keep getting is Error in eval(expr, envir, enclos) : 
 could not find function k.  I've used this line of code for other nls 
 models (with different data, parameter estimates, etc.), but have never 
 gotten this error.  The data is 
 
 AGE,Otolith,Scale
 1,207.1052632,207.1052632
 2,329.962963,332.7586207
 3,401.9473684,406
 4,422,413.111
 5,452.6785714,458.34375
 6,510.75,533
 7,477,674
 8,643,704
 9,,615
 10,695.5,
 12,615,
 
 Are the missing values (e.g., no value for Otolith, AGE 9) having an effect? 
  I am using Tinn-R as an editor  
 
 I'm new to R, trying to get away from Rcmdr (though it has been helpful), 
 and still trying to learn the language with the aid of several books on the 
 R.  A search of the R Archive did not prove fruitful.
 
 Thanks in advance, 
 
 SR
 
 Steven H. Ranney

You've made a typo.

Check out the formula you passed to nls -- you forget to include a * after k.

What I think you want is something like

Oto - nls(Otolith ~ Linf * (1 - exp(-k * (AGE - t0) ) ), ...)


Cheers,

Michael





[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Lucke, Joseph F
And to follow FH and HW

What level of significance are you using? .05 is excessively liberal.
Are you adjusting your p-values for the number of possible models? Do
you realize the p-values for dropping a term, being selected as the
maximum of a set of p-values, do not follow their usual distributions?
How are you compensating for sample size, as a p-value's being
significant is a function of sample size?  How are you compensating for
the fact that the current model choice is dependent on the previous
model choices? How do you know your tree of model choices is the optimal
one?  Have you considered cross-validation?  Are you looking for a model
that true describes a phenomenon or a predictive model that can be used
for practical purposes?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of hadley wickham
Sent: Wednesday, June 11, 2008 9:34 AM
To: Frank E Harrell Jr
Cc: r-help@r-project.org; ChCh
Subject: Re: [R] model simplification using Crawley as a guide

On Wed, Jun 11, 2008 at 6:42 AM, Frank E Harrell Jr
[EMAIL PROTECTED] wrote:
 ChCh wrote:

 Hello,

 I have consciously avoided using step() for model simplification in 
 favour of manually updating the model by removing non-significant 
 terms one at a time.  I'm using The R Book by M.J. Crawley as a 
 guide. It comes as no surprise that my analysis does proceed as 
 smoothly as does Crawley's and being a beginner, I'm struggling with
what to do next.
 I have a model:

 lm(y~A * B * C)

 where A is a categorical variable with three levels and B and C are 
 continuous covariates.

 Following Crawley, I execute the model, then use summary.aov() to 
 identify non-significant terms.  I begin deleting non-significant 
 interaction terms one at a time (using update).  After each update() 
 statement, I use
 anova(modelOld,modelNew) to contrast the previous model with the 
 updated one.  After removing all the interaction terms, I'm left
with:

 lm(y~ A + B + C)

 again, using summary.aov() I identify A to be non-significant, so I 
 remove it, leaving:

 lm(y~B + C) both of which are continuous variables

 Does it still make sense to use summary.aov() or should I use 
 summary.lm() instead?  Has the analysis switched from an ANCOVA to a 
 regression?  Both give different results so I'm uncertain which
summary to accept.

 Any help would be appreciated!



 What is the theoretical basis for removing insignificant terms?  How 
 will you compensate for this in the final analysis (e.g., how do you 
 unbias your estimate of sigma squared)?

And in a similar vein, where are your exploratory graphics?  How do you
know that there is a linear relationship between your response and your
predictors?  Are the distributional assumptions you are making
appropriate?

Hadley

--
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Word wrapping for character objects (WINDOWS R ONLY)

2008-06-11 Thread Toby Marthews
Can anybody help me with this problem? ** ONLY WINDOWS R - PROBLEM DOESN'T
OCCUR ON LINUX **

I want to print a long character to screen:

 getOption(width)
[1] 60
 z=(1:20)/10#z is a vector of length between 20 and 30 (depending on
user options) containing lengths in mm (i.e. each element is 1-5
characters long)
 str1=paste(The depths chosen are (,toString(z),) mm, and more text
...\n)
 cat(str1)
The depths chosen are ( 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1,
1.1, 1.2, 1.3, 1.$


The problem is that on R for Windows the string is cropped by the window
size (hence the $). On R for Linux, this doesn't happen and the text is
word wrapped (the default for the shell, I guess):

 cat(str1)
The depths chosen are ( 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1,
1.1, 1.2, 1.3,
1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2 ) mm, and more text ...


I can't find any option for word wrapping in the cat command (fill=TRUE
has no effect). I also checked the menu Edit - GUI preferences..., but
there doesn't seem to be a Word Wrap option there either.

How do I get word wrapping like this in Windows? Perhaps the attached
screenshots clarify this question.

THANKS FOR ANY HELP!
Toby Marthews


Previous relevant posts:

- The post from 2006 about Screen Wrapping
(http://tolstoy.newcastle.edu.au/R/help/06/05/26673.html) which Brian
Ripley answered was about controlling how long vectors are cropped to the
screen. Unfortunately, the width option in options() does not affect
character objects, so I can't use that control here.

- I sent the same question to [EMAIL PROTECTED] in Oct 2007, but
noone there could help me with it.

- Try the following command on Windows R with a small window
(getOption(width)117) and a large window (getOption(width)117) and
you'll see you get extra nonexistent options in the menu:

a=c(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);menu(a)
I guess this is a related problem?__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] applying a function recursively

2008-06-11 Thread Georg Otto

Hi,

I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:


 test.list-list(I=list(A=c(a, b, c), B=c(d, e, f), 
 C=c(g, h, i)),
+ II=list(A=list(a=c(a, b, c), b=c(d, e, f),
+ c=c(g, h, i)),
+   B=c(d, e, f), C=c(g, h, i)))

 test.list
$I
$I$A
[1] a b c

$I$B
[1] d e f

$I$C
[1] g h i


$II
$II$A
$II$A$a
[1] a b c

$II$A$b
[1] d e f

$II$A$c
[1] g h i


$II$B
[1] d e f

$II$C
[1] g h i



I would like to apply a function recursively to that list, in a way
that the function does someting with each vector (eg. rev()) and
returns a list of modified vectors that has the same structure as the
input list, in my example:


$I
$I$A
[1] c b a

$I$B
[1] f e d

$I$C
[1] i h g


$II
$II$A
$II$A$a
[1] c b a

$II$A$b
[1] f e d

$II$A$c
[1] i h g


$II$B
[1] f e d

$II$C
[1] i h g



I understand that with a fixed number of recursion levels one can use
lapply() in a nested way, but what if the numbers of recursion levels
is not fixed or is different between the list elements as it is in my
example?

Any hint will be appreciated.

Best,

Georg

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Some problem with the OLS

2008-06-11 Thread Charles C. Berry

On Wed, 11 Jun 2008, roberto laforgia wrote:


Dear all!!

I estimated the following OLS model with R 2.5.6:

Output R 2.5.6


You need to read and follow the posting guide AND provide a minimal, 
reproducible example.


What is R 2.5.6 ??

What do sessionInfo() or version report?

Where can I get a copy? ;-)

(Hint: Correct answer is NOT on CRAN. There is not such version.)



Call:

lm(formula = UN ~ log(x) + time2, data = dati)



Residuals:

  Min 1Q Median 3QMax

-5.649 -2.753 -1.015  1.225 16.199



Coefficients:

 Estimate Std. Error t value Pr(|t|)

(Intercept)  7.3036294  0.6871025  10.630   2e-16 ***

log(x)  -0.0028542  0.0270730  -0.1050.916

time2   -0.0002670  0.0003823  -0.6980.487

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



Residual standard error: 4.323 on 87 degrees of freedom

Multiple R-Squared: 0.02933,Adjusted R-squared: 0.007017

F-statistic: 1.314 on 2 and 87 DF,  p-value: 0.2739

is significant only the intercept

After I estimated the same model with R 2.7 and this is the new output:

Output R 2.7

regressione14-lm(UN ~ log(x)+ time2,data=dati)


summary(regressione14)




Call:

lm(formula = UN ~ log(x) + time2, data = dati)



Residuals:

  Min 1Q Median 3QMax

-8.825 -2.094 -0.861  2.233 12.664



Coefficients:

Estimate Std. Error t value Pr(|t|)

(Intercept) 22.724208   3.304670   6.876 8.89e-10 ***

log(x)  -7.117981   1.499482  -4.747 8.05e-06 ***

time20.002051   0.000523   3.922 0.000175 ***

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



Residual standard error: 3.853 on 87 degrees of freedom

Multiple R-Squared: 0.2289, Adjusted R-squared: 0.2112

F-statistic: 12.91 on 2 and 87 DF,  p-value: 1.227e-05


Well, how you can see the two outputs are very differents, so i try to
estimated the same model with another package and i show the

output:





*Variabile*

*Coefficiente*

*Errore Std.*

*Statistica t*

*p-value*



const

22,7242

3,30467

6,8764

0,1

***

logx

-7,11798

1,49948

-4,7470

0,1

***

time2

0,00205144

0,000523012

3,9224

0,00017

***



   Media della variabile dipendente = 6,47833

   Scarto quadratico medio della variabile dipendente = 4,33827

   Somma dei quadrati dei residui = 1291,58

   Errore standard dei residui = 3,85302

   R2 = 0,228922

   R2 corretto = 0,211196

   Statistica F (2, 87) = 12,9145 (p-value = 1,23e-005)

   Log-verosimiglianza = -247,576

   Criterio di informazione di Akaike = 501,152

   Criterio bayesiano di Schwarz = 508,652

   Criterio di Hannan-Quinn = 504,176

 How you can see this package show the same output of the R 2.7

My question is where is the bug?



Kind regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Word wrapping for character objects (WINDOWS R ONLY)

2008-06-11 Thread Greg Snow
You could try passing your character string to the strwrap function first, then 
use cat on the result.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Toby Marthews
 Sent: Wednesday, June 11, 2008 6:52 AM
 To: r-help@r-project.org
 Subject: [R] Word wrapping for character objects (WINDOWS R ONLY)

 Can anybody help me with this problem? ** ONLY WINDOWS R -
 PROBLEM DOESN'T OCCUR ON LINUX **

 I want to print a long character to screen:

  getOption(width)
 [1] 60
  z=(1:20)/10#z is a vector of length between 20 and 30
 (depending on
 user options) containing lengths in mm (i.e. each element is
 1-5 characters long)
  str1=paste(The depths chosen are (,toString(z),) mm, and
 more text
 ...\n)
  cat(str1)
 The depths chosen are ( 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,
 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.$
 

 The problem is that on R for Windows the string is cropped by
 the window size (hence the $). On R for Linux, this doesn't
 happen and the text is word wrapped (the default for the
 shell, I guess):

  cat(str1)
 The depths chosen are ( 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,
 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2 )
 mm, and more text ...
 

 I can't find any option for word wrapping in the cat
 command (fill=TRUE has no effect). I also checked the menu
 Edit - GUI preferences..., but there doesn't seem to be a
 Word Wrap option there either.

 How do I get word wrapping like this in Windows? Perhaps the
 attached screenshots clarify this question.

 THANKS FOR ANY HELP!
 Toby Marthews


 Previous relevant posts:

 - The post from 2006 about Screen Wrapping
 (http://tolstoy.newcastle.edu.au/R/help/06/05/26673.html)
 which Brian Ripley answered was about controlling how long
 vectors are cropped to the screen. Unfortunately, the width
 option in options() does not affect character objects, so I
 can't use that control here.

 - I sent the same question to [EMAIL PROTECTED] in
 Oct 2007, but noone there could help me with it.

 - Try the following command on Windows R with a small window
 (getOption(width)117) and a large window
 (getOption(width)117) and you'll see you get extra
 nonexistent options in the menu:

 a=c(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct
 ,Nov,Dec);menu(a)
 I guess this is a related problem?


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] applying a function recursively

2008-06-11 Thread Prof Brian Ripley

See ?rapply

On Wed, 11 Jun 2008, Georg Otto wrote:



Hi,

I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:



test.list-list(I=list(A=c(a, b, c), B=c(d, e, f), C=c(g, h, 
i)),

+ II=list(A=list(a=c(a, b, c), b=c(d, e, f),
+ c=c(g, h, i)),
+   B=c(d, e, f), C=c(g, h, i)))


test.list

$I
$I$A
[1] a b c

$I$B
[1] d e f

$I$C
[1] g h i


$II
$II$A
$II$A$a
[1] a b c

$II$A$b
[1] d e f

$II$A$c
[1] g h i


$II$B
[1] d e f

$II$C
[1] g h i



I would like to apply a function recursively to that list, in a way
that the function does someting with each vector (eg. rev()) and
returns a list of modified vectors that has the same structure as the
input list, in my example:


$I
$I$A
[1] c b a

$I$B
[1] f e d

$I$C
[1] i h g


$II
$II$A
$II$A$a
[1] c b a

$II$A$b
[1] f e d

$II$A$c
[1] i h g


$II$B
[1] f e d

$II$C
[1] i h g



I understand that with a fixed number of recursion levels one can use
lapply() in a nested way, but what if the numbers of recursion levels
is not fixed or is different between the list elements as it is in my
example?

Any hint will be appreciated.

Best,

Georg

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Increase Number of Decimals

2008-06-11 Thread Neil Gupta
R Users,

I'm new to R and was wondering how I can show more decimal places when I run
commands. If I'm simply running a correlation(ES,YM) how would I increase
the number of decimal places R shows? When I run this it shows me .9734044.
How can I extend this further?

In addition I was running histograms on high frequency data to check a
Spread. The spread moves at an extremely granular level. It may move .01
frequently but again at a low level. How  can I increase the graularity of
the histogram plots to detect smaller moves?

I appreciate any and all help.

Neil

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] applying a function recursively

2008-06-11 Thread Charles C. Berry


See

?rapply

for your example

rapply( test.list, rev, how='replace' )

HTH,

Chuck

On Wed, 11 Jun 2008, Georg Otto wrote:



Hi,

I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:



test.list-list(I=list(A=c(a, b, c), B=c(d, e, f), C=c(g, h, 
i)),

+ II=list(A=list(a=c(a, b, c), b=c(d, e, f),
+ c=c(g, h, i)),
+   B=c(d, e, f), C=c(g, h, i)))


test.list

$I
$I$A
[1] a b c

$I$B
[1] d e f

$I$C
[1] g h i


$II
$II$A
$II$A$a
[1] a b c

$II$A$b
[1] d e f

$II$A$c
[1] g h i


$II$B
[1] d e f

$II$C
[1] g h i



I would like to apply a function recursively to that list, in a way
that the function does someting with each vector (eg. rev()) and
returns a list of modified vectors that has the same structure as the
input list, in my example:


$I
$I$A
[1] c b a

$I$B
[1] f e d

$I$C
[1] i h g


$II
$II$A
$II$A$a
[1] c b a

$II$A$b
[1] f e d

$II$A$c
[1] i h g


$II$B
[1] f e d

$II$C
[1] i h g



I understand that with a fixed number of recursion levels one can use
lapply() in a nested way, but what if the numbers of recursion levels
is not fixed or is different between the list elements as it is in my
example?

Any hint will be appreciated.

Best,

Georg

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] applying a function recursively

2008-06-11 Thread Marc Schwartz

on 06/11/2008 10:51 AM Georg Otto wrote:

Hi,

I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:



test.list-list(I=list(A=c(a, b, c), B=c(d, e, f), C=c(g, h, 
i)),

+ II=list(A=list(a=c(a, b, c), b=c(d, e, f),
+ c=c(g, h, i)),
+   B=c(d, e, f), C=c(g, h, i)))


test.list

$I
$I$A
[1] a b c

$I$B
[1] d e f

$I$C
[1] g h i


$II
$II$A
$II$A$a
[1] a b c

$II$A$b
[1] d e f

$II$A$c
[1] g h i


$II$B
[1] d e f

$II$C
[1] g h i



I would like to apply a function recursively to that list, in a way
that the function does someting with each vector (eg. rev()) and
returns a list of modified vectors that has the same structure as the
input list, in my example:


$I
$I$A
[1] c b a

$I$B
[1] f e d

$I$C
[1] i h g


$II
$II$A
$II$A$a
[1] c b a

$II$A$b
[1] f e d

$II$A$c
[1] i h g


$II$B
[1] f e d

$II$C
[1] i h g



I understand that with a fixed number of recursion levels one can use
lapply() in a nested way, but what if the numbers of recursion levels
is not fixed or is different between the list elements as it is in my
example?

Any hint will be appreciated.

Best,

Georg


See ?rapply, which is a recursive version of lapply():

 rapply(test.list, rev, how = list)
$I
$I$A
[1] c b a

$I$B
[1] f e d

$I$C
[1] i h g


$II
$II$A
$II$A$a
[1] c b a

$II$A$b
[1] f e d

$II$A$c
[1] i h g


$II$B
[1] f e d

$II$C
[1] i h g


HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to save an updated dataset

2008-06-11 Thread Chris Stubben

I wrote a package which includes a number of genome sequencing project
statistics on the web like http://www.ncbi.nlm.nih.gov/genomes/lproks.cgi. I
included some generic functions to summarize, plot, and update the tables
with the most recent version

data(lproks)   
update(lproks)   
 [1] lproks successfully updated, 7 new genomes added

I usually save the dataset back to my package data directory...

save(lproks, file=/path/to/genomes/data/lproks.rda)

but I may one day put the package on CRAN (or BioConductor), so now I need
to know where the package/data directory is located, if the user has
permission to save to that directory, and probably some other complications
I'm missing.  Any suggestions?  

Thanks,
Chris Stubben

-- 
View this message in context: 
http://www.nabble.com/how-to-save-an-updated-dataset-tp17782584p17782584.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Increase Number of Decimals

2008-06-11 Thread jim holtman
options(digits=...)

On Wed, Jun 11, 2008 at 12:17 PM, Neil Gupta [EMAIL PROTECTED] wrote:
 R Users,

 I'm new to R and was wondering how I can show more decimal places when I run
 commands. If I'm simply running a correlation(ES,YM) how would I increase
 the number of decimal places R shows? When I run this it shows me .9734044.
 How can I extend this further?

 In addition I was running histograms on high frequency data to check a
 Spread. The spread moves at an extremely granular level. It may move .01
 frequently but again at a low level. How  can I increase the graularity of
 the histogram plots to detect smaller moves?

 I appreciate any and all help.

 Neil

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Increase Number of Decimals

2008-06-11 Thread Charilaos Skiadas

On Jun 11, 2008, at 12:17 PM, Neil Gupta wrote:


R Users,

I'm new to R and was wondering how I can show more decimal places  
when I run
commands. If I'm simply running a correlation(ES,YM) how would I  
increase
the number of decimal places R shows? When I run this it shows me . 
9734044.

How can I extend this further?


I am not sure what you can gain by looking at more decimal points in  
a correlation, but there are two ways, as far as I can tell:


1) Wrap the command in print, and use the digits optional argument  
in print. Have a look at ?print for details
2) Change the default more permanently for the session, by something  
like

options(digits=10)
Look at ?options for details


In addition I was running histograms on high frequency data to check a
Spread. The spread moves at an extremely granular level. It may  
move .01
frequently but again at a low level. How  can I increase the  
graularity of

the histogram plots to detect smaller moves?


We would need a reproducible example for this, I think.


I appreciate any and all help.

Neil


Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Parsing a data file - Help

2008-06-11 Thread A Ezhil
Hi All,

I have the data in the following format:

idktsaaplahto   pidg
5266199119943078A
526619921005199210302968A
19930208199302093074A
2002032920020402F322
2002040220020409F322
6866198107131981091729800
6866198111091981112029550
6866198202031982021929550

I would like to parse the data and reformat into a single row for each unique 
idkt, something like:
5266  1991  1994 3078A 19921005 19921030 2968A

I have tried with 

f - read.table(file.txt, sep=\t, header=TRUE);
attach(f);
fac - factor(f[,1]);
id - matrix(length(fac), 4);
for(i in fac) id[i] - f[idkt %in% fac[i], ]; 

I am not able make the list id into a single row. Could you please help how I 
can do this?

Thanks in advance.

Kind regards,
Ezhil

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Barplot help

2008-06-11 Thread stephen sefick
#I am having trouble figuring out this one.  I have read the help and I am
at a loss.  what am I missing

x - structure(list(X = structure(c(6L, 5L, 9L, 2L, 10L, 8L, 7L, 3L,
13L, 12L, 11L, 4L, 1L, 1L, 1L), .Label = c(, April, August,
December, February, January, July, June, March, May,
November, October, September), class = factor), X2006 = c(5987.387,
6478.592, 8386, 4651.273, 4339.167, 4631.978, 5217.306, 5846.903,
3867.825, 3886.434, 3959.668, 3848.853, NA, NA, NA), X2007 = c(4354.516,
5924.315, 5559.468, 3967.5, 5053.56, 4808.694, 4017.632, 3969.883,
3910.236, 3782.094, 3961.286, 3711.262, NA, NA, NA), X2008 = c(3685.789,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c(X,
X2006, X2007, X2008), class = data.frame, row.names = c(NA,
-15L))

barplot(x)

#I would like the months to be on the x-axis and then have the bars be the
values for the year


-- 
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Barplot help

2008-06-11 Thread Marc Schwartz

on 06/11/2008 12:44 PM stephen sefick wrote:

#I am having trouble figuring out this one.  I have read the help and I am
at a loss.  what am I missing

x - structure(list(X = structure(c(6L, 5L, 9L, 2L, 10L, 8L, 7L, 3L,
13L, 12L, 11L, 4L, 1L, 1L, 1L), .Label = c(, April, August,
December, February, January, July, June, March, May,
November, October, September), class = factor), X2006 = c(5987.387,
6478.592, 8386, 4651.273, 4339.167, 4631.978, 5217.306, 5846.903,
3867.825, 3886.434, 3959.668, 3848.853, NA, NA, NA), X2007 = c(4354.516,
5924.315, 5559.468, 3967.5, 5053.56, 4808.694, 4017.632, 3969.883,
3910.236, 3782.094, 3961.286, 3711.262, NA, NA, NA), X2008 = c(3685.789,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c(X,
X2006, X2007, X2008), class = data.frame, row.names = c(NA,
-15L))

barplot(x)

#I would like the months to be on the x-axis and then have the bars be the
values for the year


Is this what you want?

  barplot(t(x[-1]), names.arg = x$X, las = 2)

Note that the 'height' argument for barplot() needs to be either a 
vector or a matrix.


HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Barplot help

2008-06-11 Thread stephen sefick
I had to to get the data as a matrix and fix a couple of other things-  If
you would like for me to post my solution then I can.  I appoligize my
fingers went faster than my brain.

Stephen

On Wed, Jun 11, 2008 at 1:55 PM, Marc Schwartz [EMAIL PROTECTED]
wrote:

 on 06/11/2008 12:44 PM stephen sefick wrote:

 #I am having trouble figuring out this one.  I have read the help and I am
 at a loss.  what am I missing

 x - structure(list(X = structure(c(6L, 5L, 9L, 2L, 10L, 8L, 7L, 3L,
 13L, 12L, 11L, 4L, 1L, 1L, 1L), .Label = c(, April, August,
 December, February, January, July, June, March, May,
 November, October, September), class = factor), X2006 =
 c(5987.387,
 6478.592, 8386, 4651.273, 4339.167, 4631.978, 5217.306, 5846.903,
 3867.825, 3886.434, 3959.668, 3848.853, NA, NA, NA), X2007 = c(4354.516,
 5924.315, 5559.468, 3967.5, 5053.56, 4808.694, 4017.632, 3969.883,
 3910.236, 3782.094, 3961.286, 3711.262, NA, NA, NA), X2008 = c(3685.789,
 NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c(X,
 X2006, X2007, X2008), class = data.frame, row.names = c(NA,
 -15L))

 barplot(x)

 #I would like the months to be on the x-axis and then have the bars be the
 values for the year


 Is this what you want?

  barplot(t(x[-1]), names.arg = x$X, las = 2)

 Note that the 'height' argument for barplot() needs to be either a vector
 or a matrix.

 HTH,

 Marc Schwartz




-- 
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] MLE Estimation of Gamma Distribution Parameters for data with 'zeros'

2008-06-11 Thread Fox, Aaron
Greetings, all

I am having difficulty getting the fitdistr() function to return without
an error on my data. Specifically, what I'm trying to do is get a
parameter estimation for fracture intensity data in a well / borehole.
Lower bound is 0 (no fractures in the selected data interval), and upper
bound is ~ 10 - 50, depending on what scale you are conducting the
analysis on.

I read in the data from a text file, convert it to numerics, and then
calculate initial estimates of the shape and scale parameters for the
gamma distribution from moments. I then feed this back into the
fitdistr() function.

R code (to this point):

data.raw=c(readLines(FSM_C_9m_ENE.inp))
data.num - as.numeric(data.raw)
data.num
library(MASS)
shape.mom = ((mean(data.num))/ (sd(data.num))^2
shape.mom
med.data = mean(data.num)
sd.data = sd(data.num)
med.data
sd.data
shape.mom = (med.data/sd.data)^2
shape.mom
scale.mom = (sd.data^2)/med.data
scale.mom
fitdistr(data.num,gamma,list(shape=shape.mom,
scale=scale.mom),lower=0)

fitdistr() returns the following error:

 Error in optim(x = c(0.402707037, 0.40348, 0.404383704,
2.432626667,  : 
  L-BFGS-B needs finite values of 'fn'

Next thing I tried was to manually specify the negative log-likelihood
function and pass it straight to mle() (the method specified in Ricci's
tutorial on fitting distributions with R).  Basically, I got the same
result as using fitdistr().

Finally I tried using some R code I found from someone with a similar
problem back in 2003 from the archives of this mailing list:

R code

gamma.param1 - shape.mom
gamma.param2 - scale.mom
log.gamma.param1 - log(gamma.param1)
log.gamma.param2 - log(gamma.param2)


   gammaLoglik -
function(params, 
negative=TRUE){
   lglk - sum(dgamma(data, shape=exp(params[1]), scale=exp(params[2]),
log=TRUE))
   if(negative)
  return(-lglk)
   else
  return(lglk)
}

optim.list - optim(c(log.gamma.param1, log.gamma.param2), gammaLoglik)
gamma.param1 - exp(optim.list$par[1])
gamma.param2 - exp(optim.list$par[2])
#

If I test this function using my sample data and the estimates of shape
and scale derived from the method of moments, gammaLogLike returns as
INF. I suspect the problem is that the zeros in the data are causing the
optim solver problems when it attempts to minimize the negative
log-likelihood function.

Can anyone suggest some advice on a work-around?  I have seen
suggestions online that a 'censoring' algorithm can allow one to use MLE
methods to estimate the gamma distribution for data with zero values
(Wilkes, 1990, Journal of Climate). I have not, however, found R code to
implement this, and, frankly, am not smart enough to do it myself... :-)

Any suggestions? Has anyone else run up against this and written code to
solve the problem?

Thanks in advance!

Aaron Fox
Senior Project Geologist, Golder Associates
+1 425 882 5484 || +1 425 736 3958 (mobile)
[EMAIL PROTECTED] || www.fracturedreservoirs.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Parsing a data file - Help

2008-06-11 Thread Chuck Cleland

On 6/11/2008 1:29 PM, A Ezhil wrote:

Hi All,

I have the data in the following format:

idktsaaplahto   pidg
5266199119943078A
526619921005199210302968A
19930208199302093074A
2002032920020402F322
2002040220020409F322
6866198107131981091729800
6866198111091981112029550
6866198202031982021929550

I would like to parse the data and reformat into a single row for each unique 
idkt, something like:
5266  1991  1994 3078A 19921005 19921030 2968A

I have tried with 


f - read.table(file.txt, sep=\t, header=TRUE);
attach(f);
fac - factor(f[,1]);
id - matrix(length(fac), 4);
for(i in fac) id[i] - f[idkt %in% fac[i], ]; 


I am not able make the list id into a single row. Could you please help how I 
can do this?


  If you can create a variable that differentiates multiple records 
from the same idkt, you can use reshape() like this:


f - idkt saap lahto pidg
5266 1991 1994 3078A
5266 19921005 19921030 2968A
 19930208 19930209 3074A
 20020329 20020402 F322
 20020402 20020409 F322
6866 19810713 19810917 29800
6866 19811109 19811120 29550
6866 19820203 19820219 29550

fdata - read.table(textConnection(f), sep= , header=TRUE)

fdata$time - unlist(lapply(table(fdata$idkt), function(x){1:x}))

reshape(fdata, idvar = idkt, timevar = time, direction=wide)

  idkt   saap.1  lahto.1 pidg.1   saap.2  lahto.2 pidg.2   saap.3 
lahto.3 pidg.3
1 5266 1991 1994  3078A 19921005 19921030  2968A   NA 
NA   NA
3  19930208 19930209  3074A 20020329 20020402   F322 20020402 
20020409   F322
6 6866 19810713 19810917  29800 19811109 19811120  29550 19820203 
19820219  29550



Thanks in advance.

Kind regards,
Ezhil
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Search entire table for a value

2008-06-11 Thread naw3
Hi,

I have a table of numbers without any repeats. Is there a function that will
search the entire table for a specified value and return the indices if it is
found? Also, some rows may have columns without values.

Thank you so much,
-Nina

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] specifying ranges in scatter plot

2008-06-11 Thread He, Yulei
Hi, there:

 

Does anyone know how to specify the ranges in the axises when I make
scatter plots using pairs()? In the general plot function, I can use
xlim and ylim option. But how can I do this if I use pairs()?

 

Thanks.

 

Yulei

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Search entire table for a value

2008-06-11 Thread Henrique Dallazuanna
See ?which

On Wed, Jun 11, 2008 at 4:19 PM, [EMAIL PROTECTED] wrote:

 Hi,

 I have a table of numbers without any repeats. Is there a function that
 will
 search the entire table for a specified value and return the indices if it
 is
 found? Also, some rows may have columns without values.

 Thank you so much,
 -Nina

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help!!! Agnes dendogram (Clustering)

2008-06-11 Thread Sharai Gomez-Raygoza
The data one is a vector of 553 observations
 agglone-agnes(one, metric = manhattan, stand = TRUE)
plot(agglone,which.plots=2, nmax=150)
My problem is in the dendogram, I can not see the nodes because it is too 
crowded. I have attached the diagram.
Any help is more than welcome. Thank you a lot!!!
 
 
 
 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R and Fortran

2008-06-11 Thread Derrick Lee

Dear Fellow R-Users,

I am having some difficulties loading a Fortran subroutine into R and 
wondering if anyone could lend me some insight to this problem. When I 
load some simpler Fortran codes into R, it loads fine, but when I load 
more complex codes I get the following error:


 Error in dyn.load(x, as.logical(local), as.logical(now)) :
 unable to load shared library 
/nfs/home/grad/d.lee/Testing/chol.o:
   ld.so.1: R: fatal: relocation error: file 
/nfs/home/grad/d.lee/Testing/chol.o: symbol s_wsle: referenced symbol 
not found


From what I have gathered, it appears to be a problem when with linking 
the library to the Fortran system library, but I am unsure how to deal 
with this. The current 32-bit machine that runs R is:


platform sparc-sun-solaris2.8
arch sparc
os   solaris2.8
system   sparc, solaris2.8
status
major2
minor0.1
year 2004
month11
day  15
language R

Any help to this query would be very much appreciated. Cheers.


Sincerely

- Derrick


Derrick Lee, MSc Candidate
Department of Statistics
The University of British Columbia
LSK-314A | 604 - 822 - 1299 x532
d.lee at stat dot ubc dot ca | dgylee at mun dot ca
www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] specifying ranges in scatter plot

2008-06-11 Thread Henrique Dallazuanna
You can use also xlim and ylim, from the help page:

  ...: arguments to be passed to or from methods.

pairs(iris[1:4], main = Anderson's Iris Data -- 3 species,
pch = 21, bg = c(red, green3, blue)[unclass(iris$Species)])

pairs(iris[1:4], main = Anderson's Iris Data -- 3 species,
pch = 21, bg = c(red, green3, blue)[unclass(iris$Species)],
xlim = c(0,10), ylim = c(0,10))


On Wed, Jun 11, 2008 at 2:05 PM, He, Yulei [EMAIL PROTECTED] wrote:

 Hi, there:



 Does anyone know how to specify the ranges in the axises when I make
 scatter plots using pairs()? In the general plot function, I can use
 xlim and ylim option. But how can I do this if I use pairs()?



 Thanks.



 Yulei




[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R and Fortran

2008-06-11 Thread Derrick Lee

Dear Fellow R-Users,

I am having some difficulties loading a Fortran subroutine into R and 
wondering if anyone could lend me some insight to this problem. When I 
load some simpler Fortran codes into R, it loads fine, but when I load 
more complex codes I get the following error:


  Error in dyn.load(x, as.logical(local), as.logical(now)) :
  unable to load shared library 
/nfs/home/grad/d.lee/Testing/chol.o:
ld.so.1: R: fatal: relocation error: file 
/nfs/home/grad/d.lee/Testing/chol.o: symbol s_wsle: referenced symbol 
not found


From what I have gathered, it appears to be a problem when with linking 
the library to the Fortran system library, but I am unsure how to deal 
with this. As well, I was wondering why I am unsuccessful loading those 
same successful codes when I go from a 32-bit machine to a 64-bit 
machine, why does that cause such a big issue? The current 32-bit 
machine that runs R is:


platform sparc-sun-solaris2.8
arch sparc 
os   solaris2.8
system   sparc, solaris2.8 
status 
major2 
minor0.1   
year 2004  
month11
day  15
language R


Any help to these queries would be very much appreciated. Cheers.


Sincerely

- Derrick


Derrick Lee, MSc Candidate
Department of Statistics
The University of British Columbia
LSK-314A | 604 - 822 - 1299 x532
d.lee at stat dot ubc dot ca | dgylee at mun dot ca
www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] piper diagram

2008-06-11 Thread Dylan Beaudette
On Wednesday 11 June 2008, Jim Lemon wrote:
 Jim Lemon wrote:
  Dylan Beaudette wrote:
  Hi,
 
  Is anyone on the list familiar with an R implementation of Piper
  Diagrams?
 
  Example:
  http://faculty.uml.edu/nelson_eby/89.315/IMAGES/Figure%209-78.jpg
 
  I am thinking that two calls to triax.plot (plotrix) along with some
  kind of affine-transformed standard plot would do the trick. Not so
  sure about the final layout, or a nice generalized version for
  something like lattice.

 Okay, I've had a look at the Piper diagram and with better labeled ones
 and some explanations, I think I've got the picture. No, triax.plot
 won't do the job, but it's a similar sort of illustration. Give me a few
 days to think about it and I may be able to put one together.

 Jim

Any ideas would be appreciated!

Cheers,

Dylan

-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R and Fortran

2008-06-11 Thread Derrick Lee

Hi Erin,

Unfortunately no, its not named chol, I know about the cholesky 
decomposition in R, I was just testing out a more complex subroutine as 
the subroutine I intend to use gets similar errors. Thanks for the 
insight, though. Cheers.



- Derrick


Erin Hodgess wrote:

Hi Derrick!

Is your subroutine named chol?

There is a function in R by the name of chol.

You might be having a problem with that.

thanks,
Erin


On Wed, Jun 11, 2008 at 2:39 PM, Derrick Lee [EMAIL PROTECTED] wrote:
  

Dear Fellow R-Users,

I am having some difficulties loading a Fortran subroutine into R and
wondering if anyone could lend me some insight to this problem. When I load
some simpler Fortran codes into R, it loads fine, but when I load more
complex codes I get the following error:

Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
/nfs/home/grad/d.lee/Testing/chol.o:
  ld.so.1: R: fatal: relocation error: file
/nfs/home/grad/d.lee/Testing/chol.o: symbol s_wsle: referenced symbol not
found

From what I have gathered, it appears to be a problem when with linking the
library to the Fortran system library, but I am unsure how to deal with
this. The current 32-bit machine that runs R is:

platform sparc-sun-solaris2.8
arch sparc
os   solaris2.8
system   sparc, solaris2.8
status
major2
minor0.1
year 2004
month11
day  15
language R

Any help to this query would be very much appreciated. Cheers.


Sincerely

- Derrick


Derrick Lee, MSc Candidate
Department of Statistics
The University of British Columbia
LSK-314A | 604 - 822 - 1299 x532
d.lee at stat dot ubc dot ca | dgylee at mun dot ca
www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






  



--
Sincerely

- Derrick


Derrick Lee, MSc Candidate
Department of Statistics
The University of British Columbia
LSK-314A | 604 - 822 - 1299 x532
d.lee at stat dot ubc dot ca | dgylee at mun dot ca
www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] MLE Estimation of Gamma Distribution Parameters for data with 'zeros'

2008-06-11 Thread Peter Dalgaard

Fox, Aaron wrote:

Greetings, all

I am having difficulty getting the fitdistr() function to return without
an error on my data. Specifically, what I'm trying to do is get a
parameter estimation for fracture intensity data in a well / borehole.
Lower bound is 0 (no fractures in the selected data interval), and upper
bound is ~ 10 - 50, depending on what scale you are conducting the
analysis on.

I read in the data from a text file, convert it to numerics, and then
calculate initial estimates of the shape and scale parameters for the
gamma distribution from moments. I then feed this back into the
fitdistr() function.

R code (to this point):

data.raw=c(readLines(FSM_C_9m_ENE.inp))
data.num - as.numeric(data.raw)
data.num
library(MASS)
shape.mom = ((mean(data.num))/ (sd(data.num))^2
shape.mom
med.data = mean(data.num)
sd.data = sd(data.num)
med.data
sd.data
shape.mom = (med.data/sd.data)^2
shape.mom
scale.mom = (sd.data^2)/med.data
scale.mom
fitdistr(data.num,gamma,list(shape=shape.mom,
scale=scale.mom),lower=0)

fitdistr() returns the following error:

 Error in optim(x = c(0.402707037, 0.40348, 0.404383704,
2.432626667,  : 
  L-BFGS-B needs finite values of 'fn'


Next thing I tried was to manually specify the negative log-likelihood
function and pass it straight to mle() (the method specified in Ricci's
tutorial on fitting distributions with R).  Basically, I got the same
result as using fitdistr().

Finally I tried using some R code I found from someone with a similar
problem back in 2003 from the archives of this mailing list:

R code

gamma.param1 - shape.mom
gamma.param2 - scale.mom
log.gamma.param1 - log(gamma.param1)
log.gamma.param2 - log(gamma.param2)


   gammaLoglik -
function(params, 
negative=TRUE){

   lglk - sum(dgamma(data, shape=exp(params[1]), scale=exp(params[2]),
log=TRUE))
   if(negative)
  return(-lglk)
   else
  return(lglk)
}

optim.list - optim(c(log.gamma.param1, log.gamma.param2), gammaLoglik)
gamma.param1 - exp(optim.list$par[1])
gamma.param2 - exp(optim.list$par[2])
#

If I test this function using my sample data and the estimates of shape
and scale derived from the method of moments, gammaLogLike returns as
INF. I suspect the problem is that the zeros in the data are causing the
optim solver problems when it attempts to minimize the negative
log-likelihood function.

Can anyone suggest some advice on a work-around?  I have seen
suggestions online that a 'censoring' algorithm can allow one to use MLE
methods to estimate the gamma distribution for data with zero values
(Wilkes, 1990, Journal of Climate). I have not, however, found R code to
implement this, and, frankly, am not smart enough to do it myself... :-)

Any suggestions? Has anyone else run up against this and written code to
solve the problem?
  
It's fairly easy. You decide that the zeros really represent values less 
than delta (e.g. 0.5 if your data are integers), then replace 
dgamma(0,) with pgamma(delta,...) in the likelihood. (And, BTW, the 
problem is not that the optimizers get in trouble, but rather that the 
log-likelihood *is* +/- Inf if there are zeros in data unless the shape 
parameter is exactly 1 -- the x^(a-1) factor in the gamma density causes 
this).



--
  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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R and Fortran

2008-06-11 Thread Derrick Lee

Dear Fellow R-Users,

I am having some difficulties loading a Fortran subroutine into R and 
wondering if anyone could lend me some insight to this problem. When I 
load some simpler Fortran codes into R, it loads fine, but when I load 
more complex codes I get the following error:


   Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library 
/nfs/home/grad/d.lee/Testing/chol.o:
 ld.so.1: R: fatal: relocation error: file 
/nfs/home/grad/d.lee/Testing/chol.o: symbol s_wsle: referenced symbol 
not found


From what I have gathered, it appears to be a problem when with linking 
the library to the Fortran system library, but I am unsure how to deal 
with this. As well, I was wondering why I am unsuccessful loading those 
same successful codes when I go from a 32-bit machine to a 64-bit 
machine, why does that cause such a big issue? The current 32-bit 
machine that runs R is:


platform sparc-sun-solaris2.8
arch sparc  
os   solaris2.8 
system   sparc, solaris2.8  
status  
major2  
minor0.1
year 2004   
month11 
day  15 
language R


Any help to these queries would be very much appreciated. Cheers.


Sincerely

- Derrick


Derrick Lee, MSc Candidate
Department of Statistics
The University of British Columbia
LSK-314A | 604 - 822 - 1299 x532
d.lee at stat dot ubc dot ca | dgylee at mun dot ca
www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Copula fitting

2008-06-11 Thread Frankg

first, verify the class of your data by the following code:
class(data)
the class must be numeric

if ok

the problem can be caused from the starting value. Try choose other value. 
-- 
View this message in context: 
http://www.nabble.com/-R--Copula-fitting-tp6947714p17786789.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Close Window Button Problems

2008-06-11 Thread damon
i have created a wrapper C++ class that popen()s R. When i create a x11
window and plot, i cannot close it using the window button. Also, when i
minimize or maximize the window, the plot does not redraw. Can anybody
tell me if there is a way i can get back this window functionality or if
it is not possible?
thank you kindly.

-damon

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R and Fortran

2008-06-11 Thread Prof Brian Ripley
Are you serious, reporting on a 2004 version of R?  Please do as the 
posting guide requested, and update your R.  (Only posting one copy is 
also appreciated around here.)


Beyond that, normally foo.o is not a shared library but a compiled object. 
You have not told us what you did, and probably the issue is that you 
don't know how to make a shared library from Fortran.  Please ask your IT 
advisers about that (and hint, R CMD SHLIB may help you).


On Wed, 11 Jun 2008, Derrick Lee wrote:


Dear Fellow R-Users,

I am having some difficulties loading a Fortran subroutine into R and 
wondering if anyone could lend me some insight to this problem. When I load 
some simpler Fortran codes into R, it loads fine, but when I load more 
complex codes I get the following error:


Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library 
/nfs/home/grad/d.lee/Testing/chol.o:
  ld.so.1: R: fatal: relocation error: file 
/nfs/home/grad/d.lee/Testing/chol.o: symbol s_wsle: referenced symbol not 
found


From what I have gathered, it appears to be a problem when with linking the 
library to the Fortran system library, but I am unsure how to deal with this. 
The current 32-bit machine that runs R is:


platform sparc-sun-solaris2.8
arch sparc
os   solaris2.8
system   sparc, solaris2.8
status
major2
minor0.1
year 2004
month11
day  15
language R

Any help to this query would be very much appreciated. Cheers.


Sincerely

- Derrick


Derrick Lee, MSc Candidate
Department of Statistics
The University of British Columbia
LSK-314A | 604 - 822 - 1299 x532
d.lee at stat dot ubc dot ca | dgylee at mun dot ca
www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/


--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] the title is too long for a graph

2008-06-11 Thread Hua Li
Thank you all! The answers are very helpful!

Best regards,

Hua


--- On Wed, 6/11/08, Prof Brian Ripley [EMAIL PROTECTED] wrote:

 
  Hua Li wrote:
  Hi All,
  
  I have a problem of putting long titles on a
 graph:
  
  for example,
  
  x= seq(1:100)
  y=seq(1:100)
 
 plot(x,y,main=p=0.05:A-B=3,C-D=10,D-E=100,A-F=2,AFR-E=3,ACE-D=1,ADEF-M=0,AED-E=10,DE-F=3,AB-J=4,AC-J=10,ED-F=1,ED-B=4,AF-B=10,CD-S=10,AM-C=4)
  
  R seems not able to print the whole title. The

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ETH Internship - Dynamic Portfolio Asset Allocation

2008-06-11 Thread Diethelm Wuertz



Summer Internship at ETH Zurich
Dynamic Portfolio Asset Allocation


We offer a 3-months internship starting
midth July 2008. The topic addresses
Dynamic Portfolio Asset Allocation
including alternative instruments and
hedge funds. The goal will be to compare
the robust mean-variance, the lower partial
moment and the conditional value-at-risk
approaches for portfolio construction and
optimization using the Rmetrics package
fPortfolio. Moreover, we will investigate
the influence of quadratic covariance and
copulae related tail risk budget constraints
as an option to limit and control the risk
attributed by individual assets.

We offer a generous compensation for traveling,
accomodation, and living costs in the beautiful
city of Zurich.

The candidate should have a strong quantitative
background and have experience in data
modelling with the R language.

The application should include a letter of
motivation (highlighting your interest and prior
knowledge in the internship topic) and an
up-to-date CV. Please send your application to
[EMAIL PROTECTED]

If you need further information, please contact us.

PD Dr. Diethelm Wuertz
Econophysics Group at the
Institute of Theoretical Physics
ETH Zurich

www.ethz.ch
www.phys.ethz.ch
www.rmetrics.org

NOTE:
Rmetrics Workshop: http://www.rmetrics.org/meielisalp.htm
June 29th - July 3rd Meielisalp, Lake Thune, Switzerland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] MLE Estimation of Gamma Distribution Parameters for data with 'zeros'

2008-06-11 Thread Ben Bolker
Fox, Aaron Afox at golder.com writes:

 
 Greetings, all
 
 I am having difficulty getting the fitdistr() function to return without
 an error on my data. Specifically, what I'm trying to do is get a
 parameter estimation for fracture intensity data in a well / borehole.
 Lower bound is 0 (no fractures in the selected data interval), and upper
 bound is ~ 10 - 50, depending on what scale you are conducting the
 analysis on.
 

  You're right that the basic problem is with the gamma
distribution.  P(x,shape) dx = 0 (shape1), 1 (shape=1), or Inf (shape1).
A quick cheat would be to add a small number (0.001?) to your data,
try it again, and see how sensitive the estimate is to how small
that number is.  You could also try a negative binomial fit, which
is the discrete analog of the gamma (and hence won't have any
problem with zeros).  People who do beta regressions with
zero values in them often talk about adding a small Bayesian
'fudge factor' to deal with this problem ... (see 
http://psychology.anu.edu.au/people/smithson/details/betareg/Readme.pdf )

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Close Window Button Problems

2008-06-11 Thread Bert Gunter
This should be posted on R-devel, not here.

-- Bert 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, June 11, 2008 1:30 PM
To: r-help@r-project.org
Subject: [R] Close Window Button Problems

i have created a wrapper C++ class that popen()s R. When i create a x11
window and plot, i cannot close it using the window button. Also, when i
minimize or maximize the window, the plot does not redraw. Can anybody
tell me if there is a way i can get back this window functionality or if
it is not possible?
thank you kindly.

-damon

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Ben Bolker
Lucke, Joseph F Joseph.F.Lucke at uth.tmc.edu writes:

 
 And to follow FH and HW
 
 What level of significance are you using? .05 is excessively liberal.
 Are you adjusting your p-values for the number of possible models? Do
 you realize the p-values for dropping a term, being selected as the
 maximum of a set of p-values, do not follow their usual distributions?
 How are you compensating for sample size, as a p-value's being
 significant is a function of sample size?  How are you compensating for
 the fact that the current model choice is dependent on the previous
 model choices? How do you know your tree of model choices is the optimal
 one?  Have you considered cross-validation?  Are you looking for a model
 that true describes a phenomenon or a predictive model that can be used
 for practical purposes?
 

   Ouch.  While Frank Harrell and Joseph Lucke are raising
serious issues about model selection, maybe we could keep in mind that
we don't want to scare off all the students who ever try to use R
to figure out basic statistics.  I would follow Peter Dalgaard's advice
(about drop1) and Hadley Wickham's (about graphical diagnostics), 
and if possible bring up the other issues about
model selection with others around you -- if you're a student, ask
your prof. or someone in the stats department.  It can be tough
to try to do things right if those around you are still
doing them wrong ...  If you tell us what field you're in we
may be able to point you to more subject-specific references
(e.g. Whittingham, Mark J., Philip A. Stephens, Richard B. Bradbury, and Robert
P. Freckleton. 2006. Why do we still use stepwise modelling in ecology and
behaviour? Journal of Animal Ecology 75, no. 5: 1182-1189)

   Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] converting a data set to a format for time series analysis

2008-06-11 Thread Ricardo Pietrobon
Jim, it worked perfectly.  thanks a lot

On Mon, Jun 9, 2008 at 8:58 PM, jim holtman [EMAIL PROTECTED] wrote:
 This should do it:

 x - read.table(textConnection(subject hospitaldate_enrollment
 hospital_beds
 +  1   hospitalA   1/3/2002300
 +  2   hospitalA   1/6/2002300
 +  3   hospitalB   2/4/2002150
 +  4   hospitalC   3/2/2002200), header=TRUE)
 closeAllConnections()
 y - as.Date(x$date_enrollment, %m/%d/%Y)
 z - cbind(x, year=format(y, %Y), month=format(y, %m))
 # partition the data
 z.s - split(z, list(z$year, z$month, z$hospital), drop=TRUE)
 # now aggregate
 do.call(rbind, lapply(z.s, function(a) data.frame(hospital=a$hospital[1],
 cases=nrow(a),
 + year=a$year[1], month=a$month[1], beds=a$hospital[1])))
hospital cases year month  beds
 2002.01.hospitalA hospitalA 2 200201 hospitalA
 2002.02.hospitalB hospitalB 1 200202 hospitalB
 2002.03.hospitalC hospitalC 1 200203 hospitalC





 On Mon, Jun 9, 2008 at 1:51 PM, Ricardo Pietrobon [EMAIL PROTECTED]
 wrote:

 Jim, thanks a lot.  This does the trick for dates, but what I have
 been struggling the most with is actually the conversion from having
 one subject per row to having one month per row.  I didn't explain
 that well at all in my previous email and so let me try again.  The
 idea is that the current data set is displayed with one subject per
 row.  I would like to have it displayed having one hospital per month
 per row.  For example, the new data set would look like this:

 month   yearsite   number_enrolled_subjects
  hospital_beds
 1  2002   hospitalA   22
   300

 meaning that hospital A enrolled 22 subjects in 01/2002, and hospital
 A has 300 beds -- the beds variable is one variable in a vector that
 would display all the covariates for my ARIMA model

 your suggestion solved the problem for the dates, but the command I am
 looking for now is something that would count the number of subjects
 per site per month of a year and then displayed it in the format
 above.  any thoughts?

 I really appreciate your help




 On Mon, Jun 9, 2008 at 1:04 PM, jim holtman [EMAIL PROTECTED] wrote:
  Will something like this work for you:
 
  x - read.table(textConnection(subject hospitaldate_enrollment
  hospital_beds
  + 1   hospitalA   1/3/2002300
  + 2   hospitalA   1/6/2002300
  + 3   hospitalB   2/4/2002150
  + 4   hospitalC   3/2/2002200), header=TRUE)
  closeAllConnections()
  y - as.Date(x$date_enrollment, %m/%d/%Y)
  cbind(x, year=format(y, %Y), month=format(y, %m))
subject  hospital date_enrollment hospital_beds year month
  1   1 hospitalA1/3/2002   300 200201
  2   2 hospitalA1/6/2002   300 200201
  3   3 hospitalB2/4/2002   150 200202
  4   4 hospitalC3/2/2002   200 200203
 
 
 
 
  On Mon, Jun 9, 2008 at 12:45 PM, Ricardo Pietrobon [EMAIL PROTECTED]
  wrote:
 
  I currently have a data set describing human subjects enrolled into an
  international clinical trial, the name of the hospital enrolling this
  human subject, the date when the subject was enrolled, and a vector
  with variables representing characteristics of the site (e.g., number
  of beds in a hospital).  my data sets looks like this:
 
  subject hospitaldate_enrollment hospital_beds
  1   hospitalA   1/3/2002300
  2   hospitalA   1/6/2002300
  3   hospitalB   2/4/2002150
  4   hospitalC   3/2/2002200
 
  to perform a time series analysis I am now trying to get to a format
  that would give me the following variables:
 
  month   yearsitenumber_enrolled_subjectshospital_beds
 
  the data would be displayed on one-month intervals, and number of
  subjects clustered around sites.
 
  any help would be greatly appreciate
 
  thanks
 
 
  Ricardo
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
  --
  Jim Holtman
  Cincinnati, OH
  +1 513 646 9390
 
  What is the problem you are trying to solve?



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

 What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] I wonder if cch function in Survival package can calculate time dependent covariate

2008-06-11 Thread Jin Wang
Hi

In case cohort study, we can fit proportional hazard regression model to
case-cohort data. In R, the function is cch() in Survival package
Now I am working on case cohort analysis with time dependent covariates
using cch() of Survival R package. I wonder if cch() provide this utility
or not?
The cch() manual does not say if time dependent covariate is allowed
I know coxph() in Survival package can estimate time dependent covariates.

Thanks

Jin Wang

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] difference between nlm and nlminb

2008-06-11 Thread Douglas Bates
nlminb provides unconstrained optimization and optimization subject to
box constraints (i.e. upper and/or lower constraints on individual
elements of the parameter vector).  The nlm function provides
unconstrained optimization.

I created the nlminb function because I was unable to get reliable
convergence on some difficult optimization problems for the nlme and
lme4 packages using nlm and optim.  The nlme package was originally
written for S from Bell Labs (the forerunner of S-PLUS) and the PORT
package was the optimization code used.  Even though it is very old
style Fortran code I find it quite reliable as an optimizer.  It
allows for what is called reverse communication which is convenient in
an environment like R.  It is a technical issue that has to do with
what code is in control when your R expression needs to be evaluated.

That said, I still don't feel that I have seen good, modern
Open-Source optimization code.  I would welcome suggestions of where
one might find such code.


On Wed, Jun 11, 2008 at 3:16 AM, DavidM.UK [EMAIL PROTECTED] wrote:

 I believe nlminb() performs *constrained* optimization, where as nlm() is for
 *unconstrained* opimization

 So I guess nlm() is for solving min(f[a,b]), and nlminb() min(f[a,b]) given
 a+b = c

 FYI I think optim() also does constrained optimization, well I've used for
 min(f[a,b]) given a = a* and b = b*.

 David


 ae2356 wrote:


 Hi,

 I was wondering if someone could give a brief, big picture overview of the
 difference between the two optimization functions nlm and nlminb. I'm not
 familiar with PORT routines, so I was hoping someone could give an
 explanation.

 Thanks,
 Angelo
 _
 Instantly invite friends from Facebook and other social networks to join
 yo
 https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



 --
 View this message in context: 
 http://www.nabble.com/difference-between-nlm-and-nlminb-tp17769859p17772440.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Frank E Harrell Jr

Ben Bolker wrote:

Lucke, Joseph F Joseph.F.Lucke at uth.tmc.edu writes:


And to follow FH and HW

What level of significance are you using? .05 is excessively liberal.
Are you adjusting your p-values for the number of possible models? Do
you realize the p-values for dropping a term, being selected as the
maximum of a set of p-values, do not follow their usual distributions?
How are you compensating for sample size, as a p-value's being
significant is a function of sample size?  How are you compensating for
the fact that the current model choice is dependent on the previous
model choices? How do you know your tree of model choices is the optimal
one?  Have you considered cross-validation?  Are you looking for a model
that true describes a phenomenon or a predictive model that can be used
for practical purposes?



   Ouch.  While Frank Harrell and Joseph Lucke are raising
serious issues about model selection, maybe we could keep in mind that
we don't want to scare off all the students who ever try to use R
to figure out basic statistics.  I would follow Peter Dalgaard's advice
(about drop1) and Hadley Wickham's (about graphical diagnostics), 
and if possible bring up the other issues about

model selection with others around you -- if you're a student, ask
your prof. or someone in the stats department.  It can be tough
to try to do things right if those around you are still
doing them wrong ...  If you tell us what field you're in we
may be able to point you to more subject-specific references
(e.g. Whittingham, Mark J., Philip A. Stephens, Richard B. Bradbury, and Robert
P. Freckleton. 2006. Why do we still use stepwise modelling in ecology and
behaviour? Journal of Animal Ecology 75, no. 5: 1182-1189)

   Ben Bolker


Good points Ben.  For now I'd recommend simply that the allergic 
reaction to insignificant statistical tests be treated with an 
antihistimine :-)


Frank



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem when combining dotplot() and textplot() using grid

2008-06-11 Thread Paul Murrell
Hi


Bernhard wrote:
 Hi everyone.
 
 I want to solve the following problem. I have a data.frame and I
 create a dotplot using lattice.
 
 Then I want to use the grid-package to create a combined graphic which
 contains the dotplot as well as a textplot() (using package gplots) of
 the data.frame next to the dotplot.
 
 Example code:
 library(lattice)
 library(grid)
 library(gplots)
 
 xx - data.frame(f=factor(rep(1:5, each=5)), gr= rep(c(gr1, gr2,
 gr3, gr4, gr5), 5), val=rnorm(25))
 grid.newpage()
 pushViewport(viewport(layout = grid.layout(1, 2)))
 pushViewport(viewport(layout.pos.col=1, layout.pos.row=1))
 p - dotplot(f ~ val, groups=gr, xx, cex=1.7, pch=20)
 print(p, newpage=FALSE)
 popViewport(1)
 
 pushViewport(viewport(layout.pos.col=2, layout.pos.row=1))
 textplot(xx, show.rownames=FALSE)
 popViewport(1)
 
 Obviously, this does not work since textplot() seems to call plot.new
 no matter what options are set with par().
 
 My question: Is it possible to archieve my goal to plot the data.frame
 with textplot() next to the dotplot?


This should work (adjustments to your code are accompanied by comments):

library(lattice)
library(grid)
library(gplots)
# Also need gridBase
library(gridBase)

# Start a traditional graphics page
plot.new()

xx - data.frame(f=factor(rep(1:5, each=5)), gr= rep(c(gr1, gr2,
gr3, gr4, gr5), 5), val=rnorm(25))
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 2)))
pushViewport(viewport(layout.pos.col=1, layout.pos.row=1))
p - dotplot(f ~ val, groups=gr, xx, cex=1.7, pch=20)
print(p, newpage=FALSE)
popViewport(1)

pushViewport(viewport(layout.pos.col=2, layout.pos.row=1))
# Prevent textplot() starting new page
par(new=TRUE)
# Locate traditional plot region based on grid viewport
par(plt=gridPLT())
textplot(xx, show.rownames=FALSE)
popViewport(1)


 And furthermore, if it is possible to do so, is it even possible to
 adjust the textplot in a way that the each row of the data.frame when
 plotted using textplot() is at the same height than the corresponding
 row in the dotplot? I guess that this is quite tricky and any hint on
 which package or functions I could use would be very helpful.


This is starting to push things a bit;  you are getting to the point
where it might be easier to start drawing things yourself.  However,
here's one approach that might give you what you want.  The idea is
to draw the textplot() for each level of the factor in its own viewport
(to get the alignment with the scale on the lattice plot).

# Start a traditional graphics page
plot.new()
grid.newpage()
# Viewport in left half of page to leave space for text
pushViewport(viewport(x=0, width=.5, just=left))
p - dotplot(f ~ val, groups=gr, xx, cex=1.7, pch=20)
print(p, newpage=FALSE,
  # Control name of lattice viewport so we can get back to it
  prefix=lattice)
# Leave all viewports so we can navigate back
upViewport(1)

# Go back into the lattice plot viewport to add text bits
downViewport(lattice.panel.1.1.off.vp)
# For each level of 'f'
for (i in levels(xx$f)) {
# Push a viewport off to the side
  pushViewport(viewport(x=unit(1, npc) + unit(1, cm),
# Here's the vertical alignment bit
y=unit(as.numeric(as.character(i)),
   native) +
  unit(1, lines),
height=1/(length(levels(xx$f)) + 1),
just=c(left, top)))
  # Just to show where we are (can be removed)
grid.rect(gp=gpar(col=grey))
  # Align the traditional plot region
  par(new=TRUE)
par(fig=gridFIG())
  # Fiddle with size of text
par(cex=0.7)
# Draw the relevant subset of the data frame
textplot(xx[xx$f == i, ], halign=left, valign=top,
   mar=rep(0, 4))
  popViewport()
}
# Final tidy up
upViewport(0)

Bits of this are very your-example-specific, but this might be enough
for a one-off.

Paul


 Thank you very much.
 Bernhard
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with as.Date

2008-06-11 Thread Mr Natural

Data into R from Excel csv file
xd-read.csv(court.dates1.txt,as.is=T, header = F)

 str(xd)
'data.frame':   5 obs. of  1 variable:
 $ V1: chr  6/6 5/27 5/16 5/2 ...


xd

 V1
1  6/6
2 5/27
3 5/16
4  5/2
5 4/29

cdates - as.Date(xd,  format =  %m/ %d)

Error in as.Date.default(xd, format =  %m/ %d) : 
  do not know how to convert 'xd' to class Date


Suggestions appreciated,

Don


-- 
View this message in context: 
http://www.nabble.com/problem-with-as.Date-tp17788563p17788563.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem with as.Date

2008-06-11 Thread Gabor Grothendieck
Using

xd - structure(list(V1 = c(6/6, 5/27, 5/16, 5/2)), .Names =
V1, row.names = c(NA,
-4L), class = data.frame)

Try:

 as.Date(paste(2008, xd$V1, sep = /), %Y/%m/%d)
[1] 2008-06-06 2008-05-27 2008-05-16 2008-05-02

See R News 4/1 article on dates.

On Wed, Jun 11, 2008 at 6:22 PM, Mr Natural [EMAIL PROTECTED] wrote:

 Data into R from Excel csv file
 xd-read.csv(court.dates1.txt,as.is=T, header = F)

 str(xd)
 'data.frame':   5 obs. of  1 variable:
  $ V1: chr  6/6 5/27 5/16 5/2 ...


xd

  V1
 1  6/6
 2 5/27
 3 5/16
 4  5/2
 5 4/29

 cdates - as.Date(xd,  format =  %m/ %d)

 Error in as.Date.default(xd, format =  %m/ %d) :
  do not know how to convert 'xd' to class Date


 Suggestions appreciated,

 Don


 --
 View this message in context: 
 http://www.nabble.com/problem-with-as.Date-tp17788563p17788563.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem with as.Date

2008-06-11 Thread d f
since it's a dataframe, use xd$V1.
also, it doesn't seem like your data has a space between the / and the
numbers, so take that out of the pattern:

cdates - as.Date(xd$V1,  format = %m/%d)

On Wed, Jun 11, 2008 at 6:22 PM, Mr Natural [EMAIL PROTECTED] wrote:

 Data into R from Excel csv file
 xd-read.csv(court.dates1.txt,as.is=T, header = F)

 str(xd)
 'data.frame':   5 obs. of  1 variable:
  $ V1: chr  6/6 5/27 5/16 5/2 ...


xd

  V1
 1  6/6
 2 5/27
 3 5/16
 4  5/2
 5 4/29

 cdates - as.Date(xd,  format =  %m/ %d)

 Error in as.Date.default(xd, format =  %m/ %d) :
  do not know how to convert 'xd' to class Date


 Suggestions appreciated,

 Don


 --
 View this message in context: 
 http://www.nabble.com/problem-with-as.Date-tp17788563p17788563.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Marc Schwartz

on 06/11/2008 05:53 PM Frank E Harrell Jr wrote:

Ben Bolker wrote:

Lucke, Joseph F Joseph.F.Lucke at uth.tmc.edu writes:


And to follow FH and HW

What level of significance are you using? .05 is excessively liberal.
Are you adjusting your p-values for the number of possible models? Do
you realize the p-values for dropping a term, being selected as the
maximum of a set of p-values, do not follow their usual distributions?
How are you compensating for sample size, as a p-value's being
significant is a function of sample size?  How are you compensating for
the fact that the current model choice is dependent on the previous
model choices? How do you know your tree of model choices is the optimal
one?  Have you considered cross-validation?  Are you looking for a model
that true describes a phenomenon or a predictive model that can be used
for practical purposes?



   Ouch.  While Frank Harrell and Joseph Lucke are raising
serious issues about model selection, maybe we could keep in mind that
we don't want to scare off all the students who ever try to use R
to figure out basic statistics.  I would follow Peter Dalgaard's advice
(about drop1) and Hadley Wickham's (about graphical diagnostics), 
and if possible bring up the other issues about

model selection with others around you -- if you're a student, ask
your prof. or someone in the stats department.  It can be tough
to try to do things right if those around you are still
doing them wrong ...  If you tell us what field you're in we
may be able to point you to more subject-specific references
(e.g. Whittingham, Mark J., Philip A. Stephens, Richard B. Bradbury, 
and Robert
P. Freckleton. 2006. Why do we still use stepwise modelling in ecology 
and

behaviour? Journal of Animal Ecology 75, no. 5: 1182-1189)

   Ben Bolker


Good points Ben.  For now I'd recommend simply that the allergic 
reaction to insignificant statistical tests be treated with an 
antihistamine :-)



A vote for Frank's comment to be added to the 'fortunes' package.

:-)

Regards,

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Adding new columns to (output) data - e.g., read 5 cols write 8

2008-06-11 Thread Esmail Bonakdarian

Hello, I have the following task I'd like to accomplish:

A file contains 5 columns of data (several hundred rows), let's call
them a, b, c, d and e (ie these are their column headers)

I also have a set of definitions, e.g.,

f = a + b
g = a * 3
h = c + d
etc.

I would like to write out a new .rda file that contains columns

a b c d e f g h etc.

I.e. , the original data plus new columns (with headers and data).

It seems that there ought to be a simple way to do this, could
someone provide some guidance on the best way to accomplish
this task? (I tried a few things as this seemed rather trivial,
but did not succeed. I still hope/assume this is a trivial thing
to do if one knows R well)

Thanks,

Esmail

ps: I want to thank everyone again who posted their solutions
to my previous query. Seeing different solutions for the same
problem is a tremendously effective way to learn something
new.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread Simon Blomberg

  Good points Ben.  For now I'd recommend simply that the allergic 
  reaction to insignificant statistical tests be treated with an 
  antihistamine :-)
 
 
 A vote for Frank's comment to be added to the 'fortunes' package.
 
Seconded! :-)

 :-)
 
 Regards,
 
 Marc
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Adding new columns to (output) data - e.g., read 5 cols write 8

2008-06-11 Thread jim holtman
yourDF - cbind(yourDF, f=yourDF$a+yourDF$b, g=yourDF$a * 3,
h=yourDF$c + yourDF$d)

On Wed, Jun 11, 2008 at 9:26 PM, Esmail Bonakdarian [EMAIL PROTECTED] wrote:
 Hello, I have the following task I'd like to accomplish:

 A file contains 5 columns of data (several hundred rows), let's call
 them a, b, c, d and e (ie these are their column headers)

 I also have a set of definitions, e.g.,

 f = a + b
 g = a * 3
 h = c + d
 etc.

 I would like to write out a new .rda file that contains columns

 a b c d e f g h etc.

 I.e. , the original data plus new columns (with headers and data).

 It seems that there ought to be a simple way to do this, could
 someone provide some guidance on the best way to accomplish
 this task? (I tried a few things as this seemed rather trivial,
 but did not succeed. I still hope/assume this is a trivial thing
 to do if one knows R well)

 Thanks,

 Esmail

 ps: I want to thank everyone again who posted their solutions
to my previous query. Seeing different solutions for the same
problem is a tremendously effective way to learn something
new.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Adding new columns to (output) data - e.g., read 5 cols write 8

2008-06-11 Thread Erik Iverson

Esmail -

Esmail Bonakdarian wrote:

Hello, I have the following task I'd like to accomplish:

A file contains 5 columns of data (several hundred rows), let's call
them a, b, c, d and e (ie these are their column headers)


Are these 5 vectors of data stored in a data.frame?  I assume so.



I also have a set of definitions, e.g.,

f = a + b
g = a * 3
h = c + d
etc.

I would like to write out a new .rda file that contains columns

a b c d e f g h etc.

I.e. , the original data plus new columns (with headers and data).


Example,

test - data.frame(a = 1:10, b = 2:11, c = 3:12)
test2 - transform(test, d = 2*a + b, e = 3*c)
save(test2, file = test2.Rdata)

Does this help?

Best,
Erik Iverson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mgcv::gam error message for predict.gam

2008-06-11 Thread David Katz

Sometimes, for specific models, I get this error from predict.gam in library
mgcv:

Error in complete.cases(object) : negative length vectors are not allowed

 Here's an example:

model.calibrate -
  gam(meansalesw ~ s(tscore,bs=cs,k=4),
  data=toplot,
  weights=weight,
  gam.method=perf.magic)


 test - predict(model.calibrate,newdata)
Error in complete.cases(object) : negative length vectors are not allowed
 

The data is shown below:

 toplot[,c(meansalesw,tscore,weight)]
   meansalesw  tscore weight
1   0.1275841 0.003446797  15224
2   0.1495748 0.004017158  15523
3   0.2245844 0.004375278  15520
4   0.2197668 0.004753941  15525
5   0.1317830 0.005049050  15524
6   0.2809621 0.005403199  15498
7   0.2933119 0.005764413  15529
8   0.4791150 0.006335145  15514
9   0.1833688 0.006617095  15528
10  0.3200599 0.007135850  15527
11  0.4931882 0.007781095  15529
12  0.4207684 0.008766088  15512
13  0.5928568 0.009731357  15514
14  0.8025296 0.010927579  15520
15  0.6286192 0.012004714  15513
16  0.7477922 0.014083143  15527
17  0.7251362 0.017382274  15531
18  1.1871948 0.025481173  15521
19  1.6495832 0.048264689  15524
20  5.1180227 0.131198022  15218

 newdata
 tscore
1 0.5059341
2 0.4125522
3 1.4335818
4 0.7060673
5 0.3229316

Thanks!
-- 
View this message in context: 
http://www.nabble.com/mgcv%3A%3Agam-error-message-for-predict.gam-tp17789318p17789318.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Adding new columns to (output) data - e.g., read 5 cols write 8

2008-06-11 Thread Esmail Bonakdarian

Hi Erik,

Erik Iverson wrote:

Esmail -

Are these 5 vectors of data stored in a data.frame?  I assume so.


Yes, I do a simple load() call first to read the .rda file ...


test2 - transform(test, d = 2*a + b, e = 3*c)
save(test2, file = test2.Rdata)

Does this help?


Yes it does .. this is just what I needed. I'll probably do it
in this way:

df=transform(df, X5=X1+X2)
df=transform(df, X6=X1-X2)
etc ...


building it up the df line by line since the definitions have been
provided one per line (instead of queuing them up in one line like
you showed). I'll have to write a  little awk or ruby script to take
the original definitions and wrap them into the transform call, but then
I should be all set to go.

Thanks again!

Esmail

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Adding new columns to (output) data - e.g., read 5 cols write 8

2008-06-11 Thread Esmail Bonakdarian

jim holtman wrote:

yourDF - cbind(yourDF, f=yourDF$a+yourDF$b, g=yourDF$a * 3,
h=yourDF$c + yourDF$d)


Thanks Jim, I also learned about the transform() method from Erik
which will also work beautifully.

Esmail

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Data.matrix fail to convert data.frame into matrix

2008-06-11 Thread Gundala Viswanath
Hi,

With the following codes, I attempt to convert
the data.frame into a matrix.

However I notice that data.matrix function doesn't
seem to work.

__ BEGIN__
dat - read.table(mydata, comment.char = ! , na.strings = null);
# Select n-genes by random sample
# n = 1
nosamp - 1
geneid - sequence(nrow(dat))
geneid.samp - sample(geneid,nosamp)
geneid.samp

gexp- dat[geneid.samp,]
gexp.arr - data.matrix(gexp, rownames.force = NA)
print(is.matrix(gexp.arr))
print(gexp.arr)

__END__

Yielding this output:

__BEGIN__
  print(is.matrix(gexp.arr))
[1] TRUE
  print(gexp.arr)
V1 V2V3V4V5V6V7V8
10354 803.1 1107.8 431.6 349.8 386.7 646.3 744.2 620.9
__END__

I expect gexp.arr to be a plain vector (numeric).
What's wrong with my code above?





-- 
Gundala Viswanath
Jakarta-Indonesia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Panel-specific colours in barchart, lattice package.

2008-06-11 Thread Rolf Turner


I would like, for possibly invalid reasons, to have the bars of the  
barchart
in each panel to be the same colour, but with *different* colours  
from panel

to panel.  Can this be done? If so, how?

I've read the help as much as I am capable of, and done an RSiteSearch 
() without

becoming any wiser.

Here's an example of what I'd like to do:

X - structure(list(y = c(2.8, 6.7, 12.8, 22.9, 18.4, 16.2, 10.1,
5.6, 4.5, 6.9, 19.8, 25.7, 23.8, 12.9, 5.9, 3, 1, 1, 12.9, 24.2,
24.2, 25, 8.1, 3.2, 1.6, 0.8, 0, 5, 12.5, 25, 17.5, 20, 12.5,
5, 0, 2.5, 25, 33.3, 25, 0, 0, 8.3, 8.3, 0, 0), x = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L), .Label = c(1,
2, 3, 4, 5, 6, 7, 8, 9), class = factor), f =  
structure(c(1L,

1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c(a,
b, c, d, e), class = factor)), .Names = c(y, x,
f), row.names = c(NA, -45L), class = data.frame)

barchart(y ~ x | f, data=X, as.table=TRUE)

EXCEPT that I'd like panel ``a'' to have its bars being, say, solid red,
panel ``b'' to have its bars solid blue, panel ``c'' to have its bars
solid green, etc.

Can I arrange this?  Thanks.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Panel-specific colours in barchart, lattice package.

2008-06-11 Thread Gabor Grothendieck
Try this:

barchart(y ~ x | f, data=X, as.table=TRUE,
  panel = function(...) panel.barchart(..., col = panel.number()))


On Wed, Jun 11, 2008 at 11:46 PM, Rolf Turner [EMAIL PROTECTED] wrote:

 I would like, for possibly invalid reasons, to have the bars of the barchart
 in each panel to be the same colour, but with *different* colours from panel
 to panel.  Can this be done? If so, how?

 I've read the help as much as I am capable of, and done an RSiteSearch()
 without
 becoming any wiser.

 Here's an example of what I'd like to do:

 X - structure(list(y = c(2.8, 6.7, 12.8, 22.9, 18.4, 16.2, 10.1,
 5.6, 4.5, 6.9, 19.8, 25.7, 23.8, 12.9, 5.9, 3, 1, 1, 12.9, 24.2,
 24.2, 25, 8.1, 3.2, 1.6, 0.8, 0, 5, 12.5, 25, 17.5, 20, 12.5,
 5, 0, 2.5, 25, 33.3, 25, 0, 0, 8.3, 8.3, 0, 0), x = structure(c(1L,
 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L,
 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L), .Label = c(1,
 2, 3, 4, 5, 6, 7, 8, 9), class = factor), f =
 structure(c(1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c(a,
 b, c, d, e), class = factor)), .Names = c(y, x,
 f), row.names = c(NA, -45L), class = data.frame)

 barchart(y ~ x | f, data=X, as.table=TRUE)

 EXCEPT that I'd like panel ``a'' to have its bars being, say, solid red,
 panel ``b'' to have its bars solid blue, panel ``c'' to have its bars
 solid green, etc.

 Can I arrange this?  Thanks.

cheers,

Rolf Turner

 ##
 Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Data.matrix fail to convert data.frame into matrix

2008-06-11 Thread Moshe Olshansky
Try
gexp.arr - data.matrix(gexp, rownames.force = FALSE)

You are still supposed to get a matrix with one row (not a vector - 
dim(gexp.arr) is c(1,8) and not NULL).


--- On Thu, 12/6/08, Gundala Viswanath [EMAIL PROTECTED] wrote:

 From: Gundala Viswanath [EMAIL PROTECTED]
 Subject: [R] Data.matrix fail to convert data.frame into matrix
 To: [EMAIL PROTECTED]
 Received: Thursday, 12 June, 2008, 1:28 PM
 Hi,
 
 With the following codes, I attempt to convert
 the data.frame into a matrix.
 
 However I notice that data.matrix function doesn't
 seem to work.
 
 __ BEGIN__
 dat - read.table(mydata, comment.char =
 ! , na.strings = null);
 # Select n-genes by random sample
 # n = 1
 nosamp - 1
 geneid - sequence(nrow(dat))
 geneid.samp - sample(geneid,nosamp)
 geneid.samp
 
 gexp- dat[geneid.samp,]
 gexp.arr - data.matrix(gexp, rownames.force = NA)
 print(is.matrix(gexp.arr))
 print(gexp.arr)
 
 __END__
 
 Yielding this output:
 
 __BEGIN__
   print(is.matrix(gexp.arr))
 [1] TRUE
   print(gexp.arr)
 V1 V2V3V4V5V6V7V8
 10354 803.1 1107.8 431.6 349.8 386.7 646.3 744.2 620.9
 __END__
 
 I expect gexp.arr to be a plain vector
 (numeric).
 What's wrong with my code above?
 
 
 
 
 
 -- 
 Gundala Viswanath
 Jakarta-Indonesia
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >