Re: [R] Time series indexes

2005-04-27 Thread Thomas Petzoldt
Fernando Saldanha schrieb:
I tried to assign values to specific elements of a time series and got
in trouble. The code below should be almost self-explanatory. I wanted
to assign 0 to the first element of x, but instead I assigned  zero to
the second element of x, which is not what I wanted. Is there a
function that will allow me to do this without going into index
arithmetic (which would be prone to errors)?
FS

x- ts(c(1,2,3,4), start = 2)
x
Time Series:
Start = 2 
End = 5 
Frequency = 1 
[1] 1 2 3 4

x[2] - 0
x
Time Series:
Start = 2 
End = 5 
Frequency = 1 
[1] 1 0 3 4

Hello Fernando,
is this what you want:
x[time(x)==2] - 0
ThPe
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: how to add a column with string values to a data frame while still converting them to factors

2005-04-27 Thread Uwe Ligges
avneet singh wrote:
i got the first part:
agm.data$ProdCategory=as.factor(agm.data$ProdCategory)
the second i am still struggling with

For the second part, see ?is.na.
Uwe Ligges

On 4/26/05, avneet singh [EMAIL PROTECTED] wrote:
I have 2 questions. In essence i am trying to create product
categories based on product description and have it as an additional
column of my dataframe. some products dont fit any category and i need
a list of them. i am having some trouble in this simple (for most)
task.
Could you please provide suggestions. Thank you.
avneet
Question 1)
I have a data frame

agm.data=read.xls(agm.xls)
i add a column to it by this and similar statements
agm.data$ProdCategory[agm.data$Product.Description==PGX|agm.data$Product.Description==PGW|agm.data$Product.Description==PS|agm.data$Product.Description==PSX]=Molded
Graphite
if i do
agm.data$ProdCategory
i get:
 [1] Extruded Graphite   Molded Graphite Molded Graphite
  [4] Extruded Graphite   Extruded Graphite   NA
  [7] Molded Graphite Extruded Graphite   Extruded Graphite
 [10] Extruded Graphite   Extruded Graphite   Extruded Graphite
 [13] Extruded Graphite   Porous  Iso-Molded Graphite
.
.
.
.
.
[1222] Extruded Graphite   Molded Graphite Extruded Graphite
[1225] Extruded Graphite   Extruded Graphite   NA
[1228] Iso-Molded Graphite Extruded Graphite   NA
if i check the class, i get
is(agm.data$ProdC)
[1] character vector
i want this to have..
[1] factor   oldClass
..like other columns have
Question 2)some values of agm.data$ProdCategory are NA. i want to find
corresponding values of agm.data$Product.Description so i give the
following command
agm.data$Product.Description[agm.data$ProdCategory==NA]
i get:
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA
NA NA NA
[17] NA NA NA NA NA NA NA NA NA NA NA NA NA
NA NA NA
.
.
.
.
.
.
[257] NA NA NA NA NA NA NA NA NA NA NA NA NA
NA NA NA
[273] NA NA NA NA NA
165 Levels:  1.563x24 10x50x60 61x1.25 6x72 890S 8x6 9x7; 10x1.5 AGR ... YBDXX88
--
God created man because he was disappointed over the apes. After that he has
given up any further experiments ~Mark Twain


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


Re: [R] how to modify and compile R sourse codes

2005-04-27 Thread David Whiting
Zhongming Yang [EMAIL PROTECTED] writes:

You can get the source code from the source package and modify
it. You'll have to read the relevant documentation about the tools you
need to compile it---see the archives, there was a discussion recently
about this, and see the documenation that comes with R.  I don't use
Windows so I can't give any more advice.

Depending on what you need to do you might find that what you need is
already in the CVS version of Hmisc. The code was added recently and
is mentioned here:

http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport

A PDF with a few simple examples (created while developing and testing
the code) are shown here:

http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/latexFineControl.pdf

The new options allow you to use any latex command (declaration) to
format row and column names, row and column group labels, and each
cell of a table individually.  Defining new commands in the preamble
of your LaTeX document you can great all sorts of splendid (and
awful!)  combinations of formats.

The current version (3.0-5) has options to format the row and column
group labels (note that in the CVS version the option name for the
column group labels has changed).

In case you are not aware of it I should mention that the Sweave
function in the tools package is wonderful for creating automated
reports.

HTH

David



 Dear All:
  
 I am working on writing some R functions to make statistical reports
 automatically. Dr. Harrell's Hmisc has all the wonderful stuff. But
 sometimes I need change some formats, so I want to read through it and
 make some modifications to fit my project.
  
 Ideally, I want proceed as following: 1. change some source of Hmisc
 2. compile and install the modified Hmisc 3. debug my modified
 functions.
  
 And I am working on windows 2000.
  
 Could anyone give some suggestions on the tools and the best way to do
 this?
  
 Thanks

 __



   [[alternative HTML version deleted]]

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


-- 
David Whiting
University of Newcastle upon Tyne, UK

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


Re: [R] how to modify and compile R sourse codes

2005-04-27 Thread Uwe Ligges
Zhongming Yang wrote:
Dear All:
 
I am working on writing some R functions to make statistical reports automatically. Dr. Harrell's Hmisc has all the wonderful stuff. But sometimes I need change some formats,  so I want to read through it and make some modifications to fit my project. 
 
Ideally, I want proceed as following:
1. change some source of Hmisc
2. compile and install the modified Hmisc
3. debug my modified functions.
 
And I am working on windows 2000.
 
Could anyone give some suggestions on the tools and the best way to do this?
The R Installation and Administration manual of R-2.1.0 gives not only 
suggestions: it provides all the details on the tools required! The 
manual Writing R Extensions is relevant as well.

Uwe Ligges

Thanks 

__

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


Re: [R] Re: how to add a column with string values to a data frame while still converting them to factors

2005-04-27 Thread Petr Pikal
Hi

On 26 Apr 2005 at 16:18, avneet singh wrote:

 i got the first part:
 
 agm.data$ProdCategory=as.factor(agm.data$ProdCategory)
 
 the second i am still struggling with

?is.na

is.na(whatever)

is what you probably want.

Cheers
Petr



 
 
 On 4/26/05, avneet singh [EMAIL PROTECTED] wrote:
  I have 2 questions. In essence i am trying to create product
  categories based on product description and have it as an additional
  column of my dataframe. some products dont fit any category and i
  need a list of them. i am having some trouble in this simple (for
  most) task. Could you please provide suggestions. Thank you.
  
  avneet
  
  Question 1)
  
  I have a data frame
  
  agm.data=read.xls(agm.xls)
  
  i add a column to it by this and similar statements
  agm.data$ProdCategory[agm.data$Product.Description==PGX|agm.data$
  Product.Description==PGW|agm.data$Product.Description==PS|agm.d
  ata$Product.Description==PSX]=Molded
  Graphite
  
  if i do
  agm.data$ProdCategory
  
  i get:
  
[1] Extruded Graphite   Molded Graphite Molded Graphite
 [4] Extruded Graphite   Extruded Graphite   NA
 [7] Molded Graphite Extruded Graphite   Extruded
 Graphite
[10] Extruded Graphite   Extruded Graphite   Extruded
Graphite [13] Extruded Graphite   Porous 
Iso-Molded Graphite
  .
  .
  .
  .
  .
  [1222] Extruded Graphite   Molded Graphite Extruded
  Graphite [1225] Extruded Graphite   Extruded Graphite   NA
  [1228] Iso-Molded Graphite Extruded Graphite   NA
  
  if i check the class, i get
  is(agm.data$ProdC)
  [1] character vector
  
  i want this to have..
  [1] factor   oldClass
  
  ..like other columns have
  
  Question 2)some values of agm.data$ProdCategory are NA. i want to
  find corresponding values of agm.data$Product.Description so i give
  the following command
  agm.data$Product.Description[agm.data$ProdCategory==NA]
  
  i get:
  
  [1] NA NA NA NA NA NA NA NA NA NA NA NA NA
  NA NA NA
   [17] NA NA NA NA NA NA NA NA NA NA NA NA
   NA
  NA NA NA
  .
  .
  .
  .
  .
  .
  [257] NA NA NA NA NA NA NA NA NA NA NA NA
  NA NA NA NA [273] NA NA NA NA NA 165 Levels: 
  1.563x24 10x50x60 61x1.25 6x72 890S 8x6 9x7; 10x1.5 AGR ... YBDXX88
  
  --
  God created man because he was disappointed over the apes. After
  that he has given up any further experiments ~Mark Twain
  
 
 
 -- 
 God created man because he was disappointed over the apes. After that
 he has given up any further experiments ~Mark Twain
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] making table() work

2005-04-27 Thread Ale iberna
I belive that the problem is not with the table, but with your predictions 
which are not 0s and 1s.

Ales Ziberna
- Original Message - 
From: Stephen Choularton [EMAIL PROTECTED]
To: 'R Help' r-help@stat.math.ethz.ch
Sent: Wednesday, April 27, 2005 4:19 AM
Subject: [R] making table() work

I am trying to do some verification across a large dataset, cuData, that
has 23 columns.
Column 23 (similarity) is the outcome 0 or 1 and the other columns are
the features.
I do this:
verificationglm.model - glm(formula = similarity ~ ., family=binomial,
data=cuData[1:1000,])
and produce the model:
summary(verificationglm.model)
Call:
glm(formula = similarity ~ ., family = binomial, data = cuData[1:1000,
   ])
Deviance Residuals:
   Min   1Q   Median   3Q  Max
-2.3885  -0.8943  -0.2918   0.8851   2.7025
Coefficients:
   Estimate Std. Error z value Pr(|z|)
(Intercept)   26.3112869 21.2229690   1.240 0.215066
length-0.6249415  0.1906254  -3.278 0.001044 **
meanPitch -0.0110389  0.0053083  -2.080 0.037565 *
minimumPitch   0.0002689  0.0024290   0.111 0.911845
maximumPitch  -0.0013454  0.0038149  -0.353 0.724326
meanF1-0.0362153  0.0112499  -3.219 0.001286 **
meanF2 0.0016765  0.0115335   0.145 0.884430
meanF3 0.0073960  0.0076235   0.970 0.331964
meanF4 0.0063015  0.0016820   3.746 0.000179 ***
meanF5-0.0022535  0.0024885  -0.906 0.365153
ratioF2ToF1   -1.2322825  7.0036532  -0.176 0.860334
ratioF3ToF1   -4.9643148  4.5973552  -1.080 0.280222
jitter-8.7535283 14.5273818  -0.603 0.546806
shimmer1.6706067  2.6327972   0.635 0.525731
percentUnvoicedFrames -0.4863219  1.1638115  -0.418 0.676042
numberOfVoiceBreaks   -0.0335636  0.0634956  -0.529 0.597086
percentOfVoiceBreaks  -2.9353239  0.8945600  -3.281 0.001033 **
meanIntensity -0.2931293  0.3355314  -0.874 0.382321
minimumIntensity   0.0689654  0.1531059   0.450 0.652392
maximumIntensity   0.2186570  0.2510906   0.871 0.383848
ratioIntensity-8.1777871 13.1676287  -0.621 0.534565
noSyllsIntensity   0.1714826  0.0695021   2.467 0.013614 *
speakingRate  -0.3564808  0.1507373  -2.365 0.018034 *
startSpeech   -1.3537348  6.7337461  -0.201 0.840669
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
(Dispersion parameter for binomial family taken to be 1)
   Null deviance: 1384.0  on 999  degrees of freedom
Residual deviance: 1084.7  on 976  degrees of freedom
AIC: 1132.7
Number of Fisher Scoring iterations: 5

Now I want to use the model to predict on a different part of the
dataset.
I try this, and get my prediction:

pred - predict(verificationglm.model, cuData[1001:2000,1:23])
pred
   1001 1002 1003 1004 1005
1006 1007
-0.495901722 -2.406349629 -0.911082179 -0.965869553 -0.488695693
-1.849622304 -1.637722247
   1008 1009 1010 1011 1012
1013 1014
-1.148952722 -0.191538278 -1.511895046 -2.989036645 -2.775775622
0.603852124 -0.838613048
   1015 1016 1017 1018 1019
1020 1021
-0.434259674 -2.004230065 -0.234829011  1.666502334  2.039631718
-0.592192326  1.667700087
   1022 1023 1024 1025 1026
1027 1028
0.104644531  1.748724399  0.391461247  1.356898357  1.468154760
1.090708994  1.071487227
   1029 1030 1031 1032 1033
1034 1035
0.720596788  2.378350706 -0.128248232  0.969373318  0.315142756
1.372108172 -2.399517898
   1036 1037 1038 1039 1040
1041 1042
-0.684530171  0.761198819 -1.298372615  1.185368711 -1.148974059
0.358234433  0.671495255
   1043 1044 1045 1046 1047
1048 1049
0.683771224  0.663767266  2.009012643  0.196591464  2.063417812
0.823472345  0.696638161
[runs on to 2000]
However, I then want to check for classAgreement (an e1701 package
function).  First I want a table. I do this:
t = table(pred,cuData[1001:2000,24])
t
pred   0 1
 -8.900700989801060 1
 -8.0484071844879 0 1
 -7.792985487755231 0
 -7.183383306090131 0
[runs on]
when I expect this
0 1
0  ??
1  ??
with the ?s being some count.  When I look at my slice of cuData it
looks like this:
cuData[1001:2000,24]
  [1] 1 0 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 1
1 1 1 1
 [38] 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 0 0
0 1 1 0
 [75] 1 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 0 1
0 0 0 0
[112] 0 1 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0
[149] 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1
0 1 0 0
[186] 0 1 0 0 0 1 0 0 0 0 1 1 0 1 1 1 0 0 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1
1 

Re: [R] survreg with numerical covariates

2005-04-27 Thread Ales Ziberna
As you can se from the example bellow, survreg works prefeclty fine with 
numerical values. (I'm runing R2.0.1 on WinXP(SP2) and 32bit AMD with 
survival version 2.17.).

As the posting guide asks, plese provide a small example.
Ales Ziberna

