[R] Calculating Percentile in R

2007-06-18 Thread Megh Dal
Hi all,
 
I have a problem on how R calculates Percentiles :
 
Suppose I have following data set:
 data1
  [1] -16648185 -14463457 -14449400 -13905309 -13443436 -13234755 -12956282 
-11660896
  [9] -10061040  -9805005  -9789583  -9754642  -9562164  -9391709  -9212182  
-9151073
 [17]  -9092732  -9068214  -8978151  -8943912  -8761890  -8632106  -8541580  
-8501249
 [25]  -8234466  -8219015  -8193543  -7488279  -7340768  -7236684  -7225458  
-7159465
 [33]  -6819625  -6810858  -6755620  -6626439  -6610901  -6551762  -6207377  
-6192583
 [41]  -6106783  -6077051  -6035300  -6035195  -6019017  -5954375  -5946285  
-5886082
 [49]  -5880402  -5723368  -5668698  -5599168  -5548276  -5445734  -5412312  
-5384707
 [57]  -5309365  -5303425  -5285274  -5204585  -5096301  -5092182  -5053349  
-5041533
 [65]  -5021234  -5005402  -4984232  -4981990  -4964457  -4936653  -4920384  
-4918021
 [73]  -4895351  -4843258  -4824730  -4774792  -4771018  -4616156  -4590430  
-262
 [81]  -4443954  -4435397  -4415112  -4374465  -4341858  -4267891  -4252410  
-4185021
 [89]  -4164458  -4158863  -4020436  -4006030  -3975819  -3959667  -3916414  
-3876878
 [97]  -3765340  -3729338  -3713670  -3634991

Now the 5th percentile should be value corresponding to 0.05*(100+1) = 5.05 = 5 
(rounded)
 
hence : -13443436 
 
But R give the value :
 quantile(data1, 0.05)
   5% 
-13245189 
 
Can anyone clarify me on this regards?
 
Thanks
Megh


   


Comedy with an Edge to see what's on, when. 

[[alternative HTML version deleted]]

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


Re: [R] Loading problem with R2HTML package

2007-06-18 Thread Prof Brian Ripley
On Sun, 17 Jun 2007, spime wrote:

 I have downloaded latest version of R2HTML (v1.54) for 64-bit windows 
 PC.

The latest version is 1.58 from September 2006.  See
http://cran.r-project.org/src/contrib/Descriptions/R2HTML.html

 My R version 2.5.0. My problem arises when i want to install SciViews-R 
 which need R2HTML package.

 library(R2HTML)
 Error in `parent.env-`(`*tmp*`, value = NULL) :
use of NULL environment is defunct
 Error: package/namespace load failed for 'R2HTML'

 Any remedy ?

Use the real 'latest version'.  Have you perhaps used a broken 'mirror' of 
CRAN?

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

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


Re: [R] Calculating Percentile in R

2007-06-18 Thread ecatchpole
Quantiles aren't uniquely defined. Type

?quantile

to learn more about the various possibilities built in to R.

Ted.

Megh Dal wrote on 06/18/2007 04:37 PM:
 Hi all,
  
 I have a problem on how R calculates Percentiles :
  
 Suppose I have following data set:
   
 data1
 
   [1] -16648185 -14463457 -14449400 -13905309 -13443436 -13234755 -12956282 
 -11660896
   [9] -10061040  -9805005  -9789583  -9754642  -9562164  -9391709  -9212182  
 -9151073
  [17]  -9092732  -9068214  -8978151  -8943912  -8761890  -8632106  -8541580  
 -8501249
  [25]  -8234466  -8219015  -8193543  -7488279  -7340768  -7236684  -7225458  
 -7159465
  [33]  -6819625  -6810858  -6755620  -6626439  -6610901  -6551762  -6207377  
 -6192583
  [41]  -6106783  -6077051  -6035300  -6035195  -6019017  -5954375  -5946285  
 -5886082
  [49]  -5880402  -5723368  -5668698  -5599168  -5548276  -5445734  -5412312  
 -5384707
  [57]  -5309365  -5303425  -5285274  -5204585  -5096301  -5092182  -5053349  
 -5041533
  [65]  -5021234  -5005402  -4984232  -4981990  -4964457  -4936653  -4920384  
 -4918021
  [73]  -4895351  -4843258  -4824730  -4774792  -4771018  -4616156  -4590430  
 -262
  [81]  -4443954  -4435397  -4415112  -4374465  -4341858  -4267891  -4252410  
 -4185021
  [89]  -4164458  -4158863  -4020436  -4006030  -3975819  -3959667  -3916414  
 -3876878
  [97]  -3765340  -3729338  -3713670  -3634991

 Now the 5th percentile should be value corresponding to 0.05*(100+1) = 5.05 = 
 5 (rounded)
  
 hence : -13443436 
  
 But R give the value :
   
 quantile(data1, 0.05)
 
5% 
 -13245189 
  
 Can anyone clarify me on this regards?
  
 Thanks
 Megh



 

 Comedy with an Edge to see what's on, when. 

   [[alternative HTML version deleted]]

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


-- 
 Dr E.A. Catchpole  
 Visiting Fellow
 Univ of New South Wales at ADFA, Canberra, Australia
_ and University of Kent, Canterbury, England
   'v'- www.pems.adfa.edu.au/~ecatchpole  
  /   \   - fax: +61 2 6268 8786   
   m m- ph:  +61 2 6268 8895

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


Re: [R] Calculating Percentile in R

2007-06-18 Thread Prof Brian Ripley
On Sun, 17 Jun 2007, Megh Dal wrote:

 Hi all,

 I have a problem on how R calculates Percentiles :

 Suppose I have following data set:
 data1
  [1] -16648185 -14463457 -14449400 -13905309 -13443436 -13234755 -12956282 
 -11660896
  [9] -10061040  -9805005  -9789583  -9754642  -9562164  -9391709  -9212182  
 -9151073
 [17]  -9092732  -9068214  -8978151  -8943912  -8761890  -8632106  -8541580  
 -8501249
 [25]  -8234466  -8219015  -8193543  -7488279  -7340768  -7236684  -7225458  
 -7159465
 [33]  -6819625  -6810858  -6755620  -6626439  -6610901  -6551762  -6207377  
 -6192583
 [41]  -6106783  -6077051  -6035300  -6035195  -6019017  -5954375  -5946285  
 -5886082
 [49]  -5880402  -5723368  -5668698  -5599168  -5548276  -5445734  -5412312  
 -5384707
 [57]  -5309365  -5303425  -5285274  -5204585  -5096301  -5092182  -5053349  
 -5041533
 [65]  -5021234  -5005402  -4984232  -4981990  -4964457  -4936653  -4920384  
 -4918021
 [73]  -4895351  -4843258  -4824730  -4774792  -4771018  -4616156  -4590430  
 -262
 [81]  -4443954  -4435397  -4415112  -4374465  -4341858  -4267891  -4252410  
 -4185021
 [89]  -4164458  -4158863  -4020436  -4006030  -3975819  -3959667  -3916414  
 -3876878
 [97]  -3765340  -3729338  -3713670  -3634991

 Now the 5th percentile should be value corresponding to 0.05*(100+1) = 
 5.05 = 5 (rounded)

According to you, but not according to ?quantile, which gives you a choice 
of 9 definitions, yours not being the default.

 hence : -13443436

 But R give the value :
 quantile(data1, 0.05)
   5%
 -13245189

 Can anyone clarify me on this regards?

 Thanks
 Megh


   [[alternative HTML version deleted]]

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

PLEASE do as we ask.

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

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


[R] to read table

2007-06-18 Thread elyakhlifi mustapha
Hello,
I have a problem to read a csv table. To read it I used this syntax

 donParCara - read.table(C:/Documents and Settings/melyakhlifi/Mes 
 documents/feuilles excel/calcul2.csv,header=TRUE,sep=;,quote=,dec=,)

I don't understand my errors

Erreur dans scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  
: 
la ligne 16 n'avait pas 21 éléments

Can you help me please?


  
_ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
[[alternative HTML version deleted]]

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


Re: [R] Lines connecting the boxes in a boxplot

2007-06-18 Thread Christoph Buser
Dear Arne

I' recommend to save the information of your boxplots

a - boxplot(...)
str(a)

Then you have the information that you need about your boxplot
(e.g. the value of the median) and can use segments() to draw
the lines you want.

Hope this helps

Best regards,

Christoph

--

Credit and Surety PML study: visit our web page www.cs-pml.org

--
Christoph Buser [EMAIL PROTECTED]
Seminar fuer Statistik, LEO C13
ETH Zurich  8092 Zurich  SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
--


Arne Brutschy writes:
  Hello,
  
  I'm currently using a boxplot to visualize data for three different
  models. As I have three models, I'm plotting three parallel boxplots
  for each factor.
  
  This works fine - what I need now is a line connecting the medians of
  each boxplot of each model. I want to do this in order to visualize
  the trend that one of the models exhibit. Basically, I want to plot a
  curve for each model (slightly offset on the x axis), with a boxplot
  on each datapoint.
  
  It's only an idea, and I don't know if it's not too confusing after
  adding the lines... Is it possible? Has anyone done this before?
  
  Sorry if this has been asked before or is a standard feature, I simply
  have now clue how to name the feature I want. Ergo: I cannot search
  for it.. :\
  
  Regards,
  Arne
  
  PS: this is my current code
  
  require(gplots)
  boxwex=0.15
  
  data - read.table(all_runs_fitness.data);
  colnames(data)=c(model,matrix,fitness)
  
  boxplot(fitness ~ matrix,
  data=data, boxwex=boxwex, at=(1:7 - 0.2),
  main=Fitness for Matrix/Models, xlab=Matrixtype,
  ylab=Fitness, ylim=c(20,100), 
  subset=(model==dyn), col=lightblue, xaxt=n, whisklty=1)
  boxplot(fitness ~ matrix,
  data=data, boxwex=boxwex, at = 1:7, add=TRUE, 
  subset=(model==dl3), col=mistyrose, xaxt=n, whisklty=1)
  boxplot(fitness ~ matrix,
  data=data, boxwex=boxwex, at=(1:7 + 0.2), add=TRUE, 
  subset=(model==dl4), col=lightcyan, xaxt=n, whisklty=1)
  
  axis(1, 1:8-0.5, labels=FALSE)
  axis(1, 1:7, tck=FALSE, labels=levels(data[,2]))
  
  smartlegend(x=left, y=bottom, inset = 0.01,
  c(dyn,dl3,dl4), fill = c(lightblue, mistyrose, 
  lightcyan))
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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


[R] what about options in BATCH

2007-06-18 Thread elyakhlifi mustapha
hello,
when I run a calcul in BATCH the screen displays all the code of my  programs 
and even the introduction of R how can I do to don't display it?
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] to read table

2007-06-18 Thread Stefan Grosse
Why are you not using read.csv or read.csv2 when you are reading a csv file?

 Original Message  
Subject: [R] to read table
From: elyakhlifi mustapha [EMAIL PROTECTED]
To: R-help@stat.math.ethz.ch
Date: 18.06.2007 09:23
 Hello,
 I have a problem to read a csv table. To read it I used this syntax

   
 donParCara - read.table(C:/Documents and Settings/melyakhlifi/Mes 
 documents/feuilles excel/calcul2.csv,header=TRUE,sep=;,quote=,dec=,)
 

 I don't understand my errors

 Erreur dans scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
  : 
 la ligne 16 n'avait pas 21 éléments

 Can you help me please?



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


Re: [R] to read table

2007-06-18 Thread Katharina Surovcik
That means that R doesn't see 21 elements in line 16 of your file. This
can happen if one of your entries consists of two words, which are then
read as two elements.

Katharina

elyakhlifi mustapha schrieb:
 Hello,
 I have a problem to read a csv table. To read it I used this syntax

   
 donParCara - read.table(C:/Documents and Settings/melyakhlifi/Mes 
 documents/feuilles excel/calcul2.csv,header=TRUE,sep=;,quote=,dec=,)
 

 I don't understand my errors

 Erreur dans scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
  : 
 la ligne 16 n'avait pas 21 éléments

 Can you help me please?


   
 _ 
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
   [[alternative HTML version deleted]]

   
 

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


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


[R] Problem with binding data-frames

2007-06-18 Thread Junnila, Jouni
Hello,

I'm having a problem concerning r-binding datasets.

I have six datasets, from six different plates, and two different days.
I want to combine these datasets together for analysis. Datasets from
day 2, have all the same columns than datasets from day 1. However in
addition, there are few columns more in day 2. Thus, using rbind for
this, results a error, because the objects are not the same length. 

Error in paste(nmi[nii == 0L], collapse = , ) : 
object nii not found
In addition: Warning message:
longer object length
is not a multiple of shorter object length in: clabs == nmi 


What I need, is to combine all the six together, and give for example
NA-value in day 1, for those columns which can only be found in day 2.
Is this somehow possible?

I have several of these six-datasets groups, and only few of them are
having this problem described above, and I cannot know in advance which.
With most of the groups writing
rbind(data1,data2,data3,data4,data5,data6)
works easily, but these few problematic groups need also to be
combined... 
Any help greatly appreciated!

-Jouni

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


Re: [R] Lines connecting the boxes in a boxplot

2007-06-18 Thread Arne Brutschy
Hi,

C I' recommend to save the information of your boxplots
C Then you have the information that you need about your boxplot
C (e.g. the value of the median) and can use segments() to draw
C the lines you want.
Thanks, works like a charm!

Regards,
Arne

C Arne Brutschy writes:
  Hello,
  
  I'm currently using a boxplot to visualize data for three different
  models. As I have three models, I'm plotting three parallel boxplots
  for each factor.
  
  This works fine - what I need now is a line connecting the medians of
  each boxplot of each model. I want to do this in order to visualize
  the trend that one of the models exhibit. Basically, I want to plot a
  curve for each model (slightly offset on the x axis), with a boxplot
  on each datapoint.
  
  It's only an idea, and I don't know if it's not too confusing after
  adding the lines... Is it possible? Has anyone done this before?
  
  Sorry if this has been asked before or is a standard feature, I simply
  have now clue how to name the feature I want. Ergo: I cannot search
  for it.. :\
  
  Regards,
  Arne
  
  PS: this is my current code
  
  require(gplots)
  boxwex=0.15
  
  data - read.table(all_runs_fitness.data);
  colnames(data)=c(model,matrix,fitness)
  
  boxplot(fitness ~ matrix,
  data=data, boxwex=boxwex, at=(1:7 - 0.2),
  main=Fitness for Matrix/Models, xlab=Matrixtype,
  ylab=Fitness, ylim=c(20,100), 
  subset=(model==dyn), col=lightblue, xaxt=n, whisklty=1)
  boxplot(fitness ~ matrix,
  data=data, boxwex=boxwex, at = 1:7, add=TRUE, 
  subset=(model==dl3), col=mistyrose, xaxt=n, whisklty=1)
  boxplot(fitness ~ matrix,
  data=data, boxwex=boxwex, at=(1:7 + 0.2), add=TRUE, 
  subset=(model==dl4), col=lightcyan, xaxt=n, whisklty=1)
  
  axis(1, 1:8-0.5, labels=FALSE)
  axis(1, 1:7, tck=FALSE, labels=levels(data[,2]))
  
  smartlegend(x=left, y=bottom, inset = 0.01,
  c(dyn,dl3,dl4), fill = c(lightblue, mistyrose, 
  lightcyan))
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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


[R] merging dataframes with diffent rownumbers

2007-06-18 Thread Thomas Hoffmann
Dear R-Helpers,

I have following problem:

I do have two data frames dat1 and dat2 with a commen column BNUM (long 
integer). dat1 has a larger number of BNUM than dat2 and different rows 
of dat2 have equal BNUM. The numbers of rows in dat1 and dat2 is not 
equal.  I applied the  tapply-function to dat2 with BNUM as index. I 
would like to add the columns from dat1 to the results of

b.sum - tapply(dat2, BNUM, sum).

However the BNUM of b.sum are only a subset of the dat1.

Does anybody knows a elegant way to solve the problem?
Thanks in advance

Thomas H.

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


[R] help with panel.lda

2007-06-18 Thread Silvia Lomascolo

I work with Windows, R version 2.4.1

I am trying to plot the results of a discriminant analysis done using the
lda function in the MASS library. The discriminant. analysis goes like this:

