[R] Re : 财务心声。

2007-09-12 Thread justin bem
So you expect answer to  your post ! hum
 
Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246

- Message d'origine 
De : 宝华工业 <[EMAIL PROTECTED]>
À : r-help <[EMAIL PROTECTED]>
Envoyé le : Jeudi, 13 Septembre 2007, 5h26mn 23s
Objet : [R] 财务心声。

  TO:财务部收!

  尊敬的公司、厂家财务你好:

   
本公司深圳一家大型企业,与全国各地众多公司有密切业务往来
  
  
现因进项较多有余额发/票,可为贵公司(厂)以较低税率代开
  全国各地部分下例发/票:

 
〈1〉普通国税发/票为商品销售(包含所有行业的商品)。
 〈2〉普通地税发/票为建筑、安装、广告、设计、运输、 
  信息、咨询、培训、劳务、住宿等其它服务行业 。   
 〈3〉公司承诺:受理谨慎 成功收费 
,保证随时查询,验证、先验证后付款, 
  
  如贵公司在税务低扣,做帐或进销存方面 
如需用到的话,
  欢迎来电或留言咨询.我们会在第一时间回复您

联系人:许文祥手 机: 135 381 99800

业 务QQ:546843050邮 箱: [EMAIL PROTECTED]
  
   顺祝商祺!








  
_ 

