Re: [R] Lda and Qda

2007-12-28 Thread Prof Brian Ripley

?lda explains the object produced: please do study it.

Hint: you asked for leave-one-out cross-validation, and what is the output 
from cross-validation of a classifer?  The predicted class for each 
observation.  How many observations do you have?


You are using software from a contributed package without credit, and that 
software is support for a book (see library(help=MASS) and the help page). 
Please consult the book for the background.


On Thu, 27 Dec 2007, [EMAIL PROTECTED] wrote:




Hi all,

I'm working with some data: 54 variables and a column of classes, each 
observation as one of a possible seven different classes:



var.can3-lda(x=dados[,c(1:28,30:54)],grouping=dados[,55],CV=TRUE)

Warning message:
In lda.default(x, grouping, ...) : variables are collinear

summary(var.can3)

 Length Class  Mode
class  3 factor numeric   ### why?? I don't understand it
posterior 21 -none- numeric
call   4 -none- call## what's this?



var.can-lda(dados[,c(1:28,30:54)],dados[,55])#porque a variavel 29 é constante

Warning message:
In lda.default(x, grouping, ...) : variables are collinear

summary(var.can)

   Length Class  Mode
prior 7-none- numeric
counts7-none- numeric
means   371-none- numeric
scaling 318-none- numeric
lev   7-none- character
svd   6-none- numeric
N 1-none- numeric
call  3-none- call

(normalizar-function(matriz){ n-dim(matriz)[1]; m-dim(matriz)[2]; 
normas-sqrt(colSums(matriz*matriz)); 
matriz.normalizada-matriz/t(matrix(rep(normas,n),m,n));return(matriz.normalizada)})

function(matriz){ n-dim(matriz)[1]; m-dim(matriz)[2]; 
normas-sqrt(colSums(matriz*matriz)); 
matriz.normalizada-matriz/t(matrix(rep(normas,n),m,n));return(matriz.normalizada)}

var.canonicas-as.matrix(dados[,c(1:28,30:54)])%*%(normalizar(var.can$scaling))
summary(var.canonicas)

 LD1   LD2  LD3   LD4
Min.   :-21.942   Min.   :-6.820   Min.   :-10.138   Min.   :-6.584
1st Qu.:-20.014   1st Qu.:-5.480   1st Qu.: -8.280   1st Qu.: 0.872
Median :-19.495   Median :-5.007   Median : -7.800   Median : 1.083
Mean   :-18.827   Mean   :-4.760   Mean   : -7.803   Mean   : 1.134
3rd Qu.:-18.975   3rd Qu.:-4.456   3rd Qu.: -7.278   3rd Qu.: 1.311
Max.   : -7.886   Max.   : 3.116   Max.   : -1.619   Max.   : 5.556
 LD5   LD6
Min.   :-11.083   Min.   :-4.4972
1st Qu.: -1.237   1st Qu.:-1.6497
Median : -1.100   Median :-1.0909
Mean   : -1.100   Mean   :-0.9808
3rd Qu.: -0.957   3rd Qu.:-0.4598
Max.   :  4.712   Max.   : 7.5356





I don't know wether I need to specify a training set and a testing set, 
I also don't know the error nor the classifier; shouldn't the lenght of 
class of var.can3 be 7 since I only have 7 different classes?


Best regards,

Pedro Marques

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



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


Re: [R] warning on gamma option in par(args) or calling par(= new)?

2007-12-28 Thread Prof Brian Ripley
You are calling par() *before* opening  and (in on.exit) *after* closing 
the pdf() device.  par() applies on a per-device basis, and if no device 
is open the default device will be opened.

As for why you get the warnings about 'gamma' and 'new', see ?par and read 
their entries.  Since you don't change any pars, I do not see why you are 
attempting to reset them.


On Thu, 27 Dec 2007, AA wrote:

 Dear All,

 I have the following function

 tstpar -
  function(n = 200, want.pdf = FALSE, pdfFileName = NULL){
oldpar - par(no.readonly = TRUE)
on.exit(par(oldpar))
steps  - seq(from = 1, to = 8, by = 1)
h - 10; w - 6
if(want.pdf){pdf(file = pdfFileName, onefile = TRUE,
paper = letter, width = w, height = h)}
par(mfrow = c(4,2))
for(i in steps){
  txt - paste(i = , i)
  hist(rnorm(n), main = txt)
}
if(want.pdf){dev.off()}
  }

 when called with default values tstpar() every thing works fine.
 However I get 2 sorts of warnings
 1- if I call the function to generate a pdf as
   tstpar(want.pdf = TRUE, pdfFilename = jj.pdf)
   I get the following warning msg:
   calling par(new=) with no plot in: par(oldpar)
   with an empty device which I don not understand since I close
   the device in the function.
 2- If I comment the line
   if (want.pdf){dev.off()}
   I get the following warning
   'gamma' cannot be modified on this device in: par(args)
   with 2 empty devices.

 I do not understand why I get those warnings and why I get those empty 
 devices.
 I looked up in RSiteSearch and I found the 2 following posts
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/38553.html
 In this post M. Schwarz explains that there is not a plot created that's why 
 R generates the
 warning. In the case of tstpar, I generate the hist plots and should not be 
 getting the warning.

 And in the following post Prof Ripley refers to an old R warning for pdf() 
 devices
 Which is not the case here.
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/23215.html

 I do not see what I am missing. Thanks for any hint.
 I use R 2.5.1 under Win XP.
 I apologize if the question is related to my older R version which I will 
 upgrade.

 AA.

   [[alternative HTML version deleted]]

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


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

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


Re: [R] How to catch data from the different dataframes and lm problem?

2007-12-28 Thread Richard . Cotton
 1) I have a dataframe.  Based on “formulation” and “subject”, a
 dataframe is split into 4 dataframes.  The
 example is as follows.  Moreover, I want
 to calculate “test” value for these 4 dataframes.  My question is 
 that the “test” values not
 correct and I do not know where the problem is.
What does the variable test represent?  It isn't clear from your code 
what it means.  (Currently it looks like a cumulative rate of change of 
concentration with respect to time; are you really sure you want this?)

 2) There are 12 “test” (y) values from 1).  Then, I want to model 
 the relationship
 between “concentration” (X) and “test” (Y) by fitting the linear 
regression,
 such lm(Y~X) and this is my target.  I
 think that if I can catch “test” (Y) values and “concentration” (X) 
 values into
 a dataframe, then I can carry out regression.  So, how to catch all 
 “test” values from
 different dataframes?  Or does anyone
 have better way to get this target?
Once you have all your test values, you probably want to perform a 
regression on all the data, in a single data frame, with formulation and 
subject as effects, e.g.
lm(test~concentration+formulation+subject, data=df)

If the subjects are drawn from a large population, it is better to 
represent them as random effects in a mixed effects model.
library(nlme)
lme(test~concentration+formulaion, data=df, random=~1|subject)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.

Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.

Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.



This e-mail message has been scanned for Viruses and Content and cleared 
by NetIQ MailMarshal

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Conditionally incrementing a loop counter: Take 2