data.tb-read.table('C:\\Documents and
Settings\\silvia\\Desktop\\dicrim_test.txt', header=T) ## the actual made-up
test matrix is pasted below
train-sample (1:36, 15)
table (data.tb$group[train])
data.lda-lda(group~., data.tb, subset = train)
predict (data.lda, data.tb[-train,])$class

Then I want to obtain a plot by writing: 

plot(data.lda, cex=0.7, 2, xlab='LD1', ylab='LD2')

but it's not working.  It says that it could not find the function panel. 
When I include panel=panel.lda, it tells me that the object 'panel.lda' was
not found.  All I get is an empty plot in the graphics window.  Was I
supposed to create an object called panel.lda? I cannot find in the help
what that object might be.

Any help would be appreciated.
 
TABLE USED:
   group var1 var2 var3
1  13   556
2  14   667
3  15   558
4  14   667
5  13   446
6  13   555
7  13   444
8  14   443
9  14   447
10 14   666
11 25   889
12 24   998
13 28   889
14 29   768
15 28   669
16 29   99   10
17 2   10  1009
18 24   999
19 28   888
20 29   769
21 28   66   10
22 29   999
23 32   11   11
24 33   222
25 31   333
26 31   111
27 32   442
28 33   223
29 34   111
30 31   111
31 32   222
32 33   333
33 31   111
34 31   442
35 32   223
36 33   111

-- 
View this message in context: 
http://www.nabble.com/help-with-panel.lda-tf3939027.html#a11172049
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Readline - wait for user input

2007-06-18 Thread Antje
Hello,

I also have problems to get to run the following lines. If I run the 
block instead of every single line, it simply does not wait for the input.
Can anybody help me?


pos_name - readline(Please type: )

r - substr(pos_name, 1,1)
c - substr(pos_name, 2,nchar(pos_name))



Thank you!
Antje


Peter Dalgaard schrieb:
 Forest Floor wrote:
 Hi,

 I've seen various posts on this question, but still can't get the code 
 right. 

 If I run the following code one line at a time, it works fine.  If I run 
 it together as a block, however, it doesn't wait for the input and gives 


 an error.

 There must be a way to have are pause/wait for an answer, but I can't 
 seem to find it.  Thanks!  J

 Code:

 choosefunction - function(){readline(1. linear, 2. linear with lag, 3. 
 nonlinear )}
 ans - as.integer(choosefunction())
 if (ans==1){K2=x1}
 if (ans==2){K2=x2 }
 if (ans==3){K2=x3 }
 ans

 Error text:
   ans - as.integer(choosefunction())
 1. linear, 2. linear with lag, 3. nonlinear if (ans==1) {K2=x1}]}
 Warning message:
 NAs introduced by coercion
   if (ans==2){K2=x2) }
 Error in if (ans == 2) { : missing value where TRUE/FALSE needed
   if (ans==3){K2=x3}
 Error in if (ans == 3) { : missing value where TRUE/FALSE needed
   ans
 [1] NA
   
 As you may have realized already, the issue is that choosefunction()
 takes the next command as its input. Since if (ans==1){K2=x1} isn't an
 integer ans becomes NA, and it just goes downhill from there.
 
 An extra set of braces may help
 
 choosefunction - function(){readline(1. linear, 2. linear with lag, 3.
 + nonlinear )}
 {ans - as.integer(choosefunction())
 + if (ans==1){K2=x1}
 + if (ans==2){K2=x2 }
 + if (ans==3){K2=x3 }
 + ans}
 1. linear, 2. linear with lag, 3.
 nonlinear 3
 Error: object x3 not found
 
 It still doesn't quite work, but the reason(s) for that should be plain
 to see.


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


[R] change fold from packageDEDS

2007-06-18 Thread XinMeng
Hi all:
packageDEDS can find out differentially expressed genes via computing 
changefold.

But if there're 3(or more)groups(1\2\3 for instance),I wanna know the which 
group vs group the changefold is referd to(1 vs 2/1 vs 3/2 vs 3 for instance)?

Thanks a lot!

My best!

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


[R] Prediction accuracy of poisson regression model

2007-06-18 Thread Des Callaghan
Dear all,
 
I'd like to measure the prediction accuracy of a model I have derived from
poisson regression. Can somebody help me with suggesting a good approach
please? Thanks very much in advance.
 
Best wishes,
Des
 

[[alternative HTML version deleted]]

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


[R] Inverse BoxCox transformation

2007-06-18 Thread Des Callaghan
Hi,
 
I can't seem to find a function in R that will reverse a BoxCox
transformation. Can somebody help me locate one please? Thanks in advance.
 
Best wishes,
Des
 

[[alternative HTML version deleted]]

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


Re: [R] Responding to a posting in the digest

2007-06-18 Thread Martin Maechler
Thanks a lot, Ted, for your comprehensive answer!

[See one short note way below: ]

 TH == Ted Harding [EMAIL PROTECTED]
 on Thu, 14 Jun 2007 09:54:04 +0100 (BST) writes:

TH On 14-Jun-07 07:26:26, Moshe Olshansky wrote:
 Is there a convenient way to respond to a particular
 posting which is a part of the digest?  I mean something
 that will automatically quote the original message,
 subject, etc.
 
 Thank you!
 
 Moshe Olshansky [EMAIL PROTECTED]

TH This will depend on two things.

TH 1. Whether the mail software you use has the capability;
TH 2. Whether the digest format would permit it anyway.

TH Regarding (2), if you are receiving R-help in
TH traditional digest format (all the messages, each with
TH its principal headers, as one single long message-body),
TH then the only way to respond to a particular message is
TH to start to compose a new message and copy what you need
TH from the digest.

TH While I've never reveived R-help in digest format
TH myself, according to Martin Maechler:

TH http://finzi.psych.upenn.edu/R/Rhelp02a/archive/59429.html

TH   Please open the URL at the end of every message
TH https://stat.ethz.ch/mailman/listinfo/r-help go to the
TH bottom and log in -- clicking the [Unsubscribe or Edit
TH Options] field. You need your mailing list password
TH sooner or later. The one you get sent every 1st of the
TH month; or you can have it sent to you again.

TH   Then you are in a page entitled R-help Membership
TH Configuration for foo@bar Scroll down to the section
TH Your R-help Subscription where the 3rd entry is
TH entitled Get MIME or Plain Text Digests?  and now you
TH want MIME.

TH In MIME digest format, each message with its own main
TH headers is a separate MIME attachment, and suitable mail
TH software can bring any message up on its own, You can
TH then reply in the normal way.

TH However (and here is where I'm ignorant as a result of
TH never having received R-help as digest), your reply may
TH not continue the thread -- since this depends on
TH message-identifier headers being present which allow
TH threading software to trace which messages are replies
TH to which message. The JISCMAIL MIME digest for the
TH AllStat mailing list only includes a Message-ID for the
TH digest as a whole, i.e. the ID for the entire digest
TH message.  Message-IDs for the individual messages in the
TH digest (as would be seen by people who received them
TH singly) are absent: you only get the likes of

TH   Date: DoW, DD Mon  HH:MM:SS TZ From: Sender
TH (person who sent the message to the list) Subject:
TH Subject of individual message MIME-Version: 1.0
TH Content-Type: text/plain; charset=iso-8859-1
TH Content-Transfer-Encoding: quoted-printable

TH and no Message ID for the original message from
TH Sender. So any reply to this component message is not
TH identifiable as belonging to its thread.

TH I don't know whether R-help's 'mailman' provides such
TH headers (Martin??). 

Yes, it does (I've checked with a pseudo-user who receives
r-help in digests in MIME format). 
So you can indeed do the following.

In my limited experience, the main problem is the bad quality of
people'e e-mail software which does not properly work with
the (typically invisible) 'References:' and 'In-Reply-To:'
headers which mailman indeed does preserve in its MIME-digests.

TH If it does, then your reply could
TH include an In-Reply-To: which identifies the
TH thread. Otherwise it can't.

TH As to (1), you will probably get several suggestions for
TH suitable mail software. My own (see below) opens an
TH AllStat digest in a window with attachment tags
TH displayed, one for Tablf of Contents, one for each
TH message. Clicking on one of these opens a new window
TH with the message attached to that tag displayed, and now
TH the usual reply/forward etc mail sunctions can be
TH applied to that message.  But it will reply only to the
TH address given in the From: header (i.e. the original
TH sender, as above), not to the AllStat list (so you have
TH to enter that address by hand, if you want to reply to
TH the list).

TH In principle, mailer software could also identify the
TH address of the list from which the digest has been sent,
TH as well as the sender of the original message, so you
TH could get the option to reply to either or both. But my
TH XFMail does not, and only offers the original
TH sender. Whether other mailer software can do this is for
TH others to comment on!

TH Hoping this helps, Ted.

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

[R] Question about lmer

2007-06-18 Thread Julia Proudnikova
Hello,

We have a problem with function lmer. This is our code:

Get_values-function(ff_count, fixed_factors, rf_count, random_factors, 
y_values)
{   
  SA-matrix(as.array(c(fixed_factors, random_factors)), ncol=3)
  data-as.data.frame(SA)
  y-as.array(y_values)

  dd-data.frame(SA)
  for(i in 1:(ff_count+rf_count)){
dd[,i]-as.factor(data[,i])
  }
  
  fit_full=lmer(y~dd[,1]+dd[,2]+(1|dd[,3]),method=ML)
  fit_full
}

A-c(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1)
B-c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1)
C-c(0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1)
Y-c(5,3,4,1,1,2,6,1,5,3,7,1,2,3,1,1,5,3,4,1,1,2,6,1,5,3,7,1,2,3,1,1)
r-Get_values(2, c(A,B),1,c(C),Y)
r 

R output:
Error in inherits(x, factor) : object dd not found

Can this function work with random array? Because this code is
working:

D-as.factor(data[,3])
fit_full=lmer(y~dd[,1]+dd[,2]+(1|D),method=ML)
 

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


[R] Unix-like permissions to allow a user to update recommended packages

2007-06-18 Thread Patrick Connolly
I installed R from the tar.gz file (as root) in a directory under
/usr/local.  The recommended packages are installed in a library in
that directory whereas additional packages I install in a directory
under the /home directory as a user.

Updating the additional packages is very easy with update.packages()
as a non-root user, but the recommended packages cannot be done so
readily because of file permissions.

My question is how do I set the permissions or ownerships in the
/usr/local/R-2.5.0 directory so that everything necessary can be
writable by a user?  Should I make a group for R users (total of one
member) or is it simpler than that?

TIA

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] Inverse BoxCox transformation

2007-06-18 Thread joris . dewolf


to backtransform 'estimate':




if (lambda == 0 ) {


log(estimate)


} else {



estimate^(1/lambda)

}











   
 Des Callaghan   
 [EMAIL PROTECTED] 
 er.co.uk  To 
 Sent by:  r-help@stat.math.ethz.ch  
 [EMAIL PROTECTED]  cc 
 at.math.ethz.ch   
   Subject 
   [R] Inverse BoxCox transformation   
 18/06/2007 09:32  
   
   
   
   
   




Hi,

I can't seem to find a function in R that will reverse a BoxCox
transformation. Can somebody help me locate one please? Thanks in advance.

Best wishes,
Des


 [[alternative HTML version deleted]]

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

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


Re: [R] Inverse BoxCox transformation

2007-06-18 Thread Charles Annis, P.E.
Look at the definition for the transform.  For example in the car package,
?box.cox

Then do the simple algebraic manipulations yourself.

Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Des Callaghan
Sent: Monday, June 18, 2007 3:33 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Inverse BoxCox transformation

Hi,
 
I can't seem to find a function in R that will reverse a BoxCox
transformation. Can somebody help me locate one please? Thanks in advance.
 
Best wishes,
Des
 

[[alternative HTML version deleted]]

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

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


Re: [R] merging dataframes with diffent rownumbers

2007-06-18 Thread Michael Dewey
At 09:09 18/06/2007, Thomas Hoffmann wrote:
Dear R-Helpers,

I have following problem:

I do have two data frames dat1 and dat2 with a commen column BNUM 
(long integer). dat1 has a larger number of BNUM than dat2 and 
different rows of dat2 have equal BNUM. The numbers of rows in dat1 
and dat2 is not equal.  I applied the  tapply-function to dat2 with 
BNUM as index. I would like to add the columns from dat1 to the results of

b.sum - tapply(dat2, BNUM, sum).

However the BNUM of b.sum are only a subset of the dat1.

Does anybody knows a elegant way to solve the problem?

If I understand you correctly
?merge
should help you here

Thanks in advance

Thomas H.



Michael Dewey
http://www.aghmed.fsnet.co.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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] merging dataframes with diffent rownumbers

2007-06-18 Thread Petr Klasterecky
No easy to understand what exactly you mean, but try
?merge
?cbind
?rbind

Petr

Thomas Hoffmann napsal(a):
 Dear R-Helpers,
 
 I have following problem:
 
 I do have two data frames dat1 and dat2 with a commen column BNUM (long 
 integer). dat1 has a larger number of BNUM than dat2 and different rows 
 of dat2 have equal BNUM. The numbers of rows in dat1 and dat2 is not 
 equal.  I applied the  tapply-function to dat2 with BNUM as index. I 
 would like to add the columns from dat1 to the results of
 
 b.sum - tapply(dat2, BNUM, sum).
 
 However the BNUM of b.sum are only a subset of the dat1.
 
 Does anybody knows a elegant way to solve the problem?
 Thanks in advance
 
 Thomas H.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

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


Re: [R] Unix-like permissions to allow a user to update recommen

2007-06-18 Thread Ted Harding
On 18-Jun-07 10:11:43, Patrick Connolly wrote:
 I installed R from the tar.gz file (as root) in a directory under
 /usr/local.  The recommended packages are installed in a library in
 that directory whereas additional packages I install in a directory
 under the /home directory as a user.
 
 Updating the additional packages is very easy with update.packages()
 as a non-root user, but the recommended packages cannot be done so
 readily because of file permissions.
 
 My question is how do I set the permissions or ownerships in the
 /usr/local/R-2.5.0 directory so that everything necessary can be
 writable by a user?  Should I make a group for R users (total of one
 member) or is it simpler than that?

Since you have root access, do you need to segregate the additional
packages to a particular user?

Though I don't run R as root for general use, I always install/update
by running R CMD as root. This makes all of R (recommended and also
any extras) available system-wide, and no pemission problems arise.

This of course does not stop you from setting up a special .Rprofile
for each user, since this by definition lives in the user's home
directory.

Does this help? Or are there issues you haven't mentioned which make
such an approach not feasible?

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 18-Jun-07   Time: 11:53:19
-- XFMail --

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


Re: [R] Problem with binding data-frames

2007-06-18 Thread Petr Klasterecky
Junnila, Jouni napsal(a):
 Hello,
 
 I'm having a problem concerning r-binding datasets.
 
 I have six datasets, from six different plates, and two different days.
 I want to combine these datasets together for analysis. Datasets from
 day 2, have all the same columns than datasets from day 1. However in
 addition, there are few columns more in day 2. Thus, using rbind for
 this, results a error, because the objects are not the same length. 
 
 Error in paste(nmi[nii == 0L], collapse = , ) : 
 object nii not found
 In addition: Warning message:
 longer object length
 is not a multiple of shorter object length in: clabs == nmi 

Hi,

1. the error has nothing to do with differing lengths of your objects - 
that's what the following warning is about. The error occured because 
your indexing object 'nii' does not exist where R is looking for it.

2. using rbind on dataframes is a bad practice, since the input is 
converted to marices if possible. Use merge() instead.

Petr

 
 
 What I need, is to combine all the six together, and give for example
 NA-value in day 1, for those columns which can only be found in day 2.
 Is this somehow possible?
 
 I have several of these six-datasets groups, and only few of them are
 having this problem described above, and I cannot know in advance which.
 With most of the groups writing
 rbind(data1,data2,data3,data4,data5,data6)
 works easily, but these few problematic groups need also to be
 combined... 
 Any help greatly appreciated!
 
 -Jouni
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

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


Re: [R] what about options in BATCH

2007-06-18 Thread Christophe Pallier
?BATCH

Read second paragraph of Details section.


On 6/18/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote:

 hello,
 when I run a calcul in BATCH the screen displays all the code of
 my  programs and even the introduction of R how can I do to don't display
 it?
 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
 and provide commented, minimal, self-contained, reproducible code.




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


[R] Readline

2007-06-18 Thread Antje
Hello,

I also have problems to get to run the following lines. If I run the
block instead of every single line, it simply does not wait for the input.
Can anybody help me?


pos_name - readline(Please type: )

r - substr(pos_name, 1,1)
c - substr(pos_name, 2,nchar(pos_name))



Thank you!
Antje


Peter Dalgaard schrieb:
   Forest Floor wrote:
   Hi,
  
   I've seen various posts on this question, but still can't get the 
code
   right.
  
   If I run the following code one line at a time, it works fine. 
If I run
   it together as a block, however, it doesn't wait for the input 
and gives


   an error.
  
   There must be a way to have are pause/wait for an answer, but I 