l 
[[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] barplot border width

2007-09-12 Thread John Lande
I need to increase the width of the border in a barplot, i checked both
barplot, and barplot2, but cant find how to do it. how can I do?


thank you


john

[[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] stastistical test on normalized data

2007-09-12 Thread Simone Pifferi
I performed experiments to analyse the effect of 2 different drugs of my 
preparations.
The designs od the experiment is the following:
on 11 preparations I tested the effect of drug 1
and on another 5 preparation I tested the second drug
So the I calculated the % of the effect of the drugs respect to the control 
condictions\
What type of statistical test can I use to verify if the effect of the drug 
is different or not?
Can I use the ANOVA??

These are the data

 

Control  drug 1   

  0.49
 0.29
 
  0.29
 0.08
 
  0.32
 0.07
 
  0.32
 0.06
 
  0.32
 0.14
 
  0.59
 0.18
 
  0.74
 0.13
 
  1.2
 0.25
 
  0.45
 0.15
 
  0.28
 0.06
 
  0.54
 0.04
 

 

Control drug 2

  0.32
 0.12
 
  0.73
 0.36
 
  0.3
 0.08
 
  0.36
 0.14
 

 

Son the normalized data are

Effect of drug1effect drug2

  59.183673
 37.5
 
  27.586207
 49.315068
 
  21.875
 26.67
 
  18.75
 38.89
 
  43.75
  
 
  30.508475
  
 
  17.567568
  
 
  20.83
  
 
  33.33
  
 
  21.428571
  
 
  7.4074074
  
 

 

Thanks

Simone


[[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] Call C code from R

2007-09-12 Thread Olga K. Kamneva
Hello, All!

I have function which is written in C, the function uses other functions
also builded bu me. Now I need to use the function to build R function.
My questions are:
1. How can I include libraries (for example, iomanip, sstream, tcl.h)?
2. Should I put other function to the separate file and then include the
file?

Thanks All :)
Olga

[[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] reshape help

2007-09-12 Thread Peter Dalgaard
Ross Darnell wrote:
>   
>   
> Yup. 2.6.0 will also allow this simplified variant:
>
>  > reshape(mydat, direction="long", varying=3:8, sep="")
>  tree serra time  bt   mm id
> 1.1 1 11 101 9101  1
> 2.1 2 11 102 9102  2
> 3.1 3 11 103 9103  3
>   

[Ross D] 

That's neat but how did the function recognize the difference between the 3:5 
and 6:8 structure?

Ross Darnell

(Ross: Your emailer put your reply into my original signature, making it 
unquotable without cut&paste. Don't do that)

It looks at the variable names (the current version can do that as well, 
but the case where the separator is not a dot is less easy to specify).

-- 
   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] Running R file from Command line.

2007-09-12 Thread chenxh007
For example, you can use:

R CMD BATCH mean.R mean.Rout

Xiaohui

Vaibhav Gathibandhe wrote:
> Hi all,
> 
> Is there any way through which i can run a R file from Command line.
> 
> For example
> 
>> r mean.R
> 
> Thanks and Regards,
> Vaibhav Gathibandhe
> 
>   [[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] 财务心声。

2007-09-12 Thread 宝华工业
  TO:财务部收!

  尊敬的公司、厂家财务你好:

   本公司深圳一家大型企业,与全国各地众多公司有密切业务往来  
  现因进项较多有余额发/票,可为贵公司(厂)以较低税率代开
  全国各地部分下例发/票:

 〈1〉普通国税发/票为商品销售(包含所有行业的商品)。
 〈2〉普通地税发/票为建筑、安装、广告、设计、运输、 
  信息、咨询、培训、劳务、住宿等其它服务行业 。   
 〈3〉公司承诺:受理谨慎 成功收费 ,保证随时查询,验证、先验证后付款, 
  
  如贵公司在税务低扣,做帐或进销存方面 如需用到的话,
  欢迎来电或留言咨询.我们会在第一时间回复您

联系人:许文祥手 机: 135 381 99800

业 务QQ:546843050邮 箱: [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] Problem using xtable on an array

2007-09-12 Thread Peter Dunn
Hi all

I know about producing a minimal example to show my problem.  But I'm
having trouble producing a minimal example that displays this
behaviour, so please bear with me to begin with.


Observe:  I create an array called model.mat.  Some details on this:

> str(model.mat)
 num [1:18, 1:4] -0.170 -0.304 -2.617  2.025 -1.610 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:18] "Amount: CP for VF" "Amount: CP for F" "Amount: CP for 
M" "Amount: RD for VF" ...
  ..$ : chr [1:4] "beta_0" "P-value" "beta_1" "P-value"


It contains the following:

> model.mat[1:2,]
  beta_0   P-valuebeta_1  P-value
Amount: CP for VF -0.1702877 0.7716153 0.5148616 2.020602e-03
Amount: CP for F  -0.3042522 0.1966133 0.8795982 6.058299e-12



That's fine.  Now to produce a LaTeX table using xtable,
I get:

> xtable(model.mat[1:2,])

  Amount: CP for VF & $-$0.17 & 0.77 & 0.51 & 0.77 \\
  Amount: CP for F & $-$0.30 & 0.20 & 0.88 & 0.20 \\


That is, the final column does *not* correspond to the final
column of model.mat itself.  It is actually column 2 repeated.

What's going on?  If I try repeating on a minimal type example,
xtable works as expected:


> fred <- array( seq(1,18*4), dim=c(18,4))
> fred[1:2, ]
 [,1] [,2] [,3] [,4]
[1,]1   19   37   55
[2,]2   20   38   56
> xtable(fred[1:2, ])
% latex table generated in R 2.5.0 by xtable 1.4-6 package
% Thu Sep 13 14:09:46 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{r}
  \hline
 & 1 & 2 & 3 & 4 \\
  \hline
1 &   1 &  19 &  37 &  55 \\
  2 &   2 &  20 &  38 &  56 \\
   \hline
\end{tabular}
\end{center}
\end{table}


So it is not a generic problem. But what could it be?  I can't decide
where to look, so find a solution or produce a minimal example to display
this behaviour.  I actually use this construct with xtable a lot, so
it disturbs me to find this error... which is probably is something
I am doing.



The problem exists for a smaller subsets of this array also; let's take
columns 2, 3 and 4 only:

> model.mat[1:2,2:4]
P-valuebeta_1  P-value
Amount: CP for VF 0.7716153 0.5148616 2.020602e-03
Amount: CP for F  0.1966133 0.8795982 6.058299e-12
> xtable(model.mat[1:2,2:4])
% latex table generated in R 2.5.0 by xtable 1.4-6 package
% Thu Sep 13 14:04:40 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{}
  \hline
 & P-value & beta\_1 & P-value \\
  \hline
Amount: CP for VF & 0.77 & 0.51 & 0.77 \\
  Amount: CP for F & 0.20 & 0.88 & 0.20 \\
   \hline
\end{tabular}
\end{center}
\end{table}


Is it a problem with my particular array  model.mat  or something
I am doing wrong/silly?  I don't know where to start.

Thanks all, as always.

P.

> sessionInfo()
R version 2.5.0 (2007-04-23)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
car  xtable statmod
"1.2-1" "1.4-6" "1.3.0"



-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidential an...{{dropped}}

__
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] Running R file from Command line.

2007-09-12 Thread Vaibhav Gathibandhe
Hi all,

Is there any way through which i can run a R file from Command line.

For example

> r mean.R

Thanks and Regards,
Vaibhav Gathibandhe

[[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] Someone Using Java/R Interface--- JRI ?

2007-09-12 Thread Vaibhav Gathibandhe
Hi all,

I am writing R code and I want to interface with JAVA i.e. I want to call R
from JAVA. That's why i have installed JRI on my machine.

There is also documentation available in "Javadoc".

But as i am  very new to JAVA and well as R, I don't understand much of it.

If someone is using this package i.e. JRI, please let me know whether i am
going in right direction or not.

As i am using regressions, Boot library etc. in my R codes. Is it possible
to use all these if i use JRI package?

[[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] Nested anova with unbalanced design and corrected sample size for spatial autocorrelation

2007-09-12 Thread Ben Bolker
   


Francesc Montan�  ctfc.es> writes:

> 
> 
> Hello all,
> 
> This may be a simple question to answer, but I'm a little bit stumped with
> respect to the calculation of the F statistics in nested  anovas with
> unbalanced design in R.


  I would strongly recommend getting a copy of Pinheiro and
Bates (2000) and going through it.  aov() is out of the question, and it's
probably better to incorporate spatial correlation
directly in the model than to adjust degrees of freedom
to account for it.

  good luck,
 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.


[R] Multivariate, multilevel regression?

2007-09-12 Thread John McHenry
Dear WizaRds,

This is mostly a statistics question, but I'm figuring that R is the right 
solution (even before I start!)

I have some bio data of heart rate versus time (rats taken from resting to 
maximal heart rate). I want to regress heart rate on time. The data have been 
normalized such that resting heart rate is zero at time=0, so that all curves 
intersect at the origin (and at the origin only). The regression function is 
monotonically increasing, but little is known about it.

The data are also strictly ordinal: I have a factor such that lower-order data 
*must* be on a curve that is offset beneath a higher-order curve. Don't ask 
where the factors come from...but *given* these factors the assumption, or 
rather the *constraint*, is that lower orders are better (lower-order rats are 
fitter rats with better cardiovascular response). Most important is that these 
curves do not intersect because of these factors (a fitter rat can not have a 
worse heart-rate 
response than a less fit rat!).

Here's a schematic to show you what I mean. It's very rough, but it gets the 
point across:

seq(0, 1, len=100)
f<- 1/seq(.3,1,len=6)
windows(); 
plot(t, sqrt(3*t), type='n', xlab='time', ylab='heart rate'); 
grid()
for (i in seq(along=f)) 
lines(t, sqrt(f[i]*t), col=ceiling(2*i))


Now I'm wondering where I should start and I'm think that this is really not 
much different from having a y_i ~ x_i | factor_i ... the i^th response curve 
just like a dummy variable male/female linear regression. But in some way the 
factors are related (there's a dose behind it, if ya see what I mean), so they 
are not independent...they're all part of a "system" (some studies have more 
"juice" overall, so the whole "system" is varying from one group of rats to the 
next).
This means that in some "systems" the curves will be closer or some curves 
within the system will be closer together.

Here is my question for you guys: what is the best way to model this kind of 
problem, especially given that each "i^th curve" could have as few as 3 data 
points? If I can only vaguely assume the type of the regression function 
(monotonic, rapidly increasing from the origin kind of like sqrt(t), as above)
should it be a parametric or nonparametric regression? What about those errors? 
Gee! It's hard to assume anything (there're so few of 'em and they're probably 
heteroskedastic!

Where do I begin? I'd gladly accept all references, pointers, and such like.

Best, and thanks for R and R-Help, all you Core guys!!!

Jack.

   
-

[[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] reshape help

2007-09-12 Thread François Pinard
[Ross Darnell]

>>> I'm trying to use reshape but I cannot quite understand how it 
>>> works.

>Yup. 2.6.0 will also allow this simplified variant:

> > reshape(mydat, direction="long", varying=3:8, sep="")
> > [...]

Hi, people.  Have "melt" and "cast" (from the "reshape" package) ever 
been considered for integration in R "stats" package (or any convenient 
standardly distributed package)?  They gave me the impression of being 
neatly specified, and presumably useful for many of us.

-- 
François Pinard   http://pinard.progiciels-bpi.ca

__
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: to view the memory

2007-09-12 Thread Henrik Bengtsson
For listings, you have ls(), ls.str(), and also ll() in R.oo, e.g.

> library(R.oo)
R.oo v1.3.0 (2006-08-29) successfully loaded. See ?R.oo for help.

> data(USArrests)
> data(lynx)
> data(Nile)
> data(iris3)
> data(iris)
> data(euro)

> ls()
[1] "euro"   "euro.cross" "iris"   "iris3"
[5] "lynx"   "Nile"   "USArrests"

> ls.str()
euro :  Named num [1:11]  13.76  40.34   1.96 166.39   5.95 ...
euro.cross :  num [1:11, 1:11] 1. 0.3411 7.0355 0.0827 2.3143
iris : 'data.frame':150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1
1 ...
iris3 :  num [1:50, 1:4, 1:3] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9
lynx :  Time-Series [1:114] from 1821 to 1934:  269  321  585  871
Nile :  Time-Series [1:100] from 1871 to 1970: 1120 1160 963 1210
1230 1370 1140 ...
USArrests : 'data.frame':   50 obs. of  4 variables:
 $ Murder  : num  13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...
 $ Assault : int  236 263 294 190 276 204 110 238 335 211 ...
 $ UrbanPop: int  58 48 80 50 91 78 77 72 80 60 ...
 $ Rape: num  21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8

> ll()
  member data.class dimension objectSize
1   euronumeric11632
2 euro.cross matrix  c(11,11)   2016
3   iris data.frame  c(150,5)   6424
4  iris3  array c(50,4,3)   5368
5   lynx ts   114   1168
6   Nile ts   100   1056
7  USArrests data.frame   c(50,4)   3824

Cheers

Henrik

On 9/12/07, Bert Gunter <[EMAIL PROTECTED]> wrote:
> You probably should be inserting browser() calls into your function instead
> -- once there you can list and examine all variables at whatever state your
> function is in. (and debugging is specifically what browser() was designed
> for).
>
> See ?browser()
>
>
> Bert Gunter
> Genentech Nonclinical Statistics
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, September 11, 2007 7:02 PM
> To: r-help@r-project.org
> Subject: [R] R: to view the memory
>
> Hello,
>
> I am wondering if it is possible to view what variables and vairable
> values are stored in the R memory. This to enable debugging of R-scripts
> I write.
>
> 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.
>
> __
> 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] reshape help

2007-09-12 Thread Ross Darnell


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard
Sent: Thursday, 13 September 2007 7:02 AM
To: Chuck Cleland
Cc: R-help; juli pausas
Subject: Re: [R] reshape help

Chuck Cleland wrote:
> juli pausas wrote:
>   
>> Hi,
>> I'm trying to use reshape but I cannot quite understand how it works.
>> Could somebody help me on this? Example, my data is something like:
>>
>> mydat <- data.frame(tree= 1:10, serra=rep(1:2, c(5,5)), bt01= 101:110,
>> bt02= 201:210, bt03= 301:310,  mm01= 9101:9110, mm02= 9201:9210, mm03=
>> 9301:9310)
>>
>> 
>>> mydat
>>>   
>>tree serra bt01 bt02 bt03 mm01 mm02 mm03
>> 1 1 1  101  201  301  9101  9201  9301
>> 2 2 1  102  202  302  9102  9202  9302
>> 3 3 1  103  203  303  9103  9203  9303
>> 4 4 1  104  204  304  9104  9204  9304
>> 5 5 1  105  205  305  9105  9205  9305
>> 6 6 2  106  206  306  9106  9206  9306
>> 7 7 2  107  207  307  9107  9207  9307
>> 8 8 2  108  208  308  9108  9208  9308
>> 9 9 2  109  209  309  9109  9209  9309
>> 10   10 2  110  210  310  9110  9210  9310
>>
>> that is, in the "wide form" with 2 constant variables (tree, serra)
>> and 6 variables that correspond to two variables (bt mm) measured in 3
>> years 01, 02, 03
>>
>> I would like to reshaped the data to the long format as follows:
>>
>>   tree serra   YEAR   bt   mm
>>  1 12001   101   9101
>>  2 12001   102   9102
>>  3 12001   103   9103
>>  4 12001   104   9104
>>  5 12001   105   9105
>>  6 22001   106   9106
>>  7 22001   107   9107
>>  8 22001   108   9108
>>  9 22001   109   9109
>> 10 22001   110   9110
>>  1 12002   201   9201
>>  2 12002   202   9202
>>  3 12002   203   9203
>>  4 12002   204   9204
>>  5 12002   205   9205
>>  6 22002   206   9206
>>  7 22002   207   9207
>>  8 22002   208   9208
>>  9 22002   209   9209
>> 10 22002   210   9210
>>  1 12003   301   9301
>>  2 12003   302   9302
>>  3 12003   303   9303
>>  4 12003   304   9304
>>  5 12003   305   9305
>>  6 22003   306   9306
>>  7 22003   307   9307
>>  8 22003   308   9308
>>  9 22003   309   9309
>> 10 22003   310   9310
>>
>> I would appreciate if somebody let me know how could I do this with reshape
>> 
>
> reshape(mydat, varying = list(c("bt01","bt02","bt03"),
>   c("mm01","mm02","mm03")),
>v.names=c("bt","mm"),
>timevar = "YEAR",
>times = c(2001, 2002, 2003),
>idvar = "tree",
>direction = "long")
>   
Yup. 2.6.0 will also allow this simplified variant:

 > reshape(mydat, direction="long", varying=3:8, sep="")
 tree serra time  bt   mm id
1.1 1 11 101 9101  1
2.1 2 11 102 9102  2
3.1 3 11 103 9103  3
4.1 4 11 104 9104  4
5.1 5 11 105 9105  5
6.1 6 21 106 9106  6
7.1 7 21 107 9107  7
8.1 8 21 108 9108  8
9.1 9 21 109 9109  9
10.1   10 21 110 9110 10
1.2 1 12 201 9201  1
2.2 2 12 202 9202  2
3.2 3 12 203 9203  3
4.2 4 12 204 9204  4
5.2 5 12 205 9205  5
6.2 6 22 206 9206  6
7.2 7 22 207 9207  7
8.2 8 22 208 9208  8
9.2 9 22 209 9209  9
10.2   10 22 210 9210 10
1.3 1 13 301 9301  1
2.3 2 13 302 9302  2
3.3 3 13 303 9303  3
4.3 4 13 304 9304  4
5.3 5 13 305 9305  5
6.3 6 23 306 9306  6
7.3 7 23 307 9307  7
8.3 8 23 308 9308  8
9.3 9 23 309 9309  9
10.3   10 23 310 9310 10



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


[Ross D] 

That's neat but how did the function recognize the difference between the 3:5 
and 6:8 structure?

Ross Darnell
__
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, minim

Re: [R] trouble with installing Biobase package

2007-09-12 Thread Martin Morgan
Hi Tena -- Please use the Bioconductor mailing list for Bioconductor
questions.

You need to update your development version of R to the prerelease
version (provide the output of sessionInfo() with problem reports).

Martin

"Tena Sakai" <[EMAIL PROTECTED]> writes:

> Hi Everybody,
>
> I am having a problem with loading Biobase package.  I typed
> 2 lines below at R prompt
>
>  > source ("http://boconductor.org/biocLite.R";)
>  > biocLite (lib="/usr/local/lib/R/library")
>
> which attempted to install a bunch of packages with varying
> degree of success.  Out of 29, 13 failed.  Biobase is one of
> them.  As a matter of fact, when I looked at logs, most other
> failures seemed due to the fact Biobase not being there.  So,
> why is Biobase failing to compile?  Here's the complaint:
>
>  * Installing *source* package 'Biobase' ...
>  ** libs
>  gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
> -I/usr/local/include-fpic  -g -O2 -c anyMissing.c -o anyMissing.o
>  gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
> -I/usr/local/include-fpic  -g -O2 -c envir.c -o envir.o
>  gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
> -I/usr/local/include-fpic  -g -O2 -c matchpt.c -o matchpt.o
>  gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
> -I/usr/local/include-fpic  -g -O2 -c Rinit.c -o Rinit.o
>  gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
> -I/usr/local/include-fpic  -g -O2 -c rowMedians.c -o rowMedians.o
>  gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
> -I/usr/local/include-fpic  -g -O2 -c sublist_extract.c -o 
> sublist_extract.o
>  gcc -std=gnu99 -shared -L/usr/local/lib64 -o Biobase.so anyMissing.o envir.o 
> matchpt.o Rinit.o rowMedians.o sublist_extract.o  
>  ** R
>  ** data
>  ** inst
>  ** preparing package for lazy loading
>  Loading required package: tools
>  Error : could not find function "numeric_version"
>  Error: unable to load R code in package 'Biobase'
>  Execution halted
>  ERROR: lazy loading failed for package 'Biobase'
>  ** Removing '/usr/local/lib/R/library/Biobase'
>
> It is choking at not finding a function "numeric_version".  Has anybody
> seen this before and have any insight to the solution?  I would appreciate
> a bit of helping hand.
>
> The platform I am on is Dell 64-bit server, running redhat enterprise
> server.
>
> Regards,
>
> Tena Sakai
> [EMAIL PROTECTED]
>
>   [[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.

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

__
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] trouble with installing Biobase package

2007-09-12 Thread Tena Sakai
Hi Everybody,

I am having a problem with loading Biobase package.  I typed
2 lines below at R prompt

 > source ("http://boconductor.org/biocLite.R";)
 > biocLite (lib="/usr/local/lib/R/library")

which attempted to install a bunch of packages with varying
degree of success.  Out of 29, 13 failed.  Biobase is one of
them.  As a matter of fact, when I looked at logs, most other
failures seemed due to the fact Biobase not being there.  So,
why is Biobase failing to compile?  Here's the complaint:

 * Installing *source* package 'Biobase' ...
 ** libs
 gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c anyMissing.c -o anyMissing.o
 gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c envir.c -o envir.o
 gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c matchpt.c -o matchpt.o
 gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c Rinit.c -o Rinit.o
 gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c rowMedians.c -o rowMedians.o
 gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c sublist_extract.c -o sublist_extract.o
 gcc -std=gnu99 -shared -L/usr/local/lib64 -o Biobase.so anyMissing.o envir.o 
matchpt.o Rinit.o rowMedians.o sublist_extract.o  
 ** R
 ** data
 ** inst
 ** preparing package for lazy loading
 Loading required package: tools
 Error : could not find function "numeric_version"
 Error: unable to load R code in package 'Biobase'
 Execution halted
 ERROR: lazy loading failed for package 'Biobase'
 ** Removing '/usr/local/lib/R/library/Biobase'

It is choking at not finding a function "numeric_version".  Has anybody
seen this before and have any insight to the solution?  I would appreciate
a bit of helping hand.

The platform I am on is Dell 64-bit server, running redhat enterprise
server.

Regards,

Tena Sakai
[EMAIL PROTECTED]

[[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] Email Classified Send Over 100000-Pakistani BIZ Email Addresses

2007-09-12 Thread Email Classified Now 1st time in Pakistan!
Monthly!
Sender: "Email Classified Now 1st time in Pakistan!" <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: multipart/related; type="multipart/alternative"; 
boundary="=_NextPart_000_0177DE59_0.557487C2"
Date: Wed, 12 Sep 2007 15:53:57 -0700
Message-ID: <[EMAIL PROTECTED]>
X-Priority: 1 (Highest)
Importance: High

This is a multipart MIME formatted message.

--=_NextPart_000_0177DE59_0.557487C2
Content-Type: multipart/alternative; 
boundary="=_NextPart_000_0177DE59_1.557487C2"

--=_NextPart_000_0177DE59_1.557487C2
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

PAKISTAN 1st E-mail Classified!
Send Over 10-Pakistani Business E-mail Addresses!Advertise your AD here=
 Only Rs.7500/Month
Order Now at 0333-2303103 
Your AD Title here:
Your AD Description here.
 



Contact:
E-mail:Your AD Title here:
Your AD Description here.







Contact:
E-mail:Your AD Title here:
Your AD Description here.







Contact:
E-mail:
Your AD Title here:
Your AD Description here.

 


Contact:
E-mail:
*
Your AD Title here:
Your AD Description here.
 


Contact:
E-mail:
  *
Your AD Title here:
Your AD Description here.





Contact:
E-mail:Why Advertised in Pakistan 1st E-mail Classified?
* E-mail Classified Send Daily Over 3000-Freash  Active Pakistani Business =
E-mail Addresses!
* Real Time Hourly, Daily, Weekly, Monthly & Yearly E-mail Reading Log repo=
rt!
* We Only Accept Business, Education, Entertainment, Technical, Jobs, Real =
Estate, Travel Agencies Ads.
* We have Right to Reject any AD any Time with or without any Reasons.
* No E-mail Response Guaranteed!
* Offered Only Valid for our Pakistan Subscribers! 
* 100% Advanced Payment Required to Place your AD Here.
* We Accept Payment Through Bank Transfer Only.
Your AD Title here:
Your AD Description here.




Contact:
E-mail:Your AD Title here:
Your AD Description here.




Contact:
E-mail: 
Your AD Title here:
Your AD Description here.




Contact:
E-mail: Your AD Title here:
Your AD Description here.




Contact:
E-mail:  
Pakistan 1stE-mail Classified! For Placing your AD here Please Call/SMS at =
0333-2303103(24-Hour & Sunday Open!). 
If you wish to cancel your subscription to Pakistan 1st E-mail Classified P=
lease click here

--=_NextPart_000_0177DE59_1.557487C2
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



Pakistan 1st E-mail Classified







  
  

=09PAKIST=
AN 1st 
=09E-mail Classified!
=09Send Over 10-Pakistani 
=09Business E-mail Addresses!

=09Advertise your AD here Only Rs.7500/Month
  Order Now at 0333-2303103=

=09
  
=09
  =09
=09Your AD Title here:
Your AD Description here.
  
=09
=09
=09Contact:
=09E-mail:
=

=09Your AD Title here:
Your AD Description here.
=09
=09
=09
=09
=09
=09
=09
=09Contact:
=09E-mail:

  Your AD Title he=
re:
Your AD Description here.
=09=09
=09=09
=09=09
=09=09
=09=09
=09=09
=09=09
=09=09Contact:
=09=09E-mail:
  
=09

=09
  Your AD Title h=
ere:
=09Your AD Description here.
=09=09=09
 
=09=09=09
=09=09=09Contact:
=09=09=09E-mail:
    *
=09=09=09Your AD Title here:
=09Your AD Description here.
 
=09=09=09 
=09=09=09
=09=09=09Contact:
=09=09=09E-mail:
=09=09=09&n=
bsp; 
=09=09=09*
=09=09=09Your AD Title here:
=09Your AD Description here.
=09=09=09
=09=09=09
=09=09=09
=09=09=09
=09=09=09
=09=09=09Contact:
=09=09=09E-mail:
 
=09Why Advertised in Pakistan 1st E-mail Classified?
=09* E-mail Classified Send Daily Over 3000-Freash  Active 
=09Pakistani Business E-mail Addresses!
=09* Real Time Hourly, Daily, Weekly, Monthly & Yearly E-mail Reading L=
og 
=09report!
=09* We Only Accept Business, Education, Entertainment, Technical, Jobs, Re=
al 
=09Estate, Travel Agencies Ads.
=09* We have Right to Reject any AD any Time with or without any Reasons.
=09* No E-mail Response Guaranteed!
=09* Offered Only Valid for our Pakistan Subscribers! 
=09* 100% Advanced Payment Required to Place your AD Here.
=09* We Accept Payment Through Bank Transfer Only.

=09

=09Your AD Title here:
Your AD 

Re: [R] "Save to File..." option on File menu

2007-09-12 Thread Muenchen, Robert A (Bob)
Hi Talbot,

I just had that question a couple of weeks ago. Here's the thread:

RSiteSearch("Saving results from Linux command line")

Thomas Lumley concluded with:

There could still be functions that divert a copy of all the output to a
file, for example. And indeed there are.

sink("transcript.txt", split=TRUE)

And you're right, you do this at the start, or put it in your .Rprofile
so you don't have to remember it each time. The UNIX tee command does
this as well.

Cheers,
Bob

=
Bob Muenchen (pronounced Min'-chen), Manager 
Statistical Consulting Center
U of TN Office of Information Technology
200 Stokely Management Center, Knoxville, TN 37996-0520
Voice: (865) 974-5230 
FAX: (865) 974-4810
Email: [EMAIL PROTECTED]
Web: http://oit.utk.edu/scc, 
News: http://listserv.utk.edu/archives/statnews.html
=


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Talbot Katz
> Sent: Wednesday, September 12, 2007 3:05 PM
> To: [EMAIL PROTECTED]
> Subject: [R] "Save to File..." option on File menu
> 
> Hi.
> 
> There was an interesting thread about a year ago, called  'Command
> equivalent of rgui "File, Save to File"?'
> (http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0553.html) started by
> Michael Prager, and contributed to by Duncan Murdoch (I didn't notice
> anything beyond the four entries they posted).  The question was how
to
> replicate programmatically the "Save to File..." option on the File
> menu.
> The closest answers given involved either running in batch or using
the
> sink() command.  Perhaps I don't understand the sink() command well
> enough,
> but it appears to me that you have to set it up before you run
> commands, and
> that it can't be used to save command output from commands that were
> already
> run; am I right about this?  Whereas the "Save to File..." command
> scoops up
> everything that's still in the console.  Here is my problem.  I am
> running R
> on Linux in a VNC window.  I'd like to save my console output, but
> there
> doesn't appear to be a File menu available and I didn't start out with
> the
> sink() command.  Is there any way to replicate "Save to File..." in
> this
> situation?  Thanks!
> 
> --  TMK  --
> 212-460-5430  home
> 917-656-5351  cell
> 
> __
> 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] New Course*** R / S-Plus Graphics for SAS Users --- October 2007

2007-09-12 Thread elvis Miller
XLSolutions is proud to announce a new 2-day R / S-plus course:

   R/S-Plus Graphics for SAS Users

* San Francisco,   October  25-26, 2007
* Seattle, October  29-30, 2007
* Philadelphia,October  29-30, 2007

Should we bring this class to your city?

This 2-day intensive graphics course for SAS users introduces the basics
of R/S-Plus syntax and focuses on R/S-plus graphics. The course covers
in detail R/S-Plus traditional graphics functions and advanced graphics
topics such as trellis. Attendees will get a strong foundation for
becoming  versatile R/ S-plus graphics programmers.

- Introduction to R / S-plus
- R/S Syntax, Comparison to SAS Data Step and SAS IML
- Running R/ S-plus in Batch Mode
- Overview of R/ S-plus Graphics
- Low and High-level Graphics Functions
- Basic Plotting functions and Graphics Functions for Higher-dimensional
Data
- Enhancing Plots and Generating Multiple Figures on one Plot
- Fine Control of Graphics / Controlling the Appearance of Plots
- Trellis (Lattice) Graphics 
- Tricks and Troubleshooting
- Computer Lab Exercises Based on sample SAS graphs 
- Cutting edge R graphics packages: Rgraphiz, Iplot.

 Payment due AFTER the class
 Email us for group discounts.
 Email Sue Turner: [EMAIL PROTECTED]
 Phone: 206-686-1578
 Visit us: www.xlsolutions-corp.com/courselist.htm
 Please let us know if you and your colleagues are interested in this
 class to take advantage of group discount. Register now to secure your
 seat!
 
 Cheers,
 Elvis Miller, PhD
 Manager Training.
 XLSolutions Corporation
 206 686 1578
 www.xlsolutions-corp.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] convergence error with heidel.diag

2007-09-12 Thread Anthony Pezzola
I received the following error after running:


 > heidel.diag(posterior, eps=0.1, pvalue=0.05)
Error in glm.fit(x = X, y = Y, weights = weights, start = start, 
etastart = etastart,  :
inner loop 1; cannot correct step size
In addition: There were 21 warnings (use warnings() to see them)
 > test.diag <- heidel.diag(posterior, eps=0.1, pvalue=0.05)
Error in glm.fit(x = X, y = Y, weights = weights, start = start, 
etastart = etastart,  :
inner loop 1; cannot correct step size
In addition: There were 21 warnings (use warnings() to see them)
 > warnings()
Warning messages:
1: algorithm did not converge in: glm.fit(x = X, y = Y, weights = 
weights, start = start, etastart = etastart,   ...
#

posterior was generated using:

#
 > posterior <-MCMCirt1d(mydata, theta.fixed =1, burnin=35000, 
mcmc=75000, thin=300)
#

Is a chain of 250 simply too short for heidel.diag to work with?  If so 
how long should it be?

Thanks in advance,
Anthony

-- 
_
Anthony Pezzola
Visiting Assistant Professor
Department of Political Science
Reed College
503.517.7656

__
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] Flaw in the installation procedure ?

2007-09-12 Thread Maura E Monville
R printed out the following error messages during the installation of the
package "clusterfly":


> *install.packages("clusterfly", repos = getOption("repos"),dependencies
=TRUE)
*--- Please select a CRAN mirror for use in this session ---
trying URL '
http://umfragen.sowi.uni-mainz.de/CRAN/bin/windows/contrib/2.5/clusterfly_0.2.2.zip
'
Content type 'application/zip' length 141793 bytes
opened URL
downloaded 138Kb

package 'clusterfly' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\mmonville\Local
Settings\Temp\Rtmpj8JFsb\downloaded_packages
updating HTML package descriptions
> help(clusterfly)
No documentation for 'clusterfly' in specified packages and libraries:
you could try 'help.search("clusterfly")'
> library(clusterfly)
Loading required package: rggobi
Loading required package: RGtk2
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'C:/DOCUME~1/MMONVI~1/MYDOCU~1/R/R-25~1.1/library/rggobi/libs/rggobi.dll':
  LoadLibrary failure:  The specified module could not be found.


Error in fun(...) : Could not load the rggobi library - please ensure GGobi
is on the library path
Error : .onLoad failed in 'loadNamespace' for 'rggobi'
Error: package 'rggobi' could not be loaded
Eventually an error-message window popped up reading:
"RGui: RGui.exex - Uable To Locate Component
This application failed to start because libggobi-0.dll was not found.
Re-installig the aplication may fix this problem"

Any idea what is going on ?
Thank you in advance.

Maura


-- 
Maura E.M

[[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] reshape help

2007-09-12 Thread Peter Dalgaard
Chuck Cleland wrote:
> juli pausas wrote:
>   
>> Hi,
>> I'm trying to use reshape but I cannot quite understand how it works.
>> Could somebody help me on this? Example, my data is something like:
>>
>> mydat <- data.frame(tree= 1:10, serra=rep(1:2, c(5,5)), bt01= 101:110,
>> bt02= 201:210, bt03= 301:310,  mm01= 9101:9110, mm02= 9201:9210, mm03=
>> 9301:9310)
>>
>> 
>>> mydat
>>>   
>>tree serra bt01 bt02 bt03 mm01 mm02 mm03
>> 1 1 1  101  201  301  9101  9201  9301
>> 2 2 1  102  202  302  9102  9202  9302
>> 3 3 1  103  203  303  9103  9203  9303
>> 4 4 1  104  204  304  9104  9204  9304
>> 5 5 1  105  205  305  9105  9205  9305
>> 6 6 2  106  206  306  9106  9206  9306
>> 7 7 2  107  207  307  9107  9207  9307
>> 8 8 2  108  208  308  9108  9208  9308
>> 9 9 2  109  209  309  9109  9209  9309
>> 10   10 2  110  210  310  9110  9210  9310
>>
>> that is, in the "wide form" with 2 constant variables (tree, serra)
>> and 6 variables that correspond to two variables (bt mm) measured in 3
>> years 01, 02, 03
>>
>> I would like to reshaped the data to the long format as follows:
>>
>>   tree serra   YEAR   bt   mm
>>  1 12001   101   9101
>>  2 12001   102   9102
>>  3 12001   103   9103
>>  4 12001   104   9104
>>  5 12001   105   9105
>>  6 22001   106   9106
>>  7 22001   107   9107
>>  8 22001   108   9108
>>  9 22001   109   9109
>> 10 22001   110   9110
>>  1 12002   201   9201
>>  2 12002   202   9202
>>  3 12002   203   9203
>>  4 12002   204   9204
>>  5 12002   205   9205
>>  6 22002   206   9206
>>  7 22002   207   9207
>>  8 22002   208   9208
>>  9 22002   209   9209
>> 10 22002   210   9210
>>  1 12003   301   9301
>>  2 12003   302   9302
>>  3 12003   303   9303
>>  4 12003   304   9304
>>  5 12003   305   9305
>>  6 22003   306   9306
>>  7 22003   307   9307
>>  8 22003   308   9308
>>  9 22003   309   9309
>> 10 22003   310   9310
>>
>> I would appreciate if somebody let me know how could I do this with reshape
>> 
>
> reshape(mydat, varying = list(c("bt01","bt02","bt03"),
>   c("mm01","mm02","mm03")),
>v.names=c("bt","mm"),
>timevar = "YEAR",
>times = c(2001, 2002, 2003),
>idvar = "tree",
>direction = "long")
>   
Yup. 2.6.0 will also allow this simplified variant:

 > reshape(mydat, direction="long", varying=3:8, sep="")
 tree serra time  bt   mm id
1.1 1 11 101 9101  1
2.1 2 11 102 9102  2
3.1 3 11 103 9103  3
4.1 4 11 104 9104  4
5.1 5 11 105 9105  5
6.1 6 21 106 9106  6
7.1 7 21 107 9107  7
8.1 8 21 108 9108  8
9.1 9 21 109 9109  9
10.1   10 21 110 9110 10
1.2 1 12 201 9201  1
2.2 2 12 202 9202  2
3.2 3 12 203 9203  3
4.2 4 12 204 9204  4
5.2 5 12 205 9205  5
6.2 6 22 206 9206  6
7.2 7 22 207 9207  7
8.2 8 22 208 9208  8
9.2 9 22 209 9209  9
10.2   10 22 210 9210 10
1.3 1 13 301 9301  1
2.3 2 13 302 9302  2
3.3 3 13 303 9303  3
4.3 4 13 304 9304  4
5.3 5 13 305 9305  5
6.3 6 23 306 9306  6
7.3 7 23 307 9307  7
8.3 8 23 308 9308  8
9.3 9 23 309 9309  9
10.3   10 23 310 9310 10



-- 
   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] how to make an orthogonal contrasts matrix?

2007-09-12 Thread Richard M. Heiberger
tmp <- c(7,7,7,7, -4,-4,-4,-4,-4,-4,-4)
tmpf <- factor(letters[1:11])
tmpf
contrasts(tmpf)
contrasts(tmpf) <- tmp
contrasts(tmpf)
zapsmall(crossprod(contrasts(tmpf)))

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

2007-09-12 Thread Chuck Cleland
juli pausas wrote:
> Hi,
> I'm trying to use reshape but I cannot quite understand how it works.
> Could somebody help me on this? Example, my data is something like:
> 
> mydat <- data.frame(tree= 1:10, serra=rep(1:2, c(5,5)), bt01= 101:110,
> bt02= 201:210, bt03= 301:310,  mm01= 9101:9110, mm02= 9201:9210, mm03=
> 9301:9310)
> 
>> mydat
>tree serra bt01 bt02 bt03 mm01 mm02 mm03
> 1 1 1  101  201  301  9101  9201  9301
> 2 2 1  102  202  302  9102  9202  9302
> 3 3 1  103  203  303  9103  9203  9303
> 4 4 1  104  204  304  9104  9204  9304
> 5 5 1  105  205  305  9105  9205  9305
> 6 6 2  106  206  306  9106  9206  9306
> 7 7 2  107  207  307  9107  9207  9307
> 8 8 2  108  208  308  9108  9208  9308
> 9 9 2  109  209  309  9109  9209  9309
> 10   10 2  110  210  310  9110  9210  9310
> 
> that is, in the "wide form" with 2 constant variables (tree, serra)
> and 6 variables that correspond to two variables (bt mm) measured in 3
> years 01, 02, 03
> 
> I would like to reshaped the data to the long format as follows:
> 
>   tree serra   YEAR   bt   mm
>  1 12001   101   9101
>  2 12001   102   9102
>  3 12001   103   9103
>  4 12001   104   9104
>  5 12001   105   9105
>  6 22001   106   9106
>  7 22001   107   9107
>  8 22001   108   9108
>  9 22001   109   9109
> 10 22001   110   9110
>  1 12002   201   9201
>  2 12002   202   9202
>  3 12002   203   9203
>  4 12002   204   9204
>  5 12002   205   9205
>  6 22002   206   9206
>  7 22002   207   9207
>  8 22002   208   9208
>  9 22002   209   9209
> 10 22002   210   9210
>  1 12003   301   9301
>  2 12003   302   9302
>  3 12003   303   9303
>  4 12003   304   9304
>  5 12003   305   9305
>  6 22003   306   9306
>  7 22003   307   9307
>  8 22003   308   9308
>  9 22003   309   9309
> 10 22003   310   9310
> 
> I would appreciate if somebody let me know how could I do this with reshape

reshape(mydat, varying = list(c("bt01","bt02","bt03"),
  c("mm01","mm02","mm03")),
   v.names=c("bt","mm"),
   timevar = "YEAR",
   times = c(2001, 2002, 2003),
   idvar = "tree",
   direction = "long")

tree serra YEAR  bt   mm
1.2001 1 1 2001 101 9101
2.2001 2 1 2001 102 9102
3.2001 3 1 2001 103 9103
4.2001 4 1 2001 104 9104
5.2001 5 1 2001 105 9105
6.2001 6 2 2001 106 9106
7.2001 7 2 2001 107 9107
8.2001 8 2 2001 108 9108
9.2001 9 2 2001 109 9109
10.2001   10 2 2001 110 9110
1.2002 1 1 2002 201 9201
2.2002 2 1 2002 202 9202
3.2002 3 1 2002 203 9203
4.2002 4 1 2002 204 9204
5.2002 5 1 2002 205 9205
6.2002 6 2 2002 206 9206
7.2002 7 2 2002 207 9207
8.2002 8 2 2002 208 9208
9.2002 9 2 2002 209 9209
10.2002   10 2 2002 210 9210
1.2003 1 1 2003 301 9301
2.2003 2 1 2003 302 9302
3.2003 3 1 2003 303 9303
4.2003 4 1 2003 304 9304
5.2003 5 1 2003 305 9305
6.2003 6 2 2003 306 9306
7.2003 7 2 2003 307 9307
8.2003 8 2 2003 308 9308
9.2003 9 2 2003 309 9309
10.2003   10 2 2003 310 9310

> Thanks in advance
> 
> Juli 

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

__
R-help@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 make an orthogonal contrasts matrix?

2007-09-12 Thread szhan
Hello, R experts,
I have an 11 levels of a factor A. I am only interested in a constrast  
between first 4 vs rest 7 levels. Is there any command to make an  
orthogonal constrasts matrix given one contrast of interest such as   
7,7,7,7, -4,-4,-4,-4,-4,-4,-4?
Thanks,
Joshua

__
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] Wilcoxon Rank test

2007-09-12 Thread Wolfgang Huber
Dear Omar,

the p-value is the probability that a certain summary statistic U of the 
data takes the value it takes, given that the null-hypothesis is true. 
Your p-value is 0.002, you can compare this to an alpha of your choice, 
and if that alpha were larger, you would come to the decision that the 
null-hypothesis can be rejected.

Best wishes
   Wolfgang

--
Wolfgang Huber  EBI/EMBL  Cambridge UK  http://www.ebi.ac.uk/huber


  Baqueiro ha scritto:
> Greetings, I am trying to perform a Mann-Whitney U test to a pair of
> data series, according to what I have read about R the command to use
> is:
> 
> wilcox.test(data1, data2)
> 
> However I am having trouble interpreting the results:
> ---
> Wilcoxon rank sum test with continuity correction
> 
> data:  Dataset$OTMinR and Dataset$OTMaxW
> W = 460627.5, p-value = 0.001798
> alternative hypothesis: true location shift is not equal to 0
> ---
> 
> According to my understanding the test tests the hypothesis that  the
> two data series are drawn from a single population. And I interpret
> those results, having the p-value 0.001798, that the hypothesis is NOT
> rejected, meaning that there is a high probability that the two
> samples come from the same population. Is that interpretation true?
> 
> Also, I am not sure what is the alpha value of the performed test? is
> it 0.05? or 0.01? is there a way to change it?
> 
> Thank you!
>

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

2007-09-12 Thread juli pausas
Hi,
I'm trying to use reshape but I cannot quite understand how it works.
Could somebody help me on this? Example, my data is something like:

mydat <- data.frame(tree= 1:10, serra=rep(1:2, c(5,5)), bt01= 101:110,
bt02= 201:210, bt03= 301:310,  mm01= 9101:9110, mm02= 9201:9210, mm03=
9301:9310)

> mydat
   tree serra bt01 bt02 bt03 mm01 mm02 mm03
1 1 1  101  201  301  9101  9201  9301
2 2 1  102  202  302  9102  9202  9302
3 3 1  103  203  303  9103  9203  9303
4 4 1  104  204  304  9104  9204  9304
5 5 1  105  205  305  9105  9205  9305
6 6 2  106  206  306  9106  9206  9306
7 7 2  107  207  307  9107  9207  9307
8 8 2  108  208  308  9108  9208  9308
9 9 2  109  209  309  9109  9209  9309
10   10 2  110  210  310  9110  9210  9310

that is, in the "wide form" with 2 constant variables (tree, serra)
and 6 variables that correspond to two variables (bt mm) measured in 3
years 01, 02, 03

I would like to reshaped the data to the long format as follows:

  tree serra   YEAR   bt   mm
 1 12001   101   9101
 2 12001   102   9102
 3 12001   103   9103
 4 12001   104   9104
 5 12001   105   9105
 6 22001   106   9106
 7 22001   107   9107
 8 22001   108   9108
 9 22001   109   9109
10 22001   110   9110
 1 12002   201   9201
 2 12002   202   9202
 3 12002   203   9203
 4 12002   204   9204
 5 12002   205   9205
 6 22002   206   9206
 7 22002   207   9207
 8 22002   208   9208
 9 22002   209   9209
10 22002   210   9210
 1 12003   301   9301
 2 12003   302   9302
 3 12003   303   9303
 4 12003   304   9304
 5 12003   305   9305
 6 22003   306   9306
 7 22003   307   9307
 8 22003   308   9308
 9 22003   309   9309
10 22003   310   9310

I would appreciate if somebody let me know how could I do this with reshape
Thanks in advance

Juli


-- 
http://www.ceam.es/pausas

__
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] Wilcoxon Rank test

2007-09-12 Thread Omar Baqueiro
Greetings, I am trying to perform a Mann-Whitney U test to a pair of
data series, according to what I have read about R the command to use
is:

wilcox.test(data1, data2)

However I am having trouble interpreting the results:
---
Wilcoxon rank sum test with continuity correction

data:  Dataset$OTMinR and Dataset$OTMaxW
W = 460627.5, p-value = 0.001798
alternative hypothesis: true location shift is not equal to 0
---

According to my understanding the test tests the hypothesis that  the
two data series are drawn from a single population. And I interpret
those results, having the p-value 0.001798, that the hypothesis is NOT
rejected, meaning that there is a high probability that the two
samples come from the same population. Is that interpretation true?

Also, I am not sure what is the alpha value of the performed test? is
it 0.05? or 0.01? is there a way to change it?

Thank you!

-- 
Omar Baqueiro Espinosa
Computer Science PhD Candidate
Computer Systems Engineer
Workpage: www.csc.liv.ac.uk/~omar/
HomePage (spanish):http://www.baqueiro.co.uk/
PGP Key available at: www.csc.liv.ac.uk/~omar/pgp.html
_

__
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] Evaluating args in a function

2007-09-12 Thread Alberto Monteiro
Gabor Grothendieck wrote:
>
> You have a recursive reference.  Try using a different name other 
> than class.  For example, in the following we use class. with a dot 
> at the end
> (so that abbreviation of it still allows the user to write class):
> 
One year using R, and I hadn't known that I could abbreviate
function arguments... Thanks for the (accidental) help :-)

Alberto Monteiro

__
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] "Save to File..." option on File menu

2007-09-12 Thread Talbot Katz
Hi.

There was an interesting thread about a year ago, called  'Command 
equivalent of rgui "File, Save to File"?' 
(http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0553.html) started by 
Michael Prager, and contributed to by Duncan Murdoch (I didn't notice 
anything beyond the four entries they posted).  The question was how to 
replicate programmatically the "Save to File..." option on the File menu.  
The closest answers given involved either running in batch or using the 
sink() command.  Perhaps I don't understand the sink() command well enough, 
but it appears to me that you have to set it up before you run commands, and 
that it can't be used to save command output from commands that were already 
run; am I right about this?  Whereas the "Save to File..." command scoops up 
everything that's still in the console.  Here is my problem.  I am running R 
on Linux in a VNC window.  I'd like to save my console output, but there 
doesn't appear to be a File menu available and I didn't start out with the 
sink() command.  Is there any way to replicate "Save to File..." in this 
situation?  Thanks!

--  TMK  --
212-460-5430home
917-656-5351cell

__
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: to view the memory

2007-09-12 Thread Bert Gunter
You probably should be inserting browser() calls into your function instead
-- once there you can list and examine all variables at whatever state your
function is in. (and debugging is specifically what browser() was designed
for).

See ?browser() 


Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, September 11, 2007 7:02 PM
To: r-help@r-project.org
Subject: [R] R: to view the memory

Hello,

I am wondering if it is possible to view what variables and vairable
values are stored in the R memory. This to enable debugging of R-scripts
I write.

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.

__
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] k-means clustering

2007-09-12 Thread Ingmar Visser
Googling for sphericity gives wikipedia as a first link which says:
Sphericity is a measure of how spherical (round) an object is.

The second hit gives the connection with statistics, in particular  
ANOVA,
http://www.linguistics.ucla.edu/faciliti/facilities/statistics/spher.htm

hth, Ingmar

On Sep 12, 2007, at 5:13 PM, <[EMAIL PROTECTED]>  
<[EMAIL PROTECTED]> wrote:

> Dear list, first apologies for this is not strictly an R question but
> a theoretical one.
>
> I have read that use of k-means clustering assumes sphericity of data
> distribution. Can anyone explain me what this means? My statistical
> background is too poor. Is it another kind of distribution, like
> gaussian or binomial? What does it happen if the distribution is not
> spherical? Could you give me an example or a link to information about
> this?
>
> Thanks for your help
>
> David
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] labels into graph