library(survival)
Loading required package: splines
data(cancer)
survreg(Surv(time, status)~age,data=cancer)
Call:
survreg(formula = Surv(time, status) ~ age, data = cancer)
Coefficients:
(Intercept) age
6.88712062 -0.01360829
Scale= 0.7587515
Loglik(model)= -1151.9   Loglik(intercept only)= -1153.9
   Chisq= 3.91 on 1 degrees of freedom, p= 0.048
n= 228
- Original Message - 
From: Richard Mott [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, April 26, 2005 11:32 PM
Subject: [R] survreg with numerical covariates


Does anyone know if the survreg function in the survival package can fit 
numerical covariates ?

When I fit a survival model of the form
survreg( Surv(time,censored) ~ x )
then x is always treated as a factor even if it is numeric (and even if I 
try to force it to be numeric using as.numeric(x). Thus, in the particular 
example I am analysing, a simple numerical covariate becomes a factor with 
190 levels. Is this the expected behaviour ? Am I doing something wrong ?

I am running R 2.0.1 on a 64bit Debian Linux system, and version 2.17 of 
the survival package

Thanks
Richard Mott
--

Richard Mott   | Wellcome Trust Centre
tel 01865 287588   | for Human Genetics
fax 01865 287697   | Roosevelt Drive, Oxford OX3 7BN
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html


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


Re: [R] good editor for R sources ? - Thanks

2005-04-27 Thread vincent
Thank you very much for all the
useful answers.
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] libz library missing while installing RMySQL

2005-04-27 Thread Sebastian Leuzinger

Hello
Trying to install the MySQL package, I get the following error. The help 
archive contains something on this issue but did not help. I work on linux 
suse 9.3

Configuration error:
   Could not locate the library libz required by MySQL.

The library libz however is not on any mirrors I checked.

Sebastian Leuzinger
web   http://pages.unibas.ch/botschoen/leuzinger

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


Re: [R] survreg with numerical covariates

2005-04-27 Thread Richard Mott
Ales - I have identified the problem. It is caused by missing data. In 
my previous posting I was analysing a dataset which happened to have 190 
missing values in the covariate. I compared two models:

r0 - survreg(s ~1)
r1 - survreg(s~x)
anova(r0,r1)
I was using anova to investigate the significance of adding covariates 
to the model, rather than printing out the results of a survreg() 
directly, and this was the problem. The behaviour of anova() is subtly 
different when applied to lm() or survreg().  With lm(), if the models 
compared have different numbers of missing observations, you get a 
warning, but with survreg(), the difference in observation count shows 
up as a large change in the df and deviance, giving the appearence that 
the covariate has been fitted as a factor with 191 levels.

So my fault, although possibly anova(survreg()) should be consistent 
with anova(lm()).

-Richard
Ales Ziberna wrote:
As you can se from the example bellow, survreg works prefeclty fine 
with numerical values. (I'm runing R2.0.1 on WinXP(SP2) and 32bit AMD 
with survival version 2.17.).

As the posting guide asks, plese provide a small example.
Ales Ziberna

library(survival)
Loading required package: splines
data(cancer)
survreg(Surv(time, status)~age,data=cancer)
Call:
survreg(formula = Surv(time, status) ~ age, data = cancer)
Coefficients:
(Intercept) age
6.88712062 -0.01360829
Scale= 0.7587515
Loglik(model)= -1151.9   Loglik(intercept only)= -1153.9
   Chisq= 3.91 on 1 degrees of freedom, p= 0.048
n= 228
- Original Message - From: Richard Mott 
[EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, April 26, 2005 11:32 PM
Subject: [R] survreg with numerical covariates


Does anyone know if the survreg function in the survival package can 
fit numerical covariates ?

When I fit a survival model of the form
survreg( Surv(time,censored) ~ x )
then x is always treated as a factor even if it is numeric (and even 
if I try to force it to be numeric using as.numeric(x). Thus, in the 
particular example I am analysing, a simple numerical covariate 
becomes a factor with 190 levels. Is this the expected behaviour ? Am 
I doing something wrong ?

I am running R 2.0.1 on a 64bit Debian Linux system, and version 2.17 
of the survival package

Thanks
Richard Mott
--

Richard Mott   | Wellcome Trust Centre
tel 01865 287588   | for Human Genetics
fax 01865 287697   | Roosevelt Drive, Oxford OX3 7BN
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html




--

Richard Mott   | Wellcome Trust Centre 
tel 01865 287588   | for Human Genetics
fax 01865 287697   | Roosevelt Drive, Oxford OX3 7BN

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


[R] dyn.load(), DLL, Fortran, TLNise software

2005-04-27 Thread accetta
Dear all,

I would like to call TLNise  (Two-Level Normal indipendent sampling 
estimation)
software within R. 

This software estimates a hierarchical model and it can be download from
Philip Everson's website at 
http://www.swarthmore.edu/NatSci/peverso1/TLNise/tlnise.htm;.

The TLNise software consists of:

1) a Fortran source code (tlnisemv1.f) and 
2) a Splus code (TLNisemv1.src)


To use this codes within R:

1) I compiled the source code using g77 (from MinGW). 
I typed  g77 -c tlnisemv1.f  to  create a Fortran object file (tlnisemv1.o).


2) I edited  TLNisemv1.src to point to my copy of tlnise.o. 
I changed the path in dyn.load(c:\\tlnisemv1.o)

3) I modified the Splus code to be used in R (i.e I changed _ with -)

4) I sourced TLNisemv1.src into R using  source(c/TLNisemv1.src) to load
the R functions.


But when I tried to load  the shared library using the dyn.load() function
I got an error message: 

Error in dyn.load(x, as.logical(local), as.logical(now)) : 
unable to load shared library 
c:/programmi/wingw/programs/tlnisemv1.dll:


So I decided to build a DLL from the source file tlnisemv1.f.

For doing this, I first typed g77 --shared -o tlnisemv1.dll tlnisemv.f
using  g77 (from MinGW).
Then I edited  TLNisemv1.src to point to my copy of tlnisemv1.dll. 

But again  when I tried to load  the shared library using dyn.load() function
 I got the same error message.


How can I debug this problem? 
How should I proceed? 
Have you have used TLNise software in R?


Thank you

Gabriele Accetta

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


[R] DLL problem when using gcc+gsl

2005-04-27 Thread Vumani Dlamini
Dear list;
This might sound a bit naive, but then I am new to linking C DLL's to R.
I have built a DLL using GCC and am able to load the DLL in R 
(is.loaded(contents)==TRUE). When I include it in my function it returns 
NaN for all the variables. My R function is,

dyn.load(c:/data/tempdll.dll)
is.loaded(contents)#returns TRUE
#
contents - function(new.cases){
   cases - rep(0, length(new.cases))
   case.times - rep(0, length(new.cases))
   temp - .C(contents,
   as.integer(cases),
   as.double(case.times))
}
and the header of my C function is
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT void contents (int *cases,
double *case_times);
#endif /* _DLL_H_ */
and my C function is.
#include windows.h
#include stdio.h
#include stdlib.h
#include dll.h
#include gsl/gsl_rng.h
#include gsl/gsl_randist.h
void contents(int *cases,
 double *case_times)
{
   gsl_rng * r;
   gsl_rng_env_setup();
   r = gsl_rng_alloc (gsl_rng_default);
   int i;
for(i = 0; i  1000; i++)
{
   cases[i] = gsl_ran_negative_binomial (r, 0.10/2.10, 0.10);
   case_times[i] = gsl_ran_weibull (r, 9, 5);
}
   gsl_rng_free (r);
}
I am clueless as to where it all goes wrong, as if I make the program an 
executable it works.

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


Re: [R] dyn.load(), DLL, Fortran, TLNise software

2005-04-27 Thread Martin Maechler
 accetta == accetta  [EMAIL PROTECTED]
 on Wed, 27 Apr 2005 11:55:56 +0200 writes:

accetta Dear all, I would like to call TLNise (Two-Level
accetta Normal indipendent sampling estimation) software
accetta within R.

accetta This software estimates a hierarchical model and it
accetta can be download from Philip Everson's website at
accetta http://www.swarthmore.edu/NatSci/peverso1/TLNise/tlnise.htm;.

accetta The TLNise software consists of:

accetta 1) a Fortran source code (tlnisemv1.f) and 2) a
accetta Splus code (TLNisemv1.src)


accetta To use this codes within R:

accetta 1) I compiled the source code using g77 (from
accetta MinGW).  I typed g77 -c tlnisemv1.f to create a
accetta Fortran object file (tlnisemv1.o).


accetta 2) I edited TLNisemv1.src to point to my copy of
accetta tlnise.o.  I changed the path in
accetta dyn.load(c:\\tlnisemv1.o)

(which was not ok, as you noticed later)

accetta 3) I modified the Splus code to be used in R (i.e I
accetta changed _ with -)

accetta 4) I sourced TLNisemv1.src into R using
accetta source(c/TLNisemv1.src) to load the R functions.


accetta But when I tried to load the shared library using
accetta the dyn.load() function I got an error message:

accetta Error in dyn.load(x, as.logical(local),
accetta as.logical(now)) : unable to load shared library
accetta c:/programmi/wingw/programs/tlnisemv1.dll:


accetta So I decided to build a DLL from the source file
accetta tlnisemv1.f.

accetta For doing this, I first typed 
accetta g77 --shared -o tlnisemv1.dll tlnisemv.f using g77 (from MinGW).
accetta Then I edited TLNisemv1.src to point to my copy of
accetta tlnisemv1.dll.

Here, you should have used something like

   Rcmd SHLIB tlnisemv.f

which probably calls g77 itself, but does so in way compatible
with your version of R --- which is very important.

accetta But again when I tried to load the shared library
accetta using dyn.load() function I got the same error
accetta message.

accetta How can I debug this problem?  How should I
accetta proceed?  Have you have used TLNise software in R?

accetta Thank you
accetta Gabriele Accetta

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


Re: [R] good editor for R sources ? CE is supported

2005-04-27 Thread Michael Grant
Just for the record and to avoid confusion: R IS
supported in Crimson Editor. Look under syntax files
568 and 314. I've used it for a couple of years to no
ill effect. It is fine for light use to moderate use.
However, given the updates in R, maybe the syntax
files are a little long in tooth in a spot or two.