can't
   seem to find it.  Thanks!  J
  
   Code:
  
   choosefunction - function(){readline(1. linear, 2. linear with 
lag, 3.
   nonlinear )}
   ans - as.integer(choosefunction())
   if (ans==1){K2=x1}
   if (ans==2){K2=x2 }
   if (ans==3){K2=x3 }
   ans
  
   Error text:
 ans - as.integer(choosefunction())
   1. linear, 2. linear with lag, 3. nonlinear if (ans==1) {K2=x1}]}
   Warning message:
   NAs introduced by coercion
 if (ans==2){K2=x2) }
   Error in if (ans == 2) { : missing value where TRUE/FALSE needed
 if (ans==3){K2=x3}
   Error in if (ans == 3) { : missing value where TRUE/FALSE needed
 ans
   [1] NA
  
   As you may have realized already, the issue is that choosefunction()
   takes the next command as its input. Since if (ans==1){K2=x1} 
isn't an
   integer ans becomes NA, and it just goes downhill from there.
  
   An extra set of braces may help
  
   choosefunction - function(){readline(1. linear, 2. linear with 
lag, 3.
   + nonlinear )}
   {ans - as.integer(choosefunction())
   + if (ans==1){K2=x1}
   + if (ans==2){K2=x2 }
   + if (ans==3){K2=x3 }
   + ans}
   1. linear, 2. linear with lag, 3.
   nonlinear 3
   Error: object x3 not found
  
   It still doesn't quite work, but the reason(s) for that should be plain
   to see.
  

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

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


Re: [R] Problem with binding data-frames

2007-06-18 Thread Prof Brian Ripley
On Mon, 18 Jun 2007, Petr Klasterecky wrote:

 Junnila, Jouni napsal(a):
 Hello,

 I'm having a problem concerning r-binding datasets.

 I have six datasets, from six different plates, and two different days.
 I want to combine these datasets together for analysis. Datasets from
 day 2, have all the same columns than datasets from day 1. However in
 addition, there are few columns more in day 2. Thus, using rbind for
 this, results a error, because the objects are not the same length.

 Error in paste(nmi[nii == 0L], collapse = , ) :
 object nii not found
 In addition: Warning message:
 longer object length
 is not a multiple of shorter object length in: clabs == nmi

 Hi,

 1. the error has nothing to do with differing lengths of your objects -
 that's what the following warning is about. The error occured because
 your indexing object 'nii' does not exist where R is looking for it.

It's because the dataframes have differing number of columns, and that has 
not been allowed for in the error message in that version of R.

 2. using rbind on dataframes is a bad practice, since the input is
 converted to marices if possible. Use merge() instead.

Not so: rbind on data frames does no such conversion, and is not 
problematic provided they have the same column names (and hence the same 
number of columns).  You may have missed in ?rbind

  The functions 'cbind' and 'rbind' are S3 generic, with methods for
  data frames.  The data frame method will be used if at least one
  argument is a data frame and the rest are vectors or matrices.
...

and a later description of the data frame method for 'rbind'.


 Petr



 What I need, is to combine all the six together, and give for example
 NA-value in day 1, for those columns which can only be found in day 2.
 Is this somehow possible?

 I have several of these six-datasets groups, and only few of them are
 having this problem described above, and I cannot know in advance which.
 With most of the groups writing
 rbind(data1,data2,data3,data4,data5,data6)
 works easily, but these few problematic groups need also to be
 combined...
 Any help greatly appreciated!

 -Jouni

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




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

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


Re: [R] Question about lmer

2007-06-18 Thread Douglas Bates
On 6/18/07, Julia Proudnikova [EMAIL PROTECTED] wrote:
 Hello,

 We have a problem with function lmer. This is our code:

 Get_values-function(ff_count, fixed_factors, rf_count, random_factors, 
 y_values)
 {
   SA-matrix(as.array(c(fixed_factors, random_factors)), ncol=3)
   data-as.data.frame(SA)
   y-as.array(y_values)

   dd-data.frame(SA)
   for(i in 1:(ff_count+rf_count)){
 dd[,i]-as.factor(data[,i])
   }

   fit_full=lmer(y~dd[,1]+dd[,2]+(1|dd[,3]),method=ML)
   fit_full
 }

 A-c(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1)
 B-c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1)
 C-c(0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1)
 Y-c(5,3,4,1,1,2,6,1,5,3,7,1,2,3,1,1,5,3,4,1,1,2,6,1,5,3,7,1,2,3,1,1)
 r-Get_values(2, c(A,B),1,c(C),Y)
 r

 R output:
 Error in inherits(x, factor) : object dd not found

 Can this function work with random array? Because this code is
 working:

The full explanation of why lmer fails to find dd has to do with the
way names are resolved in a call to model.frame.  However, there may
be a way to solve your problem by redesigning your function so you
don't need to worry about what model.frame does.

Why not pass the data as a data frame and pass the names of the fixed
factors, random factors and response variable as character strings?
Your current design of creating a matrix, then converting it to a data
frame then converting numeric variables back to factors is a bit
convoluted.

If you knew that you were only going to have one random factor you
could generate the formula as

substitute(y ~ ff + (1|rf), list(y = as.name(y_name), ff =
parse(paste(ff_names, collapse = +)), rf = as.name(rf_name))

It gets a bit trickier with multiple random factors.

Having said all this, it does appear that the call to model.frame
inside lmer is getting the wrong environment from the formula and I
will correct that.

If you need more detail about the redesign I am suggesting, feel free
to contact me off-list.

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


Re: [R] Automatic paren/bracket closing in 2.5.0?

2007-06-18 Thread Duncan Murdoch
On 18/06/2007 12:30 AM, Adam D. I. Kramer wrote:
 Hello,
 
   Just upgraded to 2.5.0, and found that R now includes an rparen
 (right parentheses) or rbracket whenever I enter in an lparen. While I can
 see the use of this function, it doesn't mesh well with my personal style of
 using R (e.g., using the up arrow, adding an rparen, jumping to the
 beginning of the line, and then wrapping a summary, for instance).
 
 Some 10 minutes of google searching has failed to come up with a solution
 for turning this feature off--any suggestions from the list?

You don't say your OS.  If it's MacOSX (which I think is the only 
platform with this feature), then see the R-sig-mac list, and in 
particular Simon Urbanek's posting on May 23:

 On May 23, 2007, at 3:55 PM, Roberto Osorio wrote:
 
  I can't find a preference to disable brace completion in the  
  console in R 2.5.0 GUI 1.19.
 
 Unfortunately it didn't make it to the Preferences UI, so you have to  
 paste this in Terminal:
 
 defaults write org.R-project.R auto.close.parens NO
 
 If you want to revert back to the default you can use:
 
 defaults delete org.R-project.R auto.close.parens
 
 

Duncan Murdoch

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


Re: [R] Readline

2007-06-18 Thread Jim Lemon
Antje wrote:
 Hello,
 
 I also have problems to get to run the following lines. If I run the
 block instead of every single line, it simply does not wait for the input.
 Can anybody help me?
 
 
 pos_name - readline(Please type: )
 
 r - substr(pos_name, 1,1)
 c - substr(pos_name, 2,nchar(pos_name))
 
 
 
Hi Antje,
What you seem to be doing is pasting the lines into the R window. The 
second line looks like the input line that the first line is expecting, 
and if you remove the empty line, you will see that pos_name has been 
assigned the text of the second line.

If you put these lines into a text file and then use source to read 
it, it works as I think you expect.

Jim

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


[R] triangle contour plots

2007-06-18 Thread Robin Hankin
Suppose I have three numbers p1, p2, p3 with
0 = p1,p2,p3 = 1  and p1+p2+p3=1,
and a  function  f=f(p1,p2,p3)   =  f(p1,p2,1-p1-p2).

How to draw a contour plot of f() on the p1+p2+p3=1 plane,
that is, an equilateral triangle?

Functions triplot(), triangle.plot(), and ternaryplot()  give
only  scatterplots, AFAICS





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

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


[R] BATCH

2007-06-18 Thread elyakhlifi mustapha
Hello,
I run some programs R from BATCH using  this syntax

 R CMD BATCH options(echo = FALSE) C:\R\copie.r C:\PHP\sortie.r 

but the options doesn't work do you know why?
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Inverse BoxCox transformation

2007-06-18 Thread John Fox
Dear Des,

The following should do the trick:

invBoxCox - function(x, lambda)
if (lambda == 0) exp(x) else (lambda*x + 1)^(1/lambda)

I hope this helps,
 John


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Des Callaghan
 Sent: Monday, June 18, 2007 3:33 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Inverse BoxCox transformation
 
 Hi,
  
 I can't seem to find a function in R that will reverse a 
 BoxCox transformation. Can somebody help me locate one 
 please? Thanks in advance.
  
 Best wishes,
 Des
  
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] BATCH

2007-06-18 Thread Christophe Pallier
?BATCH

By default, the input commands are printed along with the output.
 To suppress this behavior, add 'options(echo = FALSE)' at the
 beginning of 'infile'.


at the begining of 'infile' means that 'options(echo = FALSE)' must be
included inside 'infile'( in your case copie.r), as a first line. Not before
'infile' on the command line.

Btw, the help does not mention that you can put several script files on the
command line. I am not sure if it works.

Christophe



On 6/18/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote:

 Hello,
 I run some programs R from BATCH using  this syntax

 R CMD BATCH options(echo = FALSE) C:\R\copie.r C:\PHP\sortie.r

 but the options doesn't work do you know why?
 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
 and provide commented, minimal, self-contained, reproducible code.




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


[R] data.frame

2007-06-18 Thread elyakhlifi mustapha
hello,
are there functions giving the columns number and the rows number of a matrix?
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] data.frame

2007-06-18 Thread Adaikalavan Ramasamy
See help(dim) and please read the manuals before asking basic questions 
like this. Thank you.


elyakhlifi mustapha wrote:
 hello,
 are there functions giving the columns number and the rows number of a matrix?
 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
 and provide commented, minimal, self-contained, reproducible code.
 
 


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


Re: [R] data.frame

2007-06-18 Thread Christophe Pallier
On 6/18/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote:

 hello,
 are there functions giving the columns number and the rows number of a
 matrix?


Yes, there are.

Are you trying to use R without reading *any* documentation???
The mailing list is not a substitute for the manuals.
See the Posting guide.

Christophe



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




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


Re: [R] data.frame

2007-06-18 Thread Robin Hankin

On 18 Jun 2007, at 14:16, Adaikalavan Ramasamy wrote:

 See help(dim) and please read the manuals before asking basic  
 questions
 like this. Thank you.



I think the questioner was looking for row() and col(), which (IMO) are
difficult to find if you don't know of their existence.


[as indeed are slice.index() or arow()  for the array case]

Robin



 elyakhlifi mustapha wrote:
 hello,
 are there functions giving the columns number and the rows number  
 of a matrix?
 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
 and provide commented, minimal, self-contained, reproducible code.




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

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

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


[R] data.frame

2007-06-18 Thread elyakhlifi mustapha
hello,
I'm trying to write a function which take a matrix and give a dataframe with 
column names and row names but the problem I meet it's that the column number 
is changing and the vector containing the column names is also changing how can 
I do to write a good progam for the moment I tryied like follow:

dm - ncol(M)
v - vector()
t - 1
while (dm  0) {
 v - c(v,paste(Rép,t,sep=))
 t - t + 1
 dm - dm - 1
}
nv - noquote(v)
df - function (M,x) {
 return(data.frame(nv[1] = M[,1], nv[2] = M[,2],nv[3] = M[,3], row.names = 
var[[1]], check.rows = TRUE, check.names = TRUE))
}

 I know that there are errors but the important is that R doesn't recognize nv.
For more precision the martix M is like follow:

 M
  [,1] [,2] [,3]
 [1,] 6.52   NA 6.59
 [2,] 6.99 6.85 6.38
 [3,] 6.92 6.72 6.99
 [4,] 6.59 5.51 6.45
 [5,] 6.65 7.12 6.99
 [6,] 6.18 5.71 5.78
 [7,] 6.65 6.52 6.72
 [8,] 6.65 6.79 6.12
 [9,] 6.59 6.65 6.32
[10,] 5.85 6.05 6.38
[11,] 6.38 6.79 6.65
[12,] 6.79 6.52 6.72
[13,] 6.12 6.25 6.38
[14,] 6.99 6.72 6.38
[15,] 6.59 6.65 6.99
[16,] 6.45 6.18 6.59
[17,] 5.65 6.05 6.52
[18,] 6.52 6.85 6.65
[19,] 6.18 6.32 6.32
[20,] 6.99 6.65 6.72
[21,] 6.52 6.99 6.32

Can you help me?
thanks.


  
_ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
[[alternative HTML version deleted]]

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


[R] how to obtain the OR and 95%CI with 1 SD change of a continue variable

2007-06-18 Thread felix
Dear all,

How to obtain the odds ratio (OR) and 95% confidence interval (CI) with 
1 standard deviation (SD) change of a continuous variable in logistic 
regression?

for example, to investigate the risk of obesity for stroke. I choose the 
happening of stroke (positive) as the dependent variable, and waist 
circumference as an independent variable. Then I wanna to obtain the OR 
and 95% CI with 1 SD change of waist circumference.how?

Any default package(s) or options in glm available now?

if not, how to calculate them by hand?

many thanks.

yours,sincerely,
Xingwang Ye

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


Re: [R] triangle contour plots

2007-06-18 Thread Duncan Murdoch
On 6/18/2007 8:12 AM, Robin Hankin wrote:
 Suppose I have three numbers p1, p2, p3 with
 0 = p1,p2,p3 = 1  and p1+p2+p3=1,
 and a  function  f=f(p1,p2,p3)   =  f(p1,p2,1-p1-p2).
 
 How to draw a contour plot of f() on the p1+p2+p3=1 plane,
 that is, an equilateral triangle?

The usual contour function leaves blanks where you give it NA values, so 
you could put the f values into a rectangular array with NA outside the 
triangle and use that.

I don't know how you're thinking of displaying things, but one possible 
transformation from (x,y) to (p1, p2, p3) would be

  f - function(p1, p2, p3) p3  # just to illustrate

  maxy - sin(pi/3)
  x - seq(0,1,len=100)
  y - seq(0, maxy, len=100)
  p1 - outer(x,y, function(x,y) x - y/maxy/2)
  p2 - outer(x,y, function(x,y) y/maxy)
  p3 - 1-p1-p2
  z - ifelse(0  p1  0  p3, f(p1,p2,p3), NA)
  contour(x,y,z)

This puts p1==1 at the bottom right, p2==1 at the top, and p3==1 at the 
bottom left.

Duncan Murdoch

 
 Functions triplot(), triangle.plot(), and ternaryplot()  give
 only  scatterplots, AFAICS
 
 
 
 
 
 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
   tel  023-8059-7743
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] data.frame

2007-06-18 Thread Christophe Pallier
On 6/18/07, Robin Hankin [EMAIL PROTECTED] wrote:


 I think the questioner was looking for row() and col(), which (IMO) are
 difficult to find if you don't know of their existence.



Searching for R matrix number of rows columns in google returns, in fourth
position, the manual page for 'nrow'.


-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


Re: [R] data.frame

2007-06-18 Thread Christophe Pallier
If M is the original matrix,

k - as.data.frame(M)
names(k) - paste(Rép,1:ncol(k),sep=)
rownames(k) - paste(Col,1:nrow(k),sep=) # replace by what you want
k



On 6/18/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote:

 hello,
 I'm trying to write a function which take a matrix and give a dataframe
 with column names and row names but the problem I meet it's that the column
 number is changing and the vector containing the column names is also
 changing how can I do to write a good progam for the moment I tryied like
 follow:

 dm - ncol(M)
 v - vector()
 t - 1
 while (dm  0) {
 v - c(v,paste(Rép,t,sep=))
 t - t + 1
 dm - dm - 1
 }
 nv - noquote(v)
 df - function (M,x) {
 return(data.frame(nv[1] = M[,1], nv[2] = M[,2],nv[3] = M[,3], row.names =
 var[[1]], check.rows = TRUE, check.names = TRUE))
 }

 I know that there are errors but the important is that R doesn't recognize
 nv.
 For more precision the martix M is like follow:

 M
   [,1] [,2] [,3]
 [1,] 6.52   NA 6.59
 [2,] 6.99 6.85 6.38
 [3,] 6.92 6.72 6.99
 [4,] 6.59 5.51 6.45
 [5,] 6.65 7.12 6.99
 [6,] 6.18 5.71 5.78
 [7,] 6.65 6.52 6.72
 [8,] 6.65 6.79 6.12
 [9,] 6.59 6.65 6.32
 [10,] 5.85 6.05 6.38
 [11,] 6.38 6.79 6.65
 [12,] 6.79 6.52 6.72
 [13,] 6.12 6.25 6.38
 [14,] 6.99 6.72 6.38
 [15,] 6.59 6.65 6.99
 [16,] 6.45 6.18 6.59
 [17,] 5.65 6.05 6.52
 [18,] 6.52 6.85 6.65
 [19,] 6.18 6.32 6.32
 [20,] 6.99 6.65 6.72
 [21,] 6.52 6.99 6.32

 Can you help me?
 thanks.



   
 _
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo!
 Mail
 [[alternative HTML version deleted]]


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




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


[R] source a specific function

2007-06-18 Thread Weiwei Shi
Dear Listers:

For example, if I have a .R source file which has more than one
function, and I want to just load only one of the functions, how could
I do that? (removing the rest after sourcing is not what I intend b/c
in my workspace, I might have some of the rest and I don't want to
change my workspace: i.e., I only change my workspace by adding one
function from a R source file).

Thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

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

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


[R] Odp: data.frame

2007-06-18 Thread Petr PIKAL
Hi

Why scratching your left ear with your right hand?

If M is numeric matrix

d.m - data.frame(M)
names(d.m) - paste(Rep, 1:dim(M)[2], sep=)

not sure what you want as row names as var is not defined anywhere in your 
code, but you can use the same principle for changing row names. Jus use

row.names(d.m) - whatever vector of names you can elaborate

Regards

Petr Pikal
[EMAIL PROTECTED]

BTW. R is not C and you shall use strong features of R not to try to avoid 
them.


[EMAIL PROTECTED] napsal dne 18.06.2007 15:40:38:

 hello,
 I'm trying to write a function which take a matrix and give a dataframe 
with 
 column names and row names but the problem I meet it's that the column 
number 
 is changing and the vector containing the column names is also changing 
how 
 can I do to write a good progam for the moment I tryied like follow:
 
 dm - ncol(M)
 v - vector()
 t - 1
 while (dm  0) {
  v - c(v,paste(Rép,t,sep=))
  t - t + 1
  dm - dm - 1
 }
 nv - noquote(v)
 df - function (M,x) {
  return(data.frame(nv[1] = M[,1], nv[2] = M[,2],nv[3] = M[,3], row.names 
= 
 var[[1]], check.rows = TRUE, check.names = TRUE))
 }
 
  I know that there are errors but the important is that R doesn't 
recognize nv.
 For more precision the martix M is like follow:
 
  M
   [,1] [,2] [,3]
  [1,] 6.52   NA 6.59
  [2,] 6.99 6.85 6.38
  [3,] 6.92 6.72 6.99
  [4,] 6.59 5.51 6.45
  [5,] 6.65 7.12 6.99
  [6,] 6.18 5.71 5.78
  [7,] 6.65 6.52 6.72
  [8,] 6.65 6.79 6.12
  [9,] 6.59 6.65 6.32
 [10,] 5.85 6.05 6.38
 [11,] 6.38 6.79 6.65
 [12,] 6.79 6.52 6.72
 [13,] 6.12 6.25 6.38
 [14,] 6.99 6.72 6.38
 [15,] 6.59 6.65 6.99
 [16,] 6.45 6.18 6.59
 [17,] 5.65 6.05 6.52
 [18,] 6.52 6.85 6.65
 [19,] 6.18 6.32 6.32
 [20,] 6.99 6.65 6.72
 [21,] 6.52 6.99 6.32
 
 Can you help me?
 thanks.
 
 
 
_ 

 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! 
Mail 
[[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] data.frame

2007-06-18 Thread jim holtman
Is this close to what you want?  'var' was not defined for row.names.

 M - matrix(scan(textConnection(x)), ncol=3, byrow=TRUE)
Read 63 items
 dm - ncol(M)
 v - vector()
 t - 1
 while (dm  0) {
+  v - c(v,paste(Rép,t,sep=))
+  t - t + 1
+  dm - dm - 1
+ }
 df - as.data.frame(M)
 colnames(df) - v
 df
   Rép1 Rép2 Rép3
1  6.52   NA 6.59
2  6.99 6.85 6.38
3  6.92 6.72 6.99
4  6.59 5.51 6.45
5  6.65 7.12 6.99
6  6.18 5.71 5.78
7  6.65 6.52 6.72
8  6.65 6.79 6.12
9  6.59 6.65 6.32
10 5.85 6.05 6.38
11 6.38 6.79 6.65
12 6.79 6.52 6.72
13 6.12 6.25 6.38
14 6.99 6.72 6.38
15 6.59 6.65 6.99
16 6.45 6.18 6.59
17 5.65 6.05 6.52
18 6.52 6.85 6.65
19 6.18 6.32 6.32
20 6.99 6.65 6.72
21 6.52 6.99 6.32




On 6/18/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote:

 hello,
 I'm trying to write a function which take a matrix and give a dataframe
 with column names and row names but the problem I meet it's that the column
 number is changing and the vector containing the column names is also
 changing how can I do to write a good progam for the moment I tryied like
 follow:

 dm - ncol(M)
 v - vector()
 t - 1
 while (dm  0) {
 v - c(v,paste(Rép,t,sep=))
 t - t + 1
 dm - dm - 1
 }
 nv - noquote(v)
 df - function (M,x) {
 return(data.frame(nv[1] = M[,1], nv[2] = M[,2],nv[3] = M[,3], row.names =
 var[[1]], check.rows = TRUE, check.names = TRUE))
 }

 I know that there are errors but the important is that R doesn't recognize
 nv.
 For more precision the martix M is like follow:

 M
  [,1] [,2] [,3]
 [1,] 6.52   NA 6.59
 [2,] 6.99 6.85 6.38
 [3,] 6.92 6.72 6.99
 [4,] 6.59 5.51 6.45
 [5,] 6.65 7.12 6.99
 [6,] 6.18 5.71 5.78
 [7,] 6.65 6.52 6.72
 [8,] 6.65 6.79 6.12
 [9,] 6.59 6.65 6.32
 [10,] 5.85 6.05 6.38
 [11,] 6.38 6.79 6.65
 [12,] 6.79 6.52 6.72
 [13,] 6.12 6.25 6.38
 [14,] 6.99 6.72 6.38
 [15,] 6.59 6.65 6.99
 [16,] 6.45 6.18 6.59
 [17,] 5.65 6.05 6.52
 [18,] 6.52 6.85 6.65
 [19,] 6.18 6.32 6.32
 [20,] 6.99 6.65 6.72
 [21,] 6.52 6.99 6.32

 Can you help me?
 thanks.



 _
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo!
 Mail
[[alternative HTML version deleted]]


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




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

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] source a specific function