2007-12-28 Thread Jim Lemon
Mike Jones wrote:

Hi,
I am trying a for loop from 1 to 10 by 1. However, if a condition 
does not get met, I want to throw away that iteration. So if my 
loop is for (i in 1:10) and i is say, 4 and the condition is not met 
then I don't want i to go up to 5.  Is there a way to do that? I 
can't seem to manually adjust i because from what I understand, R 
creates 10 long vector and uses that to loops thru and I'm not sure 
how to get at the index of that vector. Any suggestions? Thanks in 
advance.

Hi Mike,
Is this what you want?

i-1
while(i  11) {
  if(runif(1)  0.5) i-i+1
  print(i)
}

This increments if the condition is met, doesn't if it is not met.

Jim

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


[R] Return Value of TCl/Tk window in R

2007-12-28 Thread Richard Müller
Hello,
I have the TCl/Tk command 
tkmessageBox(titel=,message=x,icon=question,type=okcancel) in my R 
script. Now I want to perform some operation in relation to the user's 
choice, something like
if (okpressed) xxx else yyy
What values does this command give and how are they used?
Thank you, Richard
-- 
Richard Müller - Am Spring 9 - D-58802 Balve-Eisborn
www.oeko-sorpe.de

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Return Value of TCl/Tk window in R

2007-12-28 Thread Prof Brian Ripley

Is it so hard to find out?

Your tcl documentation will tell you what tk_messageBox returns, and as it 
is tcl string, you need to call tclvalue() on the value of tkmessageBox()

to get an R character vector.

On Fri, 28 Dec 2007, Richard Müller wrote:


Hello,
I have the TCl/Tk command
tkmessageBox(titel=,message=x,icon=question,type=okcancel) in my R
script. Now I want to perform some operation in relation to the user's
choice, something like
if (okpressed) xxx else yyy
What values does this command give and how are they used?
Thank you, Richard



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


Re: [R] Return Value of TCl/Tk window in R

2007-12-28 Thread Alberto Monteiro
Richard Müller wrote:

 I have the TCl/Tk command 
 tkmessageBox(titel=,message=x,icon=question,type=okcancel) 
 in my R script. Now I want to perform some operation in relation to 
 the user's choice, something like if (okpressed) xxx else yyy What 
 values does this command give and how are they used? 

Why don't you test it yourself?

library(tcltk)
x -  tkmessageBox(title=,message=x,icon=question,type=okcancel)
# press x or cancel
x
# Tcl ok or Tcl cancel

To get back from this Tcl-thing to an R-string, use

y - tclvalue(x)

Alberto Monteiro

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


Re: [R] Return Value of TCl/Tk window in R

2007-12-28 Thread Samu Mäntyniemi
This webpage has been very helpful for me:

http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/


-Samu

Richard Müller kirjoitti:
 Hello,
 I have the TCl/Tk command 
 tkmessageBox(titel=,message=x,icon=question,type=okcancel) in my R 
 script. Now I want to perform some operation in relation to the user's 
 choice, something like
 if (okpressed) xxx else yyy
 What values does this command give and how are they used?
 Thank you, Richard


-- 
--
Samu Mäntyniemi
Researcher
Fisheries and Environmental Management Group (FEM)
Department of Biological and Environmental Sciences
Biocenter 3, room 4414
Viikinkaari 1
P.O. Box 65
FIN-00014 University of Helsinki

Phone: +358 9 191 58710
Fax: +358 9 191 58257

email: [EMAIL PROTECTED]
personal webpage: http://www.helsinki.fi/people/samu.mantyniemi/
FEM webpage: http://www.helsinki.fi/science/fem/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] index question

2007-12-28 Thread Bob Green
I was hoping for some advice regarding indexing,

 From a dataframe there are 27 variables of interest, with the prefix of pre.

  [7] Decision  MHCDate   pre01 pre0  pre012pre013
[13] pre02 pre02111  pre02114  pre0211   pre0212   pre029
[19] pre03apre0311   pre0312   pre03 pre04 pre05
[25] pre06 pre07 pre08 pre09 pre10 pre11
[31] pre12 pre13 pre14 pre15 pre16

I want to combine these variables into new variables, using the 
following criteria :

(1) create a single variable PRE, when any of the 27 'pre' variables 
have a value = '1'
(2) create a variable HOM, when any of the pre01, pre0, pre012, 
pre013 variables have a value = '1'
(3) create a variable ASS, when any of the pre02, pre02111, pre02114, 
pre0211, pre0212, pre029  variables have a value   = '1'
(4) create a variable SEX, when any of the pre03a, pre0311, pre0312, 
pre03 variables have a value   = '1'
(5) create a variable VIO, when any of the pre01 to pre06 variables 
have a value   = '1'
(6) create a variable SERASS. If pre02111 or pre2114 = '1', assign a 
value of 1, if there is a value of 1 or greater for pre0211 assign a 
value of 2;   if there is a value of
1 or greater for pre0212: assign a value of 3;  if there is a value 
of 1 or greater for pre2029 assign a value of 4; everything else = 0. 
If a case has multiple values, 02111 prevails over 2114, 2114 
prevails over 0211, 0211 prevails over 0212; 0212 prevails over 2029.


I believe I can generate new variables (1) - (5) using code such 
as:  ASS - (reoffend$pre02 | reoffend$pre02111 | reoffend$pre02114 | 
reoffend$pre0211 | reoffend$pre0212 | reoffend$pre029 = '1')


I have three questions:

1. If this is correct, what is the most efficient way to generate (1) 
without having to type all the variable names. The following does not 
work: PRE - reoffend [,9:35], = '1'

2. I am unsure as to how to generate Example 6.

3. I wanted to exclude cases with a reoffend$Decision of value of 3, 
using the code below. However, I received a message saying there were 
NAs produced, however, the raw variable did not have NAs.

  MHT.decision - reoffend[reoffend$Decision = '2',]
  table(MHT.decision)
Error in vector(integer, length) : vector size cannot be NA
In addition: Warning messages:
1: NAs produced by integer overflow in: pd * (as.integer(cat) - 1L)
2: NAs produced by integer overflow in: pd * nl

  table(reoffend$Decision)
123
1136  445   66


Any assistance is much appreciated,

Bob Green

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] index question