--- vincent [EMAIL PROTECTED] wrote:
 Dear all,
 (Sorry if the question has already been answered.)
 Could someone please suggest a good text editor for
 writing R sources ?
 (I know emacs exists ... but I find it a bit heavy).
 I use crimson (http://www.crimsoneditor.com) which
 is
 small and simple, but the R syntax seems not to be
 supported.
 Thanks for any advice
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


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


[R] Take a levels

2005-04-27 Thread Muhammad Subianto
Dear all,
How can I take a levels from a dataset.
For example,

data(iris)
x.iris - iris[,1:4]
y.iris - iris[,5]
 y.iris
  [1] setosa setosa setosa setosa setosa setosa   
  [7] setosa setosa setosa setosa setosa setosa   

[139] virginica  virginica  virginica  virginica  virginica  virginica
[145] virginica  virginica  virginica  virginica  virginica  virginica
Levels: setosa versicolor virginica
 
I want like,
y.iris level are,
[] setosa versicolor virginica

Best regards,
Muhammad Subianto

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


Re: [R] Take a levels

2005-04-27 Thread Sean Davis
On Apr 27, 2005, at 8:21 AM, Muhammad Subianto wrote:
Dear all,
How can I take a levels from a dataset.
For example,
data(iris)
x.iris - iris[,1:4]
y.iris - iris[,5]
y.iris
  [1] setosa setosa setosa setosa setosa setosa
  [7] setosa setosa setosa setosa setosa setosa

[139] virginica  virginica  virginica  virginica  virginica  virginica
[145] virginica  virginica  virginica  virginica  virginica  virginica
Levels: setosa versicolor virginica
I want like,
y.iris level are,
[] setosa versicolor virginica
Muhammad,
See ?unique and ?factor.
Sean
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Take a levels

2005-04-27 Thread Dimitris Rizopoulos
probably you want:
levels(y.iris)
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/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message - 
From: Muhammad Subianto [EMAIL PROTECTED]
To: R-help@stat.math.ethz.ch
Sent: Wednesday, April 27, 2005 2:21 PM
Subject: [R] Take a levels


Dear all,
How can I take a levels from a dataset.
For example,
data(iris)
x.iris - iris[,1:4]
y.iris - iris[,5]
y.iris
 [1] setosa setosa setosa setosa setosa setosa
 [7] setosa setosa setosa setosa setosa setosa

[139] virginica  virginica  virginica  virginica  virginica 
virginica
[145] virginica  virginica  virginica  virginica  virginica 
virginica
Levels: setosa versicolor virginica

I want like,
y.iris level are,
[] setosa versicolor virginica
Best regards,
Muhammad Subianto
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

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


Re: [R] Take a levels

2005-04-27 Thread Muhammad Subianto
Thanks you very much.
 
 levels(y.iris)


Best regards,
Muhammad Subianto

[[alternative HTML version deleted]]

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


RE: [R] Take a levels

2005-04-27 Thread Eric Lecoutre



Well... did you look at the help page on factors???
Did you even make a search?
The answer is within your question:

 levels(iris[,5])
[1] setosa versicolor virginica 

Eric

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Muhammad Subianto
 Sent: mercredi 27 avril 2005 14:22
 To: R-help@stat.math.ethz.ch
 Subject: [R] Take a levels
 
 
 Dear all,
 How can I take a levels from a dataset.
 For example,
 
 data(iris)
 x.iris - iris[,1:4]
 y.iris - iris[,5]
  y.iris
   [1] setosa setosa setosa setosa setosa setosa   
   [7] setosa setosa setosa setosa setosa setosa   
 
 [139] virginica  virginica  virginica  virginica  virginica  
 virginica [145] virginica  virginica  virginica  virginica  
 virginica  virginica
 Levels: setosa versicolor virginica
  
 I want like,
 y.iris level are,
 [] setosa versicolor virginica
 
 Best regards,
 Muhammad Subianto
 
 __
 R-help@stat.math.ethz.ch mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


Re: [R] Time series indexes

2005-04-27 Thread Gabor Grothendieck
On 4/26/05, Fernando Saldanha [EMAIL PROTECTED] wrote: 
 
 I tried to assign values to specific elements of a time series and got
 in trouble. The code below should be almost self-explanatory. I wanted
 to assign 0 to the first element of x, but instead I assigned zero to
 the second element of x, which is not what I wanted. Is there a
 function that will allow me to do this without going into index
 arithmetic (which would be prone to errors)?
 
 FS
 
  x- ts(c(1,2,3,4), start = 2)
  x
 Time Series:
 Start = 2
 End = 5
 Frequency = 1
 [1] 1 2 3 4
  x[2] - 0
  x
 Time Series:
 Start = 2
 End = 5
 Frequency = 1
 [1] 1 0 3 4

 Any of the following will do it:
 x[1] - 0
 # or
 window(x, start = 2, end = 2) - 0
 # or since time 2 is at the beginning:
 window(x, end = 2) - 0

[[alternative HTML version deleted]]

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


Re: [R] Error using e1071 svm: NA/NaN/Inf in foreign function call

2005-04-27 Thread Achim Zeileis
On Wed, 27 Apr 2005 10:25:55 +0100 João Mendes Moreira wrote:

 My mistake.
 
 I am sending the ImageBeforeError.RData file.

No, no, no! Please the read the posting guide and please read the
answers that were posted for you. As you obviously did not do that, let
me read it to you again:
  Z
  Wouldn't it be possible to simply use a data set that is already
  available in R, *please*?
  /Z
The solution is definitely not to send a huge data file (6.5M) to
those who offered advice and to the subsribers of R-help (where it does
not get through anyway, I think). If it is really data-dependent, then
you might post the data on the web, but even then it is not very helpful
to post a file in which there are dozens of objects when all you need is
a data frame.

 To reproduce the error you must load the file and then to do:
 
 library(e1071)
 model - do.call(learner,learner.pars)
 
 I am using nu = 0.7. At this moment I do not get an error but the svm 
 function blocks. It was al that night running without results.

So there is no error as you claim above (and as you claimed in your
previous mail). This is just to report the fact, that your computations
are still running.

Let me provide a simple reproducible example which does not involve
spamming R-helpers with .RData files.
You seem to want to report that the svm

set.seed(1071)
y - rnorm(100)
x1 - rnorm(100)
x2 - rnorm(100)
svm(y ~ x1 + x2)

can be fitted very quickly whereas

svm(y ~ x1 + x2, cost = 4096, kernel = polynomial, degree = 4)

takes much longer. The decisive parameter here is the cost parameter
which is unusually large. I'm not sure why the algorithm gets so slow,
but you might also want to check whether a cost parameter of the
magnitude is appropriate. The other parameter which is important is the
degree of the polynomial kernel, in which the complexity is also
increasing.

So the message is: Be careful in the selection of the hyperparameters of
the SVM. Maybe someone else on the list can provide more insight on
guidelines for choosing the hyperparameters of a polynomial kernel SVM.
Z



 Using
 other kernels it used to finish in a few seconds. I have done already
 thousands of tests with other kernels. Only with the polynomial one I
 am not able to get results.
 
 Thanks for any help.
 
 Joao
 - Original Message - 
 From: Achim Zeileis [EMAIL PROTECTED]
 To: João Mendes Moreira [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Tuesday, April 26, 2005 4:09 PM
 Subject: Re: [R] Error using e1071 svm: NA/NaN/Inf in foreign function
 call
 
 
  On Tue, 26 Apr 2005 15:46:20 +0100 João Mendes Moreira wrote:
 
  Hello,
 
  As far I saw in archive mailing list, I am not the first person
 with this problem. Anyway I was not able to pass this error once the
  information I got from the archive it is not very conclusive for
 this case. I have used linear, radial and sigmoid kernels for the
 same data in the same conditions and everything is ok.  This problem
 just happens with the polynomial kernel. I send the debuging result
 from a reproducible example. The error message is at the end.
 
  I receive a different error message:
   Error in eval(expr, envir, enclos) : Object Fim not found
  So much for the reproducibility... Wouldn't it be possible to simply
  use a data set that is already available in R, *please*?
 
  Anyways, it seems that your specification of `nu' causes the
  problem: 0 might be a little bit too small.
  Z
 
  


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


[R] Split dataset as factor and numeric

2005-04-27 Thread Jan Sabee
Dear all,
If I have dataset like,
A125
B 2
AA0
C 0
A11
B 3
A10
C 3
B 0
A145
A17
C 0
B 0
A10
B 6
B 3

Is there any function to split like,
A125
A11
A10
A145
A17
A10

or 

AA0
C 0
A10
B 0
B 0
C 0
B 0
A10

Thanks,
Jan Sabee

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


[R] R for Windows MSI Installation File

2005-04-27 Thread Richard Abraham
Hi,
Just wondering if anyone has created (or knows where one is available from) 
an MSI installation file for R v2.0.1?
Many thanks,
Richard.


Richard Abraham
Senior Information Systems Officer
Department of Social Medicine, University of Bristol
Tel: 44(0)117 928 7254
Fax: 44(0)117 928 7265
Email: [EMAIL PROTECTED]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Split dataset as factor and numeric

2005-04-27 Thread Sundar Dorai-Raj
Jan Sabee wrote on 4/27/2005 5:58 AM:
Dear all,
If I have dataset like,
A125
B 2
AA0
C 0
A11
B 3
A10
C 3
B 0
A145
A17
C 0
B 0
A10
B 6
B 3
Is there any function to split like,
A125
A11
A10
A145
A17
A10
or 

AA0
C 0
A10
B 0
B 0
C 0
B 0
A10
Thanks,
Jan Sabee
Jan,
?subset
subset(x, V1 == A1)
subset(x, V2 == 0)
HTH,
--sundar
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] date format

2005-04-27 Thread alessandro carletti
Hi,
I'm trying to convert a vector containing dates in
character format (dd/mm/yy): mdy.date (from date
package) seems to be able to do that, but it returns
to me a  vector containing julian dates... but
negative!
for example:

16/12/03 is converted into -20470

it is because R recognizes year ../03 as 1903, instead
of 2003, but how can I do to solve this problem? (of
course, I could add 36525 to each data, but it's not
very elegant)

Thanks

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


Re: [R] lattice plot problem!

2005-04-27 Thread Deepayan Sarkar
On Tuesday 26 April 2005 21:52, Ivy_Li wrote:
 Hello everybody,
  Could I consult you two questions?
  Recently I write some code about lattice plot.
 1) bwplot function
  I know the lattice default background color is grey and the box
 color is green, but I don't like the color. So I change the
 background color to white use the

  trellis.device(bg=white)

That doesn't (and is not intended to) change the lattice background 
color to white. If it does, you are using an old version of R, please 
consider upgrading. In recent versions, the help page for 
trellis.device discusses this issue in some detail. Most of the 
commentary applies to earlier versions as well; if you are unwilling to 
upgrade R, you can still read it at

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

  then I modify the

  panel=function(...)

 +{
 + panel.bwplot(col=black...)
 + }

  But I find the the box color is still green, just change the color
 of point which is in the box, I guss it is the mean or median value
 of the data. So How to change the color of box, and how to change the
 shape of the point in the box. I want it like other boxplot, like a
 horizontal line.

 2) In every lattices, I want to add a mean line of the group. I try
 the

 panel.abline(h)

  But I find in very lattice add the same line. Then I try the
 panel.linejoin etc. But I can not get my wish plot.

Tom Mulholland has already responded to this part.

Deepayan

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


Re: [R] date format

2005-04-27 Thread Dimitris Rizopoulos
you could use as.Date(), i.e.,
ss - 16/12/03
as.Date(ss, %d/%m/%y)
julian(as.Date(ss, %d/%m/%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/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message - 
From: alessandro carletti [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Wednesday, April 27, 2005 3:08 PM
Subject: [R] date format


Hi,
I'm trying to convert a vector containing dates in
character format (dd/mm/yy): mdy.date (from date
package) seems to be able to do that, but it returns
to me a  vector containing julian dates... but
negative!
for example:
16/12/03 is converted into -20470
it is because R recognizes year ../03 as 1903, instead
of 2003, but how can I do to solve this problem? (of
course, I could add 36525 to each data, but it's not
very elegant)
Thanks
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

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


Re: [R] date format

2005-04-27 Thread Prof Brian Ripley
You haven't even begun to tell us how you are doing this.  R does not 
itself convert dates to numbers, to wit:

as.Date(16/12/03, %d/%m/%y)
[1] 2003-12-16
Here's one way:
x - as.Date(16/12/03, %d/%m/%y)
xx - as.POSIXlt(x)
xx$year - xx$year-100
as.Date(xx)
On Wed, 27 Apr 2005, alessandro carletti wrote:
Hi,
I'm trying to convert a vector containing dates in
character format (dd/mm/yy): mdy.date (from date
package) seems to be able to do that, but it returns
to me a  vector containing julian dates... but
negative!
for example:
16/12/03 is converted into -20470
it is because R recognizes year ../03 as 1903, instead
of 2003, but how can I do to solve this problem? (of
course, I could add 36525 to each data, but it's not
very elegant)
Not to say wrong.
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R for Windows MSI Installation File

2005-04-27 Thread Philippe Grosjean
Richard Abraham wrote:
Hi,
Just wondering if anyone has created (or knows where one is available 
from) an MSI installation file for R v2.0.1?
Many thanks,
Richard.
The setup program build by Inno Setup, as you find it in the binaries 
section of CRAN is much better than what you would get with the MSI 
installer, and it has all required features.
Best,

Philippe Grosjean

Richard Abraham
Senior Information Systems Officer
Department of Social Medicine, University of Bristol
Tel: 44(0)117 928 7254
Fax: 44(0)117 928 7265
Email: [EMAIL PROTECTED]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html


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


Re: [R] R for Windows MSI Installation File

2005-04-27 Thread Prof Brian Ripley
On Wed, 27 Apr 2005, Richard Abraham wrote:
Brian,
I can use an MSI installer package to install R on any number of Windows PCs 
without leaving my desk by using Windows' Group Policy. Is this possible 
using R's own scriptable installer? The FAQ doesn't say.
Well, did you look at the reference given there?
Professor Ripley.
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] How to add some of data in the first place dataset

2005-04-27 Thread Muhammad Subianto
Dear R-help,
 First I apologize if my question is quite simple.
 I need add some of data in the first place my dataset, how can I do that.
 I have tried with rbind, but I did not succes.
   0.1 3.6  0.4 0.9  rose
   4.1 4.0  1.2 1.2  rose
   4.4 3.2  1.9 0.5  rose
   4.6 1.1  1.1 0.2  rose
 For example,
  data(iris)
  iris[1:10,]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
 1   5.1 3.5  1.4 0.2  setosa
 2   4.9 3.0  1.4 0.2  setosa
 3   4.7 3.2  1.3 0.2  setosa
 4   4.6 3.1  1.5 0.2  setosa
 5   5.0 3.6  1.4 0.2  setosa
 6   5.4 3.9  1.7 0.4  setosa
 7   4.6 3.4  1.4 0.3  setosa
 8   5.0 3.4  1.5 0.2  setosa
 9   4.4 2.9  1.4 0.2  setosa
 10  4.9 3.1  1.5 0.1  setosa
  
 The result something like this,
 
   0.1 3.6  0.4 0.9  rose
   4.1 4.0  1.2 1.2  rose
   4.4 3.2  1.9 0.5  rose
   4.6 1.1  1.1 0.2  rose
   5.1 3.5  1.4 0.2  setosa
   4.9 3.0  1.4 0.2  setosa
   4.7 3.2  1.3 0.2  setosa
   4.6 3.1  1.5 0.2  setosa
   5.0 3.6  1.4 0.2  setosa
   5.4 3.9  1.7 0.4  setosa
   4.6 3.4  1.4 0.3  setosa
   5.0 3.4  1.5 0.2  setosa
   4.4 2.9  1.4 0.2  setosa
   4.9 3.1  1.5 0.1  setosa
 
 Sincerely,
 Muhammad Subianto

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


Re: [R] R for Windows MSI Installation File

2005-04-27 Thread Richard Abraham
Brian,
I can use an MSI installer package to install R on any number of Windows 
PCs without leaving my desk by using Windows' Group Policy. Is this 
possible using R's own scriptable installer? The FAQ doesn't say.
Thanks,
Rich.

--On 27 April 2005 14:17 +0100 Prof Brian Ripley [EMAIL PROTECTED] 
wrote:

Note that I know of: why would one want a lower-quality installer than
that provided?  The installer is scriptable: see the rw-FAQ.
On Wed, 27 Apr 2005, Richard Abraham wrote:
Just wondering if anyone has created (or knows where one is available
from)  an MSI installation file for R v2.0.1?
Many thanks,
Richard.
Of course, 2.1.0 is current.
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595


Richard Abraham
Senior Information Systems Officer
Department of Social Medicine, University of Bristol
Tel: 44(0)117 928 7254
Fax: 44(0)117 928 7265
Email: [EMAIL PROTECTED]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Time series indexes

2005-04-27 Thread Fernando Saldanha
Thanks, Gabor. Reading your suggestion (and a previous one as well) I
realized I surely expressed myself quite badly when asking the
question.

Luckily one person privately suggested the following solution, which
is exactly what I was looking for:

x[time(x)==2] - 0

This works wonderfully. However, I tested it and it is very slow. So I
am back to index arithmetic, which is fast:

x[2 - start(x)[1] + 1] - 0 

However, this is much more prone to errors than the first solution above. 

I also tried to define get() and set() functions for time series as follows:

ts.get - function(myts, i) { myts[i - start(myts)[1] + 1] }
ts.set - function(myts, i, val) { myts[i - start(myts)[1] + 1] - val; myts } 

Both of these work, and ts.get is quite useful. However, ts.set is
again slow due to the need to copy the whole object. So ts.set cannot
be used just as

ts.set(x, i, val)

but rather one must write

x - ts.set(x, i, val)

In the definition of ts.set, the expression after the semicolon
returns a modified copy of the argument myts. It has to be done this
way (please let me know if there is a better and fast way) since in R
there is no way of passing arguments by reference. That is, one cannot
have side effects on the arguments of a function.

Cheers,

FS 

On 4/27/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 
 
  
 On 4/26/05, Fernando Saldanha [EMAIL PROTECTED] wrote: 
  I tried to assign values to specific elements of a time series and got
  in trouble. The code below should be almost self-explanatory. I wanted 
  to assign 0 to the first element of x, but instead I assigned  zero to
  the second element of x, which is not what I wanted. Is there a
  function that will allow me to do this without going into index
  arithmetic (which would be prone to errors)? 
  
  FS
  
   x- ts(c(1,2,3,4), start = 2)
   x
  Time Series:
  Start = 2
  End = 5
  Frequency = 1
  [1] 1 2 3 4
   x[2] - 0
   x
  Time Series:
  Start = 2
  End = 5
  Frequency = 1 
  [1] 1 0 3 4
  
   
 Any of the following will do it: 
   
 x[1] - 0 
   
 # or 
   
 window(x, start = 2, end = 2) - 0 
   
 # or since time 2 is at the beginning: 
   
 window(x, end = 2) - 0


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


[R] Error list and debugging R code

2005-04-27 Thread Tuszynski, Jaroslaw W.
Hi,

I am trying to debug my code and looking for any tool to help me out with
it. My main problem is with the error messages I can not figure out where
they come from (what function produced them) and what do they mean. Is there
such a think as list of error messages produced by R and standard R
packages,  and what do they mean? Or any tool to extract information which
function produced the run-time error (a call stack would be great)? I looked
into debug and trace tools but you seem to have to know where the problem is
to use them.

Jarek
=\ 
 Jarek Tuszynski, PhD.   o / \ 
 Science Applications International Corporation  \__,|  
 (703) 676-4192  \
 [EMAIL PROTECTED]   `\



[[alternative HTML version deleted]]

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


[R] How to add some of data in the first place dataset

2005-04-27 Thread Tyler Smith
Try this:
x- matrix(1:12, nrow = 4, byrow = T)
y - matrix (13:24, nrow=4, by.row=T)
To add the rows of y before the rows of x:
rbind(y,x)
--
Tyler Smith
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to add some of data in the first place dataset

2005-04-27 Thread Henric Nilsson
Muhammad Subianto said the following on 2005-04-27 15:48:
Dear R-help,
 First I apologize if my question is quite simple.
 I need add some of data in the first place my dataset, how can I do that.
 I have tried with rbind, but I did not succes.
Can you send a reproducible example where rbind didn't succeed?
   0.1 3.6  0.4 0.9  rose
   4.1 4.0  1.2 1.2  rose
   4.4 3.2  1.9 0.5  rose
   4.6 1.1  1.1 0.2  rose
 For example,
  data(iris)
  iris[1:10,]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
 1   5.1 3.5  1.4 0.2  setosa
 2   4.9 3.0  1.4 0.2  setosa
 3   4.7 3.2  1.3 0.2  setosa
 4   4.6 3.1  1.5 0.2  setosa
 5   5.0 3.6  1.4 0.2  setosa
 6   5.4 3.9  1.7 0.4  setosa
 7   4.6 3.4  1.4 0.3  setosa
 8   5.0 3.4  1.5 0.2  setosa
 9   4.4 2.9  1.4 0.2  setosa
 10  4.9 3.1  1.5 0.1  setosa
Assume that you have the new data in a `data.frame', e.g.
 (new.data - read.table(clipboard, header = FALSE, col.names = 
c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species)))
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1  0.1 3.6  0.4 0.9rose
2  4.1 4.0  1.2 1.2rose
3  4.4 3.2  1.9 0.5rose
4  4.6 1.1  1.1 0.2rose

Then,
add.data - rbind(new.data, iris)
will do the trick. Confirm this by
 add.data[1:10, ]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
10.1 3.6  0.4 0.9rose
24.1 4.0  1.2 1.2rose
34.4 3.2  1.9 0.5rose
44.6 1.1  1.1 0.2rose
151  5.1 3.5  1.4 0.2  setosa
210  4.9 3.0  1.4 0.2  setosa
310  4.7 3.2  1.3 0.2  setosa
410  4.6 3.1  1.5 0.2  setosa
55.0 3.6  1.4 0.2  setosa
65.4 3.9  1.7 0.4  setosa
HTH,
Henric

  
 The result something like this,
 
   0.1 3.6  0.4 0.9  rose
   4.1 4.0  1.2 1.2  rose
   4.4 3.2  1.9 0.5  rose
   4.6 1.1  1.1 0.2  rose
   5.1 3.5  1.4 0.2  setosa
   4.9 3.0  1.4 0.2  setosa
   4.7 3.2  1.3 0.2  setosa
   4.6 3.1  1.5 0.2  setosa
   5.0 3.6  1.4 0.2  setosa
   5.4 3.9  1.7 0.4  setosa
   4.6 3.4  1.4 0.3  setosa
   5.0 3.4  1.5 0.2  setosa
   4.4 2.9  1.4 0.2  setosa
   4.9 3.1  1.5 0.1  setosa
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] libz library missing while installing RMySQL

2005-04-27 Thread Sebastian Leuzinger
Thanks Jari
although these libraries are installed now, I get the following message: 

Configuration error:
  could not find the MySQL installation include and/or library
  directories.  Manually specify the location of the MySQL
  libraries and the header files and re-run R CMD INSTALL.

Somebody has had this problem before but that did not help me. Can somebody 
give me a hint?
Sebastian


On Wednesday 27 April 2005 10:40, you wrote:
 On Wed, 2005-04-27 at 09:43 +0200, Sebastian Leuzinger wrote:
  Hello
  Trying to install the MySQL package, I get the following error. The help
  archive contains something on this issue but did not help. I work on
  linux suse 9.3
 
  Configuration error:
 Could not locate the library libz required by MySQL.
 
  The library libz however is not on any mirrors I checked.

 Sebastian, You made some R core people very happy: they have tried very
 hard to explain that there is a difference between a *library* and a
 *package*, and that this difference really matters. This seems to be the
 first case on R-News when this distinction really seems to matter: you
 need a library.  I don't know about SuSE (or with some other really
 weird capitalization), but in my system libz belongs to package zlib
 that you must install, and in my system you'd probably need zlib-devel
 as well (this is FC3). So they are system level libraries that come with
 SuSe instead of R packages.

 cheers, jari oksanen

-- 

Sebastian Leuzinger
Institute of Botany, University of Basel
Schnbeinstr. 6 CH-4056 Basel
ph0041 (0) 61 2673511
fax   0041 (0) 61 2673504
email [EMAIL PROTECTED] 
web   http://pages.unibas.ch/botschoen/leuzinger

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


Re: [R] How to add some of data in the first place dataset

2005-04-27 Thread Arne Henningsen
If you want to add rows to a data frame using rbind, your additional rows must 
be in a data frame with the same (column) names.

R data( iris )
R a - data.frame( Sepal.Length=c(1:4), Sepal.Width=c(2:5), 
  Petal.Length=c(3:6), Petal.Width=c(4:7), Species=rep(rosa,4))
R b - iris[1:10,]
R rbind(a,b)
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   1.0 2.0  3.0 4.0rosa
2   2.0 3.0  4.0 5.0rosa
3   3.0 4.0  5.0 6.0rosa
4   4.0 5.0  6.0 7.0rosa
11  5.1 3.5  1.4 0.2  setosa
21  4.9 3.0  1.4 0.2  setosa
31  4.7 3.2  1.3 0.2  setosa
41  4.6 3.1  1.5 0.2  setosa
5   5.0 3.6  1.4 0.2  setosa
6   5.4 3.9  1.7 0.4  setosa
7   4.6 3.4  1.4 0.3  setosa
8   5.0 3.4  1.5 0.2  setosa
9   4.4 2.9  1.4 0.2  setosa
10  4.9 3.1  1.5 0.1  setosa


Arne

On Wednesday 27 April 2005 15:48, Muhammad Subianto wrote:
 Dear R-help,
  First I apologize if my question is quite simple.
  I need add some of data in the first place my dataset, how can I do that.
  I have tried with rbind, but I did not succes.
0.1 3.6  0.4 0.9  rose
4.1 4.0  1.2 1.2  rose
4.4 3.2  1.9 0.5  rose
4.6 1.1  1.1 0.2  rose
  For example,

   data(iris)
   iris[1:10,]

 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
  1   5.1 3.5  1.4 0.2  setosa
  2   4.9 3.0  1.4 0.2  setosa
  3   4.7 3.2  1.3 0.2  setosa
  4   4.6 3.1  1.5 0.2  setosa
  5   5.0 3.6  1.4 0.2  setosa
  6   5.4 3.9  1.7 0.4  setosa
  7   4.6 3.4  1.4 0.3  setosa
  8   5.0 3.4  1.5 0.2  setosa
  9   4.4 2.9  1.4 0.2  setosa
  10  4.9 3.1  1.5 0.1  setosa

  The result something like this,

0.1 3.6  0.4 0.9  rose
4.1 4.0  1.2 1.2  rose
4.4 3.2  1.9 0.5  rose
4.6 1.1  1.1 0.2  rose
5.1 3.5  1.4 0.2  setosa
4.9 3.0  1.4 0.2  setosa
4.7 3.2  1.3 0.2  setosa
4.6 3.1  1.5 0.2  setosa
5.0 3.6  1.4 0.2  setosa
5.4 3.9  1.7 0.4  setosa
4.6 3.4  1.4 0.3  setosa
5.0 3.4  1.5 0.2  setosa
4.4 2.9  1.4 0.2  setosa
4.9 3.1  1.5 0.1  setosa

  Sincerely,
  Muhammad Subianto

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

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

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


[R] How to break data in quantiles properly?

2005-04-27 Thread Eric Rodriguez
Hi,

I would like to break a dataset in n.classes quantiles.
Till now, I used the following code:
Classify.Quantile - function (dataset, nclasses = 10) 
{
n.probs - seq(0,1,length=nclasses+1)
n.labels = paste(C, 1:nclasses-1, sep=)
n.rows - nrow(dataset)
n.cols - ncol(dataset)
n.motif - dataset

for (j in 2:n.cols)
{
cat(j,   );
discr = 
n.labels[unclass(cut(dataset[,j],quantile(dataset[,j],n.probs),include.lowest=T))]
n.motif[,j] = discr
}

res - list(motif=n.motif, labels=n.labels, n.classes=nclasses)
return(res)
}


but if you try to call this with a dataset with a lot of same value, you got a 
Error in cut.default(dataset[, j], quantile(dataset[, j], n.probs),
include.lowest = T) :
cut: breaks are not unique

I perfectly understand why but I would like to know how to avoid this behaviour.

for e.g., use this code to raise the error:
x=matrix(0,1000,1)
x[100]=1
Classify.Quantile(x, 10)

of course this dataset is a bit extreme but it happens to get data
with very small variance.


Thanks for any help you could provide

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


[R] Re: How to add some of data in the first place dataset

2005-04-27 Thread Muhammad Subianto
Thanks all for your help.

Kind regards,
Muhammad Subianto

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


Re: [R] Error list and debugging R code

2005-04-27 Thread Uwe Ligges
Tuszynski, Jaroslaw W. wrote:
Hi,
I am trying to debug my code and looking for any tool to help me out with
it. My main problem is with the error messages I can not figure out where
they come from (what function produced them) and what do they mean. Is there
such a think as list of error messages produced by R and standard R
packages,  and what do they mean? Or any tool to extract information which
function produced the run-time error (a call stack would be great)? I looked
into debug and trace tools but you seem to have to know where the problem is
to use them.

See any good book about R programming, the manuals, R News, and the 
following help pages:
?traceback
?debug
?recover
?browser
and other relevant pages these pages are pointing to.

Uwe Ligges

Jarek
=\ 
 Jarek Tuszynski, PhD.   o / \ 
 Science Applications International Corporation  \__,|  
 (703) 676-4192  \
 [EMAIL PROTECTED]   `\


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


[R] Fitting a kind of Proportional Odds Modell using nlme, polr, lrm or ordgee

2005-04-27 Thread Henning Henke
Hello,
I'm trying to fit a special kind of proportional odds model from:
Whitehead et al.  (2001).  Meta-analysis of ordinal outcome using 
individual patient data. Statistics in medicine 20: 2243-2260. (model 2)

The data are as follows:
library(nlme)
library(geepack)
library(Design)
library(MASS)
options(contrasts=c(contr.SAS,contr.poly))
counts  - 
c(2,22,54,29,3,4,23,45,22,2,1,22,35,11,3,14,119,180,54,6,7,16,17, 
10,3,13,20,24,10,1,8,24,73,52,13,21,106,175,62,17,2,13,18,7,1,3,14,19,3,0)
category - c(rep(1:5,10))
treatment - (rep(c(0,0,0,0,0,1,1,1,1,1,),5))
study - gl(5,10)
percoftotal - counts/sum(counts)

cout - data.frame(study,treatment,category,counts,percoftotal)


The data are from five controlled clinical trials (study). The patients 
were given placebo (treatment=0) or treatment (treatment=1) and had a 
response in one of five categories.

Now I want to fit the model given by Whitehead et al. This assumes 
proportional odds between treatments, but stratifies by study. This 
means that the cut-off points associated with the distribution of the 
underlying latent variable for determining the response category are 
allowed to vary from study to study but are the same for both treatment 
groups within a study.
It is given by

log(Q_{ijk}/(1-Q_{ijk}) =  \alpha_{ik} + \beta*x_{ij} (k=1,...,m-1)
This model can be considered as arising from a latent continuos variable 
. Assume that the response of the j-th subject in study i is truly equal 
to G_{ij} although this latent reponse will never be observerd.
G_{ij} has a logistic distribution with:

Q_{ijk} = P(G_{ij} = \alpha_{ik}) = 
1/(1+exp(-(\alpha_{ik}+\beta*x_{ij})  (k=1,...,m-1)

in which Q_{ijk} is the probabilty of having a response for the j-th 
subject in category k or better that means p_{ij1}++p_{ijk}= Q_{ijk} 
and Q_{ijm}=1, Q_{ij1}=1.


i   = 1,...,r  (r=5) #number of studies
j   = 1,,n_{i} #subject j from study i
k  = 1,...,m (m=5)#Category
My problem is how to fit this model in R although I have a SAS code from 
Whitehead which is availabe at  
http://www.rdg.ac.uk/mps/mps_home/misc/publications.htm . There it is 
fit by using Proc NLMIXED.  The result for beta is there:

The problem is  that alpha_{ik} represents the k_th intercept for the 
i_th study. A normal Proportional-Odds model
has only alpha_k which represents the k-th intercept without any 
associaton to the study.

I tried to fit it by using the functions of Pinheiro/ Bates nlme, nls, 
gnls;
  polr  by Venables/Ripley ;
  lrm  by Harrell
  ordgee by Yan;

but I came to no conclusion.
I  would be very happy if anyone could help me.
Thank you VERY VERY much in advance.
Kindly regards,
Henning Henke
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Data() and CSV files

2005-04-27 Thread McGehee, Robert
Hello,

For reasons I don't understand, data() imports CSV (Comma-Separated
Values) as if they were delimited by semicolons instead of commas. (Are
semicolon-separated Comma-Separated-Value files common somewhere?) Given
that this is the case, if I choose to put comma-delimited CSV files in
my data directory, what is the preferred method of loading these into
memory?

data(filename)
would be nice, but not applicable given the above conversion issue.

So, this was the best I came up with:

read.csv(file.path(.find.package(pkg), data, paste(filename,
csv, sep = .)))

However, given that others undoubtedly like to include (non-semicolon)
.csv files in their packages and load them easily, I would like to know
if there is a more elegant way to load these files. Perhaps an
annotation in the data/00Index or /data/datalist file that I am unaware
of?

Thanks,
Robert

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


RE: [R] Error list and debugging R code

2005-04-27 Thread Berton Gunter
I have found the tools listed by Uwe to be sufficient for my needs, but you
may also be interested in Mark Bravington's debug package.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges
 Sent: Wednesday, April 27, 2005 8:00 AM
 To: Tuszynski, Jaroslaw W.
 Cc: ([EMAIL PROTECTED])
 Subject: Re: [R] Error list and debugging R code
 
 Tuszynski, Jaroslaw W. wrote:
 
  Hi,
  
  I am trying to debug my code and looking for any tool to 
 help me out with
  it. My main problem is with the error messages I can not 
 figure out where
  they come from (what function produced them) and what do 
 they mean. Is there
  such a think as list of error messages produced by R and standard R
  packages,  and what do they mean? Or any tool to extract 
 information which
  function produced the run-time error (a call stack would be 
 great)? I looked
  into debug and trace tools but you seem to have to know 
 where the problem is
  to use them.
 
 
 See any good book about R programming, the manuals, R News, and the 
 following help pages:
 ?traceback
 ?debug
 ?recover
 ?browser
 and other relevant pages these pages are pointing to.
 
 Uwe Ligges
 
 
  Jarek
  =\ 
   Jarek Tuszynski, PhD.   o / \ 
   Science Applications International Corporation  \__,|  
   (703) 676-4192  \
   [EMAIL PROTECTED]   `\
  
  
  
  [[alternative HTML version deleted]]
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


[R] R/Splus--Perl Interface ssh

2005-04-27 Thread XIAO LIU
Hi:

I'm using RSPerl_0.6-3 calling R from Perl under UNIX system. My perl programs 
with the RSPerl work well in my computer.  If submitting these programs to a 
UNIX system by 'ssh' or to GNQS system by 'qsub', these programs do not work 
even though both systems can run R.  Details are following.  Any suggestion 
will be highly appreciated.

Xiao

My perl program 'tt.pl'
   #!/usr/bin/perl -w
   use R;
   use RReferences;
   R::initR(--silent);
   R::setDebug(0);
   R::library(RSPerl);
   @t = R::call(min, (1,2));

I have a script 'doRSPerltt' for the perl program
   #!/bin/csh
   setenv LD_LIBRARY_PATH /usr/lib/R/lib
   setenv R_HOME /usr/lib/R
   perl -I/usr/lib/R/site-library/RSPerl/examples/../share/blib/arch 
-I/usr/lib/R/site-library/RSPerl/examples/../share/blib/lib 
-I/usr/lib/R/site-library/RSPerl/scripts t
t.pl

I used ssh to submit my job to machine 'queen'
   ssh queen 'cd /nfs/fs/clarke/xiaoliu  ./doRSPerltt'
An error message returns
   Fatal error: you must specify `--save', `--no-save' or `--vanilla'

If using 'qsub' to submit my job to a GNQS system
   qsub
   doRSPerltt
An error message returns
   Warning: no access to tty (Bad file descriptor).
   Thus no job control in this shell.
   Fatal error: you must specify `--save', `--no-save' or `--vanilla'


XIAO LIU wrote:
 Hi:
 
 I'm using RSPerl_0.6-3 calling R from Perl under UNIX system.  My perl 
 programs with the RSPerl work well in my computer.  However, if submitting to 
 GNQS system, these programs do not work.  It requires defining '--vanilla'.  
 Can anyone tell me what I should do? 
 

Are you certain this has something to do with RSPerl.
Specifically, have you tried running an R program on a GNQS system
and ensuring that works without --vanilla (as part of the command line 
arguments)?

If it is only for RSPerl, perhaps you would do well to post the
error message that is generated.


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

-- 
Duncan Temple Lang[EMAIL PROTECTED]
Department of Statistics  work:  (530) 752-4782
371 Kerr Hall fax:   (530) 752-7099
One Shields Ave.
University of California at Davis
Davis, CA 95616, USA



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

Re: [R] How to break data in quantiles properly?

2005-04-27 Thread Frank E Harrell Jr
Eric Rodriguez wrote:
Hi,
I would like to break a dataset in n.classes quantiles.
Till now, I used the following code:
Classify.Quantile - function (dataset, nclasses = 10) 
{
	n.probs - seq(0,1,length=nclasses+1)
	n.labels = paste(C, 1:nclasses-1, sep=)
	n.rows - nrow(dataset)
	n.cols - ncol(dataset)
	n.motif - dataset
	
	for (j in 2:n.cols)
	{
		cat(j,   );
		discr = n.labels[unclass(cut(dataset[,j],quantile(dataset[,j],n.probs),include.lowest=T))]
		n.motif[,j] = discr
	}
	
	res - list(motif=n.motif, labels=n.labels, n.classes=nclasses)
	return(res)
}

but if you try to call this with a dataset with a lot of same value, you got a 
Error in cut.default(dataset[, j], quantile(dataset[, j], n.probs),
include.lowest = T) :
cut: breaks are not unique

I perfectly understand why but I would like to know how to avoid this behaviour.
for e.g., use this code to raise the error:
x=matrix(0,1000,1)
x[100]=1
Classify.Quantile(x, 10)
of course this dataset is a bit extreme but it happens to get data
with very small variance.
Thanks for any help you could provide
The cut2 function in the Hmisc package may help.  -FH
--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Data() and CSV files

2005-04-27 Thread Peter Dalgaard
McGehee, Robert [EMAIL PROTECTED] writes:

 Hello,
 
 For reasons I don't understand, data() imports CSV (Comma-Separated
 Values) as if they were delimited by semicolons instead of commas. (Are
 semicolon-separated Comma-Separated-Value files common somewhere?) Given
 that this is the case, if I choose to put comma-delimited CSV files in
 my data directory, what is the preferred method of loading these into
 memory?

Semicolon-separated CSV's are common in various parts of Europe, but
usually coincident with comma as decimal separator (cf.
read.csv/read.csv2). I can't remember whether there was a reason for
the choice in data().
 
 data(filename)
 would be nice, but not applicable given the above conversion issue.
 
 So, this was the best I came up with:
 
 read.csv(file.path(.find.package(pkg), data, paste(filename,
 csv, sep = .)))
 
 However, given that others undoubtedly like to include (non-semicolon)
 .csv files in their packages and load them easily, I would like to know
 if there is a more elegant way to load these files. Perhaps an
 annotation in the data/00Index or /data/datalist file that I am unaware
 of?

One trick is that .R files are processed before other files, so a mydata.R
file containing  mydata - read.csv(mydata.csv) should do the trick.

It messes with lazy loading of data sets though.

An alternative is to preprocess the data set to (say) .Rda format.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


[R] Recursive calculation of a series of values

2005-04-27 Thread Luis Torgo
Dear R-users,

I'm felling kind of blocked on a quite simple problem and I wonder if
someone could give me a help with it.

My problem:

x[0] = 100
x[1] = (1+v[1])*x[0]
x[2] = (1+v[2])*x[1]
...

i.e.

x[i] = (1+v[i])*x[i-1]
and x[0]=k

Given a set of v values I wanted to obtain the corresponding x values in
an efficient way (i.e. without a for loop).

For instance, if x[0] = 100 and v = c(0.2,-0.1,0.05) then I would get 
x = c(120,108,113.4)

I'm almost sure the function filter() from package tseries is the key
for getting these values but I'm really blocked.

Any help is much appreciated.

Lus Torgo

-- 
Luis Torgo
 FEP/LIACC, University of Porto   Phone : (+351) 22 339 20 93
 Machine Learning Group   Fax   : (+351) 22 339 20 99
 R. de Ceuta, 118, 6o email : [EMAIL PROTECTED]
 4050-190 PORTO - PORTUGALWWW   : http://www.liacc.up.pt/~ltorgo

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


[R] Question about R initial message

2005-04-27 Thread Laura Holt
Dear R:
First of all, nothing is wrong!
I just had a question about the following
Natural language support but running in an English locale
What does than mean, please?
Thanks in Advance
R 2.1.0 Windows
Laura Holt
mailto: [EMAIL PROTECTED]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Recursive calculation of a series of values

2005-04-27 Thread Berton Gunter
Algebra:
cumprod(1+v)*x[0]

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Luis Torgo
 Sent: Wednesday, April 27, 2005 7:42 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Recursive calculation of a series of values
 
 Dear R-users,
 
 I'm felling kind of blocked on a quite simple problem and I wonder if
 someone could give me a help with it.
 
 My problem:
 
 x[0] = 100
 x[1] = (1+v[1])*x[0]
 x[2] = (1+v[2])*x[1]
 ...
 
 i.e.
 
 x[i] = (1+v[i])*x[i-1]
 and x[0]=k
 
 Given a set of v values I wanted to obtain the corresponding 
 x values in
 an efficient way (i.e. without a for loop).
 
 For instance, if x[0] = 100 and v = c(0.2,-0.1,0.05) then I would get 
 x = c(120,108,113.4)
 
 I'm almost sure the function filter() from package tseries is the key
 for getting these values but I'm really blocked.
 
 Any help is much appreciated.
 
 Luís Torgo
 
 -- 
 Luis Torgo
  FEP/LIACC, University of Porto   Phone : (+351) 22 339 20 93
  Machine Learning Group   Fax   : (+351) 22 339 20 99
  R. de Ceuta, 118, 6o email : [EMAIL PROTECTED]
  4050-190 PORTO - PORTUGALWWW   : 
 http://www.liacc.up.pt/~ltorgo
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


[R] its package: inexplicable date-shifting ?!

2005-04-27 Thread Chalasani, Prasad
Can someone please explain to me why 
the dates get shifted by one day 
when I create an its ( irregular time-series ) 
object from a matrix for which I've
assigned row names.
E.g. in the example run below, 
why does the its object have dates
one-shifted from my original dates?

 install.packages('its')
 install.packages('Hmisc')
 require(its)
 m - matrix(1:2, nrow=2)
 m
 [,1]
[1,]1
[2,]2
 its.format('%Y%m%d')
[1] %Y%m%d
 rownames(m) - c('20040813', '20040814')
 m
 [,1]
200408131
200408142
 its(structure(m))
 1
20040812 1
20040813 2


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Berton Gunter
Sent: Wednesday, April 27, 2005 1:28 PM
To: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: RE: [R] Recursive calculation of a series of values


Algebra:
cumprod(1+v)*x[0]

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Luis Torgo
 Sent: Wednesday, April 27, 2005 7:42 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Recursive calculation of a series of values
 
 Dear R-users,
 
 I'm felling kind of blocked on a quite simple problem and I wonder if 
 someone could give me a help with it.
 
 My problem:
 
 x[0] = 100
 x[1] = (1+v[1])*x[0]
 x[2] = (1+v[2])*x[1]
 ...
 
 i.e.
 
 x[i] = (1+v[i])*x[i-1]
 and x[0]=k
 
 Given a set of v values I wanted to obtain the corresponding
 x values in
 an efficient way (i.e. without a for loop).
 
 For instance, if x[0] = 100 and v = c(0.2,-0.1,0.05) then I would get
 x = c(120,108,113.4)
 
 I'm almost sure the function filter() from package tseries is the key 
 for getting these values but I'm really blocked.
 
 Any help is much appreciated.
 
 Luís Torgo
 
 --
 Luis Torgo
  FEP/LIACC, University of Porto   Phone : (+351) 22 339 20 93
  Machine Learning Group   Fax   : (+351) 22 339 20 99
  R. de Ceuta, 118, 6o email : [EMAIL PROTECTED]
  4050-190 PORTO - PORTUGALWWW   : 
 http://www.liacc.up.pt/~ltorgo
 
 __
 R-help@stat.math.ethz.ch mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


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

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


Re: [R] Order of boxes in boxplot()

2005-04-27 Thread Jim Porzak
On Thu, 7 Apr 2005, michael watson (IAH-C) wrote: 
 Sorry for such an inane question - how do I control the order in which 
 the boxes are plotted using boxplot() when I pass it a formula and a 
 data.frame? It seems that the groups are plotted in alphabetical 
 order... I want to change this 

Mick,
Here's the code I use to order boxes by decreasing median value. 
SubtDays is variable of interest
ConChnl is original grouping factor.
tMedians is a temp data frame 
dConChnl is new grouping factor with desired order


boxplot(SubtDays ~ ConChnl, .  ### Default ordering of boxes

tMedians - aggregate(SubtDays, list(ConChnl), median, na.rm = TRUE)
dConChnl - factor(ConChnl, levels = tMedians[order(tMedians$x), 1])

boxplot(SubtDays ~ dConChnl, . ### Ordered by decreasing median


HTH,
Jim Porzak
Director of Analytics
Loyalty Matrix, Inc.
(415) 296-1141 x210
R.LoyaltyMatrix.com
www.LoyaltyMatrix.com

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


[R] Density curve over a histogram

2005-04-27 Thread Paul Smith
Dear All

I would like to draw a picture with the density curve of a normal
distribution over a histogram of a set of random numbers extracted
from the same normal distribution. Is that possible?

Thanks in advance,

Paul

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


Re: [R] R/Splus--Perl Interface ssh

2005-04-27 Thread Prof Brian Ripley
On Wed, 27 Apr 2005, XIAO LIU wrote:
I'm using RSPerl_0.6-3 calling R from Perl under UNIX system. My perl 
programs with the RSPerl work well in my computer.  If submitting these 
programs to a UNIX system by 'ssh' or to GNQS system by 'qsub', these 
programs do not work even though both systems can run R.  Details are 
following.  Any suggestion will be highly appreciated.

My perl program 'tt.pl'
  #!/usr/bin/perl -w
  use R;
  use RReferences;
  R::initR(--silent);
Hint: that is not correct for batch use.  Please do read `An Introduction 
to R' for how to invoke R appropriately.

[...]
Please do read the posting guide and choose an less inappropriate list.
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Question about R initial message

2005-04-27 Thread Prof Brian Ripley
On Wed, 27 Apr 2005, Laura Holt wrote:
I just had a question about the following
Natural language support but running in an English locale
What does than mean, please?
See the `R Installation and Administration' manual, which does explain 
this.

In short it means that your version of R has NLS aka internationalization 
support but you are not making use of it in this session.

--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Density curve over a histogram

2005-04-27 Thread Achim Zeileis
On Wed, 27 Apr 2005 19:06:07 +0100 Paul Smith wrote:

 Dear All
 
 I would like to draw a picture with the density curve of a normal
 distribution over a histogram of a set of random numbers extracted
 from the same normal distribution. Is that possible?

To quote Simon `Yoda' Blomberg: This is R. There is no if. Only how.
(see fortune(Yoda))

Try:

R x - rnorm(100)
R hist(x, freq = FALSE)
R curve(dnorm, col = 2, add = TRUE)

Z

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


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


Re: [R] Density curve over a histogram

2005-04-27 Thread Uwe Ligges
Paul Smith wrote:
Dear All
I would like to draw a picture with the density curve of a normal
distribution over a histogram of a set of random numbers extracted
from the same normal distribution. Is that possible?
Yes.
If you like to know how, see e.g. ?hist and ?curve.
Uew Ligges

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


Re: [R] Question about R initial message

2005-04-27 Thread Peter Dalgaard
Laura Holt [EMAIL PROTECTED] writes:

 Dear R:
 
 First of all, nothing is wrong!
 
 I just had a question about the following
 
 Natural language support but running in an English locale
 
 What does than mean, please?

$ LANG=pt_BR.UTF8 ~/r-devel/BUILD/bin/R

R : Copyright 2005, The R Foundation for Statistical Computing
Version 2.2.0 Under development (unstable) (2005-04-24), ISBN
3-900051-07-0

R é um software livre e vem sem GARANTIA ALGUMA.
Você pode redistribuí-lo sob certas circunstâncias.
Digite 'licence()' ou 'licence()' para detalhes de distribuição.

R é um projeto colaborativo com muitos contribuidores.
Digite 'contributors()' para obter mais informações e
'citation()' para saber como citar o R ou pacotes do R em publicações.

Digite 'demo()' para demonstrações, 'help()' para o sistema on-line de ajuda,
ou 'help.start()' para abrir o sistema de ajuda em HTML no seu navegador.
Digite 'q()' para sair do R.




Got it?



-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


Re: [R] Density curve over a histogram

2005-04-27 Thread Vincent Goulet
Le 27 Avril 2005 14:06, Paul Smith a écrit :
 I would like to draw a picture with the density curve of a normal
 distribution over a histogram of a set of random numbers extracted
 from the same normal distribution. Is that possible?

Sure. See curve() with add=TRUE. Don't forget to use prob=TRUE when plotting 
your histogram, though.

Vincent

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


Re: [R] Density curve over a histogram

2005-04-27 Thread Paul Smith
On 4/27/05, Achim Zeileis [EMAIL PROTECTED] wrote:
  I would like to draw a picture with the density curve of a normal
  distribution over a histogram of a set of random numbers extracted
  from the same normal distribution. Is that possible?
 
 To quote Simon `Yoda' Blomberg: This is R. There is no if. Only how.
 (see fortune(Yoda))
 
 Try:
 
 R x - rnorm(100)
 R hist(x, freq = FALSE)
 R curve(dnorm, col = 2, add = TRUE)

Fantastic! Thanks a lot, Achim.

Paul

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


Re: [R] Density curve over a histogram

2005-04-27 Thread Peter Dalgaard
Paul Smith [EMAIL PROTECTED] writes:

 Dear All
 
 I would like to draw a picture with the density curve of a normal
 distribution over a histogram of a set of random numbers extracted
 from the same normal distribution. Is that possible?

Yes. If you look at the scripts that go with the ISwR package, you'll
find a detailed example in ch01.R (end of 1.3/beginning of 1.4). Or
you could read the book, of course...

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


Re: [R] its package: inexplicable date-shifting ?!

2005-04-27 Thread Gabor Grothendieck
I don't use 'its' enough to really know but usually when you see dates off
by one and are using POSIXct (which has time zone support) -- POSIXct is 
what
'its' uses, it signals that the time zone is different than what you 
expected.
 Try to specify the time zone explicitly if 'its' supports it. Another 
possibility
is to use the 'zoo' package which can handle 'Date' class dates (as well as
'POSIXct' and others). Since 'Date' does not support time zones you can't
get into that sort of trouble in the first place.
 See the article in RNews 4/1 on dates classes for background info on dates
in R.

 On 4/27/05, Chalasani, Prasad [EMAIL PROTECTED] wrote: 
 
 Can someone please explain to me why
 the dates get shifted by one day
 when I create an its ( irregular time-series )
 object from a matrix for which I've
 assigned row names.
 E.g. in the example run below,
 why does the its object have dates
 one-shifted from my original dates?
 
  install.packages('its')
  install.packages('Hmisc')
  require(its)
  m - matrix(1:2, nrow=2)
  m
 [,1]
 [1,] 1
 [2,] 2
  its.format('%Y%m%d')
 [1] %Y%m%d
  rownames(m) - c('20040813', '20040814')
  m
 [,1]
 20040813 1
 20040814 2
  its(structure(m))
 1
 20040812 1
 20040813 2
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Berton Gunter
 Sent: Wednesday, April 27, 2005 1:28 PM
 To: [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Subject: RE: [R] Recursive calculation of a series of values
 
 Algebra:
 cumprod(1+v)*x[0]
 
 -- Bert Gunter
 Genentech Non-Clinical Statistics
 South San Francisco, CA
 
 The business of the statistician is to catalyze the scientific learning
 process. - George E. P. Box
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Luis Torgo
  Sent: Wednesday, April 27, 2005 7:42 AM
  To: r-help@stat.math.ethz.ch
  Subject: [R] Recursive calculation of a series of values
 
  Dear R-users,
 
  I'm felling kind of blocked on a quite simple problem and I wonder if
  someone could give me a help with it.
 
  My problem:
 
  x[0] = 100
  x[1] = (1+v[1])*x[0]
  x[2] = (1+v[2])*x[1]
  ...
 
  i.e.
 
  x[i] = (1+v[i])*x[i-1]
  and x[0]=k
 
  Given a set of v values I wanted to obtain the corresponding
  x values in
  an efficient way (i.e. without a for loop).
 
  For instance, if x[0] = 100 and v = c(0.2,-0.1,0.05) then I would get
  x = c(120,108,113.4)
 
  I'm almost sure the function filter() from package tseries is the key
  for getting these values but I'm really blocked.
 
  Any help is much appreciated.
 
  Luís Torgo
 
  --
  Luis Torgo
  FEP/LIACC, University of Porto Phone : (+351) 22 339 20 93
  Machine Learning Group Fax : (+351) 22 339 20 99
  R. de Ceuta, 118, 6o email : [EMAIL PROTECTED]
  4050-190 PORTO - PORTUGAL WWW :
  http://www.liacc.up.pt/~ltorgo
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


[[alternative HTML version deleted]]

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


[R] Closing RGui help windows

2005-04-27 Thread Ronnen Levinson
Hi.

I often wind up with many help windows cluttering my RGui screen when 
running Windows R 2.0.1. Is there an R instruction to close one or more 
help windows, or an RGui command to close all help windows?

Yours truly,

/Ronnen.

/P.S. E-mailed CC:s of posted replies appreciated.

[[alternative HTML version deleted]]

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


[R] interval censoring case 1 or current status data

2005-04-27 Thread Chao Zhu
Dear all,

Is there a function in R dealing with the NPMLE for current status data or 
interval censored case 1 data?

Thanks,

Jimmy
[[alternative HTML version deleted]]

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


[R] Defining binary indexing operators

2005-04-27 Thread Ali -
Assume we have a function like:
foo - function(x, y)
how is it possible to define a binary indexing operator, denoted by $, so 
that

x$y
functions the same as
foo(x, y)
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] assign to an element of a vector

2005-04-27 Thread Fernando Saldanha
I am trying to find a way to assign values to elements of a vector
that will be defined by a user. So I don't have the name of the vector
and cannot hard code the assignment in advance. In the example below I
have to get() the vector using its name. When I try to assign to an
element I get an error:

 a - c(1,2,3)
 get('a')[1] - 0
Error: Target of assignment expands to non-language object

Any suggestions?

FS

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


Re: [R] interval censoring case 1 or current status data

2005-04-27 Thread Robert Gentleman
Yes, the Icens package handles all forms of censored data (1-dim)
On Apr 27, 2005, at 11:59 AM, Chao Zhu wrote:
Dear all,
Is there a function in R dealing with the NPMLE for current status  
data or interval censored case 1 data?

Thanks,
Jimmy
[[alternative HTML version deleted]]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!  
http://www.R-project.org/posting-guide.html


+--- 
+
| Robert Gentleman  phone: (206) 667-7700
 |
| Head, Program in Computational Biology   fax:  (206) 667-1319   |
| Division of Public Health Sciences   office: M2-B865   
  |
| Fred Hutchinson Cancer Research Center 
 |
| email: [EMAIL PROTECTED]  
 |
+--- 
+

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


RE: [R] assign to an element of a vector

2005-04-27 Thread Chalasani, Prasad
how about

assign( 'a', { z - get('a'); z[1] - 0; z } )


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Fernando Saldanha
Sent: Wednesday, April 27, 2005 3:22 PM
To: Submissions to R help
Subject: [R] assign to an element of a vector


I am trying to find a way to assign values to elements of a vector that will
be defined by a user. So I don't have the name of the vector and cannot hard
code the assignment in advance. In the example below I have to get() the
vector using its name. When I try to assign to an element I get an error:

 a - c(1,2,3)
 get('a')[1] - 0
Error: Target of assignment expands to non-language object

Any suggestions?

FS

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

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


[R] [R-pkgs] GPArotation package

2005-04-27 Thread Paul Gilbert
We have just put a package GPArotation on CRAN. The functions in this 
package perform an number of different orthogonal and oblique rotations 
for factor analysis, using the gradient projection algorithm described 
in Coen A. Bernaards and Robert I. Jennrich  (2005),  Gradient 
Projection Algorithms and Software for Arbitrary Rotation Criteria in 
Factor Analysis, , Educational and Psychological Measurement (in 
press).  Additional details are available on the web site  
http://www.stat.ucla.edu/research/gpa.

The following rotations are available:
oblimin oblique   oblimin family   
quartimin   oblique
targetT orthogonaltarget rotation   
targetQ oblique   target rotation   
pstT orthogonalpartially specified target rotation
pstQ oblique   partially specified target rotation
oblimax oblique
entropy orthogonalminimum entropy   
quartimax   orthogonal 
varimax orthogonal 
simplimax   oblique
bentlerTorthogonalBentler's invariant pattern simplicity criterion
bentlerQoblique   Bentler's invariant pattern simplicity criterion
tandemI orthogonalTandem Criterion 
tandemIIorthogonalTandem Criterion 
geominT orthogonal   
geominQ oblique  
cfT orthogonalCrawford-Ferguson family 
cfQ oblique   Crawford-Ferguson family 
infomaxTorthogonal   
infomaxQoblique  
mccammonorthogonalMcCammon minimum entropy ratio

Other rotations can be fairly easily added simply by coding a small 
function to calculate the rotation criterion objective function, and 
its gradient. A detailed example of gradient computation is in the
paper mentioned above.

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


RE: [R] Defining binary indexing operators

2005-04-27 Thread Huntsinger, Reid
That sounds like a recipe for headaches. If you want to use x$y because
you want a certain kind of x to act like a list with components for
certain y, then you probably want to make a class of objects (x) which
have x$y implemented as foo(x,y). That way you won't break existing code. 

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ali -
Sent: Wednesday, April 27, 2005 3:11 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Defining binary indexing operators


Assume we have a function like:

foo - function(x, y)

how is it possible to define a binary indexing operator, denoted by $, so 
that

x$y

functions the same as

foo(x, y)

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

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


Re: [R] Closing RGui help windows

2005-04-27 Thread Prof Brian Ripley
No, and in 6 years of that interface, no one else has asked.  (The 
information on open windows is not even retained.)

You might like to try the single-window pager option in the preferences.
On Wed, 27 Apr 2005, Ronnen Levinson wrote:
I often wind up with many help windows cluttering my RGui screen when
running Windows R 2.0.1. Is there an R instruction to close one or more
help windows, or an RGui command to close all help windows?
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Defining binary indexing operators

2005-04-27 Thread Huntsinger, Reid
I should have added that if you're not wedded to $ you can do

$ %f% - function(x,y) foo(x,y)

for whatever name f you want, and then %f% is a binary infix operator form
of foo().

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Huntsinger, Reid
Sent: Wednesday, April 27, 2005 4:10 PM
To: 'Ali -'; r-help@stat.math.ethz.ch
Subject: RE: [R] Defining binary indexing operators


That sounds like a recipe for headaches. If you want to use x$y because
you want a certain kind of x to act like a list with components for
certain y, then you probably want to make a class of objects (x) which
have x$y implemented as foo(x,y). That way you won't break existing code. 

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ali -
Sent: Wednesday, April 27, 2005 3:11 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Defining binary indexing operators


Assume we have a function like:

foo - function(x, y)

how is it possible to define a binary indexing operator, denoted by $, so 
that

x$y

functions the same as

foo(x, y)

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

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


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

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


Re: [R] Defining binary indexing operators

2005-04-27 Thread Gabor Grothendieck
On 4/27/05, Ali - [EMAIL PROTECTED] wrote: 
 
 Assume we have a function like:
 
 foo - function(x, y)
 
 how is it possible to define a binary indexing operator, denoted by $, so
 that
 
 x$y
 
 functions the same as
 
 foo(x, y)

  Here is an example. Note that $ does not evaluate y so you have
to do it yourself:

x - structure(3, class = myclass)
y - 5
foo - function(x,y) x+y
$.myclass - function(x, i) { i - eval.parent(parse(text=i)); foo(x, i) }
x$y # structure(8, class = myclass)

[[alternative HTML version deleted]]

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


RE: [R] Advice for calling a C function

2005-04-27 Thread Huntsinger, Reid
You have the dimensions switched, in

 double x [*MATDESC][*OBJ];

so when the dimensions aren't equal you do get odd things.

You might be better off defining functions to index into mat with a pair of
subscripts directly (.C() copies the argument anyway). Come to think of it,
there might be macros/functions for this in Rinternals.h.  Then you don't
need to worry about row-major vs column-major order and related issues.

Finally, as this is a C programming question, it should go to R-devel.

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tyler Smith
Sent: Tuesday, April 26, 2005 11:02 AM
To: R-Help
Subject: [R] Advice for calling a C function


Hi,

I'm having some trouble with a bit of combined C  R code. I'm trying to 
write a C function to handle the for loops in a function I'm working on 
to calculate a similarity matrix. Jari Oksanen has kindly added the 
necessary changes to the vegan package so that I can use the vegdist 
function, so this isn't absolutely necessary. However, I'm stubborn and 
want to know why Jari's code works and mine doesn't! Other than, of 
course, the obvious - one of us knows what their doing and the other 
doesn't. I would appreciate any help. What I've done is:

pass a matrix x to my C function, as a double:

.C(gowsim, as.double(mat), as.integer(nrow(mat)), as.integer(ncol(mat)))

 Then I try and reconstruct the matrix, in the form of a C array:

#include R.h
#include Rmath.h
#include math.h

void gowsim ( double *mat, int *OBJ, int *MATDESC)
 {
double x [*MATDESC][*OBJ];
int i, j, nrow, ncol;
nrow = *OBJ;
ncol = *MATDESC;
   
/* Rebuild Matrix */
for (j=0; j  ncol; j++) {
for (i=0; i  nrow; i++) {
x[i][j] = *mat;
Rprintf(row %d col %d value %f\n, i, j, x[i][j]);
mat++;
}
}
for (i=0; i nrow; i++) {
Rprintf(%f %f %f %f\n, x[i][0], x[i][1], x[i][2], x[i][3]);
}
}

The Rprintf statements display what's going on at each step. It looks 
for all the world as if the assignments are working properly, but when I 
try and print the matrix I get very strange results. If mat is 3x3 or 
4x4 everything seems ok. But if mat is not symetrical the resulting x 
matrix is very strange. In the case of a 5x4 mat only the first column 
works out, and for 3x4 mat the second and third positions in the first 
column are replaced by the first and second positions of the last 
column. I'm guessing that I've messed up something in my use of 
pointers, or perhaps the for loop, but I can't for the life of me figure 
out what!! Once I sort this out I'll be calculating the differences 
between rows in the x array en route to producing a similarity matrix. I 
looked at the vegdist code, which is fancier than this, and  manages to 
avoid rebuilding the matrix entirely, but it's a bit beyond me.

I'm using WindowsXP, R 2.1.0  (2005-04-18), and the MinGW compiler.

Thanks for your continued patience,

Tyler

-- 
Tyler Smith

PhD Candidate
Department of Plant Science
McGill University
21,111 Lakeshore Road
Ste. Anne de Bellevue, Quebec
H9X 3V9
CANADA

Tel: 514 398-7851 ext. 8726
Fax: 514 398-7897

[EMAIL PROTECTED]

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

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


Re: [R] Defining binary indexing operators

2005-04-27 Thread Tony Plate
It's not necessary to be that complicated, is it?  AFAIK, the '$' 
operator is treated specially by the parser so that its RHS is treated 
as a string, not a variable name.  Hence, a method for $ can just take 
the indexing argument directly as given -- no need for any fancy 
language tricks (eval(), etc.)

 x - structure(3, class = myclass)
 y - 5
 foo - function(x,y) paste(x,  indexed by ', y, ', sep=)
 foo(x, y)
[1] 3 indexed by '5'
 $.myclass - foo
 x$y
[1] 3 indexed by 'y'

The point of the above example is that foo(x,y) behaves differently from 
x$y even when both call the same function: foo(x,y) uses the value of 
the variable 'y', whereas x$y uses the string y.  This is as desired 
for an indexing operator $.

-- Tony Plate

Gabor Grothendieck wrote:
On 4/27/05, Ali - [EMAIL PROTECTED] wrote: 

Assume we have a function like:
foo - function(x, y)
how is it possible to define a binary indexing operator, denoted by $, so
that
x$y
functions the same as
foo(x, y)

  Here is an example. Note that $ does not evaluate y so you have
to do it yourself:
x - structure(3, class = myclass)
y - 5
foo - function(x,y) x+y
$.myclass - function(x, i) { i - eval.parent(parse(text=i)); foo(x, i) }
x$y # structure(8, class = myclass)
[[alternative HTML version deleted]]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Defining binary indexing operators

2005-04-27 Thread Ali -


 Assume we have a function like:

 foo - function(x, y)

 how is it possible to define a binary indexing operator, denoted by $, 
so
 that

 x$y

 functions the same as

 foo(x, y)

  Here is an example. Note that $ does not evaluate y so you have
to do it yourself:
x - structure(3, class = myclass)
y - 5
foo - function(x,y) x+y
$.myclass - function(x, i) { i - eval.parent(parse(text=i)); foo(x, i) 
}
x$y # structure(8, class = myclass)

what about this approach:
foo - function(x, y) x+y
assign($, foo)
would this overwrite $ and make R to forget its definitions in the global 
environment?

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


[R] tcl/tk problem

2005-04-27 Thread Jennifer Skene
I have JUST started using R.  I am using R 2.0.1 on a mac (os x) to 
run another program (called GRASPER, Generalized Regression Analysis 
and Spatial Prediction for R).  When I try to run Grasper, I get an 
error for tcl/tk:

 library(grasper)
Loading required package: mgcv
This is mgcv 1.1-8
Loading required package: MASS
Loading required package: tcltk
Error in dyn.load(x, as.logical(local), as.logical(now)) :
	unable to load shared library 
/Library/Frameworks/R.framework/Resources/library/tcltk/libs/tcltk.so:
  dlcompat: dyld: /Applications/R.app/Contents/MacOS/R can't open 
library: /usr/X11R6/lib/libX11.6.dylib  (No such file or directory, 
errno = 2)
Error: .onLoad failed in loadNamespace for 'tcltk'
Error: package 'tcltk' could not be loaded

However, tcl/tk appears to be there:
 capabilities()
jpeg  pngtcltk  X11GNOME libz http/ftp  sockets
TRUE TRUE TRUE TRUEFALSE TRUE TRUE TRUE
  libxml fifo   cledit  IEEE754bzip2 PCRE
TRUE TRUE TRUE TRUE TRUE TRUE
Does anyone know of a solution to this?
Thanks,
Jennifer Skene
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Getting the name of an object as character

2005-04-27 Thread Ali -
This could be really trivial, but I cannot find the right function to get 
the name of an object as a character.

Assume we have a function like:
getName - function(obj)
Now if we call the function like:
getName(blabla)
and 'blabla' is not a defined object, I want getName to return blabla. In 
other word, if

paste(blabla)
returns
blabla
I want to define a paste function which returns the same character by:
paste(blabla)
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] How to specify the hierarchical structure of a split plot using lmer ??

2005-04-27 Thread Søren Højsgaard
I have a problem getting the lmer function of the lme4 package to use the
appropriate degrees of freedom for testing. Consider the Semiconductor data
from the SASmixed package:
 
library(SASmixed)
Semi.lme - lme(resistance ~ ET * position, random=~1|Grp, data=Semiconductor)
anova(Semi.lme)
 numDF denDF  F-value p-value
(Intercept)   124 3237.261  .0001
ET  3 81.942  0.2015
position  3243.385  0.0345
ET:position 9240.809  0.6125
 
Here, the ET effect is (correctly) tested on 8 denominator degrees of freedom.
In the example in the SASmixed package, the following code is presented:
 
(fm1Semi - lmer(resistance ~ ET * position + (1|Grp), Semiconductor))
anova(fm1Semi)
Analysis of Variance Table
Df Sum Sq Mean Sq  Denom F value  Pr(F)
ET  3  0.647   0.216 32.000  1.9415 0.14273
position   3  1.129   0.376 32.000  3.3855 0.02991 *
ET:position  9  0.809   0.090 32.000  0.8092 0.61127
 
So here, all effects are tested with 32 denominator degrees of freedom.
I have looked at the help page for lmer but have been unable to figure out
how to specify the hierarchical structure of a split plot experiment. Also,
I have Googled but without any luck. Any help will be appreciated.
Søren

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


Re: [R] Defining binary indexing operators

2005-04-27 Thread Tony Plate
Excuse me!  I misunderstood the question, and indeed, it is necessary be 
that complicated when you try to make x$y behave the same as foo(x,y), 
rather than foo(x,y) (doing the former would be inadvisible, as I 
think someelse pointed out too.)

Tony Plate wrote:
It's not necessary to be that complicated, is it?  AFAIK, the '$' 
operator is treated specially by the parser so that its RHS is treated 
as a string, not a variable name.  Hence, a method for $ can just take 
the indexing argument directly as given -- no need for any fancy 
language tricks (eval(), etc.)

  x - structure(3, class = myclass)
  y - 5
  foo - function(x,y) paste(x,  indexed by ', y, ', sep=)
  foo(x, y)
[1] 3 indexed by '5'
  $.myclass - foo
  x$y
[1] 3 indexed by 'y'
 
The point of the above example is that foo(x,y) behaves differently from 
x$y even when both call the same function: foo(x,y) uses the value of 
the variable 'y', whereas x$y uses the string y.  This is as desired 
for an indexing operator $.

-- Tony Plate

Gabor Grothendieck wrote:
On 4/27/05, Ali - [EMAIL PROTECTED] wrote:
Assume we have a function like:
foo - function(x, y)
how is it possible to define a binary indexing operator, denoted by 
$, so
that

x$y
functions the same as
foo(x, y)

  Here is an example. Note that $ does not evaluate y so you have
to do it yourself:
x - structure(3, class = myclass)
y - 5
foo - function(x,y) x+y
$.myclass - function(x, i) { i - eval.parent(parse(text=i)); 
foo(x, i) }
x$y # structure(8, class = myclass)

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

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

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


[R] Is this a bug in R?

2005-04-27 Thread Revilla,AJ (pgt)
Dear all,

I am trying to fit a nonlinear model with a autocorrelation term, but everytime 
I type in the command, I got an error message from Winwows and R closes itself.
The command line is as follows:

mod1-nlme(V~A*exp(-B*A.O)*Vac.t.1.,data,fixed=A+B~1,random=A+B~1|ORDINAL,+
correlation=corCAR1(0.3179,~A.O|ORDINAL,TRUE),start=c(A=1.2,B=0.2))

I have already fitted this model allowing Phi to vary while optimizing, and it 
was fine, but as soon as I try to keep it fixed (argument TRUE), I simply 
can't

I don't get any error message from R, just a Windows error seying something 
like R for windows GUI front-end has detected a problem and has to close. And 
thats it, R is over!

I don't know if I am doing anything wrong, or if it has to be with my system (I 
have Windows XP Pro), but it looks like a bug in R.

Do you know anything else about this. Thank you very much,

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

Re: [R] Getting the name of an object as character

2005-04-27 Thread Marc Schwartz
On Wed, 2005-04-27 at 23:03 +, Ali - wrote:
 This could be really trivial, but I cannot find the right function to get 
 the name of an object as a character.
 
 Assume we have a function like:
 
 getName - function(obj)
 
 Now if we call the function like:
 
 getName(blabla)
 
 and 'blabla' is not a defined object, I want getName to return blabla. In 
 other word, if
 
 paste(blabla)
 
 returns
 
 blabla
 
 I want to define a paste function which returns the same character by:
 
 paste(blabla)

Do you mean:

 exists(plot.default)
[1] TRUE
 deparse(substitute(plot.default))
[1] plot.default

 exists(MyPlot.Default)
[1] FALSE
 deparse(substitute(MyPlot.Default))
[1] MyPlot.Default

 x - 1:10
 x
 [1]  1  2  3  4  5  6  7  8  9 10
 deparse(substitute(x))
[1] x

Does that get what you want?

If so, see ?deparse and ?substitute

HTH,

Marc Schwartz

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


Re: [R] Defining binary indexing operators

2005-04-27 Thread Gabor Grothendieck
On 4/27/05, Ali - [EMAIL PROTECTED] wrote: 
 
 
 
  
   Assume we have a function like:
  
   foo - function(x, y)
  
   how is it possible to define a binary indexing operator, denoted by $,
 so
   that
  
   x$y
  
   functions the same as
  
   foo(x, y)
 
  Here is an example. Note that $ does not evaluate y so you have
 to do it yourself:
 
 x - structure(3, class = myclass)
 y - 5
 foo - function(x,y) x+y
 $.myclass - function(x, i) { i - eval.parent(parse(text=i)); foo(x, 
 i)
 }
 x$y # structure(8, class = myclass)
 
 what about this approach:
 
 foo - function(x, y) x+y
 assign($, foo)
 
 would this overwrite $ 

 Yes.
 and make R to forget its definitions in the global
environment?
 Yes.
 Your construct might still be used in a local environment.
 f - function(x,y) {
 $ - function(x,y) x+y
 x$y
}
f(1,2) # 3
 # or
z - local({ 
 $ - function(x,y) x+y
 x - y - 3
 x$y
})
z # 6
 works and outside of f and the local, $ works normally.

[[alternative HTML version deleted]]

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


RE: [R] assign to an element of a vector

2005-04-27 Thread Liaw, Andy
You did not explain the full context of what you are trying to do.  Perhaps
this could help:

 varName - as.name(bahbah)
 varName
bahbah
 substitute(a[1] - 0, list(a=varName))
bahbah[1] - 0

So you could perhaps eval() this expression.

Andy

 From: Fernando Saldanha
 
 I am trying to find a way to assign values to elements of a vector
 that will be defined by a user. So I don't have the name of the vector
 and cannot hard code the assignment in advance. In the example below I
 have to get() the vector using its name. When I try to assign to an
 element I get an error:
 
  a - c(1,2,3)
  get('a')[1] - 0
 Error: Target of assignment expands to non-language object
 
 Any suggestions?
 
 FS
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


Re: [R] How to specify the hierarchical structure of a split plot using lmer ??

2005-04-27 Thread Douglas Bates
Søren Højsgaard wrote:
I have a problem getting the lmer function of the lme4 package to use the
appropriate degrees of freedom for testing. Consider the Semiconductor data
from the SASmixed package:
 
library(SASmixed)
Semi.lme - lme(resistance ~ ET * position, random=~1|Grp, data=Semiconductor)
anova(Semi.lme)
 numDF denDF  F-value p-value
(Intercept)   124 3237.261  .0001
ET  3 81.942  0.2015
position  3243.385  0.0345
ET:position 9240.809  0.6125
 
Here, the ET effect is (correctly) tested on 8 denominator degrees of freedom.
In the example in the SASmixed package, the following code is presented:
 
(fm1Semi - lmer(resistance ~ ET * position + (1|Grp), Semiconductor))
anova(fm1Semi)
Analysis of Variance Table
Df Sum Sq Mean Sq  Denom F value  Pr(F)
ET  3  0.647   0.216 32.000  1.9415 0.14273
position   3  1.129   0.376 32.000  3.3855 0.02991 *
ET:position  9  0.809   0.090 32.000  0.8092 0.61127
 
So here, all effects are tested with 32 denominator degrees of freedom.
I have looked at the help page for lmer but have been unable to figure out
how to specify the hierarchical structure of a split plot experiment. Also,
I have Googled but without any luck. Any help will be appreciated.
Søren
Unfortunately the answer is quite simple.  The current version of the 
lme4 package does not attempt to get the degrees of freedom right - it 
just gives an upper bound.

The reason is more than simple laziness on my part.  The lmer function 
can fit models with non-nested grouping factors and it is not easy to 
define sensible values for the degrees of freedom in such cases.  Hence 
I have put that problem aside while dealing with other issues.  (Also - 
as long time readers of this list may know - the topic of denominator 
degrees of freedom is one of my least favorite topics.)

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


Re: [R] Advice for calling a C function

2005-04-27 Thread Tyler Smith
Thank you. I can't believe how much time I spent going over that short 
bit of code without noticing that I had switched the dimensions. I was 
sure there was some arcane bit of pointer-lore that was eluding me. 
Patrick Burns pointed out an alternative approach to me, leaving the 
data in the form of a double vector. The index in the double vector 
corresponding to the matrix location can be calculated from:

Rmatrix [row,col] is equivalent to: Cvector [(row-1) + 
(col-1)*nrows(Rmatrix)]

This is easily inserted inside a for loop, sidestepping the whole issue 
of rebuilding a matrix. This has the added bonus that I don't have to 
break the matrix back down into a vector to pass it back to R.

Thank you all for your very helpful advice. Since most of this 
discussion has been in the R-help list, that's where I sent this post. 
In future I'll direct my C questions to the devel list. Hopefully, any 
further questions I have won't involve anything so silly as switching 
indexes.

Cheers,
Tyler
Tyler Smith
PhD Candidate
Department of Plant Science
McGill University
21,111 Lakeshore Road
Ste. Anne de Bellevue, Quebec
H9X 3V9
CANADA
Tel: 514 398-7851 ext. 8726
Fax: 514 398-7897
[EMAIL PROTECTED]

Huntsinger, Reid wrote:
You have the dimensions switched, in
double x [*MATDESC][*OBJ];
so when the dimensions aren't equal you do get odd things.
You might be better off defining functions to index into mat with a pair of
subscripts directly (.C() copies the argument anyway). Come to think of it,
there might be macros/functions for this in Rinternals.h.  Then you don't
need to worry about row-major vs column-major order and related issues.
Finally, as this is a C programming question, it should go to R-devel.
Reid Huntsinger
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tyler Smith
Sent: Tuesday, April 26, 2005 11:02 AM
To: R-Help
Subject: [R] Advice for calling a C function
Hi,
I'm having some trouble with a bit of combined C  R code. I'm trying to 
write a C function to handle the for loops in a function I'm working on 
to calculate a similarity matrix. Jari Oksanen has kindly added the 
necessary changes to the vegan package so that I can use the vegdist 
function, so this isn't absolutely necessary. However, I'm stubborn and 
want to know why Jari's code works and mine doesn't! Other than, of 
course, the obvious - one of us knows what their doing and the other 
doesn't. I would appreciate any help. What I've done is:

pass a matrix x to my C function, as a double:
.C(gowsim, as.double(mat), as.integer(nrow(mat)), as.integer(ncol(mat)))
Then I try and reconstruct the matrix, in the form of a C array:
#include R.h
#include Rmath.h
#include math.h
void gowsim ( double *mat, int *OBJ, int *MATDESC)
{
   double x [*MATDESC][*OBJ];
   int i, j, nrow, ncol;
   nrow = *OBJ;
   ncol = *MATDESC;
  
   /* Rebuild Matrix */
   for (j=0; j  ncol; j++) {
   for (i=0; i  nrow; i++) {
   x[i][j] = *mat;
   Rprintf(row %d col %d value %f\n, i, j, x[i][j]);
   mat++;
   }
   }
   for (i=0; i nrow; i++) {
   Rprintf(%f %f %f %f\n, x[i][0], x[i][1], x[i][2], x[i][3]);
   }
}

The Rprintf statements display what's going on at each step. It looks 
for all the world as if the assignments are working properly, but when I 
try and print the matrix I get very strange results. If mat is 3x3 or 
4x4 everything seems ok. But if mat is not symetrical the resulting x 
matrix is very strange. In the case of a 5x4 mat only the first column 
works out, and for 3x4 mat the second and third positions in the first 
column are replaced by the first and second positions of the last 
column. I'm guessing that I've messed up something in my use of 
pointers, or perhaps the for loop, but I can't for the life of me figure 
out what!! Once I sort this out I'll be calculating the differences 
between rows in the x array en route to producing a similarity matrix. I 
looked at the vegdist code, which is fancier than this, and  manages to 
avoid rebuilding the matrix entirely, but it's a bit beyond me.

I'm using WindowsXP, R 2.1.0  (2005-04-18), and the MinGW compiler.
Thanks for your continued patience,
Tyler
 

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


Re: [R] Defining binary indexing operators

2005-04-27 Thread Ali -

 
  Here is an example. Note that $ does not evaluate y so you have
 to do it yourself:
 
 x - structure(3, class = myclass)
 y - 5
 foo - function(x,y) x+y
 $.myclass - function(x, i) { i - eval.parent(parse(text=i)); foo(x,
 i)
 }
 x$y # structure(8, class = myclass)

If I got it right, in the above example you provided '$' is defined as a 
method for a S3 class. How is it possible to do the same with a S4 class. If 
this is not possible, what is the best way to define the '$' operator whose 
first arguments is a S4 object and doesn't overwrite the global definition?

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


Re: [R] its package: inexplicable date-shifting ?!

2005-04-27 Thread Dirk Eddelbuettel

On 27 April 2005 at 13:45, Chalasani, Prasad wrote:
| Can someone please explain to me why 
| the dates get shifted by one day 
| when I create an its ( irregular time-series ) 
| object from a matrix for which I've
| assigned row names.

I think you initiated the its() object the wrong way -- the date object needs
to be supplied, you were sort-of hiding that in the matrix rownames:

 m - matrix(1:2, nrow=2)
 its(m, as.POSIXct(strptime(c('20040813', '20040814'), %Y%m%d)))
   1
2004-08-13 1
2004-08-14 2
 

Hth, Dirk


| E.g. in the example run below, 
| why does the its object have dates
| one-shifted from my original dates?
| 
|  install.packages('its')
|  install.packages('Hmisc')
|  require(its)
|  m - matrix(1:2, nrow=2)
|  m
|  [,1]
| [1,]1
| [2,]2
|  its.format('%Y%m%d')
| [1] %Y%m%d
|  rownames(m) - c('20040813', '20040814')
|  m
|  [,1]
| 200408131
| 200408142
|  its(structure(m))
|  1
| 20040812 1
| 20040813 2
| 
| 
| -Original Message-
| From: [EMAIL PROTECTED]
| [mailto:[EMAIL PROTECTED] On Behalf Of Berton Gunter
| Sent: Wednesday, April 27, 2005 1:28 PM
| To: [EMAIL PROTECTED]
| Cc: r-help@stat.math.ethz.ch
| Subject: RE: [R] Recursive calculation of a series of values
| 
| 
| Algebra:
| cumprod(1+v)*x[0]
| 
| -- Bert Gunter
| Genentech Non-Clinical Statistics
| South San Francisco, CA
|  
| The business of the statistician is to catalyze the scientific learning
| process.  - George E. P. Box
|  
|  
| 
|  -Original Message-
|  From: [EMAIL PROTECTED]
|  [mailto:[EMAIL PROTECTED] On Behalf Of Luis Torgo
|  Sent: Wednesday, April 27, 2005 7:42 AM
|  To: r-help@stat.math.ethz.ch
|  Subject: [R] Recursive calculation of a series of values
|  
|  Dear R-users,
|  
|  I'm felling kind of blocked on a quite simple problem and I wonder if 
|  someone could give me a help with it.
|  
|  My problem:
|  
|  x[0] = 100
|  x[1] = (1+v[1])*x[0]
|  x[2] = (1+v[2])*x[1]
|  ...
|  
|  i.e.
|  
|  x[i] = (1+v[i])*x[i-1]
|  and x[0]=k
|  
|  Given a set of v values I wanted to obtain the corresponding
|  x values in
|  an efficient way (i.e. without a for loop).
|  
|  For instance, if x[0] = 100 and v = c(0.2,-0.1,0.05) then I would get
|  x = c(120,108,113.4)
|  
|  I'm almost sure the function filter() from package tseries is the key 
|  for getting these values but I'm really blocked.
|  
|  Any help is much appreciated.
|  
|  Luís Torgo
|  
|  --
|  Luis Torgo
|   FEP/LIACC, University of Porto   Phone : (+351) 22 339 20 93
|   Machine Learning Group   Fax   : (+351) 22 339 20 99
|   R. de Ceuta, 118, 6o email : [EMAIL PROTECTED]
|   4050-190 PORTO - PORTUGALWWW   : 
|  http://www.liacc.up.pt/~ltorgo
|  
|  __
|  R-help@stat.math.ethz.ch mailing list 
|  https://stat.ethz.ch/mailman/listinfo/r-help
|  PLEASE do read the posting guide!
|  http://www.R-project.org/posting-guide.html
| 
| 
| __
| R-help@stat.math.ethz.ch mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide!
| http://www.R-project.org/posting-guide.html
| 
| __
| R-help@stat.math.ethz.ch mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Better to have an approximate answer to the right question than a precise 
answer to the wrong question.  --  John Tukey as quoted by John Chambers

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


Re: [R] Defining binary indexing operators

2005-04-27 Thread Gabor Grothendieck
On 4/27/05, Ali - [EMAIL PROTECTED] wrote: 
 
 
   
Here is an example. Note that $ does not evaluate y so you have
   to do it yourself:
   
   x - structure(3, class = myclass)
   y - 5
   foo - function(x,y) x+y
   $.myclass - function(x, i) { i - eval.parent(parse(text=i)); 
 foo(x,
   i)
   }
   x$y # structure(8, class = myclass)
  
 
 If I got it right, in the above example you provided '$' is defined as a
 method for a S3 class. How is it possible to do the same with a S4 class. 
 If
 this is not possible, what is the best way to define the '$' operator 
 whose
 first arguments is a S4 object and doesn't overwrite the global 
 definition?
 
 The myclass example is defined as an S3 method. In the above its defined 
 as a function, not a method.

[[alternative HTML version deleted]]

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


Re: [R] Is this a bug in R?

2005-04-27 Thread Prof Brian Ripley
You are in fact using the contributed package 'nlme', not just R.
Please read both the section on BUGS in the FAQ and the posting guide, and 
send a reproducible example to the nlme maintainer.

One thing the posting guide asks for is a useful subject line.  Something 
like

`A crash when using nlme'.
On Thu, 28 Apr 2005, Revilla,AJ  (pgt) wrote:
Dear all,
I am trying to fit a nonlinear model with a autocorrelation term, but everytime 
I type in the command, I got an error message from Winwows and R closes itself.
The command line is as follows:
mod1-nlme(V~A*exp(-B*A.O)*Vac.t.1.,data,fixed=A+B~1,random=A+B~1|ORDINAL,+
correlation=corCAR1(0.3179,~A.O|ORDINAL,TRUE),start=c(A=1.2,B=0.2))
I have already fitted this model allowing Phi to vary while optimizing, and it was fine, 
but as soon as I try to keep it fixed (argument TRUE), I simply can't
I don't get any error message from R, just a Windows error seying something like R 
for windows GUI front-end has detected a problem and has to close. And that´s it, R 
is over!
I don't know if I am doing anything wrong, or if it has to be with my system (I 
have Windows XP Pro), but it looks like a bug in R.
Do you know anything else about this. Thank you very much,
Antonio
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html