2007-06-18 Thread Don MacQueen
One way to do it would be to surround the function(s) you don't want 
sourced, like this:

if (FALSE) {
## function definition here
}

But you might find it easier to just put each function in its own file.

At 9:54 AM -0400 6/18/07, Weiwei Shi wrote:
Dear Listers:

For example, if I have a .R source file which has more than one
function, and I want to just load only one of the functions, how could
I do that? (removing the rest after sourcing is not what I intend b/c
in my workspace, I might have some of the rest and I don't want to
change my workspace: i.e., I only change my workspace by adding one
function from a R source file).

Thanks,

--
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

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

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


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, 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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] source a specific function

2007-06-18 Thread Gabor Grothendieck
This loads all the functions into an anonymous environment defined
by local and then exports f to the global environment.

f - local({
source(/a.R, local = TRUE)
environment(f) - .GlobalEnv
f
})

On 6/18/07, Weiwei Shi [EMAIL PROTECTED] wrote:
 Dear Listers:

 For example, if I have a .R source file which has more than one
 function, and I want to just load only one of the functions, how could
 I do that? (removing the rest after sourcing is not what I intend b/c
 in my workspace, I might have some of the rest and I don't want to
 change my workspace: i.e., I only change my workspace by adding one
 function from a R source file).

 Thanks,

 --
 Weiwei Shi, Ph.D
 Research Scientist
 GeneGO, Inc.

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

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


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


Re: [R] source a specific function

2007-06-18 Thread Duncan Murdoch
On 6/18/2007 9:54 AM, Weiwei Shi wrote:
 Dear Listers:
 
 For example, if I have a .R source file which has more than one
 function, and I want to just load only one of the functions, how could
 I do that? (removing the rest after sourcing is not what I intend b/c
 in my workspace, I might have some of the rest and I don't want to
 change my workspace: i.e., I only change my workspace by adding one
 function from a R source file).

In Windows, open the file in an editor, copy (e.g. by highlighting it 
and hitting Ctrl-C) the part you want to source to the clipboard, and 
then in R enter source(clipboard), or just paste the selected text.

I think source(clipboard) is Windows-specific, but other platforms 
support copy and paste in their own ways.

Duncan Murdoch

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


Re: [R] triangle contour plots

2007-06-18 Thread Greg Snow
The triplot function in the TeachingDemos package (I don't know about
the one in klaR, or the others mentioned) honors the type='l' argument
and passes it on to points.  So if you know where you want the contours
drawn, you can use triplot to draw the lines (it also has an add
argument that could be used to add labels after plotting the lines).

You can also look at the source code to see how the plotting is done and
modify it to do the plot you are interested in.

Hope this helps,

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Robin Hankin
 Sent: Monday, June 18, 2007 6:12 AM
 To: R program
 Subject: [R] triangle contour plots
 
 Suppose I have three numbers p1, p2, p3 with 0 = p1,p2,p3 = 
 1  and p1+p2+p3=1,
 and a  function  f=f(p1,p2,p3)   =  f(p1,p2,1-p1-p2).
 
 How to draw a contour plot of f() on the p1+p2+p3=1 plane, 
 that is, an equilateral triangle?
 
 Functions triplot(), triangle.plot(), and ternaryplot()  give 
 only  scatterplots, AFAICS
 
 
 
 
 
 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton European Way, 
 Southampton SO14 3ZH, UK
   tel  023-8059-7743
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] how to obtain the OR and 95%CI with 1 SD change of a continue variable

2007-06-18 Thread Peter Dalgaard
felix wrote:
 Dear all,

 How to obtain the odds ratio (OR) and 95% confidence interval (CI) with 
 1 standard deviation (SD) change of a continuous variable in logistic 
 regression?

 for example, to investigate the risk of obesity for stroke. I choose the 
 happening of stroke (positive) as the dependent variable, and waist 
 circumference as an independent variable. Then I wanna to obtain the OR 
 and 95% CI with 1 SD change of waist circumference.how?

 Any default package(s) or options in glm available now?

 if not, how to calculate them by hand?

   