2007-12-28 Thread Richard . Cotton
  From a dataframe there are 27 variables of interest, with the 
 prefix of pre.
 
   [7] Decision  MHCDate   pre01 pre0  pre012 pre013
 [13] pre02 pre02111  pre02114  pre0211   pre0212 pre029
 [19] pre03apre0311   pre0312   pre03 pre04 pre05
 [25] pre06 pre07 pre08 pre09 pre10 pre11
 [31] pre12 pre13 pre14 pre15 pre16
 
 I want to combine these variables into new variables, using the 
 following criteria :
 
 (1) create a single variable PRE, when any of the 27 'pre' variables 
 have a value = '1'
 (2) create a variable HOM, when any of the pre01, pre0, pre012, 
 pre013 variables have a value = '1'
 (3) create a variable ASS, when any of the pre02, pre02111, pre02114, 
 pre0211, pre0212, pre029  variables have a value   = '1'
 (4) create a variable SEX, when any of the pre03a, pre0311, pre0312, 
 pre03 variables have a value   = '1'
 (5) create a variable VIO, when any of the pre01 to pre06 variables 
 have a value   = '1'
 (6) create a variable SERASS. If pre02111 or pre2114 = '1', assign a 
 value of 1, if there is a value of 1 or greater for pre0211 assign a 
 value of 2;   if there is a value of
 1 or greater for pre0212: assign a value of 3;  if there is a value 
 of 1 or greater for pre2029 assign a value of 4; everything else = 0. 
 If a case has multiple values, 02111 prevails over 2114, 2114 
 prevails over 0211, 0211 prevails over 0212; 0212 prevails over 2029.
 
 
 I believe I can generate new variables (1) - (5) using code such 
 as:  ASS - (reoffend$pre02 | reoffend$pre02111 | reoffend$pre02114 | 
 reoffend$pre0211 | reoffend$pre0212 | reoffend$pre029 = '1')
 
 
 I have three questions:
 
 1. If this is correct, what is the most efficient way to generate (1) 
 without having to type all the variable names. The following does not 
 work: PRE - reoffend [,9:35], = '1'

Try something like this (data frame simplified):
df - data.frame(pre1=c(0,1,1,2),
 pre2=c(0,0,1,0),
 foo=c(0,0,1,3))
precols - grep(pre, names(df))
gt1 - function(x) x=1
PRE - apply(apply(df[,precols], 2, gt1), 1, any)


 2. I am unsure as to how to generate Example 6.
SERASS - rep(0, nrow(df))
SERASS[df$pre2029=1] - 4
SERASS[df$pre0212=1] - 3
SERASS[df$pre0211=1] - 2
SERASS[df$pre02111=1 | df$pre2114=1] - 1


 3. I wanted to exclude cases with a reoffend$Decision of value of 3, 
 using the code below. However, I received a message saying there were 
 NAs produced, however, the raw variable did not have NAs.
 
   MHT.decision - reoffend[reoffend$Decision = '2',]
   table(MHT.decision)
 Error in vector(integer, length) : vector size cannot be NA
 In addition: Warning messages:
 1: NAs produced by integer overflow in: pd * (as.integer(cat) - 1L)
 2: NAs produced by integer overflow in: pd * nl
 
   table(reoffend$Decision)
 123
 1136  445   66

I doubt that you want quotes around the '2' when defining MHT.decision.

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] encoding question again

2007-12-28 Thread Matthias Wendel
 
Hi, 
I'm running the actual R version in JGR (version 1.5-8 ). 
Sys.getlocale(category = LC_ALL) yields 
[1] 
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

I want to write some HTML-Code enhanced by statistical results and labels 
encoded in Latin-1, which I pass to a function. Some label shall generate the 
filename. Although the labels are correctly handled in JGR they are somehow 
converted when they are written to the file. Also the filename is not 
constructed as wanted. The function definition is correctly sourced into R. The 
function is defined like this:

Itemtabelle.head - function (abt ){
   # nür zöm TÄST
   abt = iconv(abt,UTF-8,LATIN1)   
   zz = file( paste(Itemtabelle/Itemtabelle, abt, .html), wt, encoding = 
LATIN1)
   cat(as.character(html xmlns:o=\urn:schemas-microsoft-com:office:office\ 
xmlns:x=\urn:schemas-microsoft-com:office:excel\ 
xmlns=\http://www.w3.org/TR/REC-html40\;  \n),
   as.character(   head  

  \n),
.
.
.
   as.character(td colspan=5 class=xl28 width=727 
style=\'width:545pt\'Gesundheitsindikatoren:  ), abt, as.character(/td 
  \n),
   as.character(   /tr   

), file = zz)
   close(zz)
   unlink(zz)
}
Setting abt as  Ärzte Innere, Gynäkologie and calling the function with this 
argument, yields a filename Itemtabelle  Ärzte Innere, Gynäkologie .html 
and in the file a line 
 td colspan=5 class=xl28 width=727 
style='width:545pt'Gesundheitsindikatoren:Ärzte Innere, Gynäkologie 
/td  
is generated. .
The problem remains the same in the rgui and rterm - except in rterm the 
resulting filename is Itemtabelle Žrzte Innere, Gyn„kologie  .html.

Cheers,
Matthias
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Accesing the value

2007-12-28 Thread Shubha Vishwanath Karanth
Hi R,

 

x=A

A=5

 

I need to get the value of A using x only. How do I do this?

 

Thanks in advance, Shubha

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

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


Re: [R] Accesing the value

2007-12-28 Thread Sundar Dorai-Raj
get(x)

This is a FAQ:

http://cran.cnr.berkeley.edu/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f

--sundar

Shubha Vishwanath Karanth said the following on 12/28/2007 8:38 AM:
 Hi R,
 
  
 
 x=A
 
 A=5
 
  
 
 I need to get the value of A using x only. How do I do this?
 
  
 
 Thanks in advance, Shubha
 
 This e-mail may contain confidential and/or privileged i...{{dropped:13}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS to R - if you don't have a SAS license

2007-12-28 Thread Frank E Harrell Jr
Wensui Liu wrote:
 while I move data between SAS and R all the time, personally I don't
 think your recommendation is very practical. Instead, I feel SAS
 transport file is much better than csv.
 
 Plus, the sas dataset created on unix can't be opened by sas viewer on
 windows. It is even undoable if the dataset is large.

That's surprising.  I hoped that a SAS Viewer would read all formats 
of SAS binary files.

There is another definite limitation to SAS Viewer: SAS invested so 
little of their billions of $ into it that it only has 2 delimiters (tab 
and comma) and doesn't even check if character strings contain the 
delimiter so as to escape those occurrences.  So the Viewer often 
produces invalid csv files.

Frank

 
 Just my $0.02.
 
 
 On Dec 27, 2007 6:33 PM, Gyula Gulyas [EMAIL PROTECTED] wrote:
 Hi all,

 if you do not have a SAS license but want to convert
 native SAS data files, the solution below will work.

 # read SAS data without SAS

 # 1. Download free SAS System Viewer from either of
 the sites below:
 #
 http://www.sas.com/apps/demosdownloads/setupcat.jsp?cat=SAS+System+Viewer
 (requires registration)
 #
 http://www.umass.edu/statdata/software/downloads/SASViewer/index.html
 # 2. Open SAS data in the SAS System Viewer
 # 3. View-Formatted sets the data in formatted view
 # 4. Save As File...csv file - this is your SAS data
 file
 # 5. View-Variables (now showing the variable names
 and formats)
 # 6. Save As File...csv file - this is your SAS
 variable definition file

 # run code below

 wrkdir-getwd() # save working directory to reset
 later

 # Select the SAS data file...
 sas.data-read.table(file.choose(),header=T, sep=,,
 na.strings=.)

 # Select SAS variable definition file...
 sas.def-read.csv(file.choose())

 # str(sas.def)
 # sas.def$SASFORMAT[sas.def$Type==Char]-character
 # sas.def$SASFORMAT[sas.def$Type==Num]-numeric

 sas.def$SASFORMAT[substr(sas.def$Format,1,4)==DATE]-date

 sas.def-sas.def[,length(names(sas.def))] # pick last
 column

 tmp-which(sas.def==date)

 sas.data[,tmp] -
 as.data.frame(strptime(sas.data[,tmp],
 %d%b%Y:%H:%M:%S))

 str(sas.data)
 print(head(sas.data))

 setwd(wrkdir) # reset working directory

 rm(wrkdir,tmp,sas.def)

 # the end


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS to R - if you don't have a SAS license

2007-12-28 Thread Marc Schwartz

On Fri, 2007-12-28 at 11:21 -0600, Frank E Harrell Jr wrote:
 Wensui Liu wrote:
  while I move data between SAS and R all the time, personally I don't
  think your recommendation is very practical. Instead, I feel SAS
  transport file is much better than csv.
  
  Plus, the sas dataset created on unix can't be opened by sas viewer on
  windows. It is even undoable if the dataset is large.
 
 That's surprising.  I hoped that a SAS Viewer would read all formats 
 of SAS binary files.

snip

We have had that problem here, having received both 32 and 64 bit SAS
files from Linux and Solaris based SAS installations. The SAS System
Viewer was largely useless for the non-Windows SAS files that we have
had accessible to us, even though it will run quite nicely under Wine.

We have a 32 bit RHEL based SAS install here now, as I have noted in
prior posts. That has helped with certain aspects of SAS dataset
generation and transfer to and from clients.

DBMS/Copy, which also runs nicely under Wine, seems to be the only tool
that we have so far, that can provide for something of a universal SAS
can opener. It will at least successfully _open_ SAS datasets
generated on a variety of platforms, when other approaches have failed.

However, as I have also noted in prior posts, the SAS datasets that
DBMS/Copy generates, are not guaranteed to be able to be opened by SAS
itself. Hence our need to install SAS here.

Theoretically, the .sas7bdat files are supposed to be cross-platform
compatible and I think Peter had commented on that in a prior thread on
this subject. However, hands on experience has suggested that this
expectation is not absolute.

HTH,

Marc Schwartz

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


[R] Pause loop

2007-12-28 Thread Armin Goralczyk
Hi list

How can I pause a loop (or any other function) for a defined time? E.g.

for(i in 1:5) {print(1:i); 'function to pause for 10 seconds'}

Thanks for help.
-- 
Armin Goralczyk, M.D.
--
Universitätsmedizin Göttingen
Abteilung Allgemein- und Viszeralchirurgie
Rudolf-Koch-Str. 40
39099 Göttingen
--
Dept. of General Surgery
University of Göttingen
Göttingen, Germany
--
http://www.gwdg.de/~agoralc
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS to R - if you don't have a SAS license

2007-12-28 Thread Frank E Harrell Jr
Marc Schwartz wrote:
 On Fri, 2007-12-28 at 11:21 -0600, Frank E Harrell Jr wrote:
 Wensui Liu wrote:
 while I move data between SAS and R all the time, personally I don't
 think your recommendation is very practical. Instead, I feel SAS
 transport file is much better than csv.

 Plus, the sas dataset created on unix can't be opened by sas viewer on
 windows. It is even undoable if the dataset is large.
 That's surprising.  I hoped that a SAS Viewer would read all formats 
 of SAS binary files.
 
 snip
 
 We have had that problem here, having received both 32 and 64 bit SAS
 files from Linux and Solaris based SAS installations. The SAS System
 Viewer was largely useless for the non-Windows SAS files that we have
 had accessible to us, even though it will run quite nicely under Wine.
 
 We have a 32 bit RHEL based SAS install here now, as I have noted in
 prior posts. That has helped with certain aspects of SAS dataset
 generation and transfer to and from clients.
 
 DBMS/Copy, which also runs nicely under Wine, seems to be the only tool
 that we have so far, that can provide for something of a universal SAS
 can opener. It will at least successfully _open_ SAS datasets
 generated on a variety of platforms, when other approaches have failed.
 
 However, as I have also noted in prior posts, the SAS datasets that
 DBMS/Copy generates, are not guaranteed to be able to be opened by SAS
 itself. Hence our need to install SAS here.
 
 Theoretically, the .sas7bdat files are supposed to be cross-platform
 compatible and I think Peter had commented on that in a prior thread on
 this subject. However, hands on experience has suggested that this
 expectation is not absolute.
 
 HTH,
 
 Marc Schwartz
 
 
 

I have had good success with Stat/Transfer (and its Windows version runs 
perfectly under Linux using wine) but haven't tested it as extensively 
as you've tested DBMS/Copy.

Frank


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

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


Re: [R] Pause loop

2007-12-28 Thread Marc Schwartz
On Fri, 2007-12-28 at 19:07 +0100, Armin Goralczyk wrote:
 Hi list
 
 How can I pause a loop (or any other function) for a defined time? E.g.
 
 for(i in 1:5) {print(1:i); 'function to pause for 10 seconds'}
 
 Thanks for help.

At least on Linux, see:

  ?Sys.sleep

Note the caveats regarding time resolution...

HTH,

Marc Schwartz

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


[R] unit attribute to list elements

2007-12-28 Thread baptiste Auguié
Hi,

I've started my own (first) package, part of which consists in  
listing common physical constants (Planck's constant, the speed of  
light in vacuum, etc). I'm wondering what would be a good way of  
dealing with pairs of value/unit.


 constants - list( cel = 2.99792458e8 , #m/s
 Z0 = 376.730313461, #ohm
 eps0 = 8.854187817e-12,#F/m
 mu0 = 4*pi*1e-7,#N/A^2
 G = 6.67428e-11 # m^3 kg-1 s-2
 )


I thought I could include the unit in the names attribute of each  
element, as in :

 names(constants$cel)-  speed of light in vacuum [m.s^-1]


Writing this for every element is very redundant... Is there any way  
to access and set the name of each first level element of the list?

 namesFirstLevelElements(constants)- c( speed of light in vacuum  
 [m.s^-1],
 impedance of vacuum [some unit],
 ...)


Quite possibly, I'm completely on the wring track;

- maybe such a package already exists

- a custom class or structure would be more appropriate? I don't  
really know how to deal with classes, though, and I'd like to keep  
the access to the constants' values as direct and generic as possible.

Many thanks in advance,

baptiste

_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] logistic mixed effects models with lmer

2007-12-28 Thread Douglas Bates
On Dec 28, 2007 9:35 AM, Sharon Goldwater [EMAIL PROTECTED] wrote:
 I have a question about some strange results I get when using lmer to
 build a logistic mixed effects model.  I have a data set of about 30k
 points, and I'm trying to do backwards selection to reduce the number
 of fixed effects in my model.  I've got 3 crossed random effects and
 about 20 or so fixed effects.  At a certain point, I get a model (m17)
 where the fixed effects are like this (full output is at end of
 message):

  print(m17, corr=F)
 ...
 Fixed effects:
Estimate Std. Error z value Pr(|z|)
 (Intercept)-1.978870.19699 -10.045   2e-16 ***
 sexM0.455530.14387   3.166 0.001544 **
 ...
 is_discTRUE 0.246760.15204   1.623 0.104576
 poly(wfreq, 2)1  -119.72397   11.00516 -10.879   2e-16 ***
 poly(wfreq, 2)217.356465.44456   3.188 0.001433 **
 poly(wlen_p, 2)1  -13.607987.26926  -1.872 0.061208 .
 poly(wlen_p, 2)2   -6.431675.24119  -1.227 0.219770
 ...

 where poly(wlen_p,2)2 is the least significant factor left in the
 model.  So I then build a model (m18) with exactly the same random and
 fixed effects except removing poly(wlen_p,2)2.  Then I do an anova,
 and I get:

  anova(m17,m18)
 Data:
 Models:
 m18: is_err ~ sex + starts_turn + before_hes + after_hes + before_part +
 m17: after_part + first_rep + is_open + is_disc + poly(wfreq,
 m18: 2) + wlen_p + poly(utt_rate, 2) + poly(dur, 2) + pmean +
 m17: poly(log_prange, 2) + poly(imean, 2) + poly(irange, 2) +
 m18: (1 | speaker) + (1 | corpus) + (1 | ref)
 m17: is_err ~ sex + starts_turn + before_hes + after_hes + before_part +
 m18: after_part + first_rep + is_open + is_disc + poly(wfreq,
 m17: 2) + poly(wlen_p, 2) + poly(utt_rate, 2) + poly(dur, 2) +
 m18: pmean + poly(log_prange, 2) + poly(imean, 2) + poly(irange,
 m17: 2) + (1 | speaker) + (1 | corpus) + (1 | ref)
 DfAICBIC logLik  Chisq Chi Df Pr(Chisq)
 m18 27  25928  26153 -12937
 m17 28  25925  26159 -12934 5.2136  10.02241 *

 So my first question is: Should I be concerned that the significance
 level shown in the original m17 is so different from the one shown by
 the anova?  It's hard for me to see how this could happen.  I noticed
 that there is a post on the FAQ about significance levels in linear
 mixed models, but I'm not sure whether it applies to the logistic
 case and if so how.

It can happen that the significance levels reported by the different
tests will be different.  The test in the summary is based on a local
approximation to the conditional mean and assumes that the variances
of the random effects will not change substantially when fitting the
model with and without that term.  Did they?

One thing I noticed is your output (and thank you for including that)
is that it reports that corpus has only two levels.  Is that correct?
If so, I would not advise using a random effect for corpus.  It is
very difficult to estimate a variance from only two levels of a
factor.  I suggest using a fixed effect for corpus instead.

 Now, my second question is a result of removing one more factor
 (is_disc) from the model, creating m19.  I do another anova:

  anova(m19,m18)
 Data:
 Models:
 m19: is_err ~ sex + starts_turn + before_hes + after_hes + before_part +
 m18: after_part + first_rep + is_open + poly(wfreq, 2) + wlen_p +
 m19: poly(utt_rate, 2) + poly(dur, 2) + pmean + poly(log_prange,
 m18: 2) + poly(imean, 2) + poly(irange, 2) + (1 | speaker) + (1 |
 m19: corpus) + (1 | ref)
 m18: is_err ~ sex + starts_turn + before_hes + after_hes + before_part +
 m19: after_part + first_rep + is_open + is_disc + poly(wfreq,
 m18: 2) + wlen_p + poly(utt_rate, 2) + poly(dur, 2) + pmean +
 m19: poly(log_prange, 2) + poly(imean, 2) + poly(irange, 2) +
 m18: (1 | speaker) + (1 | corpus) + (1 | ref)
 DfAICBIC logLik Chisq Chi Df Pr(Chisq)
 m19 26  25925  26142 -12936
 m18 27  25928  26153 -12937 0  1  1

 and now it seems that m19 (which contains fewer parameters than m18)
 is a better fit.  I don't see how it's possible to remove parameters
 from a model and get a better likelihood, but I will confess that I
 don't entirely understand how these kinds of models are estimated.
 Does this have something to do with approximations that R is making to
 fit the models, or numerical rounding errors?  Could either problem be
 due to correlations among variables?  All my fixed effects are either
 binary or numeric, and there are some fairly high correlations between
 a few pairs of them (maybe as high as .6 or .65 using Kendall tau) but I
 figured that this would be ok given the large number of data points.
 I think each value of each binary feature is observed at least
 70-100 times.

The difference could be due to approximations or due to poor
convergence.  For some models the Laplace approximation can be
generalized to a 

[R] SAS to R - if you have SAS 8.2+

2007-12-28 Thread Gyula Gulyas
Hi there,

the attached R function uses the SAS Integrated Object
Model (IOM) and it can deal with SAS dates and long
variable names. All you need to provide is the folder
where the SAS data file is and the data file name
without the extension. The function requires the rcom
package.

This is meant to be first cut...but improvements and
suggestions are more than welcome!

Gyula

 import.sas.data -
function(inPath,inSAS,as.is=FALSE){
 # Function to read in a SAS data file
 # Packages needed: rcom
 # inPath: path to SAS file
 # inSAS: SAS data file name (no extension)
 # as.is: as per read.csv (FALSE - force all character
variables to be factors)
 # outputs a data.frame object
 # Created:  December 1, 2007
 # Modified: December 4, 2007
 # Author: Gyula Gulyas ([EMAIL PROTECTED])
 # Use as is, no guarantees, liability due to data
loss is limited to the price you paid for this
function...
 
 require(rcom)

 # check if user has closing slash in path and fix it
if needed
 inPath - sub(/$,,inPath)

 obWSM -
comCreateObject(SASWorkspaceManager.WorkspaceManager)
 obWSM.Workspaces - obWSM[[Workspaces]]
 obSAS - comCreateObject(SAS.Workspace)
 obSAS.DataService - obSAS[[DataService]]
 obSAS.LanguageService - obSAS[[LanguageService]]

 # hard-coded temporary files
 # sas temporary csv file
 csvdata - paste(inPath,/t__sd__t.csv, sep=)
 # sas temporary column definition file
 coldef - paste(inPath,/t__sc__t.csv, sep=)
 
 libRef -
obSAS.DataService$AssignLibref(sasds,,inPath,)

 # create the content csv file
 cont1 - paste(proc contents data=sasds.,inSAS,
out=_tmp1(KEEP=NAME TYPE LENGTH VARNUM FORMAT)
noprint; run;,sep=)
 cont2 - proc sort data=_tmp1; by varnum; run;
 cont3 - data _tmp2; set _tmp1; if type=2 then
dummy='character'; 
 cont3 - paste(cont3,if type=1 then do; if format in
('DATE','DATETIME') then dummy='date'; ,sep=)
 cont3 - paste(cont3,else dummy='numeric'; end;
run;,sep=)
 cont4 - proc transpose data=_tmp2