2007-09-12 Thread John Kane
Hi akki,

 What kind of a graph are you trying to draw?  It is
not clear from the posting particularly as it messes
up your spacing.

I would suggest that you have a look at something like
# Using R for Data Analysis and Graphics -
Introduction, Examples and Commentary”  by John
Maindonald .

 “Simple R” by John Verzani 

Both documents are available through the R site. 
Click on 'other' in the list on the left side of the
page.

 


--- akki <[EMAIL PROTECTED]> wrote:

> Hi,
> I have a matrix as:
> ab c
> 21 3
> 22 5
> 25 9
> 
> With values of this matrix, I draw a graph. Each row
> has a different
> meaning. For this reason, I need put different names
> each row. For example:
> 
> mygraph
> ---   ---
> 
> DescriptionA   DescriptionB
> DescriptionC
> 
> -   
>  
> 
>ab   
> c1  c2
> 
> I know it is possible do, but I don'k know how can I
> do it?
> 
> Can anyone help me, please?
> 
> Thanks.
> 
>   [[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] Nested anova with unbalanced design and corrected sample size for spatial autocorrelation

2007-09-12 Thread Francesc Montan

Hello all,

This may be a simple question to answer, but I'm a little bit stumped with
respect to the calculation of the F statistics in nested  anovas with
unbalanced design in R.

In my case, I have 11 vegetation transects (with 1000 10cmx10cm squares),
where we estimated shrub cover. We have two different treatments: wildfire
(4 transects) and prescribed burning (7 transects) and we want to compare
the mean shrub cover between the 2 different treatments. I guess that I
have to apply a one-way nested anova (transect number within treatment)
with unbalanced number of samples (4000 in wildfire vs 7000 in prescribed
burning).
Moreover, I have to correct the initial sample size (1000 squares) to a
corrected sample size by spatial autocorrelation (which in fact, makes all
the n different between transects).

Can anyone, please, tell me how to do this in R? Do I need to use lme()?
Or is it possible to do it using aov()?

Thanks a lot!

Francesc

PhD student
University of Barcelona

__
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] labels into graph