Unless you want to do something advanced like factoring in the sampling
error of the SD (I don't think anyone bothers with that), probably the
easiest way is to scale() the predictor and look at the relevant line of
exp(confint(glm(.))). As in

(library(MASS); example(confint.glm))

 budworm.lg0 - glm(SF ~ sex + scale(ldose), family = binomial)
 exp(confint(budworm.lg0))
Waiting for profiling to be done...
 2.5 % 97.5 %
(Intercept)  0.2652665  0.7203169
sexM 1.5208018  6.1747207
scale(ldose) 4.3399952 10.8983903

Or, if you insist on getting asymptotic Wald-statistic based intervals:

 exp(confint.default(budworm.lg0))
2.5 % 97.5 %
(Intercept)  0.269864  0.7294944
sexM 1.496808  6.0384756
scale(ldose) 4.220890 10.5546837

You can also get it from the coefficients of the unscaled analysis, like in

 budworm.lg0 - glm(SF ~ sex + ldose, family = binomial)
 confint(budworm.lg0)
Waiting for profiling to be done...
 2.5 %97.5 %
(Intercept) -4.4582430 -2.613736
sexM 0.4192377  1.820464
ldose0.8229072  1.339086
 exp(confint(budworm.lg0)[3,]*sd(ldose))
Waiting for profiling to be done...
2.5 %97.5 %
 4.339995 10.898390


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

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


[R] discriminant analysis with lda(MASS)

2007-06-18 Thread Silvia Lomascolo

I use Widows, R version 2.4.1

I have 4 questions on lda (MASS) (code is pasted below):

1st. How can I obtain the statistics and p-value associated with
discriminant analysis? Am I supposed to calculate that manually by squaring
the svd value and looking the p value up in a table? I am writing the
following code:

training.mx-read.table('C:\\Documents and Settings\\silvia\\My
Documents\\silvia\\paper Martin\\trainingAndvalidation.txt', header=T)
train - sample (1:148) ##in a file with 399 cases, I am using the first 148
as a training set
table(training.mx$disperser[train])
training.df - lda (disperser~., training.mx, subset=train)
predict (training.df, training.mx[-train,])$class

2nd. How can I get the scores for each species on the discriminant
functions? I only get the scores for the group means, but I need the values
for all species.

3rd. Is it possible to obtain confidence intervals for my groups?

4th. (this is part of a previous posting but it's related to all my previous
questions so here it goes again) When I try to plot the resulting
discriminant functions following the example I found in the help, I get an
error saying that 'panel.lda' doesn't exist. Am I supposed to create it?
Here is the code for the plot:

plot(x, panel = panel.lda, cex = 0.7, dimen=1,
 xlab = LD1, ylab = LD2)

Help on any or all of these questions will be greatly appreciated!

Silvia.

-- 
View this message in context: 
http://www.nabble.com/discriminant-analysis-with-lda%28MASS%29-tf3941130.html#a11178433
Sent from the R help mailing list archive at Nabble.com.

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


[R] Optimization

2007-06-18 Thread livia

Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01,
x1 is the quantile of normal distribution (0.0032,x) with probability of
0.7, and the changing value should be x. Initial value for x is 0.0207. I am
using the following codes, but it does not work.

fr - function(x) {
  x1-qnorm(0.7,0.0032,x)
  x2=0.01
  x1-x2
}
xsd - optim(0.0207, fr, NULL,method=BFGS)

It is the first time I am trying to use optimization. Could anyone give me
some advice?
-- 
View this message in context: 
http://www.nabble.com/Optimization-tf3941212.html#a11178663
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] source a specific function

2007-06-18 Thread Ted Harding
On 18-Jun-07 14:28:35, Gabor Grothendieck wrote:
 This loads all the functions into an anonymous environment defined
 by local and then exports f to the global environment.
 
 f - local({
   source(/a.R, local = TRUE)
   environment(f) - .GlobalEnv
   f
 })

That looks neat! Two questions:

1. Would something similar work for extracting selected functions
   from a library (assuming that you know about interdependencies)?

   E.g. something like

  f - local({
   library(f.etc.lib)
   environment(f) - .GlobalEnv
   f
  })


2. Having done what you describe to extract just f from a source
   file, can one then delete the local environment used to load
   the source? I think what I'm basically asking is whether the
   exporting is done by value (local environment deletion OK)
   or by reference (deletion would destroy the exported object).

Apologies, but for instance ?local is a bit too deep for me!

The underlying agenda behind these queries is the saving of
memory space.

With theanks,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 18-Jun-07   Time: 17:11:15
-- XFMail --

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


[R] Large Binary file reader for Simple minds

2007-06-18 Thread Todd Remund
I'm more like a caveman when it comes to programming tools.  So, with that 
in mind, is there a way to use readBin in a batch format to read in pieces 
of a large binary file?  Thank you for the consideration of my question.

Todd Remund

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


Re: [R] source a specific function

2007-06-18 Thread Gabor Grothendieck
1. You can do this:

 library(plotrix)
 environment(draw.arc) - .GlobalEnv  # implicitly copies it
 detach()
 plot(1,1)
 draw.arc(1, 1, .1) # its there

2. Since the local environment we created in the prior post was anonymous
and since there are no other references to it either I assume it gets deleted
on the next garbage collection automatically.

On 6/18/07, Ted Harding [EMAIL PROTECTED] wrote:
 On 18-Jun-07 14:28:35, Gabor Grothendieck wrote:
  This loads all the functions into an anonymous environment defined
  by local and then exports f to the global environment.
 
  f - local({
source(/a.R, local = TRUE)
environment(f) - .GlobalEnv
f
  })

 That looks neat! Two questions:

 1. Would something similar work for extracting selected functions
   from a library (assuming that you know about interdependencies)?

   E.g. something like

  f - local({
   library(f.etc.lib)
   environment(f) - .GlobalEnv
   f
  })


 2. Having done what you describe to extract just f from a source
   file, can one then delete the local environment used to load
   the source? I think what I'm basically asking is whether the
   exporting is done by value (local environment deletion OK)
   or by reference (deletion would destroy the exported object).

 Apologies, but for instance ?local is a bit too deep for me!

 The underlying agenda behind these queries is the saving of
 memory space.

 With theanks,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 18-Jun-07   Time: 17:11:15
 -- XFMail --

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


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


Re: [R] Optimization

2007-06-18 Thread Robert A LaBudde
You don't need optimization for the solution to your problem. You 
just need an understanding of the meaning of qnorm() and some simple algebra.

Try: x- (0.01-0.0032)/qnorm(0.7,0,1)


At 12:01 PM 6/18/2007, you wrote:

Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01,
x1 is the quantile of normal distribution (0.0032,x) with probability of
0.7, and the changing value should be x. Initial value for x is 0.0207. I am
using the following codes, but it does not work.

fr - function(x) {
   x1-qnorm(0.7,0.0032,x)
   x2=0.01
   x1-x2
}
xsd - optim(0.0207, fr, NULL,method=BFGS)

It is the first time I am trying to use optimization. Could anyone give me
some advice?
--
View this message in context: 
http://www.nabble.com/Optimization-tf3941212.html#a11178663
Sent from the R help mailing list archive at Nabble.com.

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


Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

Vere scire est per causas scire

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


Re: [R] Optimization

2007-06-18 Thread Uwe Ligges


livia wrote:
 Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01,
 x1 is the quantile of normal distribution (0.0032,x) with probability of
 0.7, and the changing value should be x. Initial value for x is 0.0207. I am
 using the following codes, but it does not work.
 
 fr - function(x) {
   x1-qnorm(0.7,0.0032,x)
   x2=0.01
   x1-x2
 }
 xsd - optim(0.0207, fr, NULL,method=BFGS)


I guess you want to use optimize() and change the last line of fr to 
(x1-x2)^2 as in:


fr - function(x) {
   x1 - qnorm(0.7, 0.0032, x)
   x2 - 0.01
   (x1-x2)^2
}

optimize(fr, c(-5, 5))

Uwe Ligges




 It is the first time I am trying to use optimization. Could anyone give me
 some 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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Optimization

2007-06-18 Thread Ted Harding
On 18-Jun-07 16:01:03, livia wrote:
 
 Hi, I would like to minimize the value of x1-x2, x2 is a fixed
 value of 0.01,
 x1 is the quantile of normal distribution (0.0032,x) with
 probability of 0.7, and the changing value should be x.
 Initial value for x is 0.0207.

I'm a bit puzzled by the question. If I understand it right,
we can ignore x2 (since it is a fixed value) and simply consider
minimising x1 (instead of x1-x2).

Then, denoting by P(u) the cumulative normal distribution function
for mean=0 and variance=1 (i.e. in R: pnorm(u,0,1)), and by Q(p)
its inverse, corresponding to qnorm(p,0,1), we have (again if I
have understood right):

  P((x1 - 0.0032)/x) = 0.7

so

  x1 = 0.0032 + x*Q(0.7)

and therefore, since Q(0.7)  0 and x must be positive, the value
of x1 can be made as close to 0.032 as you please (but greater
than 0.032) by taking x small enough.

Hence there is no strictly minimising value of x, but the greatest
lower bound of all possible values of x1 is 0.032.

Then you can subtract x2.

The fact that there is no positive value of x which gives this
bound as the value probably explains the failure of your optim()
attempt.

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 18-Jun-07   Time: 17:46:01
-- XFMail --

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


Re: [R] Problem with RSVGTipsDevice

2007-06-18 Thread Tony Plate
The new version of RSVGTipsDevice (0.7.1) that is now available on CRAN 
should fix this problem.  Please let me know if it doesn't, or if there 
are other problems.

-- Tony Plate

mister_bluesman wrote:
 Hi there.
 
 I am still trying to get the RSVGTipsDevice to work, yet I can not.
 
 I have copied the first example from RSVGTipsDevice documentation:
 
 library(RSVGTipsDevice)
 devSVGTips(C:\\svgplot1.svg, toolTipMode=1,
 title=SVG example plot 1: shapes and points, tooltips are title + 1 line)
 plot(c(0,10),c(0,10), type=n, xlab=x, ylab=y,
 main=Example SVG plot with title + 1 line tips (mode=1))
 setSVGShapeToolTip(title=A rectangle, desc=that is yellow)
 rect(1,1,4,6, col='yellow')
 setSVGShapeToolTip(title=1st circle with title only)
 points(5.5,7.5,cex=20,pch=19,col='red')
 setSVGShapeToolTip(title=A triangle, desc=big and green)
 polygon(c(3,6,8), c(3,6,3), col='green')
 # no tooltips on these points
 points(2:8, 8:2, cex=3, pch=19, col='black')
 # tooltips on each these points
 invisible(sapply(1:7, function(x)
 {setSVGShapeToolTip(title=paste(point, x))
 points(x+1, 8-x, cex=3, pch=1, col='black')}))
 dev.off()
 
 This results in the following output:
 
 http://www.nabble.com/file/p11064573/svgplot1.svg svgplot1.svg 
 
 It opens but when I try and hover over the triangle, for example, I do not
 get a topptip box appear. I have tried opening the file though firefox, and
 XP IE - and on more than one computer yet it does not work. Do I need to
 install something else as well?
 
 Many 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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Automatic paren/bracket closing in 2.5.0?

2007-06-18 Thread Adam D. I. Kramer
Many thanks, Duncan. I did not expect this to be an OS-specific issue, and
figured it must be the new default and thus configurable from within the
program, though indeed I am using MacOS.

--Adam

On Mon, 18 Jun 2007, Duncan Murdoch wrote:

 On 18/06/2007 12:30 AM, Adam D. I. Kramer wrote:
 Hello,

  Just upgraded to 2.5.0, and found that R now includes an rparen
 (right parentheses) or rbracket whenever I enter in an lparen. While I can
 see the use of this function, it doesn't mesh well with my personal style 
 of
 using R (e.g., using the up arrow, adding an rparen, jumping to the
 beginning of the line, and then wrapping a summary, for instance).
 
 Some 10 minutes of google searching has failed to come up with a solution
 for turning this feature off--any suggestions from the list?

 You don't say your OS.  If it's MacOSX (which I think is the only platform 
 with this feature), then see the R-sig-mac list, and in particular Simon 
 Urbanek's posting on May 23:

 On May 23, 2007, at 3:55 PM, Roberto Osorio wrote:
 
  I can't find a preference to disable brace completion in the   console 
 in R 2.5.0 GUI 1.19.
 
 Unfortunately it didn't make it to the Preferences UI, so you have to 
 paste this in Terminal:
 
 defaults write org.R-project.R auto.close.parens NO
 
 If you want to revert back to the default you can use:
 
 defaults delete org.R-project.R auto.close.parens
 
 

 Duncan Murdoch


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


Re: [R] Optimization

2007-06-18 Thread Prof Brian Ripley
From the help page:

Note:

  'optim' will work with one-dimensional 'par's, but the default
  method does not work well (and will warn).  Use 'optimize'
  instead.

Next, there is a constraint of x=0 that you are not imposing.

Finally, it is easy to see that qnorm(0.7, 0.0032, x) is monotome in x, so 
the solution is x=0.  In fact, x1 = 0.0032 + sqrt(x) * qnorm(0.7).

optim(0.0207, fr)  does a good enough job, as does
optimize(fr, low=0, up=0.05)


Advice: numerical optimization is not a black box, and has to be used with 
some analysis of the problem to hand.  See e.g. MASS4, chapter 16.


On Mon, 18 Jun 2007, livia wrote:


 Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01,
 x1 is the quantile of normal distribution (0.0032,x) with probability of
 0.7, and the changing value should be x. Initial value for x is 0.0207. I am
 using the following codes, but it does not work.

 fr - function(x) {
  x1-qnorm(0.7,0.0032,x)
  x2=0.01
  x1-x2
 }
 xsd - optim(0.0207, fr, NULL,method=BFGS)

 It is the first time I am trying to use optimization. Could anyone give me
 some advice?


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

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


Re: [R] Optimization

2007-06-18 Thread Petr Klasterecky
Hi,

my first guess is that the algorithm returns a negative value in some 
step - recall that you start from 0.0207!! This negative value is then 
passed as standard error to qnorm and that cannot work...
My guess is based on a small experiment where I tried a different 
starting point (.02 is so close to 0 that one cannot see anything):
xsd - optim(20, fr, NULL,method=BFGS,control=list(trace=6))

The warnings which you didn't include also tell you about NaNs in 
qnorm() - another strong indication of wrong arguments to qnorm().

Try constrained optimization to resctrict to positive values.
See ?constrOptim or use optim() with a method allowing for box 
constraints - see ?optim, arguments lower, upper.

Petr

livia napsal(a):
 Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01,
 x1 is the quantile of normal distribution (0.0032,x) with probability of
 0.7, and the changing value should be x. Initial value for x is 0.0207. I am
 using the following codes, but it does not work.
 
 fr - function(x) {
   x1-qnorm(0.7,0.0032,x)
   x2=0.01
   x1-x2
 }
 xsd - optim(0.0207, fr, NULL,method=BFGS)
 
 It is the first time I am trying to use optimization. Could anyone give me
 some advice?

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

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


Re: [R] Large Binary file reader for Simple minds

2007-06-18 Thread Duncan Murdoch
On 6/18/2007 12:17 PM, Todd Remund wrote:
 I'm more like a caveman when it comes to programming tools.  So, with that 
 in mind, is there a way to use readBin in a batch format to read in pieces 
 of a large binary file?  Thank you for the consideration of my question.

I'm not sure what you mean by batch format, but you can use readBin to 
  read bits and pieces of a file, by opening a connection to the file 
and reading from there.  For example, to read a single unsigned byte 
value at offset 1, do something like this:

con - file(myfile.dat, open=rb)  # open for binary reading
seek(con, 1)
result - readBin(con, integer, size=1, signed=FALSE)
close(con)

Duncan Murdoch

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


[R] chron() question

2007-06-18 Thread javier garcia-pintado
Hi all,
I'm using chron and it seems to me that there is a strange behaviour
when constructing chronological objects.
An extract of my source data is:

 tdr.hhmm[4860:4870]
 [1] 22:22:00 22:42:00 23:02:00 23:22:00 23:42:00 00:02:00
 [7] 00:22:00 00:42:00 01:02:00 01:22:00 01:42:00
 tdr.dat$year[4860:4870]
 [1] 2005 2005 2005 2005 2005 2006 2006 2006 2006 2006 2006
 tdr.dat$day[4860:4870]
 [1] 365 365 365 365 365   1   1   1   1   1   1

And if I use:
 tdr.chron - 
chron(dates.=tdr.dat$day,times.=tdr.hhmm,origin.=c(month=1,day=0,year=tdr.dat$year),format=c(dates=d/m/y,times=h:m:s))
The result is:

 tdr.chron[4860:4870]
 [1] (31/12/05 22:22:00) (31/12/05 22:42:00) (31/12/05 23:02:00)
 [4] (31/12/05 23:22:00) (31/12/05 23:42:00) (01/01/05 00:02:00)
 [7] (01/01/05 00:22:00) (01/01/05 00:42:00) (01/01/05 01:02:00)
[10] (01/01/05 01:22:00) (01/01/05 01:42:00)

While it seems to me that, through the R recycling rule, it should
consider the year 2006 in the corresponding results. Isn't it so?

Wishes,
Javier

-- 
Javier García-Pintado
Institute of Earth Sciences Jaume Almera (CSIC)
Lluis Sole Sabaris s/n, 08028 Barcelona
Phone: +34 934095410
Fax:   +34 934110012
e-mail:[EMAIL PROTECTED] 

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


Re: [R] source a specific function

2007-06-18 Thread Duncan Murdoch
On 6/18/2007 12:11 PM, (Ted Harding) wrote:
 On 18-Jun-07 14:28:35, Gabor Grothendieck wrote:
 This loads all the functions into an anonymous environment defined
 by local and then exports f to the global environment.
 
 f - local({
   source(/a.R, local = TRUE)
   environment(f) - .GlobalEnv
   f
 })
 
 That looks neat! Two questions:
 
 1. Would something similar work for extracting selected functions
from a library (assuming that you know about interdependencies)?
 
E.g. something like
 
   f - local({
library(f.etc.lib)
environment(f) - .GlobalEnv
f
   })

The exact syntax you list there won't work, but in any case, changing 
the environment of a function in a package is a bad idea -- it may need 
to reference things from the namespace of the package.

 
 2. Having done what you describe to extract just f from a source
file, can one then delete the local environment used to load
the source? I think what I'm basically asking is whether the
exporting is done by value (local environment deletion OK)
or by reference (deletion would destroy the exported object).

Gabor answered this:  it will go away automatically.

Duncan Murdoch

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


Re: [R] Large Binary file reader for Simple minds

2007-06-18 Thread Paul Murrell
Hi


Todd Remund wrote:
 I'm more like a caveman when it comes to programming tools.  So, with that 
 in mind, is there a way to use readBin in a batch format to read in pieces 
 of a large binary file?  Thank you for the consideration of my question.


The 'hexView' package might be useful to you.  See Viewing Binary Files
with the hexView Package in R News 7/1.

Paul


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

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

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


Re: [R] Stacked barchart color

2007-06-18 Thread owenman

Hi Hadley,
Great, I am starting to get it.  It's working for me, but there is one more
thing I am having trouble with.  The ordering of the stacked bars seems to
be dictated by the name of the color, I guess because of the fill=color
argument in aes().  In other words, if I set up my colors like this: 
y$color = c(gray1,gray35,gray45,gray65)  the bars get stacked in the
opposite order than if I set up the colors like this:  y$color =
c(gray65,gray45,gray35,gray1).  How can I control the order of the
bars independent of the name of the colors?   Thanks so much in advance! 
Really neat package you've made.

FYI, my plot command now looks like this:
p = ggplot(y, aes(x=locus, y=Freq, fill=color))
p = p + geom_bar(position=fill)
p = p + scale_fill_identity(labels=levels(y$Fnd), grob=tile, name=Fnd
Results)
p = p + coord_flip()

And the data table is similar as before:
 y
  Fnd locusFreq  color
1  signeg  DPB1 0.013071895  gray1
2 neg  DPB1 0.581699346 gray35
3 pos  DPB1 0.379084967 gray45
4  sigpos  DPB1 0.026143791 gray65
5  signeg  DPA1 0.068181818  gray1
6 neg  DPA1 0.659090909 gray35
7 pos  DPA1 0.25000 gray45
8  sigpos  DPA1 0.022727273 gray65



hadley wrote:
 
 Hi Owen,
 
 The identity scale won't create a legend, unless you tell it what
 labels it should use - there's an example at
 http://had.co.nz/ggplot2/scale_identity.html.  Otherwise, if you have
 a continuous scale and you want something that works in black and
 white, p + scale_fill_gradient(low=white, high=black) might be
 easier.
 
 Hadley
 
 

  y$color = factor(y$Fnd)
  y$color = c(black,darkgray,lightgray,white)
  y
   Fnd locusFreq color
 1  signeg A 0.087248322 black
 2 neg A 0.711409396  darkgray
 3 pos A 0.201342282 lightgray
 4  sigpos A 0.0 white
 5  signeg C 0.320754717 black
 6 neg C 0.603773585  darkgray
 7 pos C 0.075471698 lightgray
 8  sigpos C 0.0 white
 9  signeg B 0.157534247 black
 10neg B 0.732876712  darkgray
 11pos B 0.109589041 lightgray
 12 sigpos B 0.0 white

  p = ggplot(y, aes(x=locus, y=Freq, fill=color)) +
  geom_bar(position=fill) + scale_fill_identity()
  p




 hadley wrote:
 
 
  Hi Dieter,
 
  You can do this with ggplot2 (http://had.co.nz/ggplot2) as follows:
 
  library(ggplot2)
 
  barley1 - subset(barley, site==Grand Rapids  variety %in%
  c(Velvet,Peatland))
  barley1[] - lapply(barley1, [, drop=TRUE)
 
  qplot(variety, yield, data=barley1, geom=bar, stat=identity,
  fill=factor(year))
 
  barley1$fill - c(red,green,blue,gray)
  qplot(variety, yield, data=barley1, geom=bar, stat=identity,
  fill=fill) + scale_fill_identity()
 
  See http://had.co.nz/ggplot2/scale_identity.html and
  http://had.co.nz/ggplot2/position_stack.html for more details.
 
  Hadley
 
 


 --
 View this message in context:
 http://www.nabble.com/Stacked-barchart-color-tf3909162.html#a11149419
 Sent from the R help mailing list archive at Nabble.com.


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

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

-- 
View this message in context: 
http://www.nabble.com/Stacked-barchart-color-tf3909162.html#a11182581
Sent from the R help mailing list archive at Nabble.com.

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


[R] psm/survreg coefficient values ?

2007-06-18 Thread sj
I am using psm to model some parametric survival data, the data is for
length of stay in an emergency department. There are several ways a
patient's stay in the emergency department can end (discharge, admit, etc..)
so I am looking at modeling the effects of several covariates on the various
outcomes. Initially I am trying to fit a  survival model for each type of
outcome using the psm function in the design package,  i.e., all  patients
who's visits  come to an end  due to  any event other than the event of
interest are considered to be censored.  Being new to the psm and  survreg
packages (and to parametric survival modeling) I am not entirely sure how to
interpret the coefficient values that psm returns. I have included the
following code to illustrate code similar to what I am using on my data. I
suppose that the coefficients are somehow rescaled , but I am not sure how
to return them to the original scale and make sense out of the coefficients,
e.g., estimate the the effect of higher acuity on time to event in minutes.
Any explanation or direction on how to interpret the  coefficient values
would be greatly appreciated.

this is from the documentation for survreg.object.
coefficientsthe coefficients of the linear.predictors, which multiply the
columns of the model matrix. It does not include the estimate of error
(sigma). The names of the coefficients are the names of the
single-degree-of-freedom effects (the columns of the model matrix). If the
model is over-determined there will be missing values in the coefficients
corresponding to non-estimable coefficients.

code:
LOS - sort(rweibull(1000,1.4,108))
AGE - sort(rnorm(1000,41,12))
ACUITY - sort(rep(1:5,200))
EVENT -  sample(x=c(0,1),replace=TRUE,1000)
psm(Surv(LOS,EVENT)~AGE+as.factor(ACUITY),dist='weibull')

output:

psm(formula = Surv(LOS, CENS) ~ AGE + as.factor(ACUITY), dist = weibull)

   Obs Events Model L.R.   d.f.  P R2
  10005132387.62  5  0   0.91

  Value  Std. Error  z p
(Intercept) 1.10550.04425  24.98 8.92e-138
AGE 0.07720.00152  50.93  0.00e+00
ACUITY=2 0.09440.01357   6.96  3.39e-12
ACUITY=3 0.17520.02111   8.30  1.03e-16
ACUITY=4 0.13910.02722   5.11  3.18e-07
ACUITY=5-0.05440.03789  -1.43  1.51e-01
Log(scale)-2.72870.03780 -72.18  0.00e+00

Scale= 0.0653

best,

Spencer

[[alternative HTML version deleted]]

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


Re: [R] Unix-like permissions to allow a user to update recommen

2007-06-18 Thread Patrick Connolly
On Mon, 18-Jun-2007 at 11:53AM +0100, Ted Harding wrote:

| On 18-Jun-07 10:11:43, Patrick Connolly wrote:
|  I installed R from the tar.gz file (as root) in a directory under
|  /usr/local.  The recommended packages are installed in a library in
|  that directory whereas additional packages I install in a directory
|  under the /home directory as a user.
|  
|  Updating the additional packages is very easy with update.packages()
|  as a non-root user, but the recommended packages cannot be done so
|  readily because of file permissions.
|  
|  My question is how do I set the permissions or ownerships in the
|  /usr/local/R-2.5.0 directory so that everything necessary can be
|  writable by a user?  Should I make a group for R users (total of one
|  member) or is it simpler than that?
| 
| Since you have root access, do you need to segregate the additional
| packages to a particular user?

It's handy to not have to reload packages that don't change between
versions of the basic installation.

| 
| Though I don't run R as root for general use, I always install/update
| by running R CMD as root. This makes all of R (recommended and also
| any extras) available system-wide, and no pemission problems arise.
| 
| This of course does not stop you from setting up a special .Rprofile
| for each user, since this by definition lives in the user's home
| directory.
| 
| Does this help? Or are there issues you haven't mentioned which make
| such an approach not feasible?

I don't exactly have issues.  It's not a huge problem I'm dealing
with.  It's simple enough for me to use update.packages() as a user
which will download the appropriate packages.  Though they won't be
installed, they are all in the one place in the /tmp/ directory from
where I can install them as root.  I just thought there must be a more
elegant way to set permissions so that users could write to the
subdirectories under /usr/local/R-2.xxx/.  So much of the installation
process of R and its packages is so elegant, I'd like to retain some
of that elegance.

best

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


[R] Second y-axis in xyplot (lattice) where y1 and y2 have different ranges

2007-06-18 Thread Andy Bunn
Hi all,

I realize this is asking a lot of lattice, but I want to add a second y
axis inside a xyplot and have y1 and y2 have different ranges. Given dat
below, I can add a second y axis by overlaying a new plot with
par(new=T) and label axis 4 with standard graphics. I've seen an example
for doing something similar in xyplot even though Deepayan has indicated
that lattice isn't the right tool for the job. 

However, is there a way to gracefully add a second y-axis to a xyplot
where y1 and y2 have different scales as in the example below? I've seen
the experimental tools to focus and modify lattice graphics but do not
know if these are applicable. 

I have unreasonable faith that lattice can do anything. Since my
eventual goal is to make use of a grouping variable as with dat2 below,
lattice will be preferable to complex layouts. Thanks, Andy


  dat - data.frame(Year = 1751:2000,
Stuff = rnorm(250),
Samples = floor(seq(5,30,length.out=250)
+rnorm(250,5)),
Grp = rep('SiteOne',250))
  par(mar=c(5,4,4,4) + 0.1)
  plot(Stuff~Year, data=dat, type='l')
  par(new=T)
  plot(Samples~Year, data=dat, type=l, axes=F, bty=n,
   xlab=, ylab=)
  axis(4, at=pretty(range(dat$Samples)))
  mtext(Number of Samples, 4, 3)

  xyplot(Stuff + Samples ~ Year | Grp, data=dat,
 layout = c(1, 1),
 panel = panel.superpose.2,
 ylab = Stuff,
 legend = list(right =
 list(fun = grid::textGrob(Samples, rot = 90))),
 type = c('l', 'l'))

  dat2 - data.frame(Year = rep(1751:2000,2),
 Stuff = rep(rnorm(250),2),
 Samples = rep(floor(seq(5,30,length.out=250)+
   rnorm(250,5)),2),
 Grp = c(rep('SiteOne',250),
 rep('SiteTwo',250)))

  xyplot(Stuff + Samples ~ Year | Grp, data=dat2,
 panel = panel.superpose.2,
 ylab = Stuff,
 legend = list(right =
 list(fun = grid::textGrob(Samples, rot = 90))),
 type = c('l', 'l'))

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


[R] Help: Upgrading to R2.5 on Ubuntu (Feisty)

2007-06-18 Thread M. Jankowski
Thank you in advance for reading this help request. I am pretty new to
R. I am experiencing some issues getting 2.5 installed on my Ubuntu
Fiesty system and
seek your advice.

To the best of my ability I followed the instructions here:

http://cran.r-project.org/bin/linux/ubuntu/README

Setting this as the last line in my sources.list:
deb http://cran.fhcrc.org/bin/linux/ubuntu feisty/

When I typed in:

[EMAIL PROTECTED]:/usr/local/lib/R/site-library$ sudo apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
r-base is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[EMAIL PROTECTED]:/usr/local/lib/R/site-library$

But when I go to R and check my version:

 version
  _
platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)


My version is still 2.4.1. I must be missing something. What do I need
to do to get R version 2.5 installed on my ubuntu feisty (7.04)
system? Let me know if there is any additional information I need to
give to be helped out with this.

Thank you for taking a look at this,
Sincerely,
Matt

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


Re: [R] source a specific function

2007-06-18 Thread Ted Harding
On 18-Jun-07 18:53:50, Duncan Murdoch wrote:
 
 The exact syntax you list there won't work, but in any case, changing 
 the environment of a function in a package is a bad idea -- it may need
 to reference things from the namespace of the package.

Well, as I said before, (assuming that you know about
interdependencies)!

I tried Gabor's suggested syntax as follows, bearing in mind that
mvrnorm in MASS is pure R code calling only base functions:

library(MASS)
environment(mvrnorm) - .GlobalEnv
mu=c(0,0)
V-matrix(c(1.0,0.5,0.5,1.0),ncol=2)
detach()
ls()
[1] %.+%%+.%mu  mvrnorm V  

mvrnorm(10,mu,V)
 [,1]   [,2]
 [1,] -1.80466069 -1.8229928
 [2,]  0.05565147 -1.6279434
 [3,] -0.28505572 -0.8927696
 [4,] -0.48919795  0.0750501
 [5,] -0.08437832  0.1349296
 [6,]  2.17399713  1.2881640
 [7,]  1.59934824  1.3784665
 [8,]  0.30555420  0.3835743
 [9,]  0.11120527 -0.7287910
[10,] -0.77281783 -1.2265502

so that one seems to have worked.

However, I'm not sure about the space used by MASS going away
after detach():

Starting R from scratch:

Type 'q()' to quit R.

 gc()
 used (Mb) gc trigger (Mb)
Ncells 412589 11.1 597831   16
Vcells 102417  0.8 7864326

 library(MASS)
 gc()
 used (Mb) gc trigger (Mb)
Ncells 459471 12.3 667722 17.9
Vcells 87  0.9 786432  6.0

 environment(mvrnorm) - .GlobalEnv
 detach()
 gc()
 used (Mb) gc trigger (Mb)
Ncells 459297 12.3 741108 19.8
Vcells 05  0.9 786432  6.0
 gc()
 used (Mb) gc trigger (Mb)
Ncells 459304 12.3 818163 21.9
Vcells 18  0.9 786432  6.0

so only about 170KB of the 2.2MB used by MASS has been recovered
after detach(). Or am I looking at the wrong indicator of space used?

On the other hand, if I first extract the code 9f mvrnorm()
which is a few lines of pure R, I get:

1. Start R from scratch:
gc()
 used (Mb) gc trigger (Mb)
Ncells 412589 11.1 597831   16
Vcells 102417  0.8 7864326

2. Paste in the code for mvrnorm, and then:
gc()
 used (Mb) gc trigger (Mb)
Ncells 412844 11.1 667722 17.9
Vcells 102591  0.8 786432  6.0

so mrvnorm on its own is only taking up about

 (412844-412589) + (102591-102417) = 429KB

Hence I wonder whether the space first occupied by MASS (2.2MB)
apart from mvrnorm gets freed up at all?

Thanks for the comments.
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 18-Jun-07   Time: 22:00:33
-- XFMail --

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


Re: [R] Unix-like permissions to allow a user to update recommen

2007-06-18 Thread Ted Harding
On 18-Jun-07 20:27:56, Patrick Connolly wrote:
 On Mon, 18-Jun-2007 at 11:53AM +0100, Ted Harding wrote:
 
| On 18-Jun-07 10:11:43, Patrick Connolly wrote:
|  I installed R from the tar.gz file (as root) in a directory under
|  /usr/local.  The recommended packages are installed in a library in
|  that directory whereas additional packages I install in a directory
|  under the /home directory as a user.
|  
|  Updating the additional packages is very easy with
|  update.packages()
|  as a non-root user, but the recommended packages cannot be done so
|  readily because of file permissions.
|  
|  My question is how do I set the permissions or ownerships in the
|  /usr/local/R-2.5.0 directory so that everything necessary can be
|  writable by a user?  Should I make a group for R users (total of
|  one
|  member) or is it simpler than that?
| 
| Since you have root access, do you need to segregate the additional
| packages to a particular user?
 
 It's handy to not have to reload packages that don't change between
 versions of the basic installation.
 
| 
| Though I don't run R as root for general use, I always install/update
| by running R CMD as root. This makes all of R (recommended and also
| any extras) available system-wide, and no pemission problems arise.
| 
| This of course does not stop you from setting up a special .Rprofile
| for each user, since this by definition lives in the user's home
| directory.
| 
| Does this help? Or are there issues you haven't mentioned which make
| such an approach not feasible?
 
 I don't exactly have issues.  It's not a huge problem I'm dealing
 with.  It's simple enough for me to use update.packages() as a user
 which will download the appropriate packages.  Though they won't be
 installed, they are all in the one place in the /tmp/ directory from
 where I can install them as root.  I just thought there must be a more
 elegant way to set permissions so that users could write to the
 subdirectories under /usr/local/R-2.xxx/.  So much of the installation
 process of R and its packages is so elegant, I'd like to retain some
 of that elegance.

On my Linux, all the places where components of R might normally
be installed (/usr/lib or /usr/local/lib) are user=root, group=root,
and when I look under them practically everything is writeable
only by user=root. So you'd have to change a lot of permissions
before any other user got rights to write to these directories.
Even adding a user to group=root wouldn't change things, since
group does not have write permissions (unless user=root too).

I'm still wondering, though, why you don't just run the command
update.packages() as root. You have root access, and you said
(in the adding user to group context) that only one user is
involved (presumably yourself?). In that case, why not start R
as root and run update.packages()?

Or am I missing something?

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 18-Jun-07   Time: 22:25:18
-- XFMail --

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


Re: [R] psm/survreg coefficient values ?

2007-06-18 Thread Frank E Harrell Jr
sj wrote:
 I am using psm to model some parametric survival data, the data is for
 length of stay in an emergency department. There are several ways a
 patient's stay in the emergency department can end (discharge, admit, etc..)
 so I am looking at modeling the effects of several covariates on the various
 outcomes. Initially I am trying to fit a  survival model for each type of
 outcome using the psm function in the design package,  i.e., all  patients
 who's visits  come to an end  due to  any event other than the event of
 interest are considered to be censored.  Being new to the psm and  survreg
 packages (and to parametric survival modeling) I am not entirely sure how to
 interpret the coefficient values that psm returns. I have included the
 following code to illustrate code similar to what I am using on my data. I
 suppose that the coefficients are somehow rescaled , but I am not sure how
 to return them to the original scale and make sense out of the coefficients,
 e.g., estimate the the effect of higher acuity on time to event in minutes.
 Any explanation or direction on how to interpret the  coefficient values
 would be greatly appreciated.
 
 this is from the documentation for survreg.object.
 coefficientsthe coefficients of the linear.predictors, which multiply the
 columns of the model matrix. It does not include the estimate of error
 (sigma). The names of the coefficients are the names of the
 single-degree-of-freedom effects (the columns of the model matrix). If the
 model is over-determined there will be missing values in the coefficients
 corresponding to non-estimable coefficients.
 
 code:
 LOS - sort(rweibull(1000,1.4,108))
 AGE - sort(rnorm(1000,41,12))
 ACUITY - sort(rep(1:5,200))
 EVENT -  sample(x=c(0,1),replace=TRUE,1000)
 psm(Surv(LOS,EVENT)~AGE+as.factor(ACUITY),dist='weibull')
 
 output:
 
 psm(formula = Surv(LOS, CENS) ~ AGE + as.factor(ACUITY), dist = weibull)
 
Obs Events Model L.R.   d.f.  P R2
   10005132387.62  5  0   0.91
 
   Value  Std. Error  z p
 (Intercept) 1.10550.04425  24.98 8.92e-138
 AGE 0.07720.00152  50.93  0.00e+00
 ACUITY=2 0.09440.01357   6.96  3.39e-12
 ACUITY=3 0.17520.02111   8.30  1.03e-16
 ACUITY=4 0.13910.02722   5.11  3.18e-07
 ACUITY=5-0.05440.03789  -1.43  1.51e-01
 Log(scale)-2.72870.03780 -72.18  0.00e+00
 
 Scale= 0.0653
 
 best,
 
 Spencer

I have a case study using psm (survreg wrapper) in my book.  Briefly, 
coefficients are on the log median survival time scale.

Frank


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


[R] data type for block data?

2007-06-18 Thread H. Paul Benton
Dear All,


I have a matrix with data that is not organised. I would like to go
through this and extract it. Each feature has 2 vectors which express
the data. I also have an index of the places where the data should be cut.
eg.
class(cc)
matrix
cc
  [,1] [,2]
 [1,]1   26
 [2,]2   27
 [3,]3   28
 [4,]4   29
 [5,]5   30
 [6,]6   31
 [7,]7   32
 [8,]8   33
 [9,]9   34
[10,]1   27
[11,]1   28
[12,]2   30
[13,]3   34
ect..
 index
[1] 10 40


Is there a way to take cc[i:index[i-1],] to another format as to where
each block could be worked on separately. ie so in one block would be
rows1:10 the next block would be rows11:40 and so on.

Thanks,

Paul



-- 
Research Technician
Mass Spectrometry
   o The
  /
o Scripps
  \
   o Research
  /
o Institute

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


Re: [R] Second y-axis in xyplot (lattice) where y1 and y2 have different ranges

2007-06-18 Thread Deepayan Sarkar
On 6/18/07, Andy Bunn [EMAIL PROTECTED] wrote:
 Hi all,

 I realize this is asking a lot of lattice, but I want to add a second y
 axis inside a xyplot and have y1 and y2 have different ranges. Given dat
 below, I can add a second y axis by overlaying a new plot with
 par(new=T) and label axis 4 with standard graphics. I've seen an example
 for doing something similar in xyplot even though Deepayan has indicated
 that lattice isn't the right tool for the job.

 However, is there a way to gracefully add a second y-axis to a xyplot
 where y1 and y2 have different scales as in the example below? I've seen
 the experimental tools to focus and modify lattice graphics but do not
 know if these are applicable.

You could use those, but one drawback there is that you don't get the
usual benefit of automatic allocation of space. Here is a ``better''
solution (as long as you realize that this is still a hack):

[Note: this won't work if scales=free or sliced]

[...]

   dat2 - data.frame(Year = rep(1751:2000,2),
  Stuff = rep(rnorm(250),2),
  Samples = rep(floor(seq(5,30,length.out=250)+
rnorm(250,5)),2),
  Grp = c(rep('SiteOne',250),
  rep('SiteTwo',250)))



scale.pars - function(x)
{
c(mx = min(x), dx = diff(range(x)))
}

rescale - function(x, pars = scale.pars(x))
{
(x - pars[mx]) / pars[dx]
}

pars.Stuff - scale.pars(dat2$Stuff)
pars.Samples - scale.pars(dat2$Samples)

rng.Stuff - range(dat2$Stuff)
rng.Samples - range(dat2$Samples)


my.yscale.components - function(lim, ...)
{
## template we will modify
ans - yscale.components.default(lim, ...)
## labels for Stuff in original scale
Stuff - yscale.components.default(rng.Stuff, ...)
Stuff$left$ticks$at -
rescale(Stuff$left$ticks$at, pars.Stuff)
Stuff$left$labels$at -
rescale(Stuff$left$labels$at, pars.Stuff)
## labels for Samples in original scale
Samples - yscale.components.default(rng.Samples, ...)
Samples$left$ticks$at -
rescale(Samples$left$ticks$at, pars.Samples)
Samples$left$labels$at -
rescale(Samples$left$labels$at, pars.Samples)
## modified 'components'
ans$left - Stuff$left
ans$right - Samples$left
ans
}


xyplot(rescale(Stuff, pars.Stuff) +
   rescale(Samples, pars.Samples) ~ Year | Grp,
   data=dat2,
   panel = panel.superpose.2,

   ## newlay added:
   yscale.components = my.yscale.components,
   scales = list(alternating = 3),

   ylab = Stuff,
   legend = list(right =
   list(fun = grid::textGrob(Samples, rot = 90))),
   type = c('l', 'l'))


-Deepayan

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


[R] viewing source code

2007-06-18 Thread Werner Wernersen
Hi,

could somebody give me a quick hint how to view the
source code of a function if sole entering of the
function name does not work?

In particular, I am trying to look at cd_plot from
the vcd package.

Many thanks in advance,
  Werner

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


Re: [R] viewing source code

2007-06-18 Thread Achim Zeileis
Werner:

 could somebody give me a quick hint how to view the
 source code of a function if sole entering of the
 function name does not work?

 In particular, I am trying to look at cd_plot from
 the vcd package.

Strategy 1: Typing cd_plot tells you that it is a generic function
  and methods(cd_plot) shows you which methods exist (default and
  formula) which are both non-visible. You can still directly access
  them via vcd:::cd_plot (which is the main work horse).

Strategy 2 (preferred, especially if you want to take a closer look):
  Obtain the source package from CRAN. Unpack the tar.gz file and
  look into the vcd/R folder where you will find cd_plot.R containing
  the sources of both methods.

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


[R] How to compare GLM and GAM models

2007-06-18 Thread Yuanchang xie
Dear Listers,

I want to compare two negative binomial models fitted using glm.nb and 
gam(mgcv) based on the same data. What would be the most appropriate 
criteria to compare these two models? Can someone point me to some 
references? Thank you very much.

Yuanchang Xie

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


[R] Histogram using frequency data

2007-06-18 Thread suman Duvvuru
Hello,

I wanted to know how to plot a histogram using a vector of frequencies
rather than the data vector as a whole. So I have two vectors:  a vector of
labels V1= c(A,B,C,D) and vector B which is a vector of frequencies
of A, B, C and D respectively  V2=c(20,50,60,30). I wanted to plot a
histogram of the labels using the frequencies. I could not figure out a way
to do this using the 'hist' function which takes only the full data vector
as input. Could you please help me with this?

Thank you,
Suman

[[alternative HTML version deleted]]

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


Re: [R] Help: Upgrading to R2.5 on Ubuntu (Feisty)

2007-06-18 Thread Paulo Tanimoto
Dear Matt,

Did you issue:
$ sudo apt-get update

before running:
$ sudo apt-get install r-base

Now, let me tell you one thing about Linux and particularly
Debian/Ubuntu.  We are spoiled to the point that we love the official
repositories.  Because the official packages go through some testing,
we tend to sacrifice a little bit of cutting edge for
stability/reliability.  If you don't think you need anything specific
from version 2.5.0, I would recommend you to stick with the current
version, 2.4.1.  You'll also have several packages already compiled
for you if you do that.

I hope it helps.

Paulo






On 6/18/07, M. Jankowski [EMAIL PROTECTED] wrote:
 Thank you in advance for reading this help request. I am pretty new to
 R. I am experiencing some issues getting 2.5 installed on my Ubuntu
 Fiesty system and
 seek your advice.

 To the best of my ability I followed the instructions here:

 http://cran.r-project.org/bin/linux/ubuntu/README

 Setting this as the last line in my sources.list:
 deb http://cran.fhcrc.org/bin/linux/ubuntu feisty/

 When I typed in:

 [EMAIL PROTECTED]:/usr/local/lib/R/site-library$ sudo apt-get install r-base
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 r-base is already the newest version.
 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
 [EMAIL PROTECTED]:/usr/local/lib/R/site-library$

 But when I go to R and check my version:

  version
   _
 platform   i486-pc-linux-gnu
 arch   i486
 os linux-gnu
 system i486, linux-gnu
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)
 

 My version is still 2.4.1. I must be missing something. What do I need
 to do to get R version 2.5 installed on my ubuntu feisty (7.04)
 system? Let me know if there is any additional information I need to
 give to be helped out with this.

 Thank you for taking a look at this,
 Sincerely,
 Matt

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


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


Re: [R] Retain names in conversion of matrix to vector

2007-06-18 Thread philozine
Fantastic. All of those methods worked, though I did have to first convert my 
matrices using the data.matrix command. Thank you for the assistance.

Is there any equally simple way to re-convert the resulting table/matrix to its 
original NxN form? I do not see any obvious opposites to the cbind or as.table 
commands.

Also, Jeff Laake, is there a way to have your routine output the vectors as 
numeric values (i.e., without the surrounding quote marks)?

Best regards,


Jeff Laake [EMAIL PROTECTED] wrote:   x=matrix(1:9,nrow=3)
  colnames(x)=c(a,b,c)
  row.names(x)=c(1,2,3)
  x
  a b c
1 1 4 7
2 2 5 8
3 3 6 9
  
cbind(as.vector(x),colnames(x)[as.vector(col(x))],row.names(x)[as.vector(row(x))])
  [,1] [,2] [,3]
 [1,] 1  a  1
 [2,] 2  a  2
 [3,] 3  a  3
 [4,] 4  b  1
 [5,] 5  b  2
 [6,] 6  b  3
 [7,] 7  c  1
 [8,] 8  c  2
 [9,] 9  c  3
 


philozine wrote:
 Hi R-listers,

 I'm using R only for a few basic functions but am having difficulty doing 
 something that *should* be simple. I have an nxn matrix, Q, where Q[i,j] is a 
 directed value (in this case, oil exports from i to j). Note that 
 Q[i,j]~=Q[j,i]. I imported column names along with the matrix then copied 
 them to the rows using rownames(Q) - colnames(Q). Simple so far.

 What I'd like to do now is convert Q for export into a vector of values with 
 the original row and column names intact. Having one vector each for row, 
 column, and cell would be ideal, e.g., [1,1] = i's name, [1,2] = j's name, 
 and [1,3] = Q[i, j]. But just being able to export my matrix data in vector 
 form with the correct row/col names for each observation would be sufficient.

 Thus far I've tried c(), vector(), and a few others, but can't get the 
 correct results. They do generate the correct vector of matrix values, but 
 they do not appear to retain both row and column names. (Or, rather, I have 
 not discovered how to make them do so.)

 To illustrate, my data currently look something like this:

 ABCD
 A | 0  |.1 |.4  |.6  |
 B |.2 | 0  |.2  |.1  |
 C |.5  |.9  | 0  |.9  |
 D |.7  | 0  |.3  | 0  |

 I would like them to look like this (at least when exported as a .txt file, 
 if not necessary when displayed within R):

   i   j   Q
 | A | A | 0 |
 | A | B |.1 |
 | A | C |.4 |
 | A | D |.6 |
 | B | A |.2 |
 | B | B | 0 |
 | B | C |.2 |
 [...] and so on

 If anybody knows how to do this, I will be extremely appreciative!

 Best regards,



 -

  [[alternative HTML version deleted]]

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


 
-
The fish are biting.

[[alternative HTML version deleted]]

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


[R] String manipulation, insert delim

2007-06-18 Thread Christopher Marcum
Hello All,

I've been using R for two years now and I am happy to say this is the
first time I could not find the answer to my problem in the R-help
archives. Here is the pending problem:

I want to be able to insert delimiters, say commas, into a string of
characters at uneven intervals such that:

foo-c(haveaniceday)#my string of character
bar-c(4,1,4,3) # my vector of uneven intervals

my.fun(foo,bar) # some function that places delimiters appropriately

have,a,nice,day # what the function would ideally return

I've tried multiple for-loops using cut and paste but have not had success.

Thanks!
Chris Marcum
UCI Sociology

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


Re: [R] Histogram using frequency data

2007-06-18 Thread Marc Schwartz
On Mon, 2007-06-18 at 19:40 -0400, suman Duvvuru wrote:
 Hello,
 
 I wanted to know how to plot a histogram using a vector of frequencies
 rather than the data vector as a whole. So I have two vectors:  a vector of
 labels V1= c(A,B,C,D) and vector B which is a vector of frequencies
 of A, B, C and D respectively  V2=c(20,50,60,30). I wanted to plot a
 histogram of the labels using the frequencies. I could not figure out a way
 to do this using the 'hist' function which takes only the full data vector
 as input. Could you please help me with this?
 
 Thank you,
 Suman

See ?barplot

To wit:

V1 - c(A, B, C, D) 
V2 - c(20, 50, 60, 30)

# Do the barplot, saving the bar midpoints in 'mp'
mp - barplot(V2, names.arg = V1, ylim = c(0, 80))

# Now add the bar values above the bars
text(mp, V2, V2, pos = 3)


See ?text and ?mtext for adding annotation

HTH,

Marc Schwartz

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


[R] classical plant hybrid analysis

2007-06-18 Thread Cam Beeck
Hi,

I am looking to perform some classical hybrid analysis on hybrid plants
including GCA and SCA components through R.  I was wondering if anybody knew
of existing packages that can perform these analyses (I cannot find any) or
any examples of these analyses being worked through.

Cameron Beeck

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


[R] genetics package not working

2007-06-18 Thread Farrel Buchinsky
Has something changed in R that requires an update in the genetics package
by Gregory Warnes? I am using R version 2.5.0
This used to work
 summary(founders[,59])

to prove that it is  a genotype class
 class(founders[,59])
[1] genotype factor

Now when I issue the command:
 summary(founders[,59])

I get:

Error in attr(retval, which) - which : attempt to set an attribute on
NULL
In addition: Warning message:
$ operator is deprecated for atomic vectors, returning NULL in:
x$allele.names

Clearly, I am missing something. What am I missing?

-- 
Farrel Buchinsky

[[alternative HTML version deleted]]

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


Re: [R] String manipulation, insert delim

2007-06-18 Thread jim holtman
This should work for you.

 foo-c(haveaniceday)#my string of character
 bar-c(4,1,4,3) # my vector of uneven intervals
 my.function - function(foo, bar){
+ # construct a matrix with start/end character positions
+ start - head(cumsum(c(1, bar)), -1) # delete last one
+ sel - cbind(start=start,
+  end=start + bar -1)
+ strings - apply(sel, 1, function(x) substr(foo, x[1], x[2]))
+ paste(strings, collapse=',')
+ }

 my.function(foo, bar)
[1] have,a,nice,day





On 6/18/07, Christopher Marcum [EMAIL PROTECTED] wrote:

 Hello All,

 I've been using R for two years now and I am happy to say this is the
 first time I could not find the answer to my problem in the R-help
 archives. Here is the pending problem:

 I want to be able to insert delimiters, say commas, into a string of
 characters at uneven intervals such that:

 foo-c(haveaniceday)#my string of character
 bar-c(4,1,4,3) # my vector of uneven intervals

 my.fun(foo,bar) # some function that places delimiters appropriately

 have,a,nice,day # what the function would ideally return

 I've tried multiple for-loops using cut and paste but have not had
 success.

 Thanks!
 Chris Marcum
 UCI Sociology

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




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

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] String manipulation, insert delim

2007-06-18 Thread Gabor Grothendieck
Try this:

 paste(read.fwf(textConnection(foo), bar, as.is = TRUE), collapse = ,)
[1] have,a,nice,day


On 6/18/07, Christopher Marcum [EMAIL PROTECTED] wrote:
 Hello All,

 I've been using R for two years now and I am happy to say this is the
 first time I could not find the answer to my problem in the R-help
 archives. Here is the pending problem:

 I want to be able to insert delimiters, say commas, into a string of
 characters at uneven intervals such that:

 foo-c(haveaniceday)#my string of character
 bar-c(4,1,4,3) # my vector of uneven intervals

 my.fun(foo,bar) # some function that places delimiters appropriately

 have,a,nice,day # what the function would ideally return

 I've tried multiple for-loops using cut and paste but have not had success.

 Thanks!
 Chris Marcum
 UCI Sociology

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


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


Re: [R] String manipulation, insert delim

2007-06-18 Thread Marc Schwartz
On Mon, 2007-06-18 at 16:54 -0700, Christopher Marcum wrote:
 Hello All,
 
 I've been using R for two years now and I am happy to say this is the
 first time I could not find the answer to my problem in the R-help
 archives. Here is the pending problem:
 
 I want to be able to insert delimiters, say commas, into a string of
 characters at uneven intervals such that:
 
 foo-c(haveaniceday)#my string of character
 bar-c(4,1,4,3) # my vector of uneven intervals
 
 my.fun(foo,bar) # some function that places delimiters appropriately
 
 have,a,nice,day # what the function would ideally return
 
 I've tried multiple for-loops using cut and paste but have not had success.
 
 Thanks!
 Chris Marcum
 UCI Sociology

One more variation on the replies already provided:

foo - c(haveaniceday)
bar - c(4, 1, 4, 3)

insert.char - function(x, at, char = ,)
{
   cs.at - cumsum(at)
   vec - unlist(strsplit(x, ))
   for (i in seq(length(cs.at) - 1))
 vec - append(vec, char, cs.at[i] + i - 1)
   paste(vec, collapse = )
}


 insert.char(foo, bar)
[1] have,a,nice,day

See ?append

HTH,

Marc Schwartz

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


[R] Histograms with strings, grouped by repeat count (w/ data)

2007-06-18 Thread Matthew Trunnell
Hello R gurus,

I just spent my first weekend wrestling with R, but so far have come
up empty handed.

I have a dataset that represents file downloads; it has 4 dimensions:
date, filename, email, and country.  (sample data below)

My first goal is to get an idea of the frequency of repeated
downloads.  Let me explain that.  Some people tend to download
multiple times, e.g. if the download fails they keep trying over and
over.  I'm trying to build a histogram that shows the repeat count
along the x-axis, that is, how many people downloaded once, twice,
three times, etc.  I plan to compare the median of that before and
after we switched ISPs.

To accomplish this, I'm assuming that I'll first need to combine the
email and filename columns so as to represent a single download
attempt by an individual.  Does that sound right?  Later, it would be
nice to limit the histogram to a single filename, country, or company.
 I can probably figure that out myself after I understand how to write
this funky histogram expression.

With the help of Verzani's introductory text, I've learned how to read
in the CSV data and do some simple tables, like this:

hist(table(d$filename))
hist(table(d$filename[substring(d$filename, 1, 5)==file1]))
hist(sort(table(d$filename[substring(d$filename, 1, 5)==file1])))

Obviously, these commands count the frequency of the files.  What I'd
like to see are the repeats grouped along the x-axis;  I'd like to
find, for all files, the distribution of retries.  I hope that makes
sense. :)