out=_tmp3(DROP=_NAME_); id name; var dummy; run;
 cont5 - paste(proc export data=_tmp3
outfile=',coldef,' dbms=csv; run;,sep=)

 obSAS.LanguageService$Submit(cont1)
 obSAS.LanguageService$Submit(cont2)
 obSAS.LanguageService$Submit(cont3)
 obSAS.LanguageService$Submit(cont4)
 obSAS.LanguageService$Submit(cont5)

 # column definitions, all as characters
 scf - read.csv(coldef,as.is=T)

 sasline1 - paste(data _tmp4; set sasds., inSAS, ;
run;,sep=)

 obSAS.LanguageService$Submit(sasline1)

 sasline2 - paste(proc export data=_tmp4
outfile=',csvdata,' dbms=csv; run;,sep=)

 obSAS.LanguageService$Submit(sasline2)

 sdf - read.csv(csvdata,as.is=as.is)

 # delete old csvdata file
 file.remove(csvdata)
 # delete old coldef file
 file.remove(coldef)
 
 # convert SAS DATETIME format into native R date
(POSIXct)
 x - which(scf==date)
 sdf[,x] - as.data.frame(strptime(sdf[,x],
%d%b%Y:%H:%M:%S))

 # cleanup SAS objects
 obSAS.UniqueIdentifier - obSAS[[UniqueIdentifier]]

obWSM.Workspaces$RemoveWorkspaceByUUID(obSAS.UniqueIdentifier)
 obSAS$Close()

 return(sdf)

}

# example call
# not run
# test- import.sas.data(path/to/data,sasdatafile)




  

Looking for last minute shopping deals?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AIC and BIC in mixed effects model

2007-12-28 Thread Chuanjun Zhang
Dear R Users:

I am trying to compare several structures of the within-patient covariance
such as unstructured, Autoregressive, and spatial by using the MIXED effects
model. Can AIC, BIC be negative ? If yes, then in what situations they may
be negative.

Thanks a lot.

[[alternative HTML version deleted]]

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


Re: [R] Return Value of TCl/Tk window in R

2007-12-28 Thread Philippe Grosjean
  res - tkmessageBox(title = test,message = Continue?,
+icon  =question, type = okcancel)
  if (tclvalue(res) == ok) 1 else 2

Happy new year!

Philippe Grosjean

Richard Müller wrote:
 Hello,
 I have the TCl/Tk command 
 tkmessageBox(titel=,message=x,icon=question,type=okcancel) in my R 
 script. Now I want to perform some operation in relation to the user's 
 choice, something like
 if (okpressed) xxx else yyy
 What values does this command give and how are they used?
 Thank you, Richard

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] gplot function - error

2007-12-28 Thread Ricardo Perrone
Hi all,

i installed the ggplot2 package via install.packages(), but the gplot function 
was not recognized in R console command. Is there any paths to configure? The 
error message reports that the function was not found.

Thanks
Ricardo




  

Be a better friend, newshound, and

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Conditionally incrementing a loop counter: Take 2

2007-12-28 Thread John Fox
Dear Mike,

You could use a repeat loop and manage the index yourself:

i - 0
repeat{
x - runif(1)
if (x  .1){
   i - i + 1
   cat(x = , x, \n)
   }
if (i == 10) break
}

But if your example problem reflects your actual application, why not just
generate uniform random numbers on the interval (0, .1)?

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]
 project.org] On Behalf Of Mike Jones
 Sent: December-27-07 6:08 PM
 To: Peter Dalgaard
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Conditionally incrementing a loop counter: Take 2
 
 Since I didn't want the i to increment in the loop when the condition
 is not met, then in my example I wanted the loop to actually run 14
 times instead of the 10 since I wanted 4 of the iterations to be thrown
 away, or ignored.  I still haven't been able to figure this out.  Going
 the while route doesn't seem to work for me either.
 
 
 nums - numeric(10)
 i - 1
 garbage - 0
 
 while (i = 10){
   x - runif(1)
   cat(x = ,x,\n)
   if (x  0.1){
   nums[i] - x
   i - i + 1
   }
   else{
   garbage - garbage+1
   }
 cat(i = ,i,garbage = ,garbage,\n)
 }
 
 -Original Message-
 From: Peter Dalgaard [mailto:[EMAIL PROTECTED]
 Sent: Thursday, December 27, 2007 5:36 PM
 To: Mike Jones
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Conditionally incrementing a loop counter: Take 2
 
 
 Mike Jones wrote:
  My apologies for not including a working example.
 
  Here it is:
 
  for (i in 1:10){
 cat(initial i = ,i,\n)
 x - runif(1)
 if (x  0.7){
i - i-1
 }
 cat(second i = ,i,\n)
  }
 
  When I ran this i got what follows, so there were four cases where I
  wanted the i not to increment.
 
  initial i =  1
  second i =  1
  initial i =  2
  second i =  1
  initial i =  3
  second i =  3
  initial i =  4
  second i =  3
  initial i =  5
  second i =  4
  initial i =  6
  second i =  6
  initial i =  7
  second i =  7
  initial i =  8
  second i =  7
  initial i =  9
  second i =  9
  initial i =  10
  second i =  10
 
 
 Is this the kind of effect you want?
 
   x - runif(10)
   cbind(x, 1:10, cumsum(x  .7))
 x
  [1,] 0.384165631  1 1
  [2,] 0.392715845  2 2
  [3,] 0.895936431  3 2
  [4,] 0.910242185  4 2
  [5,] 0.689987301  5 3
  [6,] 0.237071326  6 4
  [7,] 0.225032680  7 5
  [8,] 0.001856286  8 6
  [9,] 0.392034868  9 7
 [10,] 0.655076045 10 8
 
 If you insist on using a loop, you need to separate the loop control
 from the manipulation of i, as in (e.g.)
 
 i - 0
 for (j in 1:10){
i - i + 1
cat(initial i = ,i,\n)
x - runif(1)
if (x  0.7){
   i - i-1
}
cat(second i = ,i,\n)
 }
 
 
   -Original Message-
  From:  Mike Jones
  Sent:  Thursday, December 27, 2007 4:35 PM
  To:'[EMAIL PROTECTED]'
  Subject:   Conditionally incrementing a loop counter
 
  Hi,
  I am trying a for loop from 1 to 10 by 1. However, if a condition
  does not get met, I want to throw away that iteration. So if my
  loop is for (i in 1:10) and i is say, 4 and the condition is not met
  then I don't want i to go up to 5.  Is there a way to do that? I
  can't seem to manually adjust i because from what I understand, R
  creates 10 long vector and uses that to loops thru and I'm not
 sure
  how to get at the index of that vector. Any suggestions? Thanks in
  advance.
 
 
 
 
 
 
 
 
 
 
  Mike Jones
  Westat
  1650 Research Blvd. RE401
  Rockville, MD 20850
  Ph: 240.314.2312
 
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: (+45)
 35327907
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] groupedData function not found

2007-12-28 Thread Andrew Robinson
Hi Andrea,

did you try