2007-09-12 Thread akki
Hi,
I have a matrix as:
ab c
21 3
22 5
25 9

With values of this matrix, I draw a graph. Each row has a different
meaning. For this reason, I need put different names each row. For example:

mygraph
---   ---

DescriptionA   DescriptionB DescriptionC

- 

   abc1  c2

I know it is possible do, but I don'k know how can I do it?

Can anyone help me, please?

Thanks.

[[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] R: to view the memory

2007-09-12 Thread Matthew Keller
Hi Sumit,

Here are a couple of functions I've picked up along the way and
modified. The first lists all objects, their class, and their
dimensions (I grabbed this from the web and modified - sorry for not
acknowledging the person who first wrote it). The second is much the
same but gives their size. Hope this helps:


##LS
LS<-function (pattern = "")
{

if (length(ls(1,pat=pattern)) <1){stop("No objects are in memory")}

obs <- ls(1, pat = pattern)
cat(
formatC("DIM/LEN"),
formatC("NAME", width=max(nchar(obs)+5)),
formatC("CLASS",width=16),
"\n")


if (length(ls(1,pat="tmp")) >0){

 for (i in 2:length(obs)) {
   widim <- 0
   ww <- eval(parse(t = paste("length(dimx(", obs[i], "))")))
   for (k in 1:ww){
 widim <- eval(parse(t =
paste("length(dimx(",obs[i],"))+widim-2+nchar(dimx(", obs[i],
")[k])")))}

   cat(
eval(parse(t = paste("dimx(", obs[i], ")"))),
formatC(obs[i], width=max(nchar(obs))-widim+10),
formatC(eval(parse(t = paste("class(", obs[i], ")"))),1, 16),
"\n")  }}

else{
   for (i in 1:length(obs)) {
   widim <- 0
   ww <- eval(parse(t = paste("length(dimx(", obs[i], "))")))
   for (k in 1:ww){
 widim <- eval(parse(t =
paste("length(dimx(",obs[i],"))+widim-2+nchar(dimx(", obs[i],
")[k])")))}

   cat(
eval(parse(t = paste("dimx(", obs[i], ")"))),
formatC(obs[i], width=max(nchar(obs))-widim+10),
formatC(eval(parse(t = paste("class(", obs[i], ")"))),1, 16),
"\n")  }}}





##LSIZE
lsize <- function (pattern = "",sort=TRUE)
{

if (length(ls(1,pat=pattern)) <1){stop("No objects are in memory")}

obs <- ls(1, pat = pattern)


sizes <- vector(length=length(obs))
for (i in 1:length(obs)) { sizes[i] <-
eval(parse(t=paste("object.size(", obs[i], ")")))}
sizes <- round(sizes/1048600,2)
if (sort){obs <- obs[order(sizes)]}

cat(formatC("SIZE"),
formatC("NAME", width=max(nchar(obs)+5)),
formatC("CLASS",width=16),
"\n")

for (i in 1:length(obs)) {
   widim <- 0
   ww <- eval(parse(t = paste("length(object.size(", obs[i], "))")))
   for (k in 1:ww){
 widim <- eval(parse(t =
paste("length(object.size(",obs[i],"))+widim-2+nchar(00.00)")))}

   cat(eval(parse(t = paste("round(object.size(", obs[i], ")/1048600,2)"))),
   formatC(obs[i], width=max(nchar(obs))-widim+10),
   formatC(eval(parse(t = paste("class(", obs[i], ")"))),1, 16),
   "\n")  }

   cat(sum(sizes),formatC("***TOTAL***",
width=nchar(sum(sizes))-widim+12),"\n")}




On 9/12/07, Doran, Harold <[EMAIL PROTECTED]> wrote:
> Is this what you want when you say "values". It seems this could be very
> expensive if some of your objects are large matrices, for example. I
> thought the poster meant "size" when he said values since he later
> mentioned memory. If that is the case, you want object.size().
>
>
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of R Help
> > Sent: Wednesday, September 12, 2007 8:28 AM
> > To: [EMAIL PROTECTED]
> > Cc: r-help@r-project.org
> > Subject: Re: [R] R: to view the memory
> >
> > the function ls() will list all the variables currently in the memory.
> >  To get their values, you'll also need to use the parse and
> > eval functions.  Try the following:
> >
> > x = ls()
> > for(i in 1:length(x)){
> > print(x[i])
> > print(eval(parse(text=x[i])))
> > }
> >
> > It's a little crude, but it will do the job.
> >
> > Sam
> > On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > Hello,
> > >
> > > I am wondering if it is possible to view what variables and
> > vairable
> > > values are stored in the R memory. This to enable debugging of
> > > R-scripts I write.
> > >
> > > 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.
> > >
> >
> > __
> > 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.
>


-- 
Matthew C Keller
Postdoctoral Fellow
Virginia Institute for Psychiatric and Behavioral Genetics

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

Re: [R] Evaluating args in a function

2007-09-12 Thread Duncan Murdoch
On 9/12/2007 12:48 PM, Sandy Weisberg wrote:
> Can anyone explain what I'm doing wrong here:
> 
>  > fred <- data.frame()
>  > class(fred)
> [1] "data.frame"
>  > test.fn <- function(x,class=class(x)) {class}
>  > test.fn(fred)
> Error in test.fn(fred) : promise already under evaluation: recursive 
> default argument reference or earlier problems?
> 
> R 2.5.1 on both Windows and SUSE Linux.

As Gabor said, this is a recursive reference.  In order to know whather 
your default value class(x) should evaluate using the local variable 
named class or should go back to the base package, R needs to evaluate 
it. And there's the loop.

Another solution besides Gabor's suggestion of renaming the argument is 
to be explicit that you want the base class() function, e.g.

 > test.fn <- function(x,class=base::class(x)) {class}
 > fred <- data.frame()
 > test.fn(fred)
[1] "data.frame"

Duncan Murdoch

__
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] Tick intervals

2007-09-12 Thread Greg Snow
Do you just want the tick intervals on the axis to be changed? Or do you
want more bars in the histogram itself?

If the latter, then look at the breaks argument to hist.

-- 
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 livia
> Sent: Wednesday, September 12, 2007 10:25 AM
> To: [EMAIL PROTECTED]
> Subject: [R] Tick intervals
> 
> 
> Hi, I would like to plot a histogram with the following 
> codes, and I would like to make the tick intervals smaller. I 
> tried to add "lab=c(1,1,12)", but nothing changes.
> 
> 
> par(mfrow=c(1,1),font=1, cex=0.8)
> hist (data1, seq(-0.01,0.3,0.01),freq = FALSE,
> main="Figure1.",xlab="return",lab=c(1,1,12))
> lines(density(data1), col="blue")
> 
> 
> Could anyone give me sone advice?
> Many thanks,
> --
> View this message in context: 
> http://www.nabble.com/Tick-intervals-tf4430457.html#a12639110
> 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] Evaluating args in a function

2007-09-12 Thread Gabor Grothendieck
You have a recursive reference.  Try using a different name other than
class.  For example, in the following we use class. with a dot at the end
(so that abbreviation of it still allows the user to write class):

fred <- data.frame()
test.fn <- function(x,class.=class(x)) {class.}
test.fn(fred) # "data.frame"
test.fn(fred, class = "x") # "x"


On 9/12/07, Sandy Weisberg <[EMAIL PROTECTED]> wrote:
> Can anyone explain what I'm doing wrong here:
>
>  > fred <- data.frame()
>  > class(fred)
> [1] "data.frame"
>  > test.fn <- function(x,class=class(x)) {class}
>  > test.fn(fred)
> Error in test.fn(fred) : promise already under evaluation: recursive
> default argument reference or earlier problems?
>
> R 2.5.1 on both Windows and SUSE Linux.
>
>
> --
> Sanford Weisberg, [EMAIL PROTECTED]
> Office and mailing address:
> University of Minnesota, School of Statistics
> 312 Ford Hall, 224 Church St. SE, Minneapolis, MN  55455
> 612-625-8355, FAX 612-624-8868
>
> St. Paul office:
> 146 Classroom-Office Building, 612-625-8777
>
> __
> 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] one-class SVM in kernlab

2007-09-12 Thread Roberto Perdisci
Hello,
  I'm trying to using ksvm() in the kernlab package to fit a one-class
SVC, but I get a strage result on the cross-validation error estimate.
For example, consider this code:

data(spam)
classifier <- ksvm(type~.,data=spam[which(spam[,'type']=='spam'),],
type="one-svc",kernel="rbfdot",kpar=list(sigma=0.1),nu=0.05,cross=10)

what I get is:

> classifier
Support Vector Machine object of class "ksvm"

SV type: one-svc  (novelty detection)
 parameter : nu = 0.05

Gaussian Radial Basis kernel function.
 Hyperparameter : sigma =  0.1

Number of Support Vectors : 660

Objective Function Value : 10.5781
Training error : 0.212907
Cross validation error : 0

---

What surprises me is that the Training error (which I suppose is the
resubstitution error) is higher than the cross-validation error. Also,
even changing the value of sigma, the cross-validation error does not
change.
I get similar results with other datasets, too. For example

classifier <- ksvm(Species~.,data=iris[which(iris[,'Species']=='setosa'),],
type="one-svc",kernel="rbfdot",kpar=list(sigma=0.5),nu=0.05,cross=10)


Am I using ksvm() correctly?
I also tried to use the formula ~. exluding the attribute 'type' from
the dataset, and the results are exactly the same.

Unfortunately reading ?ksvm didn't help me much.

thank you,
regards,
Roberto

__
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] Evaluating args in a function

2007-09-12 Thread Sandy Weisberg
Can anyone explain what I'm doing wrong here:

 > fred <- data.frame()
 > class(fred)
[1] "data.frame"
 > test.fn <- function(x,class=class(x)) {class}
 > test.fn(fred)
Error in test.fn(fred) : promise already under evaluation: recursive 
default argument reference or earlier problems?

R 2.5.1 on both Windows and SUSE Linux.


-- 
Sanford Weisberg, [EMAIL PROTECTED]
Office and mailing address:
University of Minnesota, School of Statistics
312 Ford Hall, 224 Church St. SE, Minneapolis, MN  55455
612-625-8355, FAX 612-624-8868

St. Paul office:
146 Classroom-Office Building, 612-625-8777

__
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] irregular time series

2007-09-12 Thread Gabor Grothendieck
Try this.  After defining our data, tt and x, we create a zoo series
z by aggregating over days taking the last point corresponding to
each day.  Then we convert that to ts (which fills in the missing days)
and create a zoo series with no data and those times merging it
with the  original zoo series and specifying fill = 0.

library(zoo)