Can someone point me in the right direction?  I'm very new to R and to
statistics, but I write code for a living.  At this point I'd almost
be better off writing a program do this kind of simple counting... but
I have a feeling R would be so useful if I could just get past the
initial learning curve.

Thank you in advance,
Matt

Here's some real data, with the private info replaced :)

 
d-read.table(file=C:\\users\\trunnellm\\downloads\\statistics\\downloads.csv,
sep=,, quote=\, header=TRUE)

filename,last_modified,email_addr,country_residence
file1,3/4/2006 13:54,email1,Korea (South)
file2,3/4/2006 14:33,email2,United States
file2,3/4/2006 16:03,email2,United States
file2,3/4/2006 16:17,email3,United States
file2,3/4/2006 16:28,email3,United States
file3,3/4/2006 19:13,email4,United States
file2,3/4/2006 21:22,email5,India
file4,3/4/2006 21:46,email6,United States
file1,3/4/2006 22:04,email7,Japan
file2,3/4/2006 22:09,email8,Croatia
file1,3/4/2006 22:22,email7,Japan
file1,3/4/2006 22:29,email9,India
file1,3/4/2006 23:06,email6,United States
file1,3/4/2006 23:33,email6,United States
file5,3/4/2006 23:44,email10,China
file1,3/5/2006 0:13,email9,India
file2,3/5/2006 0:52,email8,Croatia
file2,3/5/2006 0:54,email8,Croatia
file2,3/5/2006 1:10,email5,India
file6,3/5/2006 2:17,email9,India
file2,3/5/2006 2:24,email11,Italy
file7,3/5/2006 2:36,email12,Italy
file8,3/5/2006 2:52,email12,Italy
file2,3/5/2006 3:09,email13,United Kingdom
file2,3/5/2006 4:02,email14,India
file2,3/5/2006 4:07,email14,India
file2,3/5/2006 4:14,email14,India
file2,3/5/2006 4:37,email5,India
file2,3/5/2006 4:44,email15,Belgium
file1,3/5/2006 5:02,email9,India
file1,3/5/2006 5:24,email16,Taiwan
file2,3/5/2006 6:06,email17,Saudi Arabia
file2,3/5/2006 7:32,email17,Saudi Arabia
file2,3/5/2006 8:12,email18,Brazil
file2,3/5/2006 8:26,email18,Brazil
file2,3/5/2006 9:49,email19,United Kingdom
file1,3/5/2006 10:49,email11,Italy
file1,3/5/2006 11:16,email13,United Kingdom
file1,3/5/2006 11:16,email13,United Kingdom
file1,3/5/2006 11:45,email13,United Kingdom
file1,3/5/2006 14:34,email20,Australia
file9,3/5/2006 14:56,email20,Australia
file9,3/5/2006 14:56,email20,Australia
file5,3/5/2006 16:43,email21,United States
file1,3/5/2006 17:17,email7,Japan
file2,3/5/2006 17:26,email22,Japan
file2,3/5/2006 17:27,email22,Japan
file2,3/5/2006 17:33,email23,China
file1,3/5/2006 17:45,email22,Japan
file2,3/5/2006 17:45,email22,Japan
file2,3/5/2006 17:59,email23,China
file1,3/5/2006 18:27,email24,Japan
file1,3/5/2006 18:47,email25,Taiwan
file2,3/5/2006 18:48,email26,New Zealand
file2,3/5/2006 19:15,email27,Canada
file2,3/5/2006 19:23,email28,Canada
file2,3/5/2006 19:24,email28,Canada
file10,3/5/2006 19:49,email29,Japan
file10,3/5/2006 19:52,email29,Japan
file10,3/5/2006 19:57,email29,Japan
file2,3/5/2006 20:01,email29,Japan
file2,3/5/2006 20:02,email29,Japan
file2,3/5/2006 20:06,email29,Japan

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