require(nlme)

?  Adding a package is not necessarily the same as loading it.

Cheers

Andrew


On Thu, Dec 27, 2007 at 10:42:27PM +, andrea previtali wrote:
 
 Hello,
 I'm trying to use the groupedData function and R is giving me the message: 
 Error: can not find function groupedData
 The code is coming from a textbook so I think it should be correct:
 
 pigs-data.frame(cbind(pig.time,pig.id,pig.wt))
 pig.growth-groupedData(pig.wt~pig.time|pig.id,data=pigs)
 
 I have added the package nlme and to confirm that it was installed 
 correctly I requested the list of functions included in the package 
 (library(help=nlme)) and I do see groupData in the list.
 I am using R 2.6.1 in Windows XP.
 
 I'll appreciate your help.
 Thanks,
 Andrea Previtali
 Post-doc fellow
 Dept. of Biology,
 Univ. of Utah, SLC, UT.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 -- 
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] unit attribute to list elements

2007-12-28 Thread Gabor Grothendieck
Is this what you want?

 Lines - cel 3.0 m/s
+ Z0 367 ohm
+ eps0 8.9e-12 F/m
+ 
 Constants.DF - read.table(textConnection(Lines), as.is = TRUE)
 Constants - as.list(Constants.DF[[2]])
 names(Constants) - Constants.DF[[1]]
 for(i in seq_along(Constants)) comment(Constants[[i]]) - Constants.DF[i, 3]

 # get value
 Constants$Z0
[1] 367
 # get comment
 comment(Constants$Z0)
[1] ohm
 # add another Constant
 Constants$e - 2.7
 comment(Constants$e) - exp


On Dec 28, 2007 2:33 PM, baptiste Auguié [EMAIL PROTECTED] wrote:
 Hi,

 I've started my own (first) package, part of which consists in
 listing common physical constants (Planck's constant, the speed of
 light in vacuum, etc). I'm wondering what would be a good way of
 dealing with pairs of value/unit.


  constants - list( cel = 2.99792458e8 , #m/s
  Z0 = 376.730313461, #ohm
  eps0 = 8.854187817e-12,#F/m
  mu0 = 4*pi*1e-7,#N/A^2
  G = 6.67428e-11 # m^3 kg-1 s-2
  )


 I thought I could include the unit in the names attribute of each
 element, as in :

  names(constants$cel)-  speed of light in vacuum [m.s^-1]


 Writing this for every element is very redundant... Is there any way
 to access and set the name of each first level element of the list?

  namesFirstLevelElements(constants)- c( speed of light in vacuum
  [m.s^-1],
  impedance of vacuum [some unit],
  ...)


 Quite possibly, I'm completely on the wring track;

 - maybe such a package already exists

 - a custom class or structure would be more appropriate? I don't
 really know how to deal with classes, though, and I'd like to keep
 the access to the constants' values as direct and generic as possible.

 Many thanks in advance,

 baptiste

 _

 Baptiste Auguié

 Physics Department
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 http://projects.ex.ac.uk/atto

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


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


Re: [R] unit attribute to list elements

2007-12-28 Thread baptiste Auguié

On 28 Dec 2007, at 20:06, Gabor Grothendieck wrote:

 Is this what you want?


Perfect! Thanks a lot!

 Lines - cel 3.0 m/s
 + Z0 367 ohm
 + eps0 8.9e-12 F/m
 + 
 Constants.DF - read.table(textConnection(Lines), as.is = TRUE)
 Constants - as.list(Constants.DF[[2]])
 names(Constants) - Constants.DF[[1]]
 for(i in seq_along(Constants)) comment(Constants[[i]]) -  
 Constants.DF[i, 3]

 # get value
 Constants$Z0
 [1] 367
 # get comment
 comment(Constants$Z0)
 [1] ohm
 # add another Constant
 Constants$e - 2.7
 comment(Constants$e) - exp


 On Dec 28, 2007 2:33 PM, baptiste Auguié [EMAIL PROTECTED] wrote:
 Hi,

 I've started my own (first) package, part of which consists in
 listing common physical constants (Planck's constant, the speed of
 light in vacuum, etc). I'm wondering what would be a good way of
 dealing with pairs of value/unit.


 constants - list( cel = 2.99792458e8 , #m/s
 Z0 = 376.730313461, #ohm
 eps0 = 8.854187817e-12,#F/m
 mu0 = 4*pi*1e-7,#N/A^2
 G = 6.67428e-11 # m^3 kg-1 s-2
 )


 I thought I could include the unit in the names attribute of each
 element, as in :

 names(constants$cel)-  speed of light in vacuum [m.s^-1]


 Writing this for every element is very redundant... Is there any way
 to access and set the name of each first level element of the list?

 namesFirstLevelElements(constants)- c( speed of light in vacuum
 [m.s^-1],
 impedance of vacuum [some unit],
 ...)


 Quite possibly, I'm completely on the wring track;

 - maybe such a package already exists

 - a custom class or structure would be more appropriate? I don't
 really know how to deal with classes, though, and I'd like to keep
 the access to the constants' values as direct and generic as  
 possible.

 Many thanks in advance,

 baptiste

 _

 Baptiste Auguié

 Physics Department
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 http://projects.ex.ac.uk/atto

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


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


Re: [R] gplot function - error

2007-12-28 Thread Domenico Vistocco
You changed the intial letter: the function is qplot and not gplot.

domenico

Ricardo Perrone wrote:
 Hi all,

 i installed the ggplot2 package via install.packages(), but the gplot 
 function was not recognized in R console command. Is there any paths to 
 configure? The error message reports that the function was not found.

 Thanks
 Ricardo




   
 
 Be a better friend, newshound, and

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



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


[R] Forcing virtual digits

2007-12-28 Thread Thomas Schwander
Hi there,

 

I'm using XP with R 2.6.1

 

I've got the following question: Is there a way to force virtual digits?

 

I mean: In the external csv-file, I read in some numbers, e.g. 33 which is
written into a variable.

 

I want to add this variable into a plot with an additional digit: 33.0.

 

I know, that this is a kind of cheating, because the number was not measured
as precisely, but it looks better in the graph.

 

Any ideas?

 

Thanks for your help,

Thomas


[[alternative HTML version deleted]]

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


[R] two plots on the same page

2007-12-28 Thread Maura E Monville
I'd like to know why I cannot get a plot and the QQnorm in the same sheet.
The commands are simple but:

 library(nlme)
 glmod1 - gls(upfmla,correlation=corAR1(),method=ML)
 summary(glmod1)
 par(mfrow = c(2,1))
 plot(glmod1, main=GLS Residuals vs. GLS Fitted)
 qqnorm(glmod1)

No matter what (I tried different permutations of the plotting commands) the
second drawing is overlapped to the first one instead of being placed
underneath it on the same page.
How come?

Thank you very much.
Happy New Year,
Maura





-- 
Maura E.M

[[alternative HTML version deleted]]

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


[R] print ggplot2 summary on graphic