# create zoo series, z, by taking last point corresponding to each day
tt <- c("2003-03-05", "2003-03-05", "2003-05-05" ,"2003-04-07" ,"2003-03-05")
x <- 1:5
z <- aggregate(zoo(x), as.Date(tt), tail, 1)

merge(z, zoo(, time(as.ts(z))), fill = 0)

# alternative to last line is the following: longer but no warning
# only change is inserting of as.Date(unclass(...)) to force Date class
merge(z, zoo(, as.Date(unclass(time(as.ts(z), fill = 0)


On 9/12/07, Nirav Mehta <[EMAIL PROTECTED]> wrote:
> Howdy!
>
> I am attempting to convert a date frame with irregular dates into a
> regular time series, aggregated by date. i have tried using both the
> 'its' and 'zoo' packages.
>
> I have something like
>
> times<-c("2003-03-05", "2003-03-05", "2003-05-05" ,"2003-04-07" ,"2003-03-05")
> aarf<-data.frame(times)
> aarf$x<-runif(5)
>
> what i want in the end, is a daily time series, aggregating x by day,
> and filling in days where there are no data with 0.
>
> I have tried, similarly to another help request, the aggregating once
> I have zoo-class data, but my dates disappear, and instead I get
> things like 12772 and so on for the various dates. I thought that
> these 5-digit numbers were maybe the number of days past Jan 1, 1970,
> but dividing these numbers by the number of days in a year gets me out
> of my data range.
>
> Also, applying as.ts() to my zoo data gives me a regularly spaced time
> series that ignores the timing imposed in zoo.
>
> Similarly, I can convert the series to an 'its' object, but then
> cannot convert the 'its' object to a regular time series with 0 filled
> in where I have no observations, since the 'its' arithmitic only
> returns the intersection of addition of two its vectors.
>
> Thanks,
> Nirav Mehta
>
> __
> 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] Tick intervals

2007-09-12 Thread livia

Hi, I would like to plot a histogram with the following codes, and I would
like to make the tick intervals smaller. I tried to add "lab=c(1,1,12)", but
nothing changes.


par(mfrow=c(1,1),font=1, cex=0.8)
hist (data1, seq(-0.01,0.3,0.01),freq = FALSE,
main="Figure1.",xlab="return",lab=c(1,1,12))
lines(density(data1), col="blue")


Could anyone give me sone advice?
Many thanks,
-- 
View this message in context: 
http://www.nabble.com/Tick-intervals-tf4430457.html#a12639110
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] irregular time series

2007-09-12 Thread Nirav Mehta
Howdy!

I am attempting to convert a date frame with irregular dates into a
regular time series, aggregated by date. i have tried using both the
'its' and 'zoo' packages.

I have something like

times<-c("2003-03-05", "2003-03-05", "2003-05-05" ,"2003-04-07" ,"2003-03-05")
aarf<-data.frame(times)
aarf$x<-runif(5)

what i want in the end, is a daily time series, aggregating x by day,
and filling in days where there are no data with 0.

I have tried, similarly to another help request, the aggregating once
I have zoo-class data, but my dates disappear, and instead I get
things like 12772 and so on for the various dates. I thought that
these 5-digit numbers were maybe the number of days past Jan 1, 1970,
but dividing these numbers by the number of days in a year gets me out
of my data range.

Also, applying as.ts() to my zoo data gives me a regularly spaced time
series that ignores the timing imposed in zoo.

Similarly, I can convert the series to an 'its' object, but then
cannot convert the 'its' object to a regular time series with 0 filled
in where I have no observations, since the 'its' arithmitic only
returns the intersection of addition of two its vectors.

Thanks,
Nirav Mehta

__
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] vectorize a matrix conversion

2007-09-12 Thread Charles C. Berry
On Wed, 12 Sep 2007, Robin Hankin wrote:

> Hello
>
>
> I have X, an n-by-n  matrix and want to convert it to Y, an
>  n(n-1)/2 -by- n matrix such that each row of Y
> corresponds to an element of the upper diagonal
> of X.   Say row k of Y corresponds to [i,j] with i\neq j.
>
> Then Y[i,k] = X[i,j] and Y[j,k] = X[j,i].
> and Y[-c(i,j),k] = NA.
>
> How to do this vectorizedly?
>

If I follow you:

   upper.indexes <- which( lower.tri( X ), arr.ind=TRUE )
   from.mat <- rbind( upper.indexes, upper.indexes[ , 2:1 ] )
   to.mat <- cbind( rep( 1:nrow(upper.indexes), 2 ), as.vector( upper.indexes[, 
2:1] ) )
   Y[ to.mat ] <- X[ from.mat ]

HTH,

Chuck


> Example follows:
>
>
>
> > X
>  [,1] [,2] [,3] [,4]
> [1,]   NA   1087
> [2,]   10   NA7   12
> [3,]   12   13   NA8
> [4,]   138   12   NA
> > Y
>  [,1] [,2] [,3] [,4]
> [1,]   10   10   NA   NA
> [2,]   12   NA8   NA
> [3,]   13   NA   NA7
> [4,]   NA   137   NA
> [5,]   NA8   NA   12
> [6,]   NA   NA   128
> >
>
> [matrix X corresponds to an all-play-all competition amongst 4
> individuals,
> entry [i,j] corresponding to the  number of times individual "i" won
> when competing against individual "j".  Thus individual 2 beat
> individual
> 3 seven times and individual 3 beat individual 2 thirteen times.
> Note X[i,j] + X[j,i]=20 as there were 20 trials for each pair]
>
>
> Pitiful nonvectorized code follows.
>
> n <- nrow(X)
> Y <-  matrix(NA,n*(n-1)/2,n)
> k <- 1
> for(i in 1:(n-1)){
>   for(j in (i+1):n){
> if( !(i==j)){
>   print(c(i,j,k))
>   Y[k,i] <- X[i,j]
>   Y[k,j] <- X[j,i]
> }
> k <- k+1
>   }
> }
>
>
>
>
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>  tel  023-8059-7743
>
> __
> 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] vectorize a matrix conversion

2007-09-12 Thread Dimitris Rizopoulos
you could try the following:

n <- nrow(X)
k <- n * (n - 1) / 2
Y <- matrix(NA, k, n)

ind.up <- which(upper.tri(X), arr.ind = TRUE)
ind.lo <- which(lower.tri(X), arr.ind = TRUE)
Y[cbind(1:k, ind.lo[, 1])] <- X[ind.up]
Y[cbind(1:k, ind.lo[, 2])] <- X[ind.lo]
Y


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: "Robin Hankin" <[EMAIL PROTECTED]>
To: "R program" 
Sent: Wednesday, September 12, 2007 4:32 PM
Subject: [R] vectorize a matrix conversion


> Hello
>
>
> I have X, an n-by-n  matrix and want to convert it to Y, an
>  n(n-1)/2 -by- n matrix such that each row of Y
> corresponds to an element of the upper diagonal
> of X.   Say row k of Y corresponds to [i,j] with i\neq j.
>
> Then Y[i,k] = X[i,j] and Y[j,k] = X[j,i].
> and Y[-c(i,j),k] = NA.
>
> How to do this vectorizedly?
>
> Example follows:
>
>
>
> > X
>  [,1] [,2] [,3] [,4]
> [1,]   NA   1087
> [2,]   10   NA7   12
> [3,]   12   13   NA8
> [4,]   138   12   NA
> > Y
>  [,1] [,2] [,3] [,4]
> [1,]   10   10   NA   NA
> [2,]   12   NA8   NA
> [3,]   13   NA   NA7
> [4,]   NA   137   NA
> [5,]   NA8   NA   12
> [6,]   NA   NA   128
> >
>
> [matrix X corresponds to an all-play-all competition amongst 4
> individuals,
> entry [i,j] corresponding to the  number of times individual "i" won
> when competing against individual "j".  Thus individual 2 beat
> individual
> 3 seven times and individual 3 beat individual 2 thirteen times.
> Note X[i,j] + X[j,i]=20 as there were 20 trials for each pair]
>
>
> Pitiful nonvectorized code follows.
>
> n <- nrow(X)
> Y <-  matrix(NA,n*(n-1)/2,n)
> k <- 1
> for(i in 1:(n-1)){
>   for(j in (i+1):n){
> if( !(i==j)){
>   print(c(i,j,k))
>   Y[k,i] <- X[i,j]
>   Y[k,j] <- X[j,i]
> }
> k <- k+1
>   }
> }
>
>
>
>
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>  tel  023-8059-7743
>
> __
> 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] k-means clustering

2007-09-12 Thread darteta001
Dear list, first apologies for this is not strictly an R question but 
a theoretical one. 

I have read that use of k-means clustering assumes sphericity of data 
distribution. Can anyone explain me what this means? My statistical 
background is too poor. Is it another kind of distribution, like 
gaussian or binomial? What does it happen if the distribution is not 
spherical? Could you give me an example or a link to information about 
this?

Thanks for your help

David

__
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] looking for a french speaking R specialist for training

2007-09-12 Thread Philippe Rousselot
Hi,

sorry if it is the wrong place to post this.  I am looking for someone 
to teach R. I will continue in french as the job will be done in french 
only.

Bonjour,

je cherche un formateur sur R pour des cycles de formations continues, 
le premier débutant en novembre-décembre.

vu le sujet, la personne devra être extrêmement pédagogue.

Merci de m'envoyer un mail directement à formations at alcatorda point 
com avec cv, expérience dans le domaine, contenu et durée (pas plus de 5 
jours) prévue pour la formation, dates de disponibilité et devis.

Les formations aurons lieu dans la région parisienne (45 minutes de la 
gare de l'est) et concerne des chercheurs et travailleurs indépendants

la formation porterait sur l'installation et la prise en main de R, 
l'utilisation pour des analyses statistiques classiques (les stagiaires 
sont supposés connaître les stats), l'initiation aux scripts. Pour 
certains cours, l'utilisation de R couplé au SIG GRASS peut être envisagé.

merci d'avance

Philippe

__
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] vars package, impulse response functions ??

2007-09-12 Thread sj
I am fitting a reduced form VAR model using VAR in the vars library. I have
several endogenous variables, and two exogenous variables. I would like to
explore the effects of a shock to one of the exogenous variables on one of
the endogenous variables. Using irf in the vars library only calculates the
irf for the endogenous variables, this is obviously by design, is there some
theoretical restriction on why it is not possible to look at the irf's from
exogenous shocks?  Is there anyway to look at the effects of exogenous
shocks in R? Do I need to consider some sort of structural model?

the following code sample illustrates what I am trying to do  and the
problems I am having (I am not an econometrician, but I know that e would be
better left as an endo variable, I just needed some common data to show what
I am trying to do)


data(Canada)
attach(Canada)
v.can<-VAR(Canada[,2:4],exogen=e, p = 2, type = "both")

irf(v.can,impulse= "e", response="prod")

thanks again,

Spencer

[[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] Integrate() error message, I am at a loss

2007-09-12 Thread Charles C. Berry
On Wed, 12 Sep 2007, Sergey Goriatchev wrote:

> Hello!
>
> I have a problem with integrate() in my function nctspa(). Integrate
> produces an error message "evaluation of function gave a result of
> wrong length". I don't know what that means. Could anyone suggest me
> what is wrong with my function?

Sure, but you can do this yourself.

For one thing, setting

options( error = recover )

before you run your function will help you to see what is happening.

(viz. after the error message select 2, then figure out what f() and ff() 
are, then try ff(1))

>
> These are the examples of function calls that work OK:
> nctspa(a=1:10,n=5)
> nctspa(a=1:10, n=5, mu=2, theta=3, renorm=0)
>
> This does not work:
> nctspa(a=1:10, n=5, mu=2, theta=3, renorm=1)
>
> Many thanks in advance for your help!
> please, send reply also to [EMAIL PROTECTED]
>
> /Sergey
>
> Here is the function:
>
> #Computes the s.p.a. to the doubly noncentral t at value x.
> #degrees of freedom n, noncentrality parameters mu and theta.
> #==#
> nctspa <- function(a,n,mu=0,theta=0,renorm=0,rec=0){
> #Pass renorm=1 to renormalize the SPA to the pdf.
> #There is a last argument called rec. DO NOT PASS it!
>
> alpha <- mu/sqrt((1+theta/n))
> normconst <- 1
> if(renorm==1 & rec==0){
>   term1 <- integrate(nctspa, -Inf, alpha, n=n, mu=mu, theta=theta)$value
>   term2 <- integrate(nctspa, alpha, Inf, n=n, mu=mu, theta=theta)$value


Whoa! Let's read the help page for integrate:

Arguments:

f: an R function taking a numeric first argument and returning a
   numeric vector of the same length. 
..^.


which is not what nctspa() does. It returns a list of length 2 not matter 
what the first arguement.

Did you mean something like

integrate(function(x,...) nctspa(x,...)$PDF,  ??


HTH,

Chuck


>   normconst <- 1/(term1+term2)
> }
> cdf <- numeric()
> pdf <- cdf
> c3 <- n^2+2*n*a^2+a^4
> c2 <- (-2*mu*(a^3+n*a))/c3
> c1 <- (-n^2-n*a^2-n*theta+a^2*mu^2)/c3
> c0 <- (n*a*mu)/c3
> q <- c1/3-(c2^2)/9
> r <- 1/6*(c1*c2-3*c0)-1/27*c2^3
> b0 <- sqrt(-4*q)*cos(acos(r/sqrt(-q^3))/3)-c2/3
> t1 <- -mu+a*b0
> t2 <- -a*t1/b0/n/2
> nu <- 1/(1-2*t2)
> w <- sqrt(-mu*t1-n*log(nu)-2*theta*nu*t2)*sign(a-alpha)
> u <- sqrt((a^2+2*n*t2)*(2*n*nu^2+4*theta*nu^3)+4*n^2*b0^2)/(2*n*b0^2)
> pdf <- normconst*dnorm(w)/u
>
> nz <- (abs(t1*b0)>=1e-10)
> iz <- (abs(t1*b0)<=1e-10)
> if(any(nz)){
>   d <- numeric()
>   d[nz] <- 1/(t1[nz]*b0[nz])
>   cdf[nz] <- pnorm(w[nz])+dnorm(w[nz])*(1/w[nz]-d[nz]/u[nz])
> }
> if(any(iz)){
>   n <- sum(iz==1)
>   rez <- nctspa(c(a[iz]-1e-4, a[iz]+1e-4),n,mu,theta,0,rec+1)
>   if(rec>5){
>   cdf[iz] <- 0.5
>   warning('Too many recursions')
>   } else {
>   cdf[iz] <- 0.5*(rez$CDF[1:n]+rez$CDF[(n+1):length(rez$CDF)])
>   }
> }
> list(PDF=pdf, CDF=cdf)
> }
> #==
>
> __
> 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.


[R] Producing Date Reference Series...

2007-09-12 Thread Levent TERLEMEZ
Dear Users,

I am trying to locate work days of the weeks for a data import automation 
function. The function below is for practice. If the day of the week is 
Saturday or Sunday, function will delete that rows and at the end the date 
series will be my reference date series. So, I can make an automation function 
which will find missing days and rearrange my main data frame according to the 
reference (if there is already one, I could not find it and sorry for extra 
disturbance.) and for example imputting the missing data in that date with 
spline. The problem, I could not delete the Nas' from tarih1 which I could find 
with if(is.na(tarih[i,1])). How should code "..." part? I tried 
tarih1<-tarih1[-i,], but it did not work. I feel that when u

function () 
{
library(chron)
tarih<-data.frame(tarih=seq.dates("01/03/05","01/14/05",by="days"))
print(tarih)
tarih1<-data.frame(tarih=array(dim=c(nrow(tarih),1)))
print(tarih1)
for(i in 1:nrow(tarih))
{
if(weekdays(tarih[i,1])!="Sat" & weekdays(tarih[i,1])!="Sun")
{
tarih1[i,1]<-tarih[i,1]
}
}
for(i in 1:nrow(tarih1))
{
if(is.na(tarih1[i,1]))
{
...
}
}
tarih1[,1]<-dates(tarih1[,1],format="m/d/y")
print(tarih1)
}
[[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] Odp: fail to recover decimal value from data frame

2007-09-12 Thread Petr PIKAL
Hi

you definitely shall try to get acustommed with data structures in R. You 
do ***not*** have numeric decimal values but factors (probably created by 
transfering data to R as you have in the column a value psi1).  Then the 
assignement places a factor code into matrix instead of a factor value. 

fac<-factor(rnorm(100))
daf<-as.data.frame(matrix(fac,10,10))
> sapply(daf, "is.factor")
  V1   V2   V3   V4   V5   V6   V7   V8   V9  V10 
TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE 

mat[1,10]<-daf[1,10]
> mat
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]   NA   NA   NA   NA   NA   NA   NA   NA   NA 1
 [2,]   NA   NA   NA   NA   NA   NA   NA   NA   NANA
 [3,]   NA   NA   NA   NA   NA   NA   NA   NA   NANA



> mat[2,10]<-daf[2,10]
mat[2,10]
[1] 4
daf.n<-sapply(daf, function(x) as.numeric(as.character(x)))
mat[3,10]<-daf.n[3,10]
mat
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]   NA   NA   NA   NA   NA   NA   NA   NA   NA 1.000
 [2,]   NA   NA   NA   NA   NA   NA   NA   NA   NA 4.000
 [3,]   NA   NA   NA   NA   NA   NA   NA   NA   NA 0.2200095
 [4,]   NA   NA   NA   NA   NA   NA   NA   NA   NANA
 [5,]   NA   NA   NA   NA   NA   NA   NA   NA   NANA
 
You need to get rid of irrelevant values in your data frame first.

Regards

Petr
[EMAIL PROTECTED]

[EMAIL PROTECTED] napsal dne 12.09.2007 16:03:36:

> Hi,
> I have some decimal values stored in a data frame (myframe) and I 
> need to place them in a matrix (mymatrix) using a for loop.
> When I type:
> 
>  > myframe[i,10]
> 
> I get:
> 
> [1] 0.8714
> 434 Levels: 0 0.0134 0.1062 0.1182 0.1241 0.1322 0.1374 0.1429 
> 0.1507 ... psi1
> 
> But when I assign that value to the matrix with:
> 
>  > mymatrix[i,2]<-myframe[i,10]
> 
> The value that gets placed in the matrix is 286, and not 0.8714 as I 
> wanted it to be. What is wrong?
> The data frame does have several rows of character cells interspersed 
> with "NA" and decimal values. It is not very simple I am just using 
> it to store a large output worksheet from where I want to draw 
> selected values.
> 
> Thanks for any help.
> 
> G.
> 
> __
> 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] : Error on tomcat...