[R] categorical time series

2007-06-18 Thread Jaydip Mukhopadhyay
Hello,
  Can anyone tell me how to simulate multinomial time series in R?
  Thanks,
  Jaydip


Jaydip Mukhopadhyay
Graduate Student
Dept of Statistics
University Of Connecticut
   
-

[[alternative HTML version deleted]]

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


Re: [R] Histograms with strings, grouped by repeat count (w/ data)

2007-06-18 Thread jim holtman
You should be using barplot and not hist.  I think this produces what you
want:

x - filename,last_modified,email_addr,country_residence
file1,3/4/2006 13:54,email1,Korea (South)
file2,3/4/2006 14:33,email2,United States
file2,3/4/2006 16:03,email2,United States
file2,3/4/2006 16:17,email3,United States
file2,3/4/2006 16:28,email3,United States
file3,3/4/2006 19:13,email4,United States
file2,3/4/2006 21:22,email5,India
file4,3/4/2006 21:46,email6,United States
file1,3/4/2006 22:04,email7,Japan
file2,3/4/2006 22:09,email8,Croatia
file1,3/4/2006 22:22,email7,Japan
file1,3/4/2006 22:29,email9,India
file1,3/4/2006 23:06,email6,United States
file1,3/4/2006 23:33,email6,United States
file5,3/4/2006 23:44,email10,China
file1,3/5/2006 0:13,email9,India
file2,3/5/2006 0:52,email8,Croatia
file2,3/5/2006 0:54,email8,Croatia
file2,3/5/2006 1:10,email5,India
file6,3/5/2006 2:17,email9,India
file2,3/5/2006 2:24,email11,Italy
file7,3/5/2006 2:36,email12,Italy
file8,3/5/2006 2:52,email12,Italy
file2,3/5/2006 3:09,email13,United Kingdom
file2,3/5/2006 4:02,email14,India
file2,3/5/2006 4:07,email14,India
file2,3/5/2006 4:14,email14,India
file2,3/5/2006 4:37,email5,India
file2,3/5/2006 4:44,email15,Belgium
file1,3/5/2006 5:02,email9,India
file1,3/5/2006 5:24,email16,Taiwan
file2,3/5/2006 6:06,email17,Saudi Arabia
file2,3/5/2006 7:32,email17,Saudi Arabia
file2,3/5/2006 8:12,email18,Brazil
file2,3/5/2006 8:26,email18,Brazil
file2,3/5/2006 9:49,email19,United Kingdom
file1,3/5/2006 10:49,email11,Italy
file1,3/5/2006 11:16,email13,United Kingdom
file1,3/5/2006 11:16,email13,United Kingdom
file1,3/5/2006 11:45,email13,United Kingdom
file1,3/5/2006 14:34,email20,Australia
file9,3/5/2006 14:56,email20,Australia
file9,3/5/2006 14:56,email20,Australia
file5,3/5/2006 16:43,email21,United States
file1,3/5/2006 17:17,email7,Japan
file2,3/5/2006 17:26,email22,Japan
file2,3/5/2006 17:27,email22,Japan
file2,3/5/2006 17:33,email23,China
file1,3/5/2006 17:45,email22,Japan
file2,3/5/2006 17:45,email22,Japan
file2,3/5/2006 17:59,email23,China
file1,3/5/2006 18:27,email24,Japan
file1,3/5/2006 18:47,email25,Taiwan
file2,3/5/2006 18:48,email26,New Zealand
file2,3/5/2006 19:15,email27,Canada
file2,3/5/2006 19:23,email28,Canada
file2,3/5/2006 19:24,email28,Canada
file10,3/5/2006 19:49,email29,Japan
file10,3/5/2006 19:52,email29,Japan
file10,3/5/2006 19:57,email29,Japan
file2,3/5/2006 20:01,email29,Japan
file2,3/5/2006 20:02,email29,Japan
file2,3/5/2006 20:06,email29,Japan
d - read.csv(textConnection(x))
barplot(table(d$filename), main=All Files, las=2)  # plot counts for all
the files
# generate plots for each file name showing which emails used them
counts - table(d$filename, d$email_addr)
for (i in seq(nrow(counts))){
.index - which(counts[i,]  0)
barplot(counts[i, .index], las=2,
names.arg=colnames(counts)[.index], main=rownames(counts)[i])
}



On 6/18/07, Matthew Trunnell [EMAIL PROTECTED] wrote:

 Hello R gurus,

 I just spent my first weekend wrestling with R, but so far have come
 up empty handed.

 I have a dataset that represents file downloads; it has 4 dimensions:
 date, filename, email, and country.  (sample data below)

 My first goal is to get an idea of the frequency of repeated
 downloads.  Let me explain that.  Some people tend to download
 multiple times, e.g. if the download fails they keep trying over and
 over.  I'm trying to build a histogram that shows the repeat count
 along the x-axis, that is, how many people downloaded once, twice,
 three times, etc.  I plan to compare the median of that before and
 after we switched ISPs.

 To accomplish this, I'm assuming that I'll first need to combine the
 email and filename columns so as to represent a single download
 attempt by an individual.  Does that sound right?  Later, it would be
 nice to limit the histogram to a single filename, country, or company.
 I can probably figure that out myself after I understand how to write
 this funky histogram expression.

 With the help of Verzani's introductory text, I've learned how to read
 in the CSV data and do some simple tables, like this:

 hist(table(d$filename))
 hist(table(d$filename[substring(d$filename, 1, 5)==file1]))
 hist(sort(table(d$filename[substring(d$filename, 1, 5)==file1])))

 Obviously, these commands count the frequency of the files.  What I'd
 like to see are the repeats grouped along the x-axis;  I'd like to
 find, for all files, the distribution of retries.  I hope that makes
 sense. :)

 Can someone point me in the right direction?  I'm very new to R and to
 statistics, but I write code for a living.  At this point I'd almost
 be better off writing a program do this kind of simple counting... but
 I have a feeling R would be so useful if I could just get past the
 initial learning curve.

 Thank you in advance,
 Matt

 Here's some real data, with the private info replaced :)

 d-read.table
 (file=C:\\users\\trunnellm\\downloads\\statistics\\downloads.csv,
 sep=,, quote=\, header=TRUE)

 

Re: [R] data type for block data?

2007-06-18 Thread jim holtman
This will create a list of the matrix subsets:

# create a matrix
x - cbind(1:40, runif(40))
index - c(10,15,33,40)  # cut points
# create a matrix with start and end points
slices - cbind(start=head(c(1,index + 1), -1), end=index)
# create a list with the matrices
matrix.subset - lapply(seq(nrow(slices)), function(.row){
x[slices[.row, 1]:slices[.row, 2], ]
})
matrix.subset


On 6/18/07, H. Paul Benton [EMAIL PROTECTED] wrote:

 Dear All,


I have a matrix with data that is not organised. I would like to go
 through this and extract it. Each feature has 2 vectors which express
 the data. I also have an index of the places where the data should be cut.
 eg.
 class(cc)
 matrix
 cc
  [,1] [,2]
 [1,]1   26
 [2,]2   27
 [3,]3   28
 [4,]4   29
 [5,]5   30
 [6,]6   31
 [7,]7   32
 [8,]8   33
 [9,]9   34
 [10,]1   27
 [11,]1   28
 [12,]2   30
 [13,]3   34
 ect..
  index
 [1] 10 40


 Is there a way to take cc[i:index[i-1],] to another format as to where
 each block could be worked on separately. ie so in one block would be
 rows1:10 the next block would be rows11:40 and so on.

 Thanks,

 Paul



 --
 Research Technician
 Mass Spectrometry
   o The
 /
 o Scripps
 \
   o Research
 /
 o Institute

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




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

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] Histograms with strings, grouped by repeat count (w/ data)

2007-06-18 Thread Matthew Trunnell
Jim,
Thanks for the quick reply!  When I run your code, I end up with a
single barplot of one datapoint, file9 vs email20 == 2.0.  I see the
call to barplot is inside a for loop... maybe it's zooming through the
display of many barplots, but all I see is the last one?

In any case, I need to figure out the distribution of the retries, such as
No. Retries   Count
1 6
2 13
3 5
4 3
5 2
6 1