2007-12-28 Thread Felipe Carrillo
Hi all: The code below works well to print annotations
on base graphics but I can't make it work using the
ggplot2 package. I tried to use the capture.output
function but only prints the summary on the R console
and no on the graphic. Any ideas on how to print
output on ggplot2 graphs? For a powerpoint
presentation I basically just want to show viewers the
mean and Median on the graph since they won't be
seeing the data or the R console.
aa - 1:10
plot(aa)
text(c(2,4),10, labels=c( mean, sd),col=2)
text(c(2,4),9.5, labels=c(mean(aa), sd(aa)),col=4)
legend(topright,capture.output(sd(aa[1:2])))

m - ggplot(movies, aes(x=rating))
m + geom_density()
capture.output(mean(movies[3]))


Felipe D. Carrillo
  Fishery Biologist
  US Fish  Wildlife Service
  California, USA



  

Looking for last minute shopping deals?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] FYI: Package installation problem with windows

2007-12-28 Thread Owe Jessen
Hello,

maybe this info is helpful for someone else, at least it is a reminder 
for me if the problem should reoccur:

The last hours R drove me nuts because it wouldn't install new packages, 
or more irritating still: It would chose randomly which packages to 
install when given a list (unable to move temporary installation ). 
The solution was to turn of the indexation of folders.

HTH

Owe

-- 
Owe Jessen
Diplom-Volkswirt
Hanssenstraße 17
24106 Kiel

[EMAIL PROTECTED]
http://www.econinfo.de

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AIC and BIC in mixed effects model

2007-12-28 Thread Ben Bolker
Chuanjun Zhang zhangchu at umkc.edu writes:

 
 Dear R Users:
 
 I am trying to compare several structures of the within-patient covariance
 such as unstructured, Autoregressive, and spatial by using the MIXED effects
 model. Can AIC, BIC be negative ? If yes, then in what situations they may
 be negative.
 

  This almost deserves to be a FAQ, although it's a statistical rather than an R
issue:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/46734.html
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/108660.html

  The one-sentence answer is that since probability *densities* can be 1,
log-likelihood *densities* can be 0 and hence negative log-likelihoods can be
0 (so AIC/BIC can also be 0).  However, there's a potentially larger issue
with using AICs for mixed models, which is that it's not always entirely clear
what the right number of degrees of freedom is for a random effect ...
 
  cheers
Ben Bolker

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


[R] How can I change the language back to english?

2007-12-28 Thread francogrex

I have reset my windows and re-installed R (I explicitly asked for english)
and although the windows XP version is in english I am having R display in
french. like:

R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.

I know I have an azerty french keyboard but even before the reset I had the
same azerty french
keyborad and the same XP settings and R was completely in english, now it's
annoyinly in french and reinstalling R again doesn't change it back to
english like I want it. how can I set it in english, I hate having my R
message in french. thanks.
-- 
View this message in context: 
http://www.nabble.com/How-can-I-change-the-language-back-to-english--tp14532778p14532778.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] two plots on the same page

2007-12-28 Thread Steven McKinney

 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Maura E Monville
 Sent: Fri 12/28/2007 2:18 PM
 To: [EMAIL PROTECTED]
 Subject: [R] two plots on the same page
  
 I'd like to know why I cannot get a plot and the QQnorm in the same sheet.
 The commands are simple but:
 
  library(nlme)
  glmod1 - gls(upfmla,correlation=corAR1(),method=ML)
  summary(glmod1)
  par(mfrow = c(2,1))
  plot(glmod1, main=GLS Residuals vs. GLS Fitted)
  qqnorm(glmod1)
 
 No matter what (I tried different permutations of the plotting commands) the
 second drawing is overlapped to the first one instead of being placed
 underneath it on the same page.
 How come?
 

Because glmod1 is of class gls

 class(glmod1)
[1] gls

so when you plot it you are invoking
plot.gls()

See the help for function plot.gls() in the nlme library.

 ?plot.gls

reports that the value of a call is

   Value

   a diagnostic Trellis plot.

so you are dealing with Trellis plots handled by the 
lattice package.  Trellis plots do not use
the par() settings used by regular plots.


Here's one way to do it.  (I substituted
an example from nlme since I don't have your
data and upfmla object.


library(nlme)

glmod1 - gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
   correlation = corAR1(form = ~ 1 | Mare))
summary(glmod1)

plot1 - plot(glmod1, main=GLS Residuals vs. GLS Fitted)
plot2 - qqnorm(glmod1)
print(plot1, split = c(1, 1, 1, 2), more = TRUE)
print(plot2, split = c(1, 2, 1, 2))



Try something like this.  The 'split' mechanism
works for me and I get both plots on one page.

Remember also that you can save the output of
trellis plot commands and print them later.  Trellis
plots do not always print right away - in many situations
you must explicitly wrap your trellis plot
command with print() before it will render on a
graphics device.


You can read more about putting multiple trellis plots on a
page in the help page for 
print.trellis 
in the lattice package.

Hope this helps.

After you master the lattice package
you can go to that New Years party
and celebrate!


Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Forcing virtual digits

2007-12-28 Thread jim holtman
?sprintf

x - 33
plot(0, main=sprintf(Value = %.1f, x))

On Dec 28, 2007 5:13 PM, Thomas Schwander [EMAIL PROTECTED] wrote:
 Hi there,



 I'm using XP with R 2.6.1



 I've got the following question: Is there a way to force virtual digits?



 I mean: In the external csv-file, I read in some numbers, e.g. 33 which is
 written into a variable.



 I want to add this variable into a plot with an additional digit: 33.0.



 I know, that this is a kind of cheating, because the number was not measured
 as precisely, but it looks better in the graph.



 Any ideas?



 Thanks for your help,

 Thomas


[[alternative HTML version deleted]]

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




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

What is the problem you are trying to solve?

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


Re: [R] FYI: Package installation problem with windows

2007-12-28 Thread Prof Brian Ripley
On Fri, 28 Dec 2007, Owe Jessen wrote:

 Hello,

 maybe this info is helpful for someone else, at least it is a reminder
 for me if the problem should reoccur:

 The last hours R drove me nuts because it wouldn't install new packages,
 or more irritating still: It would chose randomly which packages to
 install when given a list (unable to move temporary installation ).
 The solution was to turn of the indexation of folders.

See the rw-FAQ Q4.8.
It is not normal for the Windows' Indexing Service to cause any problems 
here, but enhanced versions can.

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

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


Re: [R] How can I change the language back to english?

2007-12-28 Thread Prof Brian Ripley

This is rw-FAQ Q3.2, Q3.4.

But the underlying problem is that Windows is telling R it is in French, 
and perhaps you need to sort that out.


On Fri, 28 Dec 2007, francogrex wrote:



I have reset my windows and re-installed R (I explicitly asked for english)
and although the windows XP version is in english I am having R display in
french. like:

R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.

I know I have an azerty french keyboard but even before the reset I had the
same azerty french
keyborad and the same XP settings and R was completely in english, now it's
annoyinly in french and reinstalling R again doesn't change it back to
english like I want it. how can I set it in english, I hate having my R
message in french. thanks.



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