2007-09-12 Thread d. sarthi maheshwari
Hi,

I am using TOMCAT 6.0.14 on Solaris 10 i86. I wrote a perl script which is
running a cgi on tomcat, from there i am taking input value's and using the
following way to create a graph using R and accessing that graph to attach
it on webpage:




my $to_run = "/usr/local/bin/R --vanilla --slave --args  $selected_host
$graph_start  $graph_end   < ..\/..\/..\/page\/R\/" . $graph_name . ".r ";
system("$to_run");




My R file looks like this...


.
.

files <- "/u/Docs/tomcat/webapps/page/Web/img/tmp.png"

bitmap(file = files, type = "png256", height = 8, width = 12, res = 72)
plot(strptime(dat[,1],"%Y-%m-%d %H:%M"), dat[,2],
type = "l",
ylim = c(min(dat[,2]),max(dat[,2])),
ylab = "CPU Load",
xlab = "Time",
col = "red",
main = title)
dev.off()




The problem is when I am running this Perl Script locally in unix, "tmp.png"
is getting created, however, when I run this perl script on server,
tmp.pngfile is not getting created. My server is running in the same
UNIX session
where I am trying running the perl script.

I have done several hit and trial attempt to make it happen, however, not
able to find the error. Kindly suggest. Thanks in advance.

Regards
Sar

[[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] vectorize a matrix conversion

2007-09-12 Thread Robin Hankin
Hello


I have X, an n-by-n  matrix and want to convert it to Y, an
  n(n-1)/2 -by- n matrix such that each row of Y
corresponds to an element of the upper diagonal
of X.   Say row k of Y corresponds to [i,j] with i\neq j.

Then Y[i,k] = X[i,j] and Y[j,k] = X[j,i].
and Y[-c(i,j),k] = NA.

How to do this vectorizedly?

Example follows:



 > X
  [,1] [,2] [,3] [,4]
[1,]   NA   1087
[2,]   10   NA7   12
[3,]   12   13   NA8
[4,]   138   12   NA
 > Y
  [,1] [,2] [,3] [,4]
[1,]   10   10   NA   NA
[2,]   12   NA8   NA
[3,]   13   NA   NA7
[4,]   NA   137   NA
[5,]   NA8   NA   12
[6,]   NA   NA   128
 >

[matrix X corresponds to an all-play-all competition amongst 4  
individuals,
entry [i,j] corresponding to the  number of times individual "i" won
when competing against individual "j".  Thus individual 2 beat  
individual
3 seven times and individual 3 beat individual 2 thirteen times.
Note X[i,j] + X[j,i]=20 as there were 20 trials for each pair]


Pitiful nonvectorized code follows.

n <- nrow(X)
Y <-  matrix(NA,n*(n-1)/2,n)
k <- 1
for(i in 1:(n-1)){
   for(j in (i+1):n){
 if( !(i==j)){
   print(c(i,j,k))
   Y[k,i] <- X[i,j]
   Y[k,j] <- X[j,i]
 }
 k <- k+1
   }
}





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

__
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] fail to recover decimal value from data frame

2007-09-12 Thread Julien Barnier
Hi,

> [1] 0.8714
> 434 Levels: 0 0.0134 0.1062 0.1182 0.1241 0.1322 0.1374 0.1429  
> 0.1507 ... psi1

The problem is that your data are not stored as numeric, but as a
factor.

You can see the following R FAQ entry to turn it back to a numeric
form :

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f

HTH,

Julien

-- 
Julien Barnier
Groupe de recherche sur la socialisation
ENS-LSH - Lyon, France

__
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] fail to recover decimal value from data frame

2007-09-12 Thread Gonçalo Ferraz
Hi,
I have some decimal values stored in a data frame (myframe) and I  
need to place them in a matrix (mymatrix) using a for loop.
When I type:

 > myframe[i,10]

I get:

[1] 0.8714
434 Levels: 0 0.0134 0.1062 0.1182 0.1241 0.1322 0.1374 0.1429  
0.1507 ... psi1

But when I assign that value to the matrix with:

 > mymatrix[i,2]<-myframe[i,10]

The value that gets placed in the matrix is 286, and not 0.8714 as I  
wanted it to be. What is wrong?
The data frame does have several rows of character cells interspersed  
with "NA" and decimal values. It is not very simple I am just using  
it to store a large output worksheet from where I want to draw  
selected values.

Thanks for any help.

G.

__
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] super and subscript in tcltk

2007-09-12 Thread R Help
dear list,

I'm trying to set subscripts in a tcltk menu, but I can't get it to
work.  The basic idea is produced by the following code

###
library(tcltk)
m <- tktoplevel()
norm <- tkfont.create(family="times",size=20,weight="bold")
f1 <- tkfont.create(family="symbol",size=10)
f2 <- tkfont.create(family="symbol",size=5)
frame <- tkframe(m)

entry1 <- tkentry(frame,width=5,bg='white')
entry2 <- tkentry(frame,width=5,bg='white')

tkpack(tklabel(frame,text="m",font=f1),side='left')
tkpack(tklabel(frame,text="1",font=f2),side='left')
tkpack(frame,entry1,side="left")
tkpack(tklabel(frame,text="m",font=f1),side='left')
tkpack(tklabel(frame,text="2",font=f2),side='left')
tkpack(frame,entry2,side="top")


But the problem is that the 1 and 2 are not added as subscripts.  I
think I can do it using a text-object and the offset tag, but I cannot
figure out how to do it.  Does anybody know how to use the
tktag.configure(...) function to set the offset tag so that the text
will appear below the baseline?  It should work like this

###
t <- tktext(frame,font=f1)
tktag.configure(t,"offset=-50")
tkinsert(t,"end","m")
tkinsert(t,"end","1")
###

Any help would be very much appreciated.

Thanks
Sam

__
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] plot contour map for irregular data points

2007-09-12 Thread Andre Jung
Hello,

I'm dealing with the following problem:

I have a table with x and y coordinates and corresponding values of
a mineral concentration, let's call it z.
  
Can someone provide me a short step-by-step manual for the steps
necessary to get a contour map?
  
How to sort and interpolate my matrix to an equidistant grid which
can afterwards be plotted by contour(x,y,z)? (e.g. fill the missing
locations with NAs.)
  
Thank you.

__
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] Title and labelos in ggplot2

2007-09-12 Thread Ido M. Tamir
x and y axis labels changing in ggplo2:

p <- ggplot(d03, aes(x=cs,y=taille)) + geom_hline(data=temp.df) + 
geom_boxplot() + facet_grid(.~sexe) 

I had a similar question not too long ago. Try:

p + scale_x_discrete("new label x") + scale_y_continuous("new label y") 

best wishes
ido

__
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] Bootstrap tree selection in rpart

2007-09-12 Thread Terry Therneau
Fiona Callaghan asked about using the bootstrap  instead of cross-validation in 
the tree pruning step.  
   It turns out that cross-validation works better than the bootstrap for trees.
The issue is a subtle one.  The bootstrap can be thought of as 2 steps.  

1.  Deduction: Evaluate the behavior of some statistic "zed" under repeated
sampling from the discrete distribution F-hat, i.e., the original data.  This
gives a direct evaluation of how zed behaves under F-hat.

2. Induction: Assume that (behavior of zed under sampling from F) = (behavior
under sampling from F-hat).

  It turns out that trees behave differently under discreet distributions than
they do under continuous ones, so step 2 fails.  Essentially, there are fewer 
places to split in the discrete case, tree creation is less noisy, and the 
bootstrap gives an overoptimistic view.  I remember Brad Efron giving a talk on
this long ago (I was still a student!), so the details are fuzzy; I think that
he solved it by sampling from a smoothed version of the empirical CDF.

   Terry Therneau

__
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] constructing an lm() formula in a function

2007-09-12 Thread Michael Friendly
I'm working on some functions for generalized canonical discriminant
analysis in conjunction with the heplots package.  I've written a
candisc.mlm function that takes an mlm object and computes a
candisc object containing canonical scores, coeficients, etc.

But I'm stumped on how to construct a mlm for the canonical scores,
in a function using the *same* right-hand-side of the model formula that 
was used in the original mlm for the data.

I can illustrate step-by-step and where I'm stumped.

 > # fit randomized block model, .~Block+Gp, where Gp = Contour:Depth
 > # Soils data is in car package
 > library(car)
 > soils.mod1 <- lm(cbind(pH,N,Dens,P,Ca,Mg,K,Na,Conduc) ~ Block + Gp,
+   data=Soils)
 > # Do the canonical discriminant analysis for Gp:
 > can1 <-candisc(soils.mod1, term="Gp")
 >
 > str(can1$scores)
'data.frame':   48 obs. of  11 variables:
  $ Block: Factor w/ 4 levels "1","2","3","4": 1 2 3 4 1 2 3 4 1 2 ...
  $ Gp   : Factor w/ 12 levels "D0","D1","D3",..: 9 9 9 9 10 10 10 10 11 
11 ...
  $ Can1 : num  8.87 5.57 6.31 7.01 6.64 ...
  $ Can2 : num  -3.76 -4.78 -4.63 -4.06 -3.13 ...
  $ Can3 : num   1.241 -0.561 -1.299  0.642  2.217 ...
  $ Can4 : num   1.313 -0.402 -1.631  2.481  0.384 ...
  $ Can5 : num  -1.913 -1.103 -0.428  1.134 -0.937 ...
  $ Can6 : num  -0.4219 -0.3593  1.2070  0.0652 -0.6424 ...
  $ Can7 : num   0.701  0.243 -0.728  1.147 -0.149 ...
  $ Can8 : num   0.0728  1.4491 -0.1546 -1.5191 -0.2374 ...
  $ Can9 : num  -2.4318  1.2773 -0.0905  1.0646 -1.8069 ...
 > str(can1$terms)
  chr [1:2] "Block" "Gp"

OK, so now in a function I want to do the equivalent of fitting

lm( cbind(Can1, Can2, ... Can9) ~ Block+Gp, data=can$scores)

The following function shows two ways I've tried to do this, neither of 
which works:

fitlm.candisc <- function( can ) {
factors <- can$factors  # factor variable from candisc
terms <- can$terms  # terms from original lm
scores <- can$scores# scores data fram
#   can.mod <- lm(as.matrix(scores[,paste("Can",1:can$rank,sep="")])
#  ~ paste(can1$terms,collapse="+"), data=scores)
can.mod <- lm(as.matrix(scores[,paste("Can",1:can$rank,sep="")])
   ~ scores[,terms], data=scores)
}

 > fitlm.candisc(can1)
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
 invalid type (list) for variable 'scores[, terms]'
 >

I would like the terms in the model can.mod to be Block and Gp.
What am I missing here?

thanks,

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

__
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] Title and labelos in ggplot2

2007-09-12 Thread Julien Barnier
Hi,

I am new to the ggplot2 package and I am stuck with something which
must be quite basic : I can't manage to change the x and y axis labels
when I don't use the qplot command. I manged to change the main title
by modifying the title element of the ggplot object, but I can't find
the elements for the axis labels.

Here is my code :

p <- ggplot(d03, aes(x=cs,y=taille)) + geom_hline(data=temp.df) + 
geom_boxplot() + facet_grid(.~sexe) 
p$title <- "Wonderful title"
print(p)

Thanks in advance for any help.

-- 
Julien Barnier
Groupe de recherche sur la socialisation
ENS-LSH - Lyon, France

__
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: to view the memory

2007-09-12 Thread Doran, Harold
Is this what you want when you say "values". It seems this could be very
expensive if some of your objects are large matrices, for example. I
thought the poster meant "size" when he said values since he later
mentioned memory. If that is the case, you want object.size().

 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of R Help
> Sent: Wednesday, September 12, 2007 8:28 AM
> To: [EMAIL PROTECTED]
> Cc: r-help@r-project.org
> Subject: Re: [R] R: to view the memory
> 
> the function ls() will list all the variables currently in the memory.
>  To get their values, you'll also need to use the parse and 
> eval functions.  Try the following:
> 
> x = ls()
> for(i in 1:length(x)){
> print(x[i])
> print(eval(parse(text=x[i])))
> }
> 
> It's a little crude, but it will do the job.
> 
> Sam
> On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I am wondering if it is possible to view what variables and 
> vairable 
> > values are stored in the R memory. This to enable debugging of 
> > R-scripts I write.
> >
> > 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.
> >
> 
> __
> 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] Creating Hmisc labels inside a function

2007-09-12 Thread Frank E Harrell Jr
Steve Powell wrote:
> hello list members,
> I am wanting to write a label using the Hmisc package, but inside a
> function. Normally I can do:
> 
> library(Hmisc)
> M=2
> label(M)="lab"
> 
> #But inside a function the "=" does not work:
> Test=function(obj,labe)
> {
> label(obj)=labe

at this point add the line:

obj

> }

The returned object will have what you need.  -Frank

> 
> Test(M,"new label")
> 
> I usually use the "assign" function to make assignments inside functions,
> but assign will not work with attributes, labels etc.
> Any ideas?
> Thanks in advance
> 
> Steve Powell
> 
>  
> proMENTE social research 
> research | evaluation | training & consulting 
> Kranjčevićeva 35, 71000 Sarajevo 
> mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866
> skype: stevepowell99 
> www.promente.org  |  www.mojakarijera.com  |  www.psih.org  
> 
> 
> Checked by AVG Free Edition. 
> 
> 17:43
> 
> __
> 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] [solved] Re: I can't do it again on an other PC : R+RMySQL ->error loading dll

2007-09-12 Thread Ptit_Bleu

Thanks for the procedure. It sounds easy.
I will test it when I have time and see if there are differences (I hope I
won't see anything : from a working configuration, if I change to RODBC, I'd
like to get another working one).