That is, 6 people retried the download once; 13 people retried the
download twice, etc.  So it would be counting the frequency of the
email-filename combination, and grouping those together by the number
of retries.  Does that make sense?

When I look at the counts object from your code, I can see that it's
close to what I need.  How do I access the properties of the counts
object-- it's a table, right?  If I look at counts[1,1], that returns
1.  But how do I get at the row/col name of that cell?  Is that cell
an object?  rownames(counts[1,1]) returns null.

Thanks,
Matt


On 6/18/07, jim holtman [EMAIL PROTECTED] wrote:
 You should be using barplot and not hist.  I think this produces what you
 want:

 x - filename,last_modified,email_addr,country_residence

 file1,3/4/2006 13:54,email1,Korea (South)
 file2,3/4/2006 14:33,email2,United States
 file2,3/4/2006 16:03,email2,United States
 file2,3/4/2006 16:17,email3,United States
 file2,3/4/2006 16:28,email3,United States
 file3,3/4/2006 19:13,email4,United States
 file2,3/4/2006 21:22,email5,India
 file4,3/4/2006 21:46,email6,United States
 file1,3/4/2006 22:04,email7,Japan
 file2,3/4/2006 22:09,email8,Croatia
 file1,3/4/2006 22:22,email7,Japan
 file1,3/4/2006 22:29,email9,India
 file1,3/4/2006 23:06,email6,United States
 file1,3/4/2006 23:33,email6,United States
 file5,3/4/2006 23:44,email10,China
 file1,3/5/2006 0:13,email9,India
 file2,3/5/2006 0:52,email8,Croatia
 file2,3/5/2006 0:54,email8,Croatia
 file2,3/5/2006 1:10,email5,India
 file6,3/5/2006 2:17,email9,India
 file2,3/5/2006 2:24,email11,Italy
 file7,3/5/2006 2:36,email12,Italy
 file8,3/5/2006 2:52,email12,Italy
 file2,3/5/2006 3:09,email13,United Kingdom
 file2,3/5/2006 4:02,email14,India
 file2,3/5/2006 4:07,email14,India
 file2,3/5/2006 4:14,email14,India
 file2,3/5/2006 4:37,email5,India
 file2,3/5/2006 4:44,email15,Belgium
 file1,3/5/2006 5:02,email9,India
 file1,3/5/2006 5:24,email16,Taiwan
 file2,3/5/2006 6:06,email17,Saudi Arabia
 file2,3/5/2006 7:32,email17,Saudi Arabia
 file2,3/5/2006 8:12,email18,Brazil
 file2,3/5/2006 8:26,email18,Brazil
 file2,3/5/2006 9:49,email19,United Kingdom
 file1,3/5/2006 10:49,email11,Italy
 file1,3/5/2006 11:16,email13,United Kingdom
 file1,3/5/2006 11:16,email13,United Kingdom
 file1,3/5/2006 11:45,email13,United Kingdom
 file1,3/5/2006 14:34,email20,Australia
 file9,3/5/2006 14:56,email20,Australia
 file9,3/5/2006 14:56,email20,Australia
 file5,3/5/2006 16:43,email21,United States
 file1,3/5/2006 17:17,email7,Japan
 file2,3/5/2006 17:26,email22,Japan
 file2,3/5/2006 17:27,email22,Japan
 file2,3/5/2006 17:33,email23,China
 file1,3/5/2006 17:45,email22,Japan
 file2,3/5/2006 17:45,email22,Japan
 file2,3/5/2006 17:59,email23,China
 file1,3/5/2006 18:27,email24,Japan
 file1,3/5/2006 18:47,email25,Taiwan
 file2,3/5/2006 18:48,email26,New Zealand
 file2,3/5/2006 19:15,email27,Canada
 file2,3/5/2006 19:23,email28,Canada
 file2,3/5/2006 19:24,email28,Canada
 file10,3/5/2006 19:49,email29,Japan
 file10,3/5/2006 19:52,email29,Japan
 file10,3/5/2006 19:57,email29,Japan
 file2,3/5/2006 20:01,email29,Japan
 file2,3/5/2006 20:02,email29,Japan
 file2,3/5/2006 20:06,email29,Japan
 d - read.csv(textConnection(x))
 barplot(table(d$filename), main=All Files, las=2)  # plot counts for all
 the files
 # generate plots for each file name showing which emails used them
 counts - table(d$filename, d$email_addr)
 for (i in seq(nrow(counts))){
 .index - which(counts[i,]  0)
 barplot(counts[i, .index], las=2,
 names.arg=colnames(counts)[.index], main=rownames(counts)[i])
 }



 On 6/18/07, Matthew Trunnell [EMAIL PROTECTED] wrote:
 
  Hello R gurus,
 
  I just spent my first weekend wrestling with R, but so far have come
  up empty handed.
 
  I have a dataset that represents file downloads; it has 4 dimensions:
  date, filename, email, and country.  (sample data below)
 
  My first goal is to get an idea of the frequency of repeated
  downloads.  Let me explain that.  Some people tend to download
  multiple times, e.g. if the download fails they keep trying over and
  over.  I'm trying to build a histogram that shows the repeat count
  along the x-axis, that is, how many people downloaded once, twice,
  three times, etc.  I plan to compare the median of that before and
  after we switched ISPs.
 
  To accomplish this, I'm assuming that I'll first need to combine the
  email and filename columns so as to represent a single download
  attempt by an individual.  Does that sound right?  Later, 

Re: [R] Histograms with strings, grouped by repeat count (w/ data)

2007-06-18 Thread jim holtman
If you are running on windows, make sure you have 'recording' checked in the
history window of the graphics.  You can also put the output to a pdf file
and view it later.

If you use table on the counts matrix:

 table(counts)
counts
  0   1   2   3
253  20   8   9


this shows that there were 20 single tries, 8 files downloaded twice and 9
three times.  Is this what you want?

You can also get the indices of the non-zero entries by:

 which(counts != 0, arr.ind=TRUE)
   row col
file11   1
file56   2
file11   3
file23   3
file78   4
file89   4
file11   5
file23   5
file23   6
.



On 6/18/07, Matthew Trunnell [EMAIL PROTECTED] wrote:

 Jim,
 Thanks for the quick reply!  When I run your code, I end up with a
 single barplot of one datapoint, file9 vs email20 == 2.0.  I see the
 call to barplot is inside a for loop... maybe it's zooming through the
 display of many barplots, but all I see is the last one?

 In any case, I need to figure out the distribution of the retries, such as
 No. Retries   Count
 1 6
 2 13
 3 5
 4 3
 5 2
 6 1

 That is, 6 people retried the download once; 13 people retried the
 download twice, etc.  So it would be counting the frequency of the
 email-filename combination, and grouping those together by the number
 of retries.  Does that make sense?

 When I look at the counts object from your code, I can see that it's
 close to what I need.  How do I access the properties of the counts
 object-- it's a table, right?  If I look at counts[1,1], that returns
 1.  But how do I get at the row/col name of that cell?  Is that cell
 an object?  rownames(counts[1,1]) returns null.

 Thanks,
 Matt


 On 6/18/07, jim holtman [EMAIL PROTECTED] wrote:
  You should be using barplot and not hist.  I think this produces what
 you
  want:
 
  x - filename,last_modified,email_addr,country_residence
 
  file1,3/4/2006 13:54,email1,Korea (South)
  file2,3/4/2006 14:33,email2,United States
  file2,3/4/2006 16:03,email2,United States
  file2,3/4/2006 16:17,email3,United States
  file2,3/4/2006 16:28,email3,United States
  file3,3/4/2006 19:13,email4,United States
  file2,3/4/2006 21:22,email5,India
  file4,3/4/2006 21:46,email6,United States
  file1,3/4/2006 22:04,email7,Japan
  file2,3/4/2006 22:09,email8,Croatia
  file1,3/4/2006 22:22,email7,Japan
  file1,3/4/2006 22:29,email9,India
  file1,3/4/2006 23:06,email6,United States
  file1,3/4/2006 23:33,email6,United States
  file5,3/4/2006 23:44,email10,China
  file1,3/5/2006 0:13,email9,India
  file2,3/5/2006 0:52,email8,Croatia
  file2,3/5/2006 0:54,email8,Croatia
  file2,3/5/2006 1:10,email5,India
  file6,3/5/2006 2:17,email9,India
  file2,3/5/2006 2:24,email11,Italy
  file7,3/5/2006 2:36,email12,Italy
  file8,3/5/2006 2:52,email12,Italy
  file2,3/5/2006 3:09,email13,United Kingdom
  file2,3/5/2006 4:02,email14,India
  file2,3/5/2006 4:07,email14,India
  file2,3/5/2006 4:14,email14,India
  file2,3/5/2006 4:37,email5,India
  file2,3/5/2006 4:44,email15,Belgium
  file1,3/5/2006 5:02,email9,India
  file1,3/5/2006 5:24,email16,Taiwan
  file2,3/5/2006 6:06,email17,Saudi Arabia
  file2,3/5/2006 7:32,email17,Saudi Arabia
  file2,3/5/2006 8:12,email18,Brazil
  file2,3/5/2006 8:26,email18,Brazil
  file2,3/5/2006 9:49,email19,United Kingdom
  file1,3/5/2006 10:49,email11,Italy
  file1,3/5/2006 11:16,email13,United Kingdom
  file1,3/5/2006 11:16,email13,United Kingdom
  file1,3/5/2006 11:45,email13,United Kingdom
  file1,3/5/2006 14:34,email20,Australia
  file9,3/5/2006 14:56,email20,Australia
  file9,3/5/2006 14:56,email20,Australia
  file5,3/5/2006 16:43,email21,United States
  file1,3/5/2006 17:17,email7,Japan
  file2,3/5/2006 17:26,email22,Japan
  file2,3/5/2006 17:27,email22,Japan
  file2,3/5/2006 17:33,email23,China
  file1,3/5/2006 17:45,email22,Japan
  file2,3/5/2006 17:45,email22,Japan
  file2,3/5/2006 17:59,email23,China
  file1,3/5/2006 18:27,email24,Japan
  file1,3/5/2006 18:47,email25,Taiwan
  file2,3/5/2006 18:48,email26,New Zealand
  file2,3/5/2006 19:15,email27,Canada
  file2,3/5/2006 19:23,email28,Canada
  file2,3/5/2006 19:24,email28,Canada
  file10,3/5/2006 19:49,email29,Japan
  file10,3/5/2006 19:52,email29,Japan
  file10,3/5/2006 19:57,email29,Japan
  file2,3/5/2006 20:01,email29,Japan
  file2,3/5/2006 20:02,email29,Japan
  file2,3/5/2006 20:06,email29,Japan
  d - read.csv(textConnection(x))
  barplot(table(d$filename), main=All Files, las=2)  # plot counts for
 all
  the files
  # generate plots for each file name showing which emails used them
  counts - table(d$filename, d$email_addr)
  for (i in seq(nrow(counts))){
  .index - which(counts[i,]  0)
  barplot(counts[i, .index], las=2,
  names.arg=colnames(counts)[.index], main=rownames(counts)[i])
  }
 
 
 
  On 6/18/07, Matthew Trunnell [EMAIL PROTECTED] wrote:
  
   Hello R gurus,
  
   I just spent my first weekend wrestling with R, 

[R] Fwd: Help: Upgrading to R2.5 on Ubuntu (Feisty)

2007-06-18 Thread M. Jankowski
This fixed my problem: Thanks!

Did you run 'sudo apt-get update' as well so that it actually reads
the listing at CRAN / FHCRC ?

What does 'apt-cache policy r-base' show?  [ It should display the
different vertsions it knows about; if you only see 2.4.1 then you
have a problem which may just be the missing 'apt-get update' ]

Hth, Dirk

-- Forwarded message --
From: M. Jankowski
Date: Jun 18, 2007 3:34 PM
Subject: Help: Upgrading to R2.5 on Ubuntu (Feisty)
To: r-help@stat.math.ethz.ch


Thank you in advance for reading this help request. I am pretty new to
R. I am experiencing some issues getting 2.5 installed on my Ubuntu
Fiesty system and
seek your advice.

To the best of my ability I followed the instructions here:

http://cran.r-project.org/bin/linux/ubuntu/README

Setting this as the last line in my sources.list:
deb http://cran.fhcrc.org/bin/linux/ubuntu feisty/

When I typed in:

[EMAIL PROTECTED]:/usr/local/lib/R/site-library$ sudo apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
r-base is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[EMAIL PROTECTED]:/usr/local/lib/R/site-library$

But when I go to R and check my version:

 version
  _
platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)


My version is still 2.4.1. I must be missing something. What do I need
to do to get R version 2.5 installed on my ubuntu feisty (7.04)
system? Let me know if there is any additional information I need to
give to be helped out with this.

Thank you for taking a look at this,
Sincerely,
Matt

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


Re: [R] Histograms with strings, grouped by repeat count (w/ data)

2007-06-18 Thread Matthew Trunnell
Aha!  So to expand that from the original expression,

 table(table(d$filename, d$email_addr))

  0   1   2   3
253  20   8   9

I think that is exactly what I'm looking for.  I knew it must be
simple!!!  What does the 0 column represent?

Also, does this tell me the same thing, filtered by Japan?
 table(table(d$filename, d$email_addr, 
 d$country_residence)[d$country_residence==Japan])

  0   1   2   3
958   5   2   1

How does that differ logically from this?

 table(table(d$filename, d$email_addr)[d$country_residence==Japan])

 0  1  2  3
51  4  2  1

I don't understand why that produces different results.  The first one
adds a third dimension to the table, but limits that third dimension
to a single element, Japan.  Shouldn't it be the same?  And again,
what's that zero column?

Thank you,
Matt


On 6/18/07, jim holtman [EMAIL PROTECTED] wrote:
 If you are running on windows, make sure you have 'recording' checked in the
 history window of the graphics.  You can also put the output to a pdf file
 and view it later.

 If you use table on the counts matrix:

  table(counts)
 counts
   0   1   2   3
 253  20   8   9
 

 this shows that there were 20 single tries, 8 files downloaded twice and 9
 three times.  Is this what you want?

 You can also get the indices of the non-zero entries by:

  which(counts != 0, arr.ind=TRUE)
row col
 file11   1
 file56   2
 file11   3
 file23   3
 file78   4
 file89   4
 file11   5
 file23   5
 file23   6
 .




 On 6/18/07, Matthew Trunnell [EMAIL PROTECTED] wrote:
  Jim,
  Thanks for the quick reply!  When I run your code, I end up with a
  single barplot of one datapoint, file9 vs email20 == 2.0.  I see the
  call to barplot is inside a for loop... maybe it's zooming through the
  display of many barplots, but all I see is the last one?
 
  In any case, I need to figure out the distribution of the retries, such as
  No. Retries   Count
  1 6
  2 13
  3 5
  4 3
  5 2
  6 1
 
  That is, 6 people retried the download once; 13 people retried the
  download twice, etc.  So it would be counting the frequency of the
  email-filename combination, and grouping those together by the number
  of retries.  Does that make sense?
 
  When I look at the counts object from your code, I can see that it's
  close to what I need.  How do I access the properties of the counts
  object-- it's a table, right?  If I look at counts[1,1], that returns
  1.  But how do I get at the row/col name of that cell?  Is that cell
  an object?  rownames(counts[1,1]) returns null.
 
  Thanks,
  Matt
 
 
  On 6/18/07, jim holtman [EMAIL PROTECTED] wrote:
   You should be using barplot and not hist.  I think this produces what
 you
   want:
  
   x -
 filename,last_modified,email_addr,country_residence
  
   file1,3/4/2006 13:54,email1,Korea (South)
   file2,3/4/2006 14:33,email2,United States
   file2,3/4/2006 16:03,email2,United States
   file2,3/4/2006 16:17,email3,United States
   file2,3/4/2006 16:28,email3,United States
   file3,3/4/2006 19:13,email4,United States
   file2,3/4/2006 21:22,email5,India
   file4,3/4/2006 21:46,email6,United States
   file1,3/4/2006 22:04,email7,Japan
   file2,3/4/2006 22:09,email8,Croatia
   file1,3/4/2006 22:22,email7,Japan
   file1,3/4/2006 22:29,email9,India
   file1,3/4/2006 23:06,email6,United States
   file1,3/4/2006 23:33,email6,United States
   file5,3/4/2006 23:44,email10,China
   file1,3/5/2006 0:13,email9,India
   file2,3/5/2006 0:52,email8,Croatia
   file2,3/5/2006 0:54,email8,Croatia
   file2,3/5/2006 1:10,email5,India
   file6,3/5/2006 2:17,email9,India
   file2,3/5/2006 2:24,email11,Italy
   file7,3/5/2006 2:36,email12,Italy
   file8,3/5/2006 2:52,email12,Italy
   file2,3/5/2006 3:09,email13,United Kingdom
   file2,3/5/2006 4:02,email14,India
   file2,3/5/2006 4:07,email14,India
   file2,3/5/2006 4:14,email14,India
   file2,3/5/2006 4:37,email5,India
   file2,3/5/2006 4:44,email15,Belgium
   file1,3/5/2006 5:02,email9,India
   file1,3/5/2006 5:24,email16,Taiwan
   file2,3/5/2006 6:06,email17,Saudi Arabia
   file2,3/5/2006 7:32,email17,Saudi Arabia
   file2,3/5/2006 8:12,email18,Brazil
   file2,3/5/2006 8:26,email18,Brazil
   file2,3/5/2006 9:49,email19,United Kingdom
   file1,3/5/2006 10:49,email11,Italy
   file1,3/5/2006 11:16,email13,United Kingdom
   file1,3/5/2006 11:16,email13,United Kingdom
   file1,3/5/2006 11:45,email13,United Kingdom
   file1,3/5/2006 14:34,email20,Australia
   file9,3/5/2006 14:56,email20,Australia
   file9,3/5/2006 14:56,email20,Australia
   file5,3/5/2006 16:43,email21,United States
   file1,3/5/2006 17:17,email7,Japan
   file2,3/5/2006 17:26,email22,Japan
   file2,3/5/2006 17:27,email22,Japan
   file2,3/5/2006 17:33,email23,China
   file1,3/5/2006 17:45,email22,Japan
   file2,3/5/2006 17:45,email22,Japan
   file2,3/5/2006 17:59,email23,China
   file1,3/5/2006 18:27,email24,Japan
  

  1   2   >