Ptit BLeu.



Vladimir Eremeev wrote:
> 
> Hi!
> In my case, advantages of using RODBC are in the fact that it is working,
> and is getting updated on a regular basis. Nothing more. :)
> 
> I also had some difficulties to set up the DSN, old Windows NT 4.0
> required couple of restarts, and guessing correct 'magic' line to make MS
> Excel to retrieve the data was difficult. The procedure is simplified in
> Win2000/XP.
> 
> I have MySQL ODBC 3.51 Driver installed.
> Then I go to Start -> Control Panel -> Administrative Tools, double-click
> on 'Data sources (ODBC)', click
> 'Add' in the opened window, choose 'MySQL ODBC 3.51 Driver' from the list,
> enter host name, database name, user name and password. Port is 3306 by
> default.
> Then pressing 'Test Data source' shows if everything is set up correctly.
> MySQL also have to be configured to allow connections.
> 
> RODBC also contains the file with the comprehensive instructions
> (R_HOME/Library/RODBC/Readme).
> 
> 
> Ptit_Bleu wrote:
>> 
>> Hi Vladimir,
>> 
>> In fact, at the beginning, I tried to install RODBC and the MySQL driver
>> but I did not manage (I think due to the driver and the configuration in
>> the control panel). Then I tried to install RMySQL and DBI on my PC (not
>> the one with the "real" database), and it worked without any problem. So
>> I keep working with RMySQL.
>> 
>> You think there are advantages to try again installing RODBC ?
>> 
>> Anyway, for the moment, I think I will continue with RMySQL, just because
>> it works. But for me it is a good reason (especially because I'm not a
>> specialist of PCs and I don't have the time to become one. I'm only an
>> end-user).
>> 
>> Have a nice day,
>> Ptit Bleu.
>> 
>> 
>> 
>> Vladimir Eremeev wrote:
>>> 
>>> Do you need precisely RMySQL and DBI? 
>>> RODBC can successfully replace this.
>>> 
>>> I used RMySQL some time ago, but then, after the next version upgrade it
>>> stopped working.
>>> 
>>> Switching to RODBC was almost without pain, since function names were
>>> quite similar.
>>> I simply replaced dbGetQuery with sqlGetQuery in my script and voilia.
>>> 
>>> However, you need to install the MySQL ODBC driver and set up a data
>>> source in the Windows Control Panel before.
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/I-can%27t-do-it-again-on-an-other-PC-%3A-R%2BRMySQL--%3Eerror-loading-dll-tf4414597.html#a12634485
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] R: to view the memory

2007-09-12 Thread R Help
the function ls() will list all the variables currently in the memory.
 To get their values, you'll also need to use the parse and eval
functions.  Try the following:

x = ls()
for(i in 1:length(x)){
print(x[i])
print(eval(parse(text=x[i])))
}

It's a little crude, but it will do the job.

Sam
On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am wondering if it is possible to view what variables and vairable
> values are stored in the R memory. This to enable debugging of R-scripts
> I write.
>
> 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.
>

__
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] [solved] Re: I can't do it again on an other PC : R+RMySQL ->error loading dll

2007-09-12 Thread Vladimir Eremeev

Hi!
In my case, advantages of using RODBC are in the fact that it is working,
and is getting updated on a regular basis. Nothing more. :)

I also had some difficulties to set up the DSN, old Windows NT 4.0 required
couple of restarts, and guessing correct 'magic' line to make MS Excel to
retrieve the data was difficult. The procedure is simplified in Win2000/XP.

I have MySQL ODBC 3.51 Driver installed.
Then I go to Start -> Control Panel -> Administrative Tools, double-click on
'Data sources (ODBC)', click
'Add' in the opened window, choose 'MySQL ODBC 3.51 Driver' from the list,
enter host name, database name, user name and password. Port is 3306 by
default.
Then pressing 'Test Data source' shows if everything is set up correctly.
MySQL also have to be configured to allow connections.

RODBC also contains the file with the comprehensive instructions
(R_HOME/Library/RODBC/Readme).


Ptit_Bleu wrote:
> 
> Hi Vladimir,
> 
> In fact, at the beginning, I tried to install RODBC and the MySQL driver
> but I did not manage (I think due to the driver and the configuration in
> the control panel). Then I tried to install RMySQL and DBI on my PC (not
> the one with the "real" database), and it worked without any problem. So I
> keep working with RMySQL.
> 
> You think there are advantages to try again installing RODBC ?
> 
> Anyway, for the moment, I think I will continue with RMySQL, just because
> it works. But for me it is a good reason (especially because I'm not a
> specialist of PCs and I don't have the time to become one. I'm only an
> end-user).
> 
> Have a nice day,
> Ptit Bleu.
> 
> 
> 
> Vladimir Eremeev wrote:
>> 
>> Do you need precisely RMySQL and DBI? 
>> RODBC can successfully replace this.
>> 
>> I used RMySQL some time ago, but then, after the next version upgrade it
>> stopped working.
>> 
>> Switching to RODBC was almost without pain, since function names were
>> quite similar.
>> I simply replaced dbGetQuery with sqlGetQuery in my script and voilia.
>> 
>> However, you need to install the MySQL ODBC driver and set up a data
>> source in the Windows Control Panel before.
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/I-can%27t-do-it-again-on-an-other-PC-%3A-R%2BRMySQL--%3Eerror-loading-dll-tf4414597.html#a12634122
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] Help regading time series data reading

2007-09-12 Thread Gabor Grothendieck
Try using the zoo package like this:

Lines <- " Date PEGETNHSPPTC
13/10/200441.9264.7529.869.27
14/10/200441.9361.7929.989.14
15/10/200441.6962.730.099.04
18/10/200441.3762.1430.398.96
19/10/200441.0161.9829.619.02
20/10/200441.0161.9830.259
"

Lines2 <- " Date   A   B
13/10/200464.7529.86
15/10/200462.730.09
19/10/200461.9829.61
"

library(zoo)
# replace with a line such as:
# z <- read.zoo("myfile.dat", header = TRUE, format = "%d/%m/%Y")
z <- read.zoo(textConnection(Lines), header = TRUE, format = "%d/%m/%Y")

# replace with a line such as:
# z <- read.zoo("myfile2.dat", header = TRUE, format = "%d/%m/%Y")
z2 <- read.zoo(textConnection(Lines2), header = TRUE, format = "%d/%m/%Y")

both <- merge(z, z2)  # this uses merge.zoo
plot(na.approx(both))


To learn more about zoo try:
  vignette("zoo")
  vignette("zoo-quickref")
and to learn about dates read the help desk in R News 4/1
by googling for CRAN News


On 9/11/07, Tolga Uzuner <[EMAIL PROTECTED]> wrote:
> Dear R-Users,
>
> Have a question about reading in some data and manipulating dates. I
> have a data set in excel which looks like this:
>
> Date PEGETNHSPPTC
> 13/10/200441.9264.7529.869.27
> 14/10/200441.9361.7929.989.14
> 15/10/200441.6962.730.099.04
> 18/10/200441.3762.1430.398.96
> 19/10/200441.0161.9829.619.02
> 20/10/200441.0161.9830.259
>
> I have used read.table by saving the sheety above in tab format to
> read this in but am
> having some difficulties:
> - the dates above do not seem to be getting read in in date format:
> how can I force this ?
> - I actually have two, and not one data set, and would like to
> synchronise them by date
> (exclude from both dates which are not in both): is there an easy way
> to do this ?
>
> Thanks,
> Tolga
>
> __
> 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] [solved] Re: I can't do it again on an other PC : R+RMySQL ->error loading dll

2007-09-12 Thread Ptit_Bleu

Hi Vladimir,

In fact, at the beginning, I tried to install RODBC and the MySQL driver but
I did not manage (I think due to the driver and the configuration in the
control panel). Then I tried to install RMySQL and DBI on my PC (not the one
with the "real" database), and it worked without any problem. So I keep
working with RMySQL.

You think there are advantages to try again installing RODBC ?

Anyway, for the moment, I think I will continue with RMySQL, just because it
works. But for me it is a good reason (especially because I'm not a
specialist of PCs and I don't have the time to become one. I'm only an
end-user).

Have a nice day,
Ptit Bleu.



Vladimir Eremeev wrote:
> 
> Do you need precisely RMySQL and DBI? 
> RODBC can successfully replace this.
> 
> I used RMySQL some time ago, but then, after the next version upgrade it
> stopped working.
> 
> Switching to RODBC was almost without pain, since function names were
> quite similar.
> I simply replaced dbGetQuery with sqlGetQuery in my script and voilia.
> 
> However, you need to install the MySQL ODBC driver and set up a data
> source in the Windows Control Panel before.
> 
> 
> Ptit_Bleu wrote:
>> 
>> 
>> I really have no idea about your comment. I was so happy to be able to
>> connect to my database ... 
>> 
>> In fact I found the address in the following post :
>> https://stat.ethz.ch/pipermail/r-help/2007-August/138142.html
>> 
>> Do you think I can't use it freely ? :(
>> 
>> Thanks for your comments,
>> Ptit Bleu.
>> 
>> 
>> Peter Dalgaard wrote:
>>> 
>>> 
>>> Umm, that looks more than a bit unofficial (parent directory read
>>> protected, no hint of an RMySQL package elsewhere on the site).  Are you
>>> sure that this is intended for redistribution? It sounds like it bundles
>>> in some MySQL libraries, which could imply legal issues.
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/I-can%27t-do-it-again-on-an-other-PC-%3A-R%2BRMySQL--%3Eerror-loading-dll-tf4414597.html#a12633728
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] enquiry

2007-09-12 Thread Vladimir Eremeev



ah06981 wrote:
> 
> Dear R-help,
> 
> I am trying to estimate a Cox model with nested effects basing on the 
> minimization of the overall AIC; I have two frailties terms, both gamma 
> distributed.  There is a error message (theta2 argument  misses) and I 
> don?t understand why. I would like to know what I have wrong. Thank you 
> very much for your time.
> 
> 
> fitM7 <- coxph(Surv(lifespan,censured) ~ south + frailty(id, 
> dist='gamma')+ frailty(mob, dist='gamma'), data= usa)
> 
> 
> tempfun <- function(theta1, theta2) {
> 
> fit <- coxph(Surv(lifespan,censured) ~ south + frailty(id, 
> dist='gamma', sparse= TRUE, theta=theta1)+ frailty(mob, dist='gamma', 
> sparse =TRUE, theta=theta2), data=usa)
> aic <- (fit$loglik[2] - fit$loglik[1]) - sum(fit$df)
> return(2*aic)
> }
> nlminb(c(theta1=3.2,theta2=.2), tempfun)
> 
> Error in (get(temp))(x, ...) : argument "theta2" is missing, with no
> default
> 
> Best,
> Silvia
> 

You need to 
(1) either rewrite your function to accept a single argument and treat it as
a numeric vector:

tempfun <- function(thetas) {
theta1<-thetas[1]
theta2<-thetas[2]


}

(2) or change the call to nlminb:
nlminb(3.2, tempfun,theta2=.2)

But, I suspect, the optimization in this case will be only on theta1.

-- 
View this message in context: 
http://www.nabble.com/enquiry-tf4428517.html#a12633376
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] Inferences for ratios of non-normal means

2007-09-12 Thread Paul Smith
On 9/11/07, Paul Smith <[EMAIL PROTECTED]> wrote:
> The package mratios can perform inferences for ratios of normal means.
> Is there some other package to do the same but with non-normal
> populations. Since I have got large samples, an asymptotic procedure
> would be fine.

Thanks for all replies. I am a bit confused with your replies: some of
you maintain that mratios can be used with large samples of non-normal
populations whereas others direct me to use bootstrap.

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.


Re: [R] Error handling

2007-09-12 Thread Duncan Murdoch
On 12/09/2007 5:08 AM, Christian Schäfer wrote:
> Hi,
> 
> is there a possibility to catch an occurring error and do an appropriate 
> error handling? (like the "try-catch"-statement in other programming 
> languages)

You could use the tryCatch() function (or try(), a simplified wrapper).

Duncan Murdoch
> 
> For example:
> It's quite annoying to run a script for hours only to detect an abortion 
> of the script because of an "subscript out of bounds" error. In that 
> case I would like to react accordingly, i.e. by skipping the actual step 
> in the for-loop, or so.
> 
> Thanks,
> Chris
> 
> __
> 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] enquiry

2007-09-12 Thread ah06981
Dear R-help,

I am trying to estimate a Cox model with nested effects basing on the 
minimization of the overall AIC; I have two frailties terms, both gamma 
distributed.  There is a error message (theta2 argument  misses) and I 
don?t understand why. I would like to know what I have wrong. Thank you 
very much for your time.


fitM7 <- coxph(Surv(lifespan,censured) ~ south + frailty(id, 
dist='gamma')+ frailty(mob, dist='gamma'), data= usa)


tempfun <- function(theta1, theta2) {

fit <- coxph(Surv(lifespan,censured) ~ south + frailty(id, 
dist='gamma', sparse= TRUE, theta=theta1)+ frailty(mob, dist='gamma', 
sparse =TRUE, theta=theta2), data=usa)
aic <- (fit$loglik[2] - fit$loglik[1]) - sum(fit$df)
return(2*aic)
}
nlminb(c(theta1=3.2,theta2=.2), tempfun)




Error in (get(temp))(x, ...) : argument "theta2" is missing, with no default

Best,
Silvia

__
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] stastistical test on normalized data

2007-09-12 Thread Simone Pifferi
Dear R-maillit,

I have to perform a stastistical test to asses if two grug show the same or 
different effect on my prepartion.
I tested on the same preparation only one drug and I have to use normalized 
data due to high variability in the control condictions.
What type can I use? 
A non paramatric test right?
And how can do it on R software?
Thanks in advance

Simone


[[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] Error handling

2007-09-12 Thread Christian Schäfer
Hi,

is there a possibility to catch an occurring error and do an appropriate 
error handling? (like the "try-catch"-statement in other programming 
languages)

For example:
It's quite annoying to run a script for hours only to detect an abortion 
of the script because of an "subscript out of bounds" error. In that 
case I would like to react accordingly, i.e. by skipping the actual step 
in the for-loop, or so.

Thanks,
Chris

__
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] Passing parameters to 'optim' fn function

2007-09-12 Thread Duncan Murdoch
José Luis Aznarte M. wrote:
> Hi again! I'm using the 'optim' method to fix the parameters of a 
> model. I have written the function to be minimised and another function 
> which returns the gradient of the error. Now my problem is that, in 
> order to compute that gradient, it would be extremely convenient to be 
> able to pass some parameters to the gradient function. I don't see how 
> to do it given the fixed syntax of 'optim', which does not allow for 
> parameters being passed to fn and gr:
>
>  > optim(par, fn, gr = NULL, ...)
>
> Of course the first idea would be to "pack" the extra parameters in 
> the vector 'par', but in that case the extra parameters would be 
> optimized too.
> Does anyone have an idea on how to pass parameters to gr in optim? 
> Thanks for your time!
>   

You can put the parameters in the ... argument (watch out for matches to 
earlier optim args!), or into the environments of fn and gr.  For example,

makefn <- function(x) {
  fn <- function(mu) sum((x-mu)^2)
  gr <- function(mu) sum(2*(mu-x))
  list(fn = fn, gr = gr)
}
x <- rnorm(10)
fg <- makefn(x)
optim(1, fg$fn, fg$gr)

Duncan Murdoch

__
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] plot vs curve

2007-09-12 Thread Duncan Murdoch
Christian Ritz wrote:
> Dear list members,
>
> is it intentional that:
>
>
> curve(cos, xlim = c(-5, 5))
> plot(cos, xlim = c(-5, 5))
>
>
> produce different plots?
>
> Shouldn't the 'xlim' argument in both cases set the 'from' and 'to' argument 
> if they 
> aren't supplied (at least that's what I understood reading the help page for 
> 'curve' and 
> 'plot.function')?
>   

Yes, that's a bug in plot().  It sets the default for from and to before 
it checks whether xlim was supplied.  I'll fix it.

Duncan Murdoch
>
> Christian
>
>
>
>
>  > sessionInfo()
> R version 2.5.1 (2007-06-27)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"  "methods"
> [7] "base"
>
> other attached packages:
>car   drc   plotrix  nlme  MASS   lattice
>"1.2-1"   "1.2-3"   "2.2-4"  "3.1-83"  "7.2-34" "0.15-11"
>
> __
> 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] building with atlas version of blas and lapack

2007-09-12 Thread Uwe Ligges


Yuelin Li wrote:
> On my linux machine (Ubuntu Feisty on i-686) this works:
> 
>  ./configure --with-blas="lf77blas -latlas"


Flags should be
   --with-blas="-L/usr/local/atlas/lib -lf77blas -latlas"
I guess, because /usr/local/atlas/lib is not found unless some 
environment variables have been set. This is documented in the R 
Installation and Administration manual, so you probably overlooked it.

Uwe Ligges


> Yuelin.
> 
> -- K Vanw wrote --|Tue (Sep/11/2007)[03:56]|--:
>I'd like to build R using my optimized blas and lapack libraries. It seems
>know matter what I do, the configure script uses the blas supplied with the
>source. My blas and lapack libraries are in /usr/local/atlas/lib. How can I
>get configure to use these?
>
>   [[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.
>
> 
>  
>  =
>  
>  Please note that this e-mail and any files transmitted with it may be 
>  privileged, confidential, and protected from disclosure under 
>  applicable law. If the reader of this message is not the intended 
>  recipient, or an employee or agent responsible for delivering this 
>  message to the intended recipient, you are hereby notified that any 
>  reading, dissemination, distribution, copying, or other use of this 
>  communication or any of its attachments is strictly prohibited.  If 
>  you have received this communication in error, please notify the 
>  sender immediately by replying to this message and deleting this 
>  message, any attachments, and all copies and backups from your 
>  computer.
> 
> __
> 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] Passing parameters to 'optim' fn function

2007-09-12 Thread Dimitris Rizopoulos
you need to use the `...' argument; look at ?optim() for more info.

Best,
Dimitris


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

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


- Original Message - 
From: ""José Luis Aznarte M."" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 12, 2007 10:32 AM
Subject: [R] Passing parameters to 'optim' fn function


>Hi again! I'm using the 'optim' method to fix the parameters of a
> model. I have written the function to be minimised and another 
> function
> which returns the gradient of the error. Now my problem is that, in
> order to compute that gradient, it would be extremely convenient to 
> be
> able to pass some parameters to the gradient function. I don't see 
> how
> to do it given the fixed syntax of 'optim', which does not allow for
> parameters being passed to fn and gr:
>
> > optim(par, fn, gr = NULL, ...)
>
>Of course the first idea would be to "pack" the extra parameters 
> in
> the vector 'par', but in that case the extra parameters would be
> optimized too.
>Does anyone have an idea on how to pass parameters to gr in 
> optim?
> Thanks for your time!
>
> __
> 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] Passing parameters to 'optim' fn function

2007-09-12 Thread Robin Hankin
Hi

Use the dots argument at the end to pass in named parameters.
This is documented as the last in the argument list under ?optim.


Here's a toy example using x and p:

 > f <- function(x,p){sum(x^2)+p*sum(x)}
 > gr <- function(x,p){2*x+p*rep(1,length(x))}
 > optim(par=c(10,10),fn=f,gr=gr,p=13)
$par
[1] -6.498188 -6.499652

$value
[1] -84.5

$counts
function gradient
   63   NA

$convergence
[1] 0

$message
NULL


HTH

rksh


On 12 Sep 2007, at 09:32, José Luis Aznarte M. wrote:

> Hi again! I'm using the 'optim' method to fix the parameters of a
> model. I have written the function to be minimised and another  
> function
> which returns the gradient of the error. Now my problem is that, in
> order to compute that gradient, it would be extremely convenient to be
> able to pass some parameters to the gradient function. I don't see how
> to do it given the fixed syntax of 'optim', which does not allow for
> parameters being passed to fn and gr:
>
>> optim(par, fn, gr = NULL, ...)
>
> Of course the first idea would be to "pack" the extra  
> parameters in
> the vector 'par', but in that case the extra parameters would be
> optimized too.
> Does anyone have an idea on how to pass parameters to gr in optim?
> Thanks for your time!
>
> __
> 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.

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

__
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] Help regading time series data reading

2007-09-12 Thread Petr PIKAL
[EMAIL PROTECTED] napsal dne 12.09.2007 09:36:13:

> On Tue, 2007-09-11 at 19:56 +0300, Tolga Uzuner wrote:
> > Dear R-Users,
> > 
> > Have a question about reading in some data and manipulating dates. I 
> > have a data set in excel which looks like this:
> > 
> > Date PEGETNHSPPTC
> > 13/10/200441.9264.7529.869.27
> > 14/10/200441.9361.7929.989.14
> > 15/10/200441.6962.730.099.04
> > 18/10/200441.3762.1430.398.96
> > 19/10/200441.0161.9829.619.02
> > 20/10/200441.0161.9830.259
> > 
> > I have used read.table by saving the sheety above in tab format to 
> > read this in but am
> > having some difficulties:
> > - the dates above do not seem to be getting read in in date format: 
> > how can I force this ?
> 
> For the first question (I'm not sure how to do the second):

Most probably merge can do the requested synchronization, especially with 
all.** parametrs.

Regards
Petr

> 
> We use read.table() to read in the data from file (here I saved your
> data as tab delimited file 'temp.csv'. Argument as.is = TRUE is used to
> stop R converting character strings (i.e. the Date column here) to
> factors; this saves us a step later converting them back.
> 
> > dat <- read.table("temp.csv", sep = "\t", as.is = TRUE, header = TRUE)
> 
> Data read in OK:
> 
> > dat
> Date   PEG   ETN   HSP  PTC
> 1 13/10/2004 41.92 64.75 29.86 9.27
> 2 14/10/2004 41.93 61.79 29.98 9.14
> 3 15/10/2004 41.69 62.70 30.09 9.04
> 4 18/10/2004 41.37 62.14 30.39 8.96
> 5 19/10/2004 41.01 61.98 29.61 9.02
> 6 20/10/2004 41.01 61.98 30.25 9.00
> 
> Use as.Date() to convert the character strings to a vector of class
> 'Date'. The format argument tells R how the dates are formatted in the
> character strings you just read in. The %d, %m bits etc are place
> holders describing the date parts, but the "/" characters are literal -
> if your dates were formatted "20-10-2004", you would use format = "%d-%
> m-%Y". See ?strftime for how to specify 'format' if you have dates
> formatted in other ways (say with month name instead of number).
> 
> > dat$Date <- as.Date(dat$Date, format = "%d/%m/%Y")
> 
> Note that now dat$Date is now an object of class 'Date':
> 
> > str(dat)
> 'data.frame':   6 obs. of  5 variables:
>  $ Date:Class 'Date'  num [1:6] 12704 12705 12706 12709 12710 ...
>  $ PEG : num  41.9 41.9 41.7 41.4 41.0 ...
>  $ ETN : num  64.8 61.8 62.7 62.1 62.0 ...
>  $ HSP : num  29.9 30.0 30.1 30.4 29.6 ...
>  $ PTC : num  9.27 9.14 9.04 8.96 9.02 9
> 
> Which R will treat appropriately in plots for example:
> 
> > plot(PEG ~ Date, data = dat, type = "l")
> 
> HTH
> 
> G
> 
> -- 
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Gavin Simpson [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
>  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 
> __
> 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] Passing parameters to 'optim' fn function

2007-09-12 Thread José Luis Aznarte M.
Hi again! I'm using the 'optim' method to fix the parameters of a 
model. I have written the function to be minimised and another function 
which returns the gradient of the error. Now my problem is that, in 
order to compute that gradient, it would be extremely convenient to be 
able to pass some parameters to the gradient function. I don't see how 
to do it given the fixed syntax of 'optim', which does not allow for 
parameters being passed to fn and gr:

 > optim(par, fn, gr = NULL, ...)

Of course the first idea would be to "pack" the extra parameters in 
the vector 'par', but in that case the extra parameters would be 
optimized too.
Does anyone have an idea on how to pass parameters to gr in optim? 
Thanks for your time!

__
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] why I cannot change the font and use hot-key in Editor of JGR 1.5-6

2007-09-12 Thread Jim Lemon
Xingwang Ye wrote:
> Dear R users,
> Yesterday, I updated R 2.4.1 to R 2.5.1  on Unbuntu 7.0.4 successfully. 
> I also update the JGR to 1.5-6 according to 
> http://rosuda.org/JGR/linux.shtml (after "sudo update-java-alternatives 
> -s java-6-sun", I cannot do "sudo update-java-alternatives -s 
> java-1.6.0-sun"). I can use the JGR console normally.
> 
> however, I cannot use hot-key such as "ctrl+r" in the Editor, if I use 
> it, the selected contents are replaced by "r", it seems that "ctrl" does 
> not act, whereas I can use mouse to click the "run selection ctrl + r" 
> in menu.
> 
> Another problem is that I can change the font in the console but not in 
> the Editor.
> 
> Could some one help me to solve them? thank you in advance.
> 
Hi Xingwang,
This is pure guessing, but I have noticed with NEdit that if I 
inadvertantly hit the Caps Lock key, the Alt- combinations stop 
working and the letter appears as if I had typed it. As soon as I turn 
off Caps Lock, the problem disappears.

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.


[R] plot vs curve

2007-09-12 Thread Christian Ritz
Dear list members,

is it intentional that:


curve(cos, xlim = c(-5, 5))
plot(cos, xlim = c(-5, 5))


produce different plots?

Shouldn't the 'xlim' argument in both cases set the 'from' and 'to' argument if 
they 
aren't supplied (at least that's what I understood reading the help page for 
'curve' and 
'plot.function')?


Christian




 > sessionInfo()
R version 2.5.1 (2007-06-27)
i386-pc-mingw32

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

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

other attached packages:
   car   drc   plotrix  nlme  MASS   lattice
   "1.2-1"   "1.2-3"   "2.2-4"  "3.1-83"  "7.2-34" "0.15-11"

__
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] Create a "local" repository

2007-09-12 Thread Uwe Ligges


Scott Hyde wrote:
> I'd like to create a small "local" repository that would be used to
> install a package for a class of students at their home.  I don't want
> to upload it to CRAN, as I don't think it should be disseminated at
> that level.
> 
> What I'd like to do is:
> 
>> where="http://mysite.com/";
>> install.packages("mypackage",contriburl=where)
> 
> When I try this, (after placing my mypackage_1.0.tar.gz file in the
> main directory of http://mysite.com/, it responds, in R, when I want
> to install the package:
> 
> Warning: unable to access index for repository http://mysite.com/
> 
> What do I need to do?

You need a PACKAGES file in that directory that gives an index which 
packages are available.

See function write_PACKAGES() in package "tools".

Uwe Ligges


> 
> -Scott
>

__
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] install R packages [SEC=UNCLASSIFIED]

2007-09-12 Thread Uwe Ligges
Do you have to use some proxy server at your work? In that case, please 
read the R for Windows FAQs which tells how to arrange settings.

Uwe Ligges


[EMAIL PROTECTED] wrote:
> Hi All,
> 
>  
> 
> I installed R 2.5.1 recently on a PC (Windows XP Professional 2001) and tried
> to install some R packages. It took several minutes and gave me the following
> message.
> 
>  
> 
>> utils:::menuInstallPkgs()
> 
> --- Please select a CRAN mirror for use in this session ---
> 
> Error in open.connection(file, "r") : unable to open connection
> 
> In addition: Warning message:
> 
> unable to connect to 'cran.r-project.org' on port 80. in:
> open.connection(file, "r") 
> 
> Error in contrib.url(repos, type) : trying to use CRAN without setting a
> mirror
> 
>  
> 
> I am just wondering whether this problem is caused by restrictions on
> internet imposed by my work unit or caused by something else. If the later,
> how to solve it? Thanks in advance.
> 
> Cheers,
> 
> Jin
> 
> 
> 
> Jin Li, PhD
> 
> Spatial Modeller/
> 
> Computational Statistician
> 
> Marine & Coastal Environment
> 
> Geoscience Australia
> 
> Ph: 61 (02) 6249 9899
> 
> Fax: 61 (02) 6249 9956
> 
> email: [EMAIL PROTECTED]
> 
> 
> 
> 
> 
> 
>   [[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.


Re: [R] Help regading time series data reading

2007-09-12 Thread Gavin Simpson
On Tue, 2007-09-11 at 19:56 +0300, Tolga Uzuner wrote:
> Dear R-Users,
> 
> Have a question about reading in some data and manipulating dates. I  
> have a data set in excel which looks like this:
> 
> Date PEGETNHSPPTC
> 13/10/200441.9264.7529.869.27
> 14/10/200441.9361.7929.989.14
> 15/10/200441.6962.730.099.04
> 18/10/200441.3762.1430.398.96
> 19/10/200441.0161.9829.619.02
> 20/10/200441.0161.9830.259
> 
> I have used read.table by saving the sheety above in tab format to  
> read this in but am
> having some difficulties:
> - the dates above do not seem to be getting read in in date format:  
> how can I force this ?

For the first question (I'm not sure how to do the second):

We use read.table() to read in the data from file (here I saved your
data as tab delimited file 'temp.csv'. Argument as.is = TRUE is used to
stop R converting character strings (i.e. the Date column here) to
factors; this saves us a step later converting them back.

> dat <- read.table("temp.csv", sep = "\t", as.is = TRUE, header = TRUE)

Data read in OK:

> dat
Date   PEG   ETN   HSP  PTC
1 13/10/2004 41.92 64.75 29.86 9.27
2 14/10/2004 41.93 61.79 29.98 9.14
3 15/10/2004 41.69 62.70 30.09 9.04
4 18/10/2004 41.37 62.14 30.39 8.96
5 19/10/2004 41.01 61.98 29.61 9.02
6 20/10/2004 41.01 61.98 30.25 9.00

Use as.Date() to convert the character strings to a vector of class
'Date'. The format argument tells R how the dates are formatted in the
character strings you just read in. The %d, %m bits etc are place
holders describing the date parts, but the "/" characters are literal -
if your dates were formatted "20-10-2004", you would use format = "%d-%
m-%Y". See ?strftime for how to specify 'format' if you have dates
formatted in other ways (say with month name instead of number).

> dat$Date <- as.Date(dat$Date, format = "%d/%m/%Y")

Note that now dat$Date is now an object of class 'Date':

> str(dat)
'data.frame':   6 obs. of  5 variables:
 $ Date:Class 'Date'  num [1:6] 12704 12705 12706 12709 12710 ...
 $ PEG : num  41.9 41.9 41.7 41.4 41.0 ...
 $ ETN : num  64.8 61.8 62.7 62.1 62.0 ...
 $ HSP : num  29.9 30.0 30.1 30.4 29.6 ...
 $ PTC : num  9.27 9.14 9.04 8.96 9.02 9

Which R will treat appropriately in plots for example:

> plot(PEG ~ Date, data = dat, type = "l")

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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: to view the memory - and a quiz

2007-09-12 Thread Martin Maechler
>   <[EMAIL PROTECTED]>
> on Wed, 12 Sep 2007 03:01:43 +0100 writes:

> Hello, I am wondering if it is possible to view what
> variables and vairable values are stored in the R
> memory. This to enable debugging of R-scripts I write.

In simple to moderately small examples, I'd recommend (my own creation)

ls.str()

I've lately started to use it also from inside a function,
i.e. after using debug(.) or after options(error = recover) and
a jump "inside a function" to explore the local variables of the
function I'm debugging. In that case, I use

   ls.str(envir = environment())

something which I've been using so frequently lately, that I had
started wondering a bit if some nice (short and simple!)
enhancement to ls.str() was possible which would make
   ls.str()  {without specifying  'envir = environment()'}
automagically use the "proper" environment when run inside a function.
Since then, I had never found the time to follow the idea,
we now have a quiz:  What's the best solution to the above problem?

Martin

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