Re: [R] Standard errors of least squares adjusted means

2009-01-22 Thread Mark Difford

Hi Bruno,

Apropos of ls-means ...

 I have tried help.search and RSiteSearch with several terms including
 standard errors, least square means, adjusted means.

And ls-means, which is what you call them?

There are many threads on this, spanning many years. The following,

RSiteSearch(ls-means)

will get you to some, e.g.:

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

Read through to the bottom.

There are much better ways of examining/summarizing, your model. See, for
instance, the effects package of Prof. Fox and functions in the Design
package of Prof. Harrell.

HTH, Mark.


Bruno Estigarribia wrote:
 
 Hello,
 
 I have the following model:
 lm.7 - lm(Y ~ F + C1 + C2 , data = EM4)
 F is a 4-level factor, the rest are covariates centered at their mean (Y 
 is a two-column matrix).
 I have tried to find functions to give the model-adjusted means 
 (adjusted at the covariates'means) and their standard deviations for each.
 (That is, what I believe is called in SAS least square or LS-means, 
 whose errors one obtains by STDERR)
 I have tried help.search and RSiteSearch with several terms including 
 standard errors, least square means, adjusted means. I have found 
 how to extract the SE from coefficients (se.coef from package arm), or 
 the SE for contrasts (se.contrast from package stats), but not the SE 
 for an adjusted mean.
 Thank you,
 
 -- 
 Bruno Estigarribia
 Postdoctoral Fellow
 FPG Child Development Institute
 Neurodevelopmental Disorders Research Center
 University of North Carolina at Chapel Hill
 
 105 Smith Level Rd
 Chapel Hill, NC 27599-8180
 USA
 + 1 (919) 843-7685
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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/Standard-errors-of-least-squares-adjusted-means-tp21598897p21599542.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] Replacing dates with consecutive observations

2009-01-22 Thread Indrajit Sengupta
Hi Alina,
 
You can always write a loop in R to do this:

# A function to shift values in an vector
shift = function(y) {
 cnt = length(y) - 1
 m=vector(mode = numeric,length = cnt) 
 for (j in 1:cnt) {
 m[j] = y[j+1]}
 m
}
 
Regards,

Indrajit




From: Alina Sheyman alina...@gmail.com
To: r-help@r-project.org
Sent: Thursday, January 22, 2009 2:48:42 AM
Subject: [R] Replacing dates with consecutive observations

I am working with a list of dates and I would like to replace each date with
the one that comes after, ie. 1/1/07 will become 1/5/07, 1/5/07 will become
1/7/07, etc. The number of days between my dates always varies, so I can't
just increase each one by 5 days or  so. Does anyone know of a way I can do
this in R?

thank you

    [[alternative HTML version deleted]]

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





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


[R] How to Run R Programs in a Scheduled Way

2009-01-22 Thread Thorsten Muehge
Hello R Experts,
does anyone know how to run R programs automatically using the window 
scheduler?

I want to run some R programs automatically and make the results available 
via web.

Mit freundlichen Grüßen / Best Regards / С наилучшими 
пожеланиями / 
üdvözlettel
Thorsten

[[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] problem with compating 2 strings

2009-01-22 Thread venkata kirankumar
Hi all,

I got one problem with compating charecterstrings with using  ==
can anyone suggest if any other way to compare two charecterstrings

thanks in advance

[[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] reshape() problems

2009-01-22 Thread Robin Hankin

Hi

I have a data frame with timeseries information like this:

year   cell   Q1Q2 Q3 Q4
1940   1  1.2   1.4 1.41.9
1941   1  2.9   2.1 3.4   2.4
1942   1  2.7   3.2 1.52.6
1940   2  1.4   2.1 2.62.4
1941   2  2.4   1.4 1.43.4
1942   2  1.4   2.4 2.54.4

where the Qs mean 'quarter'.  I want to extract from this
a dataframe with a timeseries for each cell:


year quarter  cell1  cell2
1940 1  1.2 1.4
1940 2  1.4 2.1
1940 3  1.4 2.6
1940 4  1.9 2.4
1941 1  2.9 2.4
1941 2  2.1 1.4
1941 3  3.4 1.4
1942 4  2.4 3.4
1942 1  2.7 1.4
1942 2  3.2 2.4
1942 3  1.5 2.5
1942 4  2.6 4.4

Thus the third and fourth columns are the timeserieses for
cell 1 and cell 2.

Is there a nice vectorized way to do this?

I can't quite make reshape() do what I want.

[the real dataset is months, not quarters, has ~2000 cells
and ~60 years]



--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Run R Programs in a Scheduled Way

2009-01-22 Thread Uwe Ligges



Thorsten Muehge wrote:

Hello R Experts,
does anyone know how to run R programs automatically using the window 
scheduler?


I want to run some R programs automatically and make the results available 
via web.



Write some Windows command script (also referred to as batch file) that 
calls Rterm with some input file or R CMD BATCH. Then tell your 
scheduler to run that file as you like.


For me this worked very well with Windows XP and Windows Server 2003. In 
Windows Server 2008 64-bit (and hence I guess the same in Vista) I found 
that the new scheduler runs R extremely slow (by a factor of roughly 10 
if some relevant amount of CPU performance and IO traffic is requested) 
so that I decided to moved to a cron implementation. At least, I have 
not found any solution for the Windows 2008 task scheduler so far.


Uwe Ligges



Mit freundlichen Grüßen / Best Regards / С наилучшими пожелани�ми / 
üdvözlettel

Thorsten

[[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] problem with compating 2 strings

2009-01-22 Thread Dimitris Rizopoulos

an example would be helpful ...

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

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


venkata kirankumar wrote:

Hi all,

I got one problem with compating charecterstrings with using  ==
can anyone suggest if any other way to compare two charecterstrings

thanks in advance

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


Re: [R] reshape() problems

2009-01-22 Thread ONKELINX, Thierry
Dear Robin,

It is rather easy if you combine melt() and cast() from the reshape
package.

dataset - expand.grid(year = 1940:1942, cell = 1:2)
dataset$Q1 - rnorm(nrow(dataset))
dataset$Q2 - rnorm(nrow(dataset))
dataset$Q3 - rnorm(nrow(dataset))
dataset$Q4 - rnorm(nrow(dataset))
library(reshape)
datasetMelt - melt(dataset, id.var = c(year, cell))
cast(datasetMelt, year + variable ~ ...)

HTH,

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Robin Hankin
Verzonden: donderdag 22 januari 2009 10:52
Aan: r-help@r-project.org
Onderwerp: [R] reshape() problems

Hi

I have a data frame with timeseries information like this:

year   cell   Q1Q2 Q3 Q4
1940   1  1.2   1.4 1.41.9
1941   1  2.9   2.1 3.4   2.4
1942   1  2.7   3.2 1.52.6
1940   2  1.4   2.1 2.62.4
1941   2  2.4   1.4 1.43.4
1942   2  1.4   2.4 2.54.4

where the Qs mean 'quarter'.  I want to extract from this
a dataframe with a timeseries for each cell:


year quarter  cell1  cell2
1940 1  1.2 1.4
1940 2  1.4 2.1
1940 3  1.4 2.6
1940 4  1.9 2.4
1941 1  2.9 2.4
1941 2  2.1 1.4
1941 3  3.4 1.4
1942 4  2.4 3.4
1942 1  2.7 1.4
1942 2  3.2 2.4
1942 3  1.5 2.5
1942 4  2.6 4.4

Thus the third and fourth columns are the timeserieses for
cell 1 and cell 2.

Is there a nice vectorized way to do this?

I can't quite make reshape() do what I want.

[the real dataset is months, not quarters, has ~2000 cells
and ~60 years]



-- 
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replacing dates with consecutive observations

2009-01-22 Thread Henrique Dallazuanna
Try this also:

x - seq(as.Date(2008-01-01), as.Date(2008-12-31), l = 10)
as.Date(embed(matrix(x), 2)[,1], origin = 1970-01-01)

On Wed, Jan 21, 2009 at 7:18 PM, Alina Sheyman alina...@gmail.com wrote:

 I am working with a list of dates and I would like to replace each date
 with
 the one that comes after, ie. 1/1/07 will become 1/5/07, 1/5/07 will become
 1/7/07, etc. The number of days between my dates always varies, so I can't
 just increase each one by 5 days or  so. Does anyone know of a way I can do
 this in R?

 thank you

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


[R] Odp: problem with compating 2 strings

2009-01-22 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 22.01.2009 10:49:26:

 Hi all,
 
 I got one problem with compating charecterstrings with using  ==
 can anyone suggest if any other way to compare two charecterstrings

Works for me

a-letters
b-letters[1:10]
 a==b
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE 
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 
FALSE FALSE
[26] FALSE
Warning message:
In a == b : longer object length is not a multiple of shorter object 
length

 a%in%b
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE 
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 
FALSE FALSE
[26] FALSE


Regards
Petr

 
 thanks in advance
 
[[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] Sweave encoding problem

2009-01-22 Thread Gerrit Voigt
Hi Roland,
thanks for your answere. I actually tried out a different, smaller  
Latex-header and the sweave-process suddenly worked. So I copied parts 
of the old header into the new one, to check what part is causing the 
trouble. In the end I had two documents with identical content.  The new 
document worked fine with Sweave the other still gave out the 
error-message. If anybody has experienced that problem before, and knows 
an answere, please let me know.
Unfortunaetly I also still have an encoding problem with the new documt, 
that ran through Sweave. If I use  ISO-8859-15 fontencoding in my 
editor and latin1 for input encoding in my Latex-document everything 
works fine. If I keep both in utf8, as I would like it, german mutated 
vowels (Umlaute) aren't displayed correctly.

Rau, Roland schrieb:
 Hi Gerrit,

   
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Gerrit Voigt
 Sent: Monday, January 19, 2009 4:48 PM
 To: r-help@r-project.org
 Subject: [R] Sweave encoding problem

 Hello,
 Sweave seems to have trouble processing german letters in R.
 For example, my noweb R-input looks like this.
 =
 Oberflächenfehler = c(4, 11, 6, 2, 7, 9)
 @
 If I send it through Sweave, I get the following error message.

 error:  chunk 1
 Error in parse(text = chunk) : unexpected input in Oberflä
 extra: Warning message:
 In readLines(f[1]) :
underfull last line in C:\

 (my R is in german, so I needed to translate the error 
 message myself.)

 I got the impression, that this is an encoding issue of 
 Sweave, since  
 the input typed into R directly works just fine. The encoding 
 I use in  
 my noweb document is utf8.
 

 I don't think it has something to do with German letters.
 I saved the following text in a file 'sweavy.Snw':
 \documentclass{article}

 \begin{document}
 Hello World!

 =
 1+1
 @ 

 =
 Oberflächenfehler = c(4, 11, 6, 2, 7, 9)
 @
 \end{document}

 This is what happened in R:
   
 library(utils)
 Sweave(sweavy.Snw)
 
 Writing to file sweavy.tex
 Processing code chunks ...
  1 : echo term verbatim
  2 : echo term verbatim

 You can now run LaTeX on 'sweavy.tex'
   
 sessionInfo()
 
 R version 2.7.0 (2008-04-22) 
 i386-pc-mingw32 

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

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

 And also the dvi looked fine after processing latex sweavy.tex
 To make things sure, I did in my editor (GNU Emacs 22.1.50.1)
 C-x RET f utf-8
 to change 
 set-buffer-file-coding-system to utf-8.
 Still works fine.

 Maybe this helps you further to track down the reason for the problem?!?

 Best,
 Roland

 --
 This mail has been sent through the MPI for Demographic Research.  Should you 
 receive a mail that is apparently from a MPI user without this text 
 displayed, then the address has most likely been faked. If you are uncertain 
 about the validity of this message, please check the mail header or ask your 
 system administrator for assistance.


   


[[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] addressing and summarizing columns of a dataframe in nlme package

2009-01-22 Thread Eva Remke

Hi!

Within the lm function I can address and summarize columns like that:

lm1-lm(I(rowSums(spec[,5:81]))~pH)


If I want to do the same in nlme package I get the following error:

 lme1-lme(I(rowSums(spec[,5:81]))~pH,random=~1|site)
Error in model.frame.default(formula = ~spec + pH + site, data = 
environment,  :

  invalid type (list) for variable 'spec'

These kind of list seem to be not accepted by the lme function and my 
formula misinterpreted.

Variables are pH and site, dataframe is spec and attached.

How can I address and summarize any number of columns of a dataframe in 
the nlme package?



Thanks a lot, cheers
Eva


--
Eva Remke

work
Biological Station, Biologenweg 15, 18565 Kloster/ Insel Hiddensee, Germany
phone   +49 (0)38300 50251
mobile  +49 (0)171 478 3920
fax +49 (0)38300 60672
evare...@gmx.net

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


[R] error using heatmap :evaluation nested too deeply.....

2009-01-22 Thread T Joshi
Hi,
I get following error when trying to plot a heatmap on a very large matrix
(808 x5000).

heatmap(ctab)
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?



 Call to heatmap function is not contained within any other function or so.
Upon searching the R mailing list, I found that someone had the same problem
and the suggested solution was to set an option using options(expressions =
500).

I tried it but even on small subset of the matrix, but it continues  giving
the  same error.  I use default distance matrix with row scaling.



Please help.

[[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] text vector clustering

2009-01-22 Thread srinivasa raghavan
Hi,

I am a new user of R using R 2.8.1 in windows 2003.  I have a  csv file with
single column which contain the 30,000 students names. There were typo
errors while entering this student names. The actual list of names is 
1000. However we dont have that list for keyword search.

 I am interested in grouping/cluster these names   as those which are
similar  letter to letter.  Are there any text clustering algorithm in R
which can group names of similar type in to segments of exactly matching ,
90% matching, 80% matching,etc.

thanks in advance,

regards,
srinivas
statistical analyst.

[[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] Standard errors of least squares adjusted means

2009-01-22 Thread John Fox
Dear Bruno,

See the effects package (on CRAN) for a generalization of adjusted means.

I hope this helps,
 John

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

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Bruno Estigarribia
 Sent: January-22-09 12:32 AM
 To: r-help@r-project.org
 Subject: [R] Standard errors of least squares adjusted means
 
 Hello,
 
 I have the following model:
 lm.7 - lm(Y ~ F + C1 + C2 , data = EM4)
 F is a 4-level factor, the rest are covariates centered at their mean (Y
 is a two-column matrix).
 I have tried to find functions to give the model-adjusted means
 (adjusted at the covariates'means) and their standard deviations for each.
 (That is, what I believe is called in SAS least square or LS-means,
 whose errors one obtains by STDERR)
 I have tried help.search and RSiteSearch with several terms including
 standard errors, least square means, adjusted means. I have found
 how to extract the SE from coefficients (se.coef from package arm), or
 the SE for contrasts (se.contrast from package stats), but not the SE
 for an adjusted mean.
 Thank you,
 
 --
 Bruno Estigarribia
 Postdoctoral Fellow
 FPG Child Development Institute
 Neurodevelopmental Disorders Research Center
 University of North Carolina at Chapel Hill
 
 105 Smith Level Rd
 Chapel Hill, NC 27599-8180
 USA
 + 1 (919) 843-7685
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] pdf() and pch problems

2009-01-22 Thread Robin Hankin

Hi

R-2.8.1,   Suse 11.1

I'm having problems with pdf(). In the following
transcript, file 'f.pdf' does not use the expected symbols for the plot.
It uses a 'q' letter instead of the open circle I get when
viewing the graphics window.

I also get the same under  r47678.

Does anyone else get this?



le112:~/scratch/R-2.8.1% R --vanilla --quiet
 pdf(file='~/f.pdf')
 plot(1:10 , pch=1)
 dev.off()
null device
 1
 sessionInfo()
R version 2.8.1 (2008-12-22)
i686-pc-linux-gnu

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

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

le112:~/scratch/R-2.8.1%








--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread Stefan Björk
Hello helpers,

This is probably quite simple, but I'm stuck.

 I want to create a summary statistics table with frequencies and summary
statistics for a large number of variables. The problem here is that (1)
there are two different classes of categories (sex, type of substance abuse
and type of treatent) which overlap, (2) the data for different variables
should be presented in different ways -- sometimes with relative
frequencies, other times with mean values.

The table would finally look something like:

   All  Male  Female Alcohol Drug ...
Age (mean) (mean) ...
Sex (% male)(freq) (freq) ...
Alcohol CS  (mean) (mean) ...
...  ...

Data is in a data frame with quite a lot of columns (variables) and each row
represents a single case.

I have found out that part of this can be done with tapply, for example
tapply(age, sex, mean) and join it with tapply(age, abuse, mean). But how to
do with frequencies? Or is there an even simpler way?

/S

[[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] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread ronggui
Since %male is basically the mean if you code male=1 and female=0,
which is more informative than absolute frequency. So, you may want to
have a glance at doBy package, especially the summaryBy function.

All the best

On Thu, Jan 22, 2009 at 7:17 PM, Stefan Björk stefan.bj...@gmail.com wrote:
 Hello helpers,

 This is probably quite simple, but I'm stuck.

  I want to create a summary statistics table with frequencies and summary
 statistics for a large number of variables. The problem here is that (1)
 there are two different classes of categories (sex, type of substance abuse
 and type of treatent) which overlap, (2) the data for different variables
 should be presented in different ways -- sometimes with relative
 frequencies, other times with mean values.

 The table would finally look something like:

   All  Male  Female Alcohol Drug ...
 Age (mean) (mean) ...
 Sex (% male)(freq) (freq) ...
 Alcohol CS  (mean) (mean) ...
 ...  ...

 Data is in a data frame with quite a lot of columns (variables) and each row
 represents a single case.

 I have found out that part of this can be done with tapply, for example
 tapply(age, sex, mean) and join it with tapply(age, abuse, mean). But how to
 do with frequencies? Or is there an even simpler way?

 /S

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




-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Homepage: http://ronggui.huang.googlepages.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] pdf() and pch problems

2009-01-22 Thread Brian D Ripley

On Thu, 22 Jan 2009, Robin Hankin wrote:


Hi

R-2.8.1,   Suse 11.1

I'm having problems with pdf(). In the following
transcript, file 'f.pdf' does not use the expected symbols for the plot.
It uses a 'q' letter instead of the open circle I get when
viewing the graphics window.

I also get the same under  r47678.

Does anyone else get this?


Yes, if you use a broken PDF viewer (you have not told us yours). From 
?pdf


useDingbats: logical.  Should small circles be rendered _via_ the
  Dingbats font?  Defaults to true, which produces smaller and
  better output - this is provided for those who insist on
  using broken PDF viewers.

I get the problem in evince but not acroread in F10.





le112:~/scratch/R-2.8.1% R --vanilla --quiet

pdf(file='~/f.pdf')
plot(1:10 , pch=1)
dev.off()

null device
1

sessionInfo()

R version 2.8.1 (2008-12-22)
i686-pc-linux-gnu

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

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base q()
le112:~/scratch/R-2.8.1%








--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  rip...@stats.ox.ac.uk
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] Does anyone has this paper in pdf?

2009-01-22 Thread Neil Shephard



aiminy wrote:
 
 de Jong, S. (1993) SIMPLS: an alternative approach to partial least
 squares 
 regression. Chemometrics and Intelligent Laboratory Systems, 18, 251–263
 
 

Yes, the publishers do, you can purchase it from
http://dx.doi.org/10.1016/0169-7439(93)85002-X

Its a shame that not all journals make their back-catalogue available free
of charge, but I don't see why you expect people on this list to breach
copyright for you?

Neil

-- 
View this message in context: 
http://www.nabble.com/Does-anyone-has-this-paper-in-pdf--tp21594321p21602580.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] Sweave encoding problem

2009-01-22 Thread Duncan Murdoch

Gerrit Voigt wrote:

Hi Roland,
thanks for your answere. I actually tried out a different, smaller  
Latex-header and the sweave-process suddenly worked. So I copied parts 
of the old header into the new one, to check what part is causing the 
trouble. In the end I had two documents with identical content.  The new 
document worked fine with Sweave the other still gave out the 
error-message. If anybody has experienced that problem before, and knows 
an answere, please let me know.
  


This sounds like you have discovered homeopathic properties in Sweave!  
It will be serious if input files remember errors even after they have 
been removed.


But I think it's more likely that the files just look the same in your 
editor, but are actually different in some way you don't see.  Candidates:
- the encoding:  maybe your editor is recognizing the encoding, and 
automatically displaying similar content from different input.

- non-printing characters:  maybe your editor is skipping some.

I'd suggest doing a binary compare on the two files to see what the 
differences are.  I think you are on Windows (but I may be misreading 
the quotes below); I recommend Beyond Compare (a shareware compare 
utility).  It has a hex viewer plug-in that could show you a detailed 
comparison.  I imagine diff on Unix has something similar.


Duncan Murdoch
Unfortunaetly I also still have an encoding problem with the new documt, 
that ran through Sweave. If I use  ISO-8859-15 fontencoding in my 
editor and latin1 for input encoding in my Latex-document everything 
works fine. If I keep both in utf8, as I would like it, german mutated 
vowels (Umlaute) aren't displayed correctly.


Rau, Roland schrieb:
  

Hi Gerrit,

  


-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of Gerrit Voigt

Sent: Monday, January 19, 2009 4:48 PM
To: r-help@r-project.org
Subject: [R] Sweave encoding problem

Hello,
Sweave seems to have trouble processing german letters in R.
For example, my noweb R-input looks like this.
=
Oberflächenfehler = c(4, 11, 6, 2, 7, 9)
@
If I send it through Sweave, I get the following error message.

error:  chunk 1
Error in parse(text = chunk) : unexpected input in Oberflä
extra: Warning message:
In readLines(f[1]) :
   underfull last line in C:\

(my R is in german, so I needed to translate the error 
message myself.)


I got the impression, that this is an encoding issue of 
Sweave, since  
the input typed into R directly works just fine. The encoding 
I use in  
my noweb document is utf8.

  

I don't think it has something to do with German letters.
I saved the following text in a file 'sweavy.Snw':
\documentclass{article}

\begin{document}
Hello World!

=
1+1
@ 


=
Oberflächenfehler = c(4, 11, 6, 2, 7, 9)
@
\end{document}

This is what happened in R:
  


library(utils)
Sweave(sweavy.Snw)

  

Writing to file sweavy.tex
Processing code chunks ...
 1 : echo term verbatim
 2 : echo term verbatim

You can now run LaTeX on 'sweavy.tex'
  


sessionInfo()

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


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

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


And also the dvi looked fine after processing latex sweavy.tex
To make things sure, I did in my editor (GNU Emacs 22.1.50.1)
C-x RET f utf-8
to change 
set-buffer-file-coding-system to utf-8.

Still works fine.

Maybe this helps you further to track down the reason for the problem?!?

Best,
Roland

--
This mail has been sent through the MPI for Demographic Research.  Should you 
receive a mail that is apparently from a MPI user without this text displayed, 
then the address has most likely been faked. If you are uncertain about the 
validity of this message, please check the mail header or ask your system 
administrator for assistance.


  




[[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] Opening a script with the R editor via file association (on Windows)

2009-01-22 Thread Duncan Murdoch

pdewitt wrote:
I read the posting about opening .R files in windows with the Rgui and was 
wondering if anything has changed for R-2.8.1 and Windows Vista?  I have not 
yet been able to get the files to open in the Rgui, the association works 
enough to open R but that is about it.  Thanks for the input.


  
I don't recall anyone submitting code to do that.  It's not easy to get 
it right:  for example, if you click on a file while R is running, you 
probably want to open the file in the current R instance, not open a new 
R session: that means running a program to send a message to R to open 
the file.  And since the R script editor isn't the greatest editor in 
the world, people who would write that sort of thing probably don't use 
it for most of their editing, and have little motivation to do all the work.


So I'd recommend that you should investigate WinEdt, or Tinn-R, or 
Emacs, all of which are much more capable editors, with available 
connections to R.


Duncan Murdoch

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


Re: [R] Sweave encoding problem

2009-01-22 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:

 I'd suggest doing a binary compare on the two files to see what the
 differences are.  I think you are on Windows (but I may be misreading
 the quotes below); I recommend Beyond Compare (a shareware compare
 utility).  It has a hex viewer plug-in that could show you a detailed
 comparison.  I imagine diff on Unix has something similar.

diff -s

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread David Winsemius
One of the various tabulation functions would seem to be the most  
appropriate for getting frequency summaries:


?table
?xtabs

On Jan 22, 2009, at 6:17 AM, Stefan Björk wrote:


Hello helpers,

This is probably quite simple, but I'm stuck.

I want to create a summary statistics table with frequencies and  
summary
statistics for a large number of variables. The problem here is that  
(1)
there are two different classes of categories (sex, type of  
substance abuse
and type of treatent) which overlap, (2) the data for different  
variables

should be presented in different ways -- sometimes with relative
frequencies, other times with mean values.

The table would finally look something like:

  All  Male  Female Alcohol Drug ...
Age (mean) (mean) ...
Sex (% male)(freq) (freq) ...
Alcohol CS  (mean) (mean) ...
...  ...

Data is in a data frame with quite a lot of columns (variables) and  
each row

represents a single case.

I have found out that part of this can be done with tapply, for  
example
tapply(age, sex, mean) and join it with tapply(age, abuse, mean).  
But how to

do with frequencies? Or is there an even simpler way?

/S

[[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] Error as.Date on Invalid Dates

2009-01-22 Thread Terry Therneau
-begin included message 
However, as.Date encounters an error when the string does not represent an
actual date.
eg:
  date1 - 2009-02-29  # Note: 2009 not a leap year
 as.Date(date1)
Error in fromchar(x) :
  character string is not in a standard unambiguous format

As I have many instances of date entries like this, date1, date2, date3,
etc. , I'd like the script to error out gracefully and to be able to point
the user to which date they need to correct, rather than Error in
fromchar(x)..., which doesn't make it obvious what they need to do to fix
the error.

Ideally I'd love to send the user a message like:
print(paste(date1, is an invalid date.  Refer to calendar., sep= ))

If anyone has any suggestions on catching this type of error and feedback
which directs the user, it would be much appreciated.

--- end inclusion -

One idea is to use the as.date function, for the older (and less capable) 
'date' 
class.  This is currently loaded by default with library(survival).  It returns 
NA for an invalid date rather than dying.  

 as.date(c(2009-5-10, 2007/2/29, 1953/3/10), order='ymd')
[1] 10May2009 NA10Mar53  

The order argument in needed here since the default assumption is the US habit 
of month-day-year.

You can then convert to the more modern format.

 temp - as.date(c(2009-5-10, 2007/2/29, 1953/3/10), order='ymd')
 as.Date(temp)
[1] 2009-05-10 NA   1953-03-10

Terry Therneau


Note: as.Date will return a string with NA's as well, AS LONG AS the first date 
in the sequence is legal.  It uses the first to pick a format (I presume).

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

2009-01-22 Thread Häring, Tim (LWF)
Hello List,

 

I`m trying to make prediction using a bagged tree with the package ipred. I 
tried to follow the manual but I`m getting an error message. Also browsing 
through the list-archive I didn`t find any hint. 

Maybe someone can help me?

 

selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)

Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : 

  length of 'dimnames' [2] not equal to array extent

 

I´m using R 2.7.2 on Win XP and the latest version of ipred.

 

Thanks a lot.

TIM

 

--- 

Dipl.-Geogr. Tim Häring

Sachgebiet Standort und Bodenschutz (SG 2.1)

Bayerische Landesanstalt für Wald und Forstwirtschaft

Am Hochanger 11

D-85354 Freising



Tel.: +49-(0)8161/71-4769

E-Mail: tim.haer...@lwf.bayern.de

http://www.lwf.bayern.de






[[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] Error as.Date on Invalid Dates

2009-01-22 Thread Brian D Ripley

On Thu, 22 Jan 2009, Terry Therneau wrote:


-begin included message 
However, as.Date encounters an error when the string does not represent an
actual date.
eg:
 date1 - 2009-02-29  # Note: 2009 not a leap year

as.Date(date1)

Error in fromchar(x) :
 character string is not in a standard unambiguous format

As I have many instances of date entries like this, date1, date2, date3,
etc. , I'd like the script to error out gracefully and to be able to point
the user to which date they need to correct, rather than Error in
fromchar(x)..., which doesn't make it obvious what they need to do to fix
the error.

Ideally I'd love to send the user a message like:
print(paste(date1, is an invalid date.  Refer to calendar., sep= ))

If anyone has any suggestions on catching this type of error and feedback
which directs the user, it would be much appreciated.

--- end inclusion -

One idea is to use the as.date function, for the older (and less capable) 'date'
class.  This is currently loaded by default with library(survival).  It returns
NA for an invalid date rather than dying.


So does as.Date *if you specify the format* (as you have to with your 
as.date: it has a default one):



as.Date(date1, format=%Y-%m-%d)

[1] NA





as.date(c(2009-5-10, 2007/2/29, 1953/3/10), order='ymd')

[1] 10May2009 NA10Mar53

The order argument in needed here since the default assumption is the US habit
of month-day-year.

You can then convert to the more modern format.


temp - as.date(c(2009-5-10, 2007/2/29, 1953/3/10), order='ymd')
as.Date(temp)

[1] 2009-05-10 NA   1953-03-10

Terry Therneau


Note: as.Date will return a string with NA's as well, AS LONG AS the first date
in the sequence is legal.  It uses the first to pick a format (I presume).



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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] pdf() and pch problems

2009-01-22 Thread T . Zumbrunn

Quoting Brian D Ripley rip...@stats.ox.ac.uk:

On Thu, 22 Jan 2009, Robin Hankin wrote:


Hi

R-2.8.1,   Suse 11.1

I'm having problems with pdf(). In the following
transcript, file 'f.pdf' does not use the expected symbols for the plot.
It uses a 'q' letter instead of the open circle I get when
viewing the graphics window.

I also get the same under  r47678.

Does anyone else get this?


Yes, if you use a broken PDF viewer (you have not told us yours). From ?pdf

useDingbats: logical.  Should small circles be rendered _via_ the
  Dingbats font?  Defaults to true, which produces smaller and
  better output - this is provided for those who insist on
  using broken PDF viewers.

I get the problem in evince but not acroread in F10.


The problem is caused by missing fontconfig rules in openSUSE 11.1  
(that the PDF library poppler depends on). I reported the problem a  
while ago here http://bugs.freedesktop.org/show_bug.cgi?id=18002  
(instructions on how to fix the issue are included) and filed a bug at  
the openSUSE bug database  
https://bugzilla.novell.com/show_bug.cgi?id=434676. The bug was  
closed, but I reopened it.






le112:~/scratch/R-2.8.1% R --vanilla --quiet

pdf(file='~/f.pdf')
plot(1:10 , pch=1)
dev.off()

null device
   1

sessionInfo()

R version 2.8.1 (2008-12-22)
i686-pc-linux-gnu

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

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

le112:~/scratch/R-2.8.1%








--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] melt stumbles over deleted columns

2009-01-22 Thread Titus von der Malsburg
I have a data frame that is the result of a cast (reshape) operation.  I
deleted the variable column and tried to melt the resulting data frame.
Depending on which method I use to delete the column I get different
error messages when melting:

 head(tinfos)
  vpn group trial_no item relation trial_type   rt variable  #
1 102 21 4351diag1 distractor 8471fix_d 27
2 102 22 1214   id target 4072fix_d 17
3 102 23 4213diag1 distractor 7040fix_d 27
4 102 24 1314   id target 4370fix_d 15
5 102 25 2655 vert distractor 4397fix_d 17
6 102 26 3322horiz distractor 6132fix_d 26
 tinfos$variable - NULL
 melt(tinfos)
Error: id variables not found in data: variable

Or:

 tinfos2 - tinfos[,-match(variable,names(tinfos))]
 melt(tinfos2)
Error in `rownames-`(`*tmp*`, value = character(0)) :
  attempt to set rownames on object with no dimensions
In addition: Warning messages:
1: In `[-.factor`(`*tmp*`, ri, value = c(8471L, 4072L, 7040L, 4370L,  :
  invalid factor level, NAs generated
2: In `[-.factor`(`*tmp*`, ri, value = c(0L, 0L, 1L, 0L, 0L, 0L, 0L,  :
  invalid factor level, NAs generated

I figure there must be some internal inconsistency in the data frame
after deletion.  Does anybody have an idea how to fix that?

Thanks!

  Titus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] melt stumbles over deleted columns

2009-01-22 Thread hadley wickham
On Thu, Jan 22, 2009 at 8:01 AM, Titus von der Malsburg
malsb...@gmail.com wrote:
 I have a data frame that is the result of a cast (reshape) operation.  I
 deleted the variable column and tried to melt the resulting data frame.
 Depending on which method I use to delete the column I get different
 error messages when melting:

 head(tinfos)
  vpn group trial_no item relation trial_type   rt variable  #
1 102 21 4351diag1 distractor 8471fix_d 27
2 102 22 1214   id target 4072fix_d 17
3 102 23 4213diag1 distractor 7040fix_d 27
4 102 24 1314   id target 4370fix_d 15
5 102 25 2655 vert distractor 4397fix_d 17
6 102 26 3322horiz distractor 6132fix_d 26
 tinfos$variable - NULL
 melt(tinfos)
Error: id variables not found in data: variable

Cast stores some extra information in the data frame that makes future
melting a bit easier, provided that you don't delete any of the
columns.  Since you have, you need to throw away the extra info with:

tinfos - as.data.frame(tinfos)

Regards,

Hadley

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

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


Re: [R] pdf() and pch problems

2009-01-22 Thread Martin Maechler
 TZ == T Zumbrunn t.zumbr...@unibas.ch
 on Thu, 22 Jan 2009 14:52:37 +0100 writes:

TZ Quoting Brian D Ripley rip...@stats.ox.ac.uk:
 On Thu, 22 Jan 2009, Robin Hankin wrote:
 
 Hi
 
 R-2.8.1,   Suse 11.1
 
 I'm having problems with pdf(). In the following
 transcript, file 'f.pdf' does not use the expected symbols for the plot.
 It uses a 'q' letter instead of the open circle I get when
 viewing the graphics window.
 
 I also get the same under  r47678.
 
 Does anyone else get this?
 
 Yes, if you use a broken PDF viewer (you have not told us yours). From 
?pdf
 
 useDingbats: logical.  Should small circles be rendered _via_ the
 Dingbats font?  Defaults to true, which produces smaller and
 better output - this is provided for those who insist on
 using broken PDF viewers.
 
 I get the problem in evince but not acroread in F10.

TZ The problem is caused by missing fontconfig rules in openSUSE 11.1  
TZ (that the PDF library poppler depends on). I reported the problem a  
TZ while ago here http://bugs.freedesktop.org/show_bug.cgi?id=18002  
TZ (instructions on how to fix the issue are included) and filed a bug at  
TZ the openSUSE bug database  
TZ https://bugzilla.novell.com/show_bug.cgi?id=434676. The bug was  
TZ closed, but I reopened it.

That's interesting, thank you very much, Thomas, for the extra
explanation!

As you know (but your text above could be read differently) this
bug ... quite long standing! ... seems to be much wider spread
than just (Open)SuSE.  I have seen and still see it on Redhat
(RHEL 5) and many Ubuntu versions too. 

And indeed, the workaround recommended (somewhere) in the above
URL is working for me too:

Add the following (without the - lines) to your
~/.fonts.conf file (or create such a file) :
--snip-
alias binding=same
 familyZapfDingbats/family
 acceptfamilyDingbats/family/accept
/alias
--snip-

Martin Maechler, ETH Zurich




 le112:~/scratch/R-2.8.1% R --vanilla --quiet
 pdf(file='~/f.pdf')
 plot(1:10 , pch=1)
 dev.off()
 null device
 1
 sessionInfo()
 R version 2.8.1 (2008-12-22)
 i686-pc-linux-gnu
 
 locale:
 
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods 
 base q()
 le112:~/scratch/R-2.8.1%
 
 
 
 
 
 
 
 
 -- 
 Robin K. S. Hankin
 Uncertainty Analyst
 University of Cambridge
 19 Silver Street
 Cambridge CB3 9EP
 01223-764877
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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,  rip...@stats.ox.ac.uk
 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.

TZ __
TZ R-help@r-project.org mailing list
TZ https://stat.ethz.ch/mailman/listinfo/r-help
TZ PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
TZ 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] infer haplotypes phasing trios tdthap

2009-01-22 Thread Tiago R Magalhães

Dear R mailing list,

I have a dataset with genotypes from trios and I would like to infer 
haplotypes for each mother, father and child. The package that I could 
find that can do this is tdthap.


But when the mother is homozygous (e.g., 2/2) the haplotype is called as 
not possible to infer (0); I would prefer for it to call the genotype 
(2). From what I understand it is doing what I would like for the father 
(example below).


Can anyone provide me with some information about this tdthap behaviour? 
And is there any other package that would do this? (Searched for it, 
couldn't find it)


Thank you very much,

Tiago Magalhães



example (ped file with pedigrees)
9 100 102 101 1 2 1 1 2 1 2 2 1 2
9 101 0 0 2 1 1 1 2 1 2 2 2 2
9 102 0 0 1 1 2 1 2 1 2 2 1 1


data out: hap.transmit(example)

pedidfathermother
9  100102   101

f.tr.1f.tr.2f.tr.3f.tr.4   
1 0   2  1


m.tr.1m.tr.2m.tr.3m.tr.4
  00 0  0

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Run R Programs in a Scheduled Way

2009-01-22 Thread Tony Breyal
Hi Thorsten, the way i do this (on Windows Vista Ultimate, SP1) is to
create a batch file and then have windows task scheduler call it at a
specific time. For example, to create my batch file i open up Notepad
and type the following single line into it:


C:\Program Files\R\R-2.8.1\bin\R.exe CMD BATCH --vanilla --slave \
\PFO-SBS001\Redirected\tonyb\Desktop\myScript.R


so this is basically: [location of R.exe] CMD BATCH --vanilla --
slave  [location of your R script file]

I then save this Notepad text file, and change the extension from
'.txt' to '.bat'. If you double click on this .bat file, it will run
your script.

All you have to do now is have scheduler point to your new .bat
file  :-)

HTH,
Tony Breyal

P.S. Be careful with windows scheduler (at least in Vista) if you want
the same script to run several times a day (e.g. setting a daily
trigger starting at 0900 and repeating every 2 hours for a duration of
12 hours). Instead of stopping when expected, it will just keep going
every 2 hours regardless of the duration you set (the only way around
this that i found was to programme in time constraints into my r
script itself, such as only running the script if a condition like
9=current.hour  current.hour=21 are met.)

On 22 Jan, 09:10, Thorsten Muehge mue...@de.ibm.com wrote:
 Hello R Experts,
 does anyone know how to run R programs automatically using the window
 scheduler?

 I want to run some R programs automatically and make the results available
 via web.

 Mit freundlichen Grüßen / Best Regards / С наилучшими 
 Ð¿Ð¾Ð¶ÐµÐ»Ð°Ð½Ð¸Ñ Ð¼Ð¸ /
 üdvözlettel
 Thorsten

         [[alternative HTML version deleted]]

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

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


Re: [R] problem with geepack

2009-01-22 Thread wiersmap

Hi,

I think in such cases you need to use the 'wave' parameter (wave = Date),
but I must admit I found contradictory comments on how missing values are
treated in geepack. Does someone know what geepack is doing with missing
values?

Popko



Giacomo Santini wrote:
 
 Hi all
 
 I am analyzing a data set containing information about the behaviour of 
 marine molluscs on a vertical wall. Since I have replicate observations 
 on the same individuals I was thinking to use the geepack library.
 
 The data are organised in a dataframe with the following variables
 
 Date = date of sampling,
 Size = dimensions (mm)
 Activity duration of activity (min)
 Water = duration of splashing by waves
 Hgt = resting eight of each specimen before activity begin
 Individual = a code indicating the id of the specimen.
 
 I have up to 12 replicate observations for individual. Some observation 
 are missing and I organized the data frame to have exactly 12 rows for 
 each specimen, with NAs where there is a missing observation.
 
 The following model worked fine:
 
 gee1-geese(Activity~Water, id=Individual, data=dataF, family=gaussian)
 
 but when I use other variables e.g
 
 gee2-geese(Activity~Hgt+Size+Water, id=Individual, data=dataF, 
 family=gaussian)
 
 I get the error message
 
 Error in geese.fit(x, y, id, offset, soffset, w, waves, zsca, zcor, 
 corp,  :
   nrow(zsca) and length(y) not match
 
 which I am not able to understand.
 
 The same problem has been reported in the list in 2006, but I have not 
 found any response to it.
 
 Any suggestion?
 
 
 Giacomo
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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/problem-with--geepack-tp15851828p21601979.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] U R ready for R! Now deploy your R models via cloud computing!

2009-01-22 Thread Ajay ohri
Hi Michael,
Can you also build the PMML model on the cloud with R, paying for the
processor ,memory usage. Any plans to extend the abilty to model, or is it
just deploy PMML models on the cloud servers.

Regards,

Ajay

http://www.decisionstats.com

On Thu, Jan 22, 2009 at 4:29 AM, MZ zeller.mich...@gmail.com wrote:

 Following the recent NYT article about R, I thought this group is not
 only ready for R but ready to take it one step further.

 Got models in R? Deploy and score them in ADAPA in minutes on the
 Amazon EC2 cloud computing infrastructure!

 Zementis ( http://www.zementis.com ) has been working with the R
 community, specifically to extend the support for the Predictive Model
 Markup Language (PMML) standard which allows model exchange among
 various statistical software tools (

 http://adapasupport.zementis.com/2008/02/how-can-i-export-pmml-code-from-r.html
 ).

 If you develop your models in R, you can easily deploy and execute
 these models in the Zementis ADAPA scoring engine (
 http://www.zementis.com/products.htm
 ) using the PMML standard. This not only eliminates potential memory
 constraints in R but also speeds execution and allows SOA-based
 integration. For the IT department, ADAPA delivers reliability and
 scalability needed for production-ready deployment and real-time
 predictive analytics.

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


[[alternative HTML version deleted]]

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


Re: [R] plot: abline() - define line length

2009-01-22 Thread Greg Snow
Use either the 'clip' function from the graphics package, or the 'clipplot' 
function from the TeachingDemos package.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Jörg Groß
 Sent: Wednesday, January 21, 2009 5:02 PM
 To: r-help@r-project.org
 Subject: [R] plot: abline() - define line length
 
 Hi,
 
 is there a way to define, that a line drawn via abline() should only
 go from for example -2 to 1 on the x-axis (with something working
 similiar to xlim()) ?
 
 thanks for any help!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Error as.Date on Invalid Dates

2009-01-22 Thread Marie Sivertsen
I am relatively new to R, so maybe I am miss something, but I now
tried the as.Date now and have problems understanding how it works (or
don't work as it seem).


Brian D Ripley wrote:
 On Thu, 22 Jan 2009, Terry Therneau wrote:

 One idea is to use the as.date function, for the older (and less capable) 
 'date'
 class.  This is currently loaded by default with library(survival).  It 
 returns
 NA for an invalid date rather than dying.

 So does as.Date **if you specify the format** (as you have to with your 
 as.date:
 it has a default one):


as.Date(2001/1/1)
Works fine

as.Date(1/1/2001)
Prints 1-01-20 ???

as.Date(13/1/2001)
Prints 13-01-20 ???

as.Date(1/13/2001)
Prints error: not in standard unambigous format

It seems that as if both 1/1/2001 and 13/1/2001 were considered by
R to be in a
standard unambiguous format (or otherwise an error be reported?) and yet they
are parsed incorrectly according to what one could think is obvious.
It is also
surprizing that not only 13/1/2001 but also 1/2/2001 and 2/1/2001 are
successful but incorrect parsed as if they are unambiguous, and yet
13/1/2001 is ambiguous, though there is really just one way to
parse it meaningfully.

I think the strings that are incorrectly parsed should raise errors,
and the last example should be succesful parsed.  What is the reason
for the observed?

Mvh.
Marie

[[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] Finding the distance between ordered integers

2009-01-22 Thread Dale Steele
I'm stuck on how best to of find the distance between ordered integers
(presented below as a birthday problem).  Given the vector x, how do I
most efficiently generate the vector x[i+1] - x[i]?  Thanks.  --Dale

For example...
set.seed(555)
x - sample(1:365, 10, replace=TRUE)
x - sort(x)

x   x[i+1]-x[i]
------
14  
14  0
75  61
136 61
197 61
236 39
253 17
310 57
323 13
355 32

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

2009-01-22 Thread David Winsemius



Simply doing a tabulation and isolating the cases with only one entry  
might have been a possibility if the count discrepancy weren't so  
high. It appears you have a greater degree of corruption than would be  
expected just from typos.


Have you looked at the packages referenced at:

http://cran.r-project.org/web/views/NaturalLanguageProcessing.html

The Soundex algorithm is an old programming chestnut which I have seen  
implemented in R, but I understand there are improved versions. How  
well they perform on persons' names may depend strongly on cultural  
origins of your population.


--
David Winsemius

On Jan 22, 2009, at 6:03 AM, srinivasa raghavan wrote:


Hi,

I am a new user of R using R 2.8.1 in windows 2003.  I have a  csv  
file with

single column which contain the 30,000 students names. There were typo
errors while entering this student names. The actual list of names  
is 

1000. However we dont have that list for keyword search.

I am interested in grouping/cluster these names   as those which are
similar  letter to letter.  Are there any text clustering algorithm  
in R
which can group names of similar type in to segments of exactly  
matching ,

90% matching, 80% matching,etc.

thanks in advance,

regards,
srinivas
statistical analyst.

[[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] Finding the distance between ordered integers

2009-01-22 Thread Jorge Ivan Velez
Dear Dale,
Try this:

set.seed(555)
x - sample(1:365, 10, replace=TRUE)
x - sort(x)
diff(x)

HTH,

Jorge


On Thu, Jan 22, 2009 at 10:07 AM, Dale Steele dale.w.ste...@gmail.comwrote:

 I'm stuck on how best to of find the distance between ordered integers
 (presented below as a birthday problem).  Given the vector x, how do I
 most efficiently generate the vector x[i+1] - x[i]?  Thanks.  --Dale

 For example...
 set.seed(555)
 x - sample(1:365, 10, replace=TRUE)
 x - sort(x)

 x   x[i+1]-x[i]
 ------
 14
 14  0
 75  61
 136 61
 197 61
 236 39
 253 17
 310 57
 323 13
 355 32

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


[[alternative HTML version deleted]]

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


Re: [R] [R-SIG-Finance] how to study the lead and lag relation of two time series?

2009-01-22 Thread Sylvain Barthelemy
Dear Michael,

David Ruelle wrote a very interesting paper on Recurrence plots of
dynamical Systems that you should read, and I remember of simples lead/lags
methods to detect random or determinist systems.

I think that you should take a look at this very interesting paper on
Lead-lag cross-sectional structure and detection of
correlated-anticorrelated regime shifts: http://tinyurl.com/b6cw5m

Regards.

Sylvain

__
Sylvain Barthélémy
Research Director, TAC
Applied Economic  Financial Research
Tel: +33.(0).299.393.140 - Fax: +33.(0).299.393.189
E-mail: ba...@tac-financial.com
www.tac-financial.com | www.sylbarth.com


-Message d'origine-
De : r-sig-finance-boun...@stat.math.ethz.ch
[mailto:r-sig-finance-boun...@stat.math.ethz.ch] De la part de Michael
Envoyé : jeudi 22 janvier 2009 02:18
À : r-help; r-sig-fina...@stat.math.ethz.ch
Objet : [R-SIG-Finance] how to study the lead and lag relation of two time
series?

Hi all,

Is there a way to study the lead and lag relation of two time series?

Let's say I have two time series, At and Bt. Is there a systematic way
of concluding whether it's A leading B or B leading A and by how much?

Thanks!

___
r-sig-fina...@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 

21/01/2009
21:15

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] trouble converting an array to a dataframe

2009-01-22 Thread hadley wickham
On Thu, Jan 22, 2009 at 9:09 AM, Christopher W. Ryan
cr...@binghamton.edu wrote:
 I probably did not explain my data clearly. I am starting with a
 dataframe with three columns:

 redlognumb radiologistbarrtotal

 where the entries in the variable radiologist are either 1 or 2,
 indicating which radiologist generated that barrtotal. All subjects had
 their X-ray read independently by both radiologists. So there are two
 rows for each subject.

 I want to convert it to this structure:

 redlognumbradiologist.1.barrtotalradiologist.2.barrtotal

 in which there is only one row for each subject.

 At any rate, in the meantime, I think I figured out that I was melting
 improperly, and I think I've got it now.  Thanks.

You should just be able to cast like:

cast(m, redlognumb ~ radiologist + variable)

If you haven't already, you might want to look at the introduction
available at http://had.co.nz/reshape

Regards,

Hadley

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

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


[R] help using zeroinfl()

2009-01-22 Thread Simon Pickett
Hi all,

I have been trying to use zeroinfl() with the pscl package with R version 
2.1.1. and with the newest versions of the contrib packages compatible with R 
2.1.1.

I have read the examples, the vignette and all the posts relating to zeroinfl() 
but I am still confused as to how to structure the model.

Here is a small example; the error message is the same for big data sets

library(mvtnorm,lib.loc=C:/Documents and Settings/simonp/My Documents/R backup 
library)
library(pscl,lib.loc=C:/Documents and Settings/simonp/My Documents/R backup 
library)

y-c(0,0.2,0.4,0.7,0,0,0,0.8,0,0,0,0,0)
x-c(3,4,5,2,3,6,3,7,4,8,5,8,3)
m1-zeroinfl(y~x|x)

Zero-Inflated Count Model
Using logit to model zero vs non-zero
Using Poisson for counts
Error in terms.formula(formula, data = data) : 
argument is not a valid model

Can anyone shed any light please?

Simon.

Dr. Simon Pickett
Research Ecologist
Land Use Department
Terrestrial Unit
British Trust for Ornithology
The Nunnery
Thetford
Norfolk
IP242PU
01842750050

[[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] Package installation failed

2009-01-22 Thread Odette Gaston
Hi folks,

I am currently having the problem with using R 2.8.1 that I cannot install
some of packages from CRAN or local drive and somebody may be able to help
me.
ex) faraway package and lme4 package. I have downloaded them in my hard
drive as local, but still R was unable to find the package (message showed
up as no such file). I could download most packages, but not all what I
want. I showed my PC to R experts around and nobody had ideas. I've
re-installed newest R and updated packages hundred times, but still same
message came up.

My working environment is:
OS: XP
Windows
R2.8.1

Any suggestions would be appreciated.
Thanks a lot,
Odette

[[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] robust regression

2009-01-22 Thread Georg Ehret
Dear Miss R,
   I have a large dataset that is skewed and would like to calculate
confidence intervals for my regression line. Unfortunately I have trouble
finding commands for rubust regression and in particular for the confidence
intervals... Can you possibly give a hint?

Thank you and best regards, Gerog.

[[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] convergence problem gamm / lme

2009-01-22 Thread geert aarts





Hope one of you could help with the following question/problem:
We would like to explain the spatial
distribution of juvenile fish. We have 2135 records, from 75 vessels
(code_tripnr) and 7 to 39 observations for each vessel, hence the random effect
for code_tripnr. The offset (‘offsetter’) accounts for the haul duration and
sub sampling factor. There are no extreme outliers in lat/lon. The model we try
to fit is:

 


gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),family=poisson,
niterPQL=200)

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in MEestimate(lmeSt, grps) :

 
NA/NaN/Inf in foreign function call (arg 1)

 

We tried several things. We added some
noise to lon and lat, modelled the density instead of using a count with model
offset, and we normalized the explanatory variables. We also changed several
settings (see models below). 

 

Interestingly, we do manage to fit a more
complex model:

 gamm2-gamm(count~offset(offsetter)+
s(lat,lon,year,dayofyear), random=list(code_tripnr=~1),family=poisson,
correlation = corGaus(0.1, form=~lat + lon)) 

 

The models are fitted using mgcv 1.4-1 and
R 2.7.1 on a 64Bits Debian OS.

 

So there seems to be a convergence problem, correct? And does someone have an 
idea what
might cause this? Secondly are there some tricks/solutions. E.g. perhaps we
could use the results from the more complex model (gamm2 above), but I do not
know exactly how. All help/advice would be greatly appreciated.

 

Kind regards, Geert

 


 


gamm3-gamm(count~offset(offsetter)+s(lon,lat),
random=list(code_tripnr=~1),family=poisson, correlation = corExp(1,
form=~X + Y),nite

rPQL=200)

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in recalc.corSpatial(object[[i]],
conLin) :

 
NA/NaN/Inf in foreign function call (arg 1)

 

 gamm3-gamm(count~offset(offsetter)+s(lon,lat,k=c(1,1)),random=list(code_tripnr=~1),family=poisson,
niterPQL=200)

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in lme.formula(fixed = fixed, random
= random, data = data, correlation = correlation,  :

  nlminb
problem, convergence error code = 1

 
message = false convergence (8)

In addition: Warning messages:

1: In if (k  M + 1) { :

  the
condition has length  1 and only the first element will be used

 

 

.Options$mgcv.vc.logrange=0.001 # we also
tried higher settings


gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),family=poisson,
niterPQL=200, control=lmeControl(opt=optim))

 

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in optim(c(coef(lmeSt)),
function(lmePars) -logLik(lmeSt, lmePars), 
:

 
initial value in 'vmmin' is not finite

 

gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),family=poisson,
niterPQL=200,control=lmeControl(minAbsParApV

ar=0.1))

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in recalc.corSpatial(object[[i]],
conLin) :

 
NA/NaN/Inf in foreign function call (arg 1)

 


gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),family=poisson,
niterPQL=200)

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in MEestimate(lmeSt, grps) :

 
NA/NaN/Inf in foreign function call (arg 1)

 


gamm3-gamm(count~offset(offsetter)+s(lon,lat,k=c(1,1)),random=list(code_tripnr=~1),family=poisson,
niterPQL=200)

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in lme.formula(fixed = fixed, random
= random, data = data, correlation = correlation,  :

 
nlminb problem, convergence
error code = 1

 
message = false convergence (8)

In addition: Warning messages:

1: In if (k  M + 1) { :

  the
condition has length  1 and only the first element will be used

2: In smooth.construct.tp.smooth.spec(object,
dk$data, dk$knots) :

 
basis dimension, k, increased to minimum possible

 

 


gamm3-gamm(count~offset(offsetter)+s(lon,lat,k=c(8,8)),random=list(code_tripnr=~1),family=poisson,
niterPQL=200)

 Maximum number of PQL iterations:  200

iteration 1

iteration 2

Error in lme.formula(fixed = fixed, random
= random, data = data, correlation = correlation,  :

 
nlminb problem, convergence
error code = 1

 
message = false convergence (8)

In addition: Warning messages:

1: In if (k  M + 1) { :

  the
condition has length  1 and only the first element will be used

2: In 1:UZ.len : numerical expression has 2
elements: only the first used

3: In if (p.rank  ncol(XZ)) p.rank
- ncol(XZ) :

  the
condition has length  1 and only the first element will be used

4: In 1:p.rank : numerical expression has 2
elements: only the first used

5: In if (p.rank  k - j) Xf - XZU[,
(p.rank + 1):(k - j), drop = FALSE] else Xf - matrix(0,  :

  the
condition has length  1 and only the first element will be used

6: In (p.rank + 1):(k - j) :

 
numerical expression has 2 elements: only the first used

7: In 1:p.rank : numerical 

Re: [R] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread David Winsemius
You should look at how summary.data.frame does it. (You are, of  
course, re-inventing the wheel.)


You probably ought to also look at the doBy package with its summaryBy  
function. The help page example uses the length function for counts.


I often prefer the output of describe() in Hmisc.

--
David Winsemius
On Jan 22, 2009, at 8:32 AM, David Winsemius wrote:

One of the various tabulation functions would seem to be the most  
appropriate for getting frequency summaries:


?table
?xtabs

On Jan 22, 2009, at 6:17 AM, Stefan Björk wrote:


Hello helpers,

This is probably quite simple, but I'm stuck.

I want to create a summary statistics table with frequencies and  
summary
statistics for a large number of variables. The problem here is  
that (1)
there are two different classes of categories (sex, type of  
substance abuse
and type of treatent) which overlap, (2) the data for different  
variables

should be presented in different ways -- sometimes with relative
frequencies, other times with mean values.

The table would finally look something like:

 All  Male  Female Alcohol Drug ...
Age (mean) (mean) ...
Sex (% male)(freq) (freq) ...
Alcohol CS  (mean) (mean) ...
...  ...

Data is in a data frame with quite a lot of columns (variables) and  
each row

represents a single case.

I have found out that part of this can be done with tapply, for  
example
tapply(age, sex, mean) and join it with tapply(age, abuse, mean).  
But how to

do with frequencies? Or is there an even simpler way?

/S

[[alternative HTML version deleted]]

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


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


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


[R] Simple package question

2009-01-22 Thread Terry Therneau
   With respect to scripts in the tests directory of a package: 
Can they depend on data sets found in the 'data' directory of said package?
-available by default
- need to use a data() call
- need to explicitly attach?

This isn't clear to me from reading the documentation in section 1.1.3 of the
Writing R Extensions document.

Terry Therneau

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


Re: [R] help using zeroinfl()

2009-01-22 Thread Achim Zeileis

On Thu, 22 Jan 2009, Simon Pickett wrote:


Hi all,

I have been trying to use zeroinfl() with the pscl package with R 
version 2.1.1.


That version is ancient, please upgrade.

and with the newest versions of the contrib packages 
compatible with R 2.1.1.


A version number for pscl would have been most helpful. I'm pretty sure 
that this is a version of pscl prior to the re-design of the count 
regression functionality, i.e., a version of the package which does not 
have the vignette you refer to. Surprisingly, the vignette applies to 
the version of the package which actually contains the vignette.


In any case, please use the most recent version of pscl.

I have read the examples, the vignette and all the posts relating to 
zeroinfl() but I am still confused as to how to structure the model.


Here is a small example; the error message is the same for big data sets

library(mvtnorm,lib.loc=C:/Documents and Settings/simonp/My Documents/R backup 
library)


Not needed here.


library(pscl,lib.loc=C:/Documents and Settings/simonp/My Documents/R backup 
library)

y-c(0,0.2,0.4,0.7,0,0,0,0.8,0,0,0,0,0)


Non-integer counts are not allowed. (If these stem from division by some 
offset, please do not divide and use the offset instead.)


hth,
Z


x-c(3,4,5,2,3,6,3,7,4,8,5,8,3)
m1-zeroinfl(y~x|x)

Zero-Inflated Count Model
Using logit to model zero vs non-zero
Using Poisson for counts
Error in terms.formula(formula, data = data) :
   argument is not a valid model

Can anyone shed any light please?

Simon.

Dr. Simon Pickett
Research Ecologist
Land Use Department
Terrestrial Unit
British Trust for Ornithology
The Nunnery
Thetford
Norfolk
IP242PU
01842750050

[[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] Package installation failed

2009-01-22 Thread Uwe Ligges



Odette Gaston wrote:

Hi folks,

I am currently having the problem with using R 2.8.1 that I cannot install
some of packages from CRAN or local drive and somebody may be able to help
me.
ex) faraway package and lme4 package. I have downloaded them in my hard
drive as local, but still R was unable to find the package (message showed
up as no such file). I could download most packages, but not all what I
want. I showed my PC to R experts around and nobody had ideas. I've
re-installed newest R and updated packages hundred times, but still same
message came up.


So, what is the error message when you try, e.g.
 install.packages(lme4) ?

Uwe Ligges




My working environment is:
OS: XP
Windows
R2.8.1

Any suggestions would be appreciated.
Thanks a lot,
Odette

[[alternative HTML version deleted]]

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


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


[R] ggplot2, pretty=FALSE

2009-01-22 Thread Vikas Rawal
The following code used to work on an earlier version of ggplot2. But it gives 
me an error now.

qplot(Year,CDR,data=b3,colour=Phase,geom=c(point,line))-p
p+scale_colour_gradient2(limits=c(1,3), midpoint=2,low=magenta, 
mid=darkgreen, high=blue)-p
(print(p,pretty=F)-p)
print(p,pretty=F)-p

The error is: 
Error in ggplotGrob(x, ...) : unused argument(s) (pretty = FALSE)


In fact, I get the same error when I run the following code from Hadley's site.

p - qplot(wt, mpg, data=mtcars, colour=cyl)
grid.newpage()
pushViewport(viewport(height=0.4, width=0.4, x=0.4, y=0.8))
print(p, newpage=FALSE, pretty=FALSE)

Is there some other way of doing pretty=FALSE in the new version of ggplot2?

Vikas Rawal


[[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] Simple package question

2009-01-22 Thread Uwe Ligges



Terry Therneau wrote:
   With respect to scripts in the tests directory of a package: 
Can they depend on data sets found in the 'data' directory of said package?

-available by default
- need to use a data() call
- need to explicitly attach?



Terry,

you need to load the package and then it depends on your package's 
settings. If you need to load the data by data() when your package is 
installed, you will also need a call to data() in your test scripts.

So for short, it behaves like your regularly installed package.

Best,
Uwe



This isn't clear to me from reading the documentation in section 1.1.3 of the
Writing R Extensions document.

Terry Therneau

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Confused about behavior of an S4 object containing a ts object

2009-01-22 Thread Lyman, Mark
I posted the question below about a month ago but received no response.
I still have not been able to figure out what is happening.

I also noticed another oddity. When the data part of the object is a
multivariate time series, it doesn't show up in the structure, but it
can be treated as a multivariate time series. Is this a bug in str?

 setClass(tsExtended, representation = representation(description 
+ = character), contains = ts)
[1] tsExtended
 tmp - new(tsExtended, matrix(1:20, ncol=2), description = My Time
Series)
 tsp(tmp) - c(1, 5.5, 2)
 tmp
Object of class tsExtended
Time Series:
Start = c(1, 1) 
End = c(5, 2) 
Frequency = 2 
Series 1 Series 2
1.01   11
1.52   12
2.03   13
2.54   14
3.05   15
3.56   16
4.07   17
4.58   18
5.09   19
5.5   10   20
Slot description:
[1] My Time Series

 str(tmp)
Formal class 'tsExtended' [package .GlobalEnv] with 4 slots
  ..@ .Data  : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  ..@ description: chr My Time Series
  ..@ tsp: num [1:3] 1 5.5 2
  ..@ .S3Class   : chr ts
 tmp[,1]
Time Series:
Start = c(1, 1) 
End = c(5, 2) 
Frequency = 2 
 [1]  1  2  3  4  5  6  7  8  9 10
 plot(tmp[,2])

Mark Lyman


-Original Message-
From: Lyman, Mark 
Sent: Thursday, December 18, 2008 1:02 PM
To: 'r-help@r-project.org'
Subject: Confused about behavior of an S4 object containing a ts object

I am trying to define an S4 class that contains a ts class object, a
simple 
example is shown in the code below. However, when I try to create a new
object 
of this class the tsp part is ignored, see below. Am I doing something
wrong, 
or is this just a peril of mixing S3 and S4 objects?

 setClass(tsExtended, representation = representation(description 
= character), contains = ts)
[1] tsExtended
 new(tsExtended, ts(1:10, frequency = 2), description = My Time
Series)
Object of class tsExtended
Time Series:
Start = 1
End = 10
Frequency = 1
 [1]  1  2  3  4  5  6  7  8  9 10
Slot description:
[1] My Time Series

 # This however seems to work
 tmp - new(tsExtended, 1:10, description = My Time Series)
 tsp(tmp) - c(1, 5.5, 2)
 tmp
Object of class tsExtended
Time Series:
Start = c(1, 1)
End = c(5, 2)
Frequency = 2
 [1]  1  2  3  4  5  6  7  8  9 10
Slot description:
[1] My Time Series

Mark Lyman, Statistician
Engineering Systems  Integration, ATK

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] blowup portion of graph beside it

2009-01-22 Thread rajesh j
Hi,

I'd like to blow up portions of my graph and put it in boxes beside the
graph.Is there an addon to do this?

-- 
Rajesh.J

[[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] quantile question

2009-01-22 Thread ANJAN PURKAYASTHA
Hi,
A simple quantile question:
I need to calculate the 95% and 5% quantiles (aka percentiles) for the
following data:
67.12
64.51
62.06
55.45
51.41
43.78
10.74
10.14

if I use the formula: 95% quantile point= 95 (8+1)/100, I get the 8.55th
point as the 95% quantile. Which does not make too much sense as I have only
8 data points.
The other option is to use (95*8)/100 = 7.6th data point (which can be found
by interpolation between the 7th and 8th data points).
Reportedly, the second formula is not too accurate. However in my case the
first formula does not make much sense.

Any advice?

TIA,
Anjan

-- 
=
anjan purkayastha, phd
bioinformatics analyst
whitehead institute for biomedical research
nine cambridge center
cambridge, ma 02142

purkayas [at] wi [dot] mit [dot] edu
703.740.6939

[[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] robust regression

2009-01-22 Thread David Winsemius

On Jan 22, 2009, at 11:06 AM, Georg Ehret wrote:


Dear Miss R,
  I have a large dataset that is skewed and would like to calculate
confidence intervals for my regression line. Unfortunately I have  
trouble


finding commands for rubust regression and in particular for the  
confidence

intervals... Can you possibly give a hint?


Such difficulty is inexplicable.

Search with Google for robust regression and add r-project to your  
search string for narrowing.
(First hit is John Fox's 4 page addendum to CAR with worked examples.  
Many hundreds of hits but with high chance that the count is inflated.  
Further addition of confidence intervals still produces hundreds of  
results.)


Search r-site-search for robust regression
http://search.r-project.org/nmz.html
(roughly 300 hits)

See also the CRAN TAsk View on Robust Statistical Methods:
http://cran.r-project.org/web/views/Robust.html

(I have had very satisfactory results with Koenker's quantreg package  
functions, but you have provided insufficient description of a) the  
data, b) the domain of analysis, or c) your goals to allow any comment  
on the need or applicability of methods to your tasks.)


--
David Winsemius



Thank you and best regards, Gerog.

[[alternative HTML version deleted]]

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


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


[R] ggplot2

2009-01-22 Thread Vikas Rawal
I have been struggling to get the legends in ggplot2 right or do away with them 
altogether (on which I have already sent a post). 

In the following code, the labels argument in the scale_colour_gradient2 does 
not give me the desired labels in the legend. Could someone explain?

qplot(Year,CDR,data=b3,colour=Phase,geom=c(point,line),legend.position=bottom)-p
p+scale_colour_gradient2(limits=c(1,2), midpoint=1,low=magenta, 
mid=magenta, high=darkblue,breaks=c(1,2),labels=c(a,b)-p
p

Vikas


[[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] blowup portion of graph beside it

2009-01-22 Thread Greg Snow
Here is one way:

tmpmat - cbind( c(1,1), c(1,1), c(2,3) )
layout(tmpmat)

with(iris, plot(Sepal.Width, Sepal.Length, 
col=c('red','green','blue')[Species]))
with(iris, plot(Sepal.Width, Sepal.Length, col=c('red','green','blue')[Species],
xlim=c(2.5,3), ylim=c(6,6.5)))
with(iris, plot(Sepal.Width, Sepal.Length, col=c('red','green','blue')[Species],
xlim=c(2.5,3.5), ylim=c(4.5,5.5)))

If that is not what you want, then give more detail so we can help better.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of rajesh j
 Sent: Thursday, January 22, 2009 9:51 AM
 To: r-help@r-project.org
 Subject: [R] blowup portion of graph beside it
 
 Hi,
 
 I'd like to blow up portions of my graph and put it in boxes beside the
 graph.Is there an addon to do this?
 
 --
 Rajesh.J
 
   [[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] quantile question

2009-01-22 Thread Greg Snow
Read the help page for the quantile function (the whole page, there is a lot of 
good detail in there), the 2nd reference on the page should also be a helpful 
read.  

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of ANJAN PURKAYASTHA
 Sent: Thursday, January 22, 2009 9:52 AM
 To: r-help@r-project.org
 Subject: [R] quantile question
 
 Hi,
 A simple quantile question:
 I need to calculate the 95% and 5% quantiles (aka percentiles) for the
 following data:
 67.12
 64.51
 62.06
 55.45
 51.41
 43.78
 10.74
 10.14
 
 if I use the formula: 95% quantile point= 95 (8+1)/100, I get the
 8.55th
 point as the 95% quantile. Which does not make too much sense as I have
 only
 8 data points.
 The other option is to use (95*8)/100 = 7.6th data point (which can be
 found
 by interpolation between the 7th and 8th data points).
 Reportedly, the second formula is not too accurate. However in my case
 the
 first formula does not make much sense.
 
 Any advice?
 
 TIA,
 Anjan
 
 --
 =
 anjan purkayastha, phd
 bioinformatics analyst
 whitehead institute for biomedical research
 nine cambridge center
 cambridge, ma 02142
 
 purkayas [at] wi [dot] mit [dot] edu
 703.740.6939
 
   [[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] quantile question

2009-01-22 Thread Dimitris Rizopoulos

have a look at the online help file of ?quantile(); check also:

x - c(67.12, 64.51, 62.06, 55.45, 51.41, 43.78, 10.74, 10.14)
sapply(1:9, function (i) quantile(x, c(0.05, 0.95), type = i))


I hope it helps.

Best,
Dimitris


ANJAN PURKAYASTHA wrote:

Hi,
A simple quantile question:
I need to calculate the 95% and 5% quantiles (aka percentiles) for the
following data:
67.12
64.51
62.06
55.45
51.41
43.78
10.74
10.14

if I use the formula: 95% quantile point= 95 (8+1)/100, I get the 8.55th
point as the 95% quantile. Which does not make too much sense as I have only
8 data points.
The other option is to use (95*8)/100 = 7.6th data point (which can be found
by interpolation between the 7th and 8th data points).
Reportedly, the second formula is not too accurate. However in my case the
first formula does not make much sense.

Any advice?

TIA,
Anjan



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-01-22 Thread Marcin Kozak
Hi,

It seems there is no straightforward way to carry out in R the loess
fitting with bisquare, as given by William Cleveland in his
Visualizing Data. Am I right?

Thanks in advance,
Marcin

--
Build up your weaknesses until they become your strong points -- Knute Rockne

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] write.fasta (seqinr package)

2009-01-22 Thread joseph
Hi
I would like to use 'write.fasta(sequences, names, nbchar = 60, file.out, open 
= w)' to convert a DNA sequence in a text file to fasta format.
How do I read the the text file to prepare the argument 'sequences' of the 
function.
The DNA sequence in the text file is one line as below:
ATCACACAACGACACTCACCCTGGACGCTCATC.
Thank you 



  
[[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] quantile question

2009-01-22 Thread ANJAN PURKAYASTHA
Thanks all for your prompt and helpful replies!
Anjan

On Thu, Jan 22, 2009 at 11:52 AM, ANJAN PURKAYASTHA 
anjan.purkayas...@gmail.com wrote:

 Hi,
 A simple quantile question:
 I need to calculate the 95% and 5% quantiles (aka percentiles) for the
 following data:
 67.12
 64.51
 62.06
 55.45
 51.41
 43.78
 10.74
 10.14

 if I use the formula: 95% quantile point= 95 (8+1)/100, I get the 8.55th
 point as the 95% quantile. Which does not make too much sense as I have only
 8 data points.
 The other option is to use (95*8)/100 = 7.6th data point (which can be
 found by interpolation between the 7th and 8th data points).
 Reportedly, the second formula is not too accurate. However in my case the
 first formula does not make much sense.

 Any advice?

 TIA,
 Anjan

 --
 =
 anjan purkayastha, phd
 bioinformatics analyst
 whitehead institute for biomedical research
 nine cambridge center
 cambridge, ma 02142

 purkayas [at] wi [dot] mit [dot] edu
 703.740.6939




-- 
=
anjan purkayastha, phd
bioinformatics analyst
whitehead institute for biomedical research
nine cambridge center
cambridge, ma 02142

purkayas [at] wi [dot] mit [dot] edu
703.740.6939

[[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] maintaining variable types in data frames

2009-01-22 Thread Mike Miller
Suppose X and Y are two data frames with the same structures, variable 
names and dimensions but with different data and different patterns of 
missing.  I want to replace missing values in Y with corresponding values 
from X.  I'll construct a simple two-by-two case:



X - as.data.frame(matrix(c(a,b,1,2),2,2), stringsAsFactors=FALSE)
X[,2] - as.integer(X[,2])
str(X)

'data.frame':   2 obs. of  2 variables:
  $ V1: chr  a b
  $ V2: int  1 2


Y - as.data.frame(matrix(c(c,d,NA,4),2,2), stringsAsFactors=FALSE)
Y[,2] - as.integer(Y[,2])
str(Y)

'data.frame':   2 obs. of  2 variables:
  $ V1: chr  c d
  $ V2: int  NA 4

This seems to be what I want to do...


Y[is.na(Y)] - X[is.na(Y)]


...and it works except that the structure of Y is changed so that Y$V2 is 
now of type chr instead of type int:



str(Y)

'data.frame':   2 obs. of  2 variables:
  $ V1: chr  c d
  $ V2: chr  1 4

This behavior makes sense because the vector X[is.na(Y)] is of the 
character type:



is.character(X[is.na(Y)])

[1] TRUE

str(X[is.na(Y)])

  chr 1

X[is.na(Y)]

[1] 1

The last couple of results seem weird at first.  The 1 was originally an 
integer but now it is a character.  This *must* be because the typing is 
done at an earlier stage in the process, back when R decides which 
elements of X have to be checked against the logical matrix is.na(Y).  It 
then decides the type for the vector and only afterward does it find that 
only one of the four elements of X will be selected, but it was prepared 
from that early stage for any of the four, even all four of them, to be 
selected.


Suppose there were no NA elements in Y, what should we expect to see if we 
repeat what we did above?



Y - as.data.frame(matrix(c(c,d,3,4),2,2), stringsAsFactors=FALSE)
Y[,2] - as.integer(Y[,2])
str(Y)

'data.frame':   2 obs. of  2 variables:
  $ V1: chr  c d
  $ V2: int  3 4

Even though there are no elements in X[is.na(Y)], the null element is of 
type chr:



is.vector(X[is.na(Y)])

[1] TRUE

is.character(X[is.na(Y)])

[1] TRUE

str(X[is.na(Y)])

  chr(0)

X[is.na(Y)]

character(0)

So what happens if we do this...


Y[is.na(Y)] - X[is.na(Y)]


...will it change the structure of Y so that Y$V2 becomes type chr?


str(Y)

'data.frame':   2 obs. of  2 variables:
  $ V1: chr  c d
  $ V2: int  3 4

No.  I think there is an obvious reason for that:  Y was not changed, and 
more specifically, Y$V2 was not changed, so no change was made to the 
variable types.


It all makes sense, but I want an easy way to maintain the structure of a 
data frame when I do this kind of operation. I ought to be able to do 
something like this:


Ytypes - get_types(Y)

Y[is.na(Y)] - X[is.na(Y)]

use_types(Y, Ytypes)

That kind of system would ensure that the basic structure of the data 
frame can be maintained.  I don't want to have to check by hand, and 
sometimes it would be impossible to do so.


So what's the trick?  Is there a trick?

Mike

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

2009-01-22 Thread Greg Snow
The loess function in R uses the tricube weights that are described in my copy 
of Cleveland, so that may do what you want.  If you really want to do the same 
general idea but with a different weight function, then it is not that hard to 
write your own function to do the estimating (but I doubt that you will see 
much improvement over the standard loess function).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Marcin Kozak
 Sent: Thursday, January 22, 2009 10:08 AM
 To: r-help@r-project.org
 Subject: [R] Loess fitting with bisquare
 
 Hi,
 
 It seems there is no straightforward way to carry out in R the loess
 fitting with bisquare, as given by William Cleveland in his
 Visualizing Data. Am I right?
 
 Thanks in advance,
 Marcin
 
 --
 Build up your weaknesses until they become your strong points --
 Knute Rockne
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Loess fitting with bisquare

2009-01-22 Thread Christian Ritz
Hi,

doing a search in R gives

help.search(loess)
?loess


Look out for the family argument in the help page.


Christian

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


Re: [R] title: words in different colors?

2009-01-22 Thread Barry Rowlingson
Here's my version of the technicolor title function:

multiTitle - function(...){
###
### multi-coloured title
###
### examples:
###  multiTitle(color=red,Traffic,
### color=orange, light ,
### color=green,signal)
###
### - note triple backslashes needed for embedding quotes:
###
###  multiTitle(color=orange,Hello ,
### color=red, \\\world\\\!)
###
### Barry Rowlingson b.rowling...@lancaster.ac.uk
###
  l = list(...)
  ic = names(l)=='color'
  colors = unique(unlist(l[ic]))

  for(i in colors){
color=par()$col.main
strings=c()
for(il in 1:length(l)){
  p = l[[il]]
  if(ic[il]){ # if this is a color:
if(p==i){  # if it's the current color
  current=TRUE
}else{
  current=FALSE
}
  }else{ # it's some text
if(current){
  # set as text
  strings = c(strings,paste('',p,'',sep=))
}else{
  # set as phantom
  strings = c(strings,paste(phantom(\,p,\),sep=))
}
  }
} # next item
## now plot this color
prod=paste(strings,collapse=*)
express = paste(expression(,prod,),sep=)
e=eval(parse(text=express))
title(e,col.main=i)
  } # next color
  return()
}

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

2009-01-22 Thread Uwe Ligges



Häring, Tim (LWF) wrote:

Hello List,

 

I`m trying to make prediction using a bagged tree with the package ipred. I tried to follow the manual but I`m getting an error message. Also browsing through the list-archive I didn`t find any hint. 


Maybe someone can help me?

 


selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)

Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : 


  length of 'dimnames' [2] not equal to array extent

 


I´m using R 2.7.2 on Win XP and the latest version of ipred.



Please do read the posting guide.

- We do not have traindat.bin, hence cannot reproduce your problem
- Does it happen with recent versions of R and ipred?

Best,
Uwe Ligges




 


Thanks a lot.

TIM

 

--- 


Dipl.-Geogr. Tim Häring

Sachgebiet Standort und Bodenschutz (SG 2.1)

Bayerische Landesanstalt für Wald und Forstwirtschaft

Am Hochanger 11

D-85354 Freising



Tel.: +49-(0)8161/71-4769

E-Mail: tim.haer...@lwf.bayern.de

http://www.lwf.bayern.de






[[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] infer haplotypes phasing trios tdthap

2009-01-22 Thread Jing Hua Zhao
Dear Tiago,

I received this message from r-help. I should say I have limited experiences 
with tdthap so David should have the final say about it? Alternatively, you may 
wish to use independent programs as listed in the linkage server at Rockefeller?

I would of course find out if I have miscopied David's original code!

Many thanks,


Jing Hua

-Original Message-
From: Tiago R Magalhães [mailto:tiag...@gmail.com] 
Sent: 22 January 2009 11:10
To: r-help@R-project.org
Subject: infer haplotypes phasing trios tdthap

Dear R mailing list,

I have a dataset with genotypes from trios and I would like to infer 
haplotypes for each mother, father and child. The package that I could 
find that can do this is tdthap.

But when the mother is homozygous (e.g., 2/2) the haplotype is called as 
not possible to infer (0); I would prefer for it to call the genotype 
(2). From what I understand it is doing what I would like for the father 
(example below).

Can anyone provide me with some information about this tdthap behaviour? 
And is there any other package that would do this? (Searched for it, 
couldn't find it)

Thank you very much,

Tiago Magalhães



example (ped file with pedigrees)
9 100 102 101 1 2 1 1 2 1 2 2 1 2
9 101 0 0 2 1 1 1 2 1 2 2 2 2
9 102 0 0 1 1 2 1 2 1 2 2 1 1


data out: hap.transmit(example)

pedidfathermother
9  100102   101

f.tr.1f.tr.2f.tr.3f.tr.4   
1 0   2  1

m.tr.1m.tr.2m.tr.3m.tr.4
   00 0  0

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Converting ddf/dct/sas data definition file to R

2009-01-22 Thread Stephan Lindner
Dear all,

I was wondering whether anyone knows about a program which converts
(part of) a data definition file (such as a .dct file for stata, or
.sas file for sas) into an R-script.

Here is an example with a .sas file: 

-- snipp 

VALUE HTYPE (default=32)
0 =  Not in household  
1 =  Married couple family household
2 =  Male householder family   
3 =  Female householder family 
4 =  Male householder nonfamily
5 =  Female householder nonfamily  
6 =  Group quarters
;

snapp -- 


This entry defines the variable HTYPE as a factor and assigns levels
and labels. Ideally, it would be transformed into the following entry
in R:


data.frame$HTYPE - factor(data.frame$HTYPE,
levels=c(0,1,2,3,4,5,6),
labels=c(Not in household,  
 Married couple family household,
 Male householder family,   
 Female householder family, 
 Male householder nonfamily,
 Female householder nonfamily,  
 Group quarters
)
)


Of course, this can be done by hand and isn't too bad with a good text
editor. The reason why I am looking for a program is because I have a
bunch of datasets (about 100) and there are about 200 variables defined
per dataset. My goal is to provide R-scripts for these datasets such
that the data files can be read in with R, making them accessible for
R users. 



Thanks! 


Stephan






-- 
---
Stephan Lindner
University of Michigan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)

2009-01-22 Thread Marie Sivertsen
Dear Brian,

I dont understand what you mean.  The thread was about the as.Date which you
suggested to be used instead of the as.date.  Following your advice I tried
the as.Date and have questions about the observed behaviour, which was
surprising to me.  Is this what you call hijacking?  Do you mean I ought
start a new thread instead?  I thought my question were relevant to the
threads' subject.  I am sorry if it were not.

So here is the questions once again:  why do the as.Date behave as in my
examples below, is this intended?



On Thu, Jan 22, 2009 at 3:55 PM, Brian D Ripley rip...@stats.ox.ac.ukwrote:

 You've hijacked a thread here.


 On Thu, 22 Jan 2009, Marie Sivertsen wrote:


 I am relatively new to R, so maybe I am miss something, but I now tried
 the a
 s.Date now and have problems understanding how it works (or don't work as
 it seem).

 Brian D Ripley wrote:
  On Thu, 22 Jan 2009, Terry Therneau wrote:
 
  One idea is to use the as.date function, for the older (and less
 capable) 'date'
  class.  This is currently loaded by default with library(survival).  It
 re
 turns

  NA for an invalid date rather than dying.
 
  So does as.Date *if you specify the format* (as you have to with your
 as.da
 te:
  it has a default one):



My examples:




 as.Date(2001/1/1)
 Works fine
 as.Date(1/1/2001)
 Prints 1-01-20 ???
 as.Date(13/1/2001)
 Prints 13-01-20 ???

 as.Date(1/13/2001)
 Prints error: not in standard unambigous format
 It seems that as if both 1/1/2001 and 13/1/2001 were considered by R
 to b
 e in a standard unambiguous format (or otherwise an error be reported?)
 and yet they


 are parsed incorrectly according to what one could think is obvious.  It
 is a
 lso surprizing that not only 13/1/2001 but also 1/2/2001 and
 2/1/2001 are successful but incorrect parsed as if they are unambiguous,
 and yet
 13/1/2001 is ambiguous, though there is really just one way to parse it
 meaningfully.
 I think the strings that are incorrectly parsed should raise errors, and
 the last example should be succesful parsed.  What is the reason for the
 observed
 ?





Mvh.
Marie





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


[[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] Converting ddf/dct/sas data definition file to R

2009-01-22 Thread Frank E Harrell Jr
The sas.get function in the Hmisc package, or the sasxport.get function, 
will do what you want by a different approach.


Frank

Stephan Lindner wrote:

Dear all,

I was wondering whether anyone knows about a program which converts
(part of) a data definition file (such as a .dct file for stata, or
.sas file for sas) into an R-script.

Here is an example with a .sas file: 

-- snipp 


VALUE HTYPE (default=32)
	0 =  Not in household  
	1 =  Married couple family household
	2 =  Male householder family   
	3 =  Female householder family 
	4 =  Male householder nonfamily
	5 =  Female householder nonfamily  
	6 =  Group quarters
;


snapp -- 



This entry defines the variable HTYPE as a factor and assigns levels
and labels. Ideally, it would be transformed into the following entry
in R:


data.frame$HTYPE - factor(data.frame$HTYPE,
levels=c(0,1,2,3,4,5,6),
	labels=c(Not in household,  
		 Married couple family household,
		 Male householder family,   
		 Female householder family, 
		 Male householder nonfamily,
		 Female householder nonfamily,  
		 Group quarters

)
)


Of course, this can be done by hand and isn't too bad with a good text

editor. The reason why I am looking for a program is because I have a
bunch of datasets (about 100) and there are about 200 variables defined
per dataset. My goal is to provide R-scripts for these datasets such
that the data files can be read in with R, making them accessible for
R users. 




Thanks! 



Stephan









--
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] Loess fitting with bisquare

2009-01-22 Thread Bert Gunter
If you you use robust fitting (family = symmetric), there are (at least)
two sets of weights used (and documented in the Help file): tricube weights
are used to weight the points by their distances from the current point
being estimated; bisquare weights are used in the robust fit to weight by
scaled residual size.

-- Bert Gunter
Genentech

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Greg Snow
Sent: Thursday, January 22, 2009 9:38 AM
To: Marcin Kozak; r-help@r-project.org
Subject: Re: [R] Loess fitting with bisquare

The loess function in R uses the tricube weights that are described in my
copy of Cleveland, so that may do what you want.  If you really want to do
the same general idea but with a different weight function, then it is not
that hard to write your own function to do the estimating (but I doubt that
you will see much improvement over the standard loess function).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Marcin Kozak
 Sent: Thursday, January 22, 2009 10:08 AM
 To: r-help@r-project.org
 Subject: [R] Loess fitting with bisquare
 
 Hi,
 
 It seems there is no straightforward way to carry out in R the loess
 fitting with bisquare, as given by William Cleveland in his
 Visualizing Data. Am I right?
 
 Thanks in advance,
 Marcin
 
 --
 Build up your weaknesses until they become your strong points --
 Knute Rockne
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Converting ddf/dct/sas data definition file to R

2009-01-22 Thread Stephan Kolassa

Hi Stephan,

Does the foreign package help?

HTH,
(another) Stephan


Stephan Lindner schrieb:

Dear all,

I was wondering whether anyone knows about a program which converts
(part of) a data definition file (such as a .dct file for stata, or
.sas file for sas) into an R-script.

Here is an example with a .sas file: 

-- snipp 


VALUE HTYPE (default=32)
	0 =  Not in household  
	1 =  Married couple family household
	2 =  Male householder family   
	3 =  Female householder family 
	4 =  Male householder nonfamily
	5 =  Female householder nonfamily  
	6 =  Group quarters
;


snapp -- 



This entry defines the variable HTYPE as a factor and assigns levels
and labels. Ideally, it would be transformed into the following entry
in R:


data.frame$HTYPE - factor(data.frame$HTYPE,
levels=c(0,1,2,3,4,5,6),
	labels=c(Not in household,  
		 Married couple family household,
		 Male householder family,   
		 Female householder family, 
		 Male householder nonfamily,
		 Female householder nonfamily,  
		 Group quarters

)
)


Of course, this can be done by hand and isn't too bad with a good text

editor. The reason why I am looking for a program is because I have a
bunch of datasets (about 100) and there are about 200 variables defined
per dataset. My goal is to provide R-scripts for these datasets such
that the data files can be read in with R, making them accessible for
R users. 




Thanks! 



Stephan








__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)

2009-01-22 Thread Gabor Grothendieck
The first number is the year,
the second is the month and the third is the day.
It ignores trailing characters.

 library(chron)
 f - function(x) str(month.day.year(as.Date(x)))

 f(2001/1/1)
List of 3
 $ month: num 1
 $ day  : num 1
 $ year : num 2001

 f(1/1/2001)
List of 3
 $ month: num 1
 $ day  : num 20
 $ year : num 1

 # trailing 01 ignored.
 f(13/1/2001)
List of 3
 $ month: num 1
 $ day  : num 20
 $ year : num 13

 # no 13th month
 as.Date(1/13/2001)
Error in fromchar(x) :
  character string is not in a standard unambiguous format

On Thu, Jan 22, 2009 at 1:54 PM, Marie Sivertsen mariesiv...@gmail.com wrote:
 Dear Brian,

 I dont understand what you mean.  The thread was about the as.Date which you
 suggested to be used instead of the as.date.  Following your advice I tried
 the as.Date and have questions about the observed behaviour, which was
 surprising to me.  Is this what you call hijacking?  Do you mean I ought
 start a new thread instead?  I thought my question were relevant to the
 threads' subject.  I am sorry if it were not.

 So here is the questions once again:  why do the as.Date behave as in my
 examples below, is this intended?



 On Thu, Jan 22, 2009 at 3:55 PM, Brian D Ripley rip...@stats.ox.ac.ukwrote:

 You've hijacked a thread here.


 On Thu, 22 Jan 2009, Marie Sivertsen wrote:


 I am relatively new to R, so maybe I am miss something, but I now tried
 the a
 s.Date now and have problems understanding how it works (or don't work as
 it seem).

 Brian D Ripley wrote:
  On Thu, 22 Jan 2009, Terry Therneau wrote:
 
  One idea is to use the as.date function, for the older (and less
 capable) 'date'
  class.  This is currently loaded by default with library(survival).  It
 re
 turns

  NA for an invalid date rather than dying.
 
  So does as.Date *if you specify the format* (as you have to with your
 as.da
 te:
  it has a default one):



 My examples:




 as.Date(2001/1/1)
 Works fine
 as.Date(1/1/2001)
 Prints 1-01-20 ???
 as.Date(13/1/2001)
 Prints 13-01-20 ???

 as.Date(1/13/2001)
 Prints error: not in standard unambigous format
 It seems that as if both 1/1/2001 and 13/1/2001 were considered by R
 to b
 e in a standard unambiguous format (or otherwise an error be reported?)
 and yet they


 are parsed incorrectly according to what one could think is obvious.  It
 is a
 lso surprizing that not only 13/1/2001 but also 1/2/2001 and
 2/1/2001 are successful but incorrect parsed as if they are unambiguous,
 and yet
 13/1/2001 is ambiguous, though there is really just one way to parse it
 meaningfully.
 I think the strings that are incorrectly parsed should raise errors, and
 the last example should be succesful parsed.  What is the reason for the
 observed
 ?





 Mvh.
 Marie





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


[[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] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)

2009-01-22 Thread Greg Snow
I believe the original thread was about whether the function returns NA or 
stops with an error when given an invalid date (such as Feb 29 in a non-leap 
year).  Your question was about how as.Date returned something different from 
what you expected.  Related, but different enough that it probably would have 
been better to start a new thread.

For your question, the help page for as.Date includes:

  format: A character string.  The default is '%Y-%m-%d'.  For
  details see 'strftime'.

And 

Character strings are processed as far as
 necessary for the format specified: any trailing characters are
 ignored.

I don't see anything in your examples that runs counter to the above.

Remember that computers do exactly what you tell them to do, not what you think 
that they should do.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Marie Sivertsen
 Sent: Thursday, January 22, 2009 11:55 AM
 To: Brian D Ripley; r-h...@stat.math.ethz.ch
 Subject: [R] Unexpected behaviour of the as.Date (was: Error as.Date on
 Invalid Dates)
 
 Dear Brian,
 
 I dont understand what you mean.  The thread was about the as.Date
 which you
 suggested to be used instead of the as.date.  Following your advice I
 tried
 the as.Date and have questions about the observed behaviour, which was
 surprising to me.  Is this what you call hijacking?  Do you mean I
 ought
 start a new thread instead?  I thought my question were relevant to the
 threads' subject.  I am sorry if it were not.
 
 So here is the questions once again:  why do the as.Date behave as in
 my
 examples below, is this intended?
 
 
 
 On Thu, Jan 22, 2009 at 3:55 PM, Brian D Ripley
 rip...@stats.ox.ac.ukwrote:
 
  You've hijacked a thread here.
 
 
  On Thu, 22 Jan 2009, Marie Sivertsen wrote:
 
 
  I am relatively new to R, so maybe I am miss something, but I now
 tried
  the a
  s.Date now and have problems understanding how it works (or don't
 work as
  it seem).
 
  Brian D Ripley wrote:
   On Thu, 22 Jan 2009, Terry Therneau wrote:
  
   One idea is to use the as.date function, for the older (and less
  capable) 'date'
   class.  This is currently loaded by default with
 library(survival).  It
  re
  turns
 
   NA for an invalid date rather than dying.
  
   So does as.Date *if you specify the format* (as you have to with
 your
  as.da
  te:
   it has a default one):
 
 
 
 My examples:
 
 
 
 
  as.Date(2001/1/1)
  Works fine
  as.Date(1/1/2001)
  Prints 1-01-20 ???
  as.Date(13/1/2001)
  Prints 13-01-20 ???
 
  as.Date(1/13/2001)
  Prints error: not in standard unambigous format
  It seems that as if both 1/1/2001 and 13/1/2001 were considered
 by R
  to b
  e in a standard unambiguous format (or otherwise an error be
 reported?)
  and yet they
 
 
  are parsed incorrectly according to what one could think is obvious.
 It
  is a
  lso surprizing that not only 13/1/2001 but also 1/2/2001 and
  2/1/2001 are successful but incorrect parsed as if they are
 unambiguous,
  and yet
  13/1/2001 is ambiguous, though there is really just one way to
 parse it
  meaningfully.
  I think the strings that are incorrectly parsed should raise errors,
 and
  the last example should be succesful parsed.  What is the reason for
 the
  observed
  ?
 
 
 
 
 
 Mvh.
 Marie
 
 
 
 
 
  --
  Brian D. Ripley,  rip...@stats.ox.ac.uk
  Professor of Applied Statistics,
 http://www.stats.ox.ac.uk/~ripley/http://www.stats.ox.ac.uk/%7Eripley/
 
  University of Oxford, Tel:  +44 1865 272861 (self)
  1 South Parks Road, +44 1865 272866 (PA)
  Oxford OX1 3TG, UKFax:  +44 1865 272595
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] looping over a string

2009-01-22 Thread Thomas Schwander

Hi list,

I'm using R 2.8.1 under Windows vista. I have the following problem:

First of all I create a string-vector. Then I convert these strings 
into variables and assign a vector of numeric values. So far 
everything's fine.
Now I want to do nearly the same again: I create another string-vector 
and I want to assign the variance. So I have to loop over the first 
string-vector.
But this does not work unfortunately. I looked in the R-list-search but 
I cannot find the right answer.


Please find enclosed the pseudo-code:

#Tage zwischen berechnung und 31.03.2009
Berechnung-as.Date(22.01.2009,%d.%m.%Y)
Enddatum-as.Date(31.03.2009,%d.%m.%Y)
Tage-difftime(Enddatum, Berechnung)
Tage-as.numeric(substr(format(Tage),1,2))

#maximal interessierend sind 100 Tage (4 Monate)-Differenzen
max_int-82
Tage-max_int
max_bob-82

varnames-paste(st_rendite_,seq(max_int),sep=)
analyse-rnorm(1)
for(i in 1:min(max_bob,max_int)){
 assign(varnames[i],diff(log(analyse),i)*100)
}

#Wurzel_t - Approximation überprüfen
varianzen-paste(var_,seq(Tage),sep=)
for(i in 1:Tage){
#in this line is the error I cannot handle (st_rendite_i):
 assign(varianzen[i],var(st_rendite_i)/100^2)
}

Thanks for your help,
Thomas

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

2009-01-22 Thread Vikas Rawal
 ggplot2 should make legends automatically if the data is in the
 correct format. If you could send a reproducible example, that would
 help detect the error.


Take the following two plots. The first one produces a broken line. In the 
second one, the variable Phase is numeric and therefore it does not break the 
line between two Phases. That is why I am trying to do it by assigning a 
number to the Phase and then use different labels in the legend. If I put the 
text of those labels in the variable Phase itself, as done in the first 
example, it gives me a broken line.

# Plot 1

data.frame(Year=c(1:20),CDR=rnorm(20))-b3
c(rep(a,10),rep(b,10))-b3$Phase
qplot(Year,CDR,data=b3,colour=Phase,geom=c(point,line),gpar(legend.position=bottom))-p
p

#Plot 2

data.frame(Year=c(1:20),CDR=rnorm(20))-b3
c(rep(1,10),rep(2,10))-b3$Phase
qplot(Year,CDR,data=b3,colour=Phase,geom=c(point,line),gpar(legend.position=bottom))-p
p+scale_colour_gradient2(limits=c(1,2), 
midpoint=1.5,low=magenta,high=darkblue,breaks=c(1,2),labels=c(a,b))-p
p

Also, legend.position does not work. I am sure I am not doing it the right way.

I appreciate your help.

Vikas



[[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] how to get a primitive function object

2009-01-22 Thread Yi Zhang
Hi,

I want to create an alias for the - function and then later
overwrite it. Any idea how I can get the - function object? I know
for other functions it's easy, something like f - seq will do; how
really no clue for this one. Thanks!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get a primitive function object

2009-01-22 Thread Henrique Dallazuanna
Is there many functions:

See:

grep(-, ls(package:base), value = TRUE)


For 'substring-':

type `substring-` in R


On Thu, Jan 22, 2009 at 5:41 PM, Yi Zhang yizhan...@gmail.com wrote:

 Hi,

 I want to create an alias for the - function and then later
 overwrite it. Any idea how I can get the - function object? I know
 for other functions it's easy, something like f - seq will do; how
 really no clue for this one. Thanks!

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




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

[[alternative HTML version deleted]]

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


Re: [R] how to get a primitive function object

2009-01-22 Thread Duncan Murdoch

On 1/22/2009 2:41 PM, Yi Zhang wrote:

Hi,

I want to create an alias for the - function and then later
overwrite it. Any idea how I can get the - function object? I know
for other functions it's easy, something like f - seq will do; how
really no clue for this one. Thanks!


get(-) will give it to you, and

`-` - function(x, y) cat(x=, x, y=, y, \n)

will change it -- and will probably be the last effective thing you do 
in that session, unless you're really careful:


 x - 1
 x
[1] 1
 `-` - function(x, y) cat(x=, x, y=, y, \n)
 x - 3
x= 1 y= 3
 x
[1] 1
 # now what?? %#*
 q(no)

Duncan Murdoch

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


Re: [R] looping over a string

2009-01-22 Thread Greg Snow
I don't see right off why the one works and the other doesn't, but this looks 
like one of those cases that would be better done using a list rather than 
global variables.

Instead of assigning the variables in the global workspace, create a list and 
assign them there.  Then you can use lapply instead of a loop and you avoid the 
potential pitfalls associated with globals.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Thomas Schwander
 Sent: Thursday, January 22, 2009 12:38 PM
 To: r-help@r-project.org
 Subject: [R] looping over a string
 
 Hi list,
 
 I'm using R 2.8.1 under Windows vista. I have the following problem:
 
 First of all I create a string-vector. Then I convert these strings
 into variables and assign a vector of numeric values. So far
 everything's fine.
 Now I want to do nearly the same again: I create another string-vector
 and I want to assign the variance. So I have to loop over the first
 string-vector.
 But this does not work unfortunately. I looked in the R-list-search but
 I cannot find the right answer.
 
 Please find enclosed the pseudo-code:
 
 #Tage zwischen berechnung und 31.03.2009
 Berechnung-as.Date(22.01.2009,%d.%m.%Y)
 Enddatum-as.Date(31.03.2009,%d.%m.%Y)
 Tage-difftime(Enddatum, Berechnung)
 Tage-as.numeric(substr(format(Tage),1,2))
 
 #maximal interessierend sind 100 Tage (4 Monate)-Differenzen
 max_int-82
 Tage-max_int
 max_bob-82
 
 varnames-paste(st_rendite_,seq(max_int),sep=)
 analyse-rnorm(1)
 for(i in 1:min(max_bob,max_int)){
   assign(varnames[i],diff(log(analyse),i)*100)
 }
 
 #Wurzel_t - Approximation überprüfen
 varianzen-paste(var_,seq(Tage),sep=)
 for(i in 1:Tage){
 #in this line is the error I cannot handle (st_rendite_i):
   assign(varianzen[i],var(st_rendite_i)/100^2)
 }
 
 Thanks for your help,
 Thomas
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Does anyone has this paper in pdf?

2009-01-22 Thread Rolf Turner


On 23/01/2009, at 12:49 AM, Neil Shephard wrote:





aiminy wrote:


de Jong, S. (1993) SIMPLS: an alternative approach to partial least
squares
regression. Chemometrics and Intelligent Laboratory Systems, 18,  
251–263





Yes, the publishers do, you can purchase it from
http://dx.doi.org/10.1016/0169-7439(93)85002-X

Its a shame that not all journals make their back-catalogue  
available free
of charge, but I don't see why you expect people on this list to  
breach

copyright for you?


Is this really a violation of copyright?  If I have a copy of a  
journal I believe
it is within the compass of ``fair practice'' (or some such jargon)  
to make a photocopy
of a particular article and give this copy to a colleague or student  
for research
purposes.  Likewise I believe it is ``fair practice'' for me to send  
a copy of a pdf
file (that I have legitimately acquired) to a colleague or student  
for research

purposes.

It always gets fussy and fiddly whenever legal issues arise.  It  
would be nice if there
were no such thing as ``intellectual property'' (which has always  
seemed to me to be

an oymoron) and no such thing as lawyers.

cheers,

Rolf
##
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.


This e-mail has been scanned and cleared by MailMarshal 
www.marshalsoftware.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] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)

2009-01-22 Thread Marie Sivertsen
Thank you Greg and Gabor for explanations.  I have some further question
below.

On Thu, Jan 22, 2009 at 8:16 PM, Greg Snow greg.s...@imail.org wrote:

 I believe the original thread was about whether the function returns NA or
 stops with an error when given an invalid date (such as Feb 29 in a non-leap
 year).  Your question was about how as.Date returned something different
 from what you expected.  Related, but different enough that it probably
 would have been better to start a new thread.



I hope it was then okay I started a new thread.





 For your question, the help page for as.Date includes:

  format: A character string.  The default is '%Y-%m-%d'.  For
  details see 'strftime'.



To be strict, neither 1/13/2001 nor 13/1/2001 match the format, so both
should raise error, I think.  Since the behaviour seem not to apply the
default strictly, why ought one think 13/1/2001 will not be parsed the
only reasonable way?




 And

 Character strings are processed as far as
 necessary for the format specified: any trailing characters are
 ignored.

 I don't see anything in your examples that runs counter to the above.



Yes they do.  None of them match the format, but some parse correctly, some
produce rubbish, and some raise error.  Maybe you want to improve the help
page fo the as.Date to say something like The default is a sequence of
numerical representations of the year, then the month, then the day,
separated by one of '-', '/', ..., which make it clearer.



 Remember that computers do exactly what you tell them to do, not what you
 think that they should do.



Computers do exactly what they were programmed to do, and what they will do
depends on what the developer told them to do when they are given certain
input.  I expect them to do exactly what I tell them to do, and it is to
parse 1/13/2001 the only reasonable way.  It seems that someone told them
to do something else...

Mvh.
Marie

[[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] looping over a string

2009-01-22 Thread Thomas Schwander

Greg Snow schrieb:

I don't see right off why the one works and the other doesn't, but this looks 
like one of those cases that would be better done using a list rather than 
global variables.

Instead of assigning the variables in the global workspace, create a list and 
assign them there.  Then you can use lapply instead of a loop and you avoid the 
potential pitfalls associated with globals.

Hope this helps,

  

Greg,

thanks for the answer. The difference is, that in the first case I 
assign a value to a string, but afterwards I want to read the value of 
the string.


Trying to get it with lists.

Cheers,
Thomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get a primitive function object

2009-01-22 Thread Yi Zhang
On Thu, Jan 22, 2009 at 3:06 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:

 get(-) will give it to you, and

 `-` - function(x, y) cat(x=, x, y=, y, \n)

 will change it -- and will probably be the last effective thing you do in
 that session, unless you're really careful:

 x - 1
 x
 [1] 1
 `-` - function(x, y) cat(x=, x, y=, y, \n)
 x - 3
 x= 1 y= 3
 x
 [1] 1
 # now what?? %#*
 q(no)

 Duncan Murdoch


Thanks for the replies! Actually I have thought about this; what I
plan to do is:
oldAssign - `-`
oldAssign(`-`, function(x,value){if (...) do_something; oldAssign(x,value)})
x-1
x # object not found!!
So the problem now is the effect of oldAssign(x,value) is only
local--within that anonymous function. Is there a way to do
assignInNamespace (or how to get the namespace where the overridden -
is called)?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 handle NA in C#, RDCOM

2009-01-22 Thread guox
I am using RDCOM as a data-transfer between R and C#.net.
I got a question on datasets with missing data.
For instance, if list = c(1,2,3,NA,5), in R, typeof(list) is integer
but, in C#, I did not see a suitable data type for (1,2,3,NA,5).
Of course, one can use is.na to transfer (1,2,3,NA,5) into string[] in C#.
So, how to handle NA in this case?
Please help. Thank,

-james

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Does anyone has this paper in pdf?

2009-01-22 Thread Wacek Kusnierczyk
Rolf Turner wrote:

 On 23/01/2009, at 12:49 AM, Neil Shephard wrote:

 s
 Is this really a violation of copyright?  If I have a copy of a
 journal I believe
 it is within the compass of ``fair practice'' (or some such jargon) to
 make a photocopy
 of a particular article and give this copy to a colleague or student
 for research
 purposes.  Likewise I believe it is ``fair practice'' for me to send a
 copy of a pdf
 file (that I have legitimately acquired) to a colleague or student for
 research
 purposes.


one message that is pervasive on this list is 'what you believe is not
necessarily what really is'.  it seems to be applicable here, rolf. 

many scientific journals restrict your rights to distribute your own
articles published with them, and you can buy printed copies for
redistribution or rights to make pdfs available for a limited number of
downloads, etc.  see, e.g., [1].

it may be ``fair practice'' to distribute your papers without asking the
publisher for permision, and it is quite common and indeed very useful,
yet it may still be a violation of copyright.  'legitimately acquired'
is underspecified, as in many circumstances you acquire a pdf of your
article or book for your own use only, not for redistribution. 
otherwise, a 'legitimately acquired' article sent to another person is
surely 'legitimately acquired' by that person, and thus, by induction,
can be further distributed for 'legitimate acquisition', with no
limitations in sight.

that said, i support the view that scientific work should be
redistributable without restrictions.  on this occasion, i inform the
person who once asked about anyone sharing a pdf copy of Prof Brian
Ripley's book on spatial statistics that one of my colleagues happens to
have such a pdf and will probably be happy to redistribute it.

vQ (one of *the trolls*, i guess)

[1] http://www.nature.com/reprints/author-reprints.html

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


[R] User input in batch mode

2009-01-22 Thread Sebastien Bihorel

Dear R-users,

[Sorry to have to send this again but my former posts were trimmed 
because of some embedded HTML code]


readline is a nice function to get user input when one is working with 
the terminal. This function does not allow any interaction with the user 
when a script in batch mode (I guess by design)... Unfortunately, that 
is exactly what I am trying to do.

I would greatly appreciate if any R-user could:
- tell me if this is possible
- indicate a function I could look at, that would allow this type of 
interaction during a batch run.


Thank you in advance,

Version: R 2.8.1 installed on a Solaris system

--
*Sebastien Bihorel, PharmD, PhD*
PKPD Scientist
Cognigen Corp
Email: sebastien.biho...@cognigencorp.com
mailto:sebastien.biho...@cognigencorp.com
Phone: (716) 633-3463 ext. 323

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

2009-01-22 Thread jimdare

Dear R-Users

I sincerely apologise for the multiple posts yesterday afternoon. Apparently
there was an error in the server here at work which resulted in the message
being sent eight times.  I am new to R, as you can probably tell from the
majority of my posts, and I really appreciate all the help I get from this
forum. The last thing I want to do is offend anyone.  Anyway, please accept
my apology, I will ensure It doesn’t happen again.

Kind Regards,
James Dare

-- 
View this message in context: 
http://www.nabble.com/Apology-for-Multiple-Posts-tp21612723p21612723.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] how to get a primitive function object

2009-01-22 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
 On 1/22/2009 2:41 PM, Yi Zhang wrote:
 Hi,

 I want to create an alias for the - function and then later
 overwrite it. Any idea how I can get the - function object? I know
 for other functions it's easy, something like f - seq will do; how
 really no clue for this one. Thanks!

 get(-) will give it to you, and

 `-` - function(x, y) cat(x=, x, y=, y, \n)

 will change it -- and will probably be the last effective thing you do
 in that session, unless you're really careful:

  x - 1
  x
 [1] 1
  `-` - function(x, y) cat(x=, x, y=, y, \n)
  x - 3
 x= 1 y= 3
  x
 [1] 1
  # now what?? %#* 

now you are really motivated to use '=' instead of '-':

x = 3
x
# 3

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)

2009-01-22 Thread Greg Snow
Comments interspersed below

From: Marie Sivertsen [mailto:mariesiv...@gmail.com] 
Sent: Thursday, January 22, 2009 1:17 PM
To: Greg Snow
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] Unexpected behaviour of the as.Date (was: Error as.Date on 
Invalid Dates)

 [snip]


For your question, the help page for as.Date includes:

 format: A character string.  The default is '%Y-%m-%d'.  For
         details see 'strftime'.


To be strict, neither 1/13/2001 nor 13/1/2001 match the format, so both 
should raise error, I think.  Since the behaviour seem not to apply the default 
strictly, why ought one think 13/1/2001 will not be parsed the only 
reasonable way?

 
The help page for as.Date refers to the help page for strptime which says that 
details are system specific. So there may be some systems where you would get 
an error from '/' not being '-', but apparently on your system they are treated 
the same.   Personally I see a big difference between interpreting an obvious 
separator as such and changing the order of values.  The fact that it sometimes 
gets the one correct does not imply to me that the other should happen 
automatically.  

Dealing with the separators can be done on an individual basis as each 
character string is processed.  Guessing the order of the entries could require 
looking at the entire vector/file/dataset, which I expect would slow things 
down quite a bit.  (and how long would it be before someone complained that it 
processed file A correctly, but file B should have been treated like A, but 
since it only included days less than 13, the program did not realize this).


And

Character strings are processed as far as
    necessary for the format specified: any trailing characters are
    ignored.

I don't see anything in your examples that runs counter to the above.


Yes they do.  None of them match the format, but some parse correctly, some 
produce rubbish, and some raise error.  Maybe you want to improve the help page 
fo the as.Date to say something like The default is a sequence of numerical 
representations of the year, then the month, then the day, separated by one of 
'-', '/', ..., which make it clearer.
But is it correct? It may be system dependent (or all systems may do the exact 
same now).  How about if the help page tells you to find out for your system 
(easy fix, it already does).

Remember that computers do exactly what you tell them to do, not what you think 
that they should do.


Computers do exactly what they were programmed to do, and what they will do 
depends on what the developer told them to do when they are given certain 
input.  I expect them to do exactly what I tell them to do, and it is to parse 
1/13/2001 the only reasonable way.  It seems that someone told them to do 
something else...

I was using the general 'you' above that includes the programmer as well as the 
user, since you (singular) did not specify the format, the computer used the 
default format that the programmer (part of the collective 'you') specified 
which says the order is year, month, day.

Many problems come as a result of users forgetting that they are smarter than 
the computer.  I see 3 ways to remedy the problem:

1. Make computers that are as smart or smarter than people.
2. Make the programmers anticipate every way that someone may use a particular 
function and make them implement all of the functionality even if they don't 
think it is worth the time/effort since there is an easy work around for many 
of the less likely used features.
3. Don't expect the computer to guess correctly and tell it exactly what you 
want it to do.

I don't think that number 1 will ever happen, and there are plenty of science 
fiction stories that suggest problems with even trying.

Option 2 stinks of hubris, and even if it were possible, I personally would not 
want to wait until they were finished before being able to use the 
functions/programs.

Which leaves option 3, which I think is the best approach even without 
arguments against the others.

I think the moral of this story is: program defensively, always specify a date 
format! 


Mvh.
Marie



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

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

2009-01-22 Thread odif

Hello,

I have the following csv file

n,  n_red
1,  0
1,  1
2,  1
2,  1
3,  0
4,  1
4,  2
4,  3

I would like to plot this data. On the x-axis there should be n and on  
the y-axis the mean of all n_red where n is the according value on the  
x-axis. The plot should look like plotting the following data:


n,  n_red
1,  0.5
2,  1
3,  0
4,  2

Is there any simple way to do this?

Greetings
odif

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get a primitive function object

2009-01-22 Thread Yi Zhang
On Thu, Jan 22, 2009 at 4:17 PM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
 Duncan Murdoch wrote:
 On 1/22/2009 2:41 PM, Yi Zhang wrote:
 Hi,

 I want to create an alias for the - function and then later
 overwrite it. Any idea how I can get the - function object? I know
 for other functions it's easy, something like f - seq will do; how
 really no clue for this one. Thanks!

 get(-) will give it to you, and

 `-` - function(x, y) cat(x=, x, y=, y, \n)

 will change it -- and will probably be the last effective thing you do
 in that session, unless you're really careful:

  x - 1
  x
 [1] 1
  `-` - function(x, y) cat(x=, x, y=, y, \n)
  x - 3
 x= 1 y= 3
  x
 [1] 1
  # now what?? %#*

 now you are really motivated to use '=' instead of '-':

 x = 3
 x
 # 3

 vQ


Thanks. That certainly is an option. But I want to preserve `-`'s
functionality because I'm writing a package and I don't want to limit
the package user's freedom to use `-`...

-- 
Yi

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

2009-01-22 Thread Greg Snow
Ah, I missed that.  You can get the value from the string by using paste to 
create the name of the variable (as you already did), then use the 'get' 
function to get its value (the other direction of assign).  But I would still 
suggest trying to use lists, then you can just use mylist[[ i ]] or mylist[[ 
names[i] ]] to grab the value or mylist[[ i ]] - something  to assign.  Or 
even better, newlist - lapply( oldlist, function ) and avoid the explicit loop 
altogether (then if you want to use the individual variables by name, just use 
with or within).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r_lo...@web.de [mailto:r_lo...@web.de]
 Sent: Thursday, January 22, 2009 1:27 PM
 To: Greg Snow; r-help@R-project.org
 Subject: Re: [R] looping over a string
 
 Greg Snow schrieb:
  I don't see right off why the one works and the other doesn't, but
 this looks like one of those cases that would be better done using a
 list rather than global variables.
 
  Instead of assigning the variables in the global workspace, create a
 list and assign them there.  Then you can use lapply instead of a loop
 and you avoid the potential pitfalls associated with globals.
 
  Hope this helps,
 
 
 Greg,
 
 thanks for the answer. The difference is, that in the first case I
 assign a value to a string, but afterwards I want to read the value
 of
 the string.
 
 Trying to get it with lists.
 
 Cheers,
 Thomas

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

2009-01-22 Thread Mike Lawrence
n.means = with(my.data,aggregate(n_red,list(n=n),mean))

plot(n.means)

On Thu, Jan 22, 2009 at 5:17 PM,  o...@gmx.de wrote:
 Hello,

 I have the following csv file

 n,  n_red
 1,  0
 1,  1
 2,  1
 2,  1
 3,  0
 4,  1
 4,  2
 4,  3

 I would like to plot this data. On the x-axis there should be n and on the
 y-axis the mean of all n_red where n is the according value on the x-axis.
 The plot should look like plotting the following data:

 n,  n_red
 1,  0.5
 2,  1
 3,  0
 4,  2

 Is there any simple way to do this?

 Greetings
 odif

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




-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
www.thatmike.com

Looking to arrange a meeting? Check my public calendar:
http://www.thatmike.com/mikes-public-calendar

~ Certainty is folly... I think. ~

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get a primitive function object

2009-01-22 Thread Wacek Kusnierczyk
Yi Zhang wrote:

 # now what?? %#*
 
 now you are really motivated to use '=' instead of '-':

 x = 3
 x
 # 3

 vQ

 

 Thanks. That certainly is an option. But I want to preserve `-`'s
 functionality because I'm writing a package and I don't want to limit
 the package user's freedom to use `-`...

   

i was sort-of joking, though it's a real option if you want it. 

but seriously, there's no reason for the %#* lamenting:

x - 1
'-' = function(x,y) 0
x - 2
# 0

.Primitive('-')(x,2)
x
# 2

base::'-'(x, 3)
x
# 3

base::'-'('-', base::'-')
x - 4
x
# 4

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] detecting the source of memory consumption (example provided)

2009-01-22 Thread Juliet Hannah
I have read in a file (call it myData). The actual file is about
3000x30,000 columns and object.size() says myData takes:

 737910472/(1024^2)
[1] 703.7263

Unfortunately, my program ends up using 40GB as indicated by maxvmem
on Unix, which causes my department's cluster to stop working.
Perhaps, I have some copying going on that I cannot find. I have
created an example below that mimics my program. Could someone help me
find my error? I am also confused about how to use Rprofmem to study
this problem. Thanks for your time.

Regards,

Juliet

#begin example
response - rnorm(50);
x1 - sample(c(1,2),50,replace=TRUE)
age - sample(seq(20,80),50,replace=TRUE)
id - rep(1:25,each=2)
var1 - rnorm(50);
var2 - rnorm(50);
var3 - rnorm(50);
myData - data.frame(response,x1,age,id,var1,var2,var3)

numVars - ncol(myData)-4;
pvalues - rep(-1,numVars);
names(pvalues) - colnames(myData)[5:ncol(myData)];

library(yags)
for (Var_num in 1:numVars)
{
   fit.yags - yags(myData$response ~
myData$age+myData$x1*myData[,(Var_num+4)], id=myData$id,
family=gaussian,corstr=exchangeable,alphainit=0.05)
   z.gee - fit.y...@coefficients[5]/sqrt(fit.y...@robust.parmvar[5,5]);
   pval - 2 * pnorm(abs(z.gee), lower.tail = FALSE);
   pvalues[Var_num] - signif(pval,3);
}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get a primitive function object

2009-01-22 Thread Yi Zhang
 i was sort-of joking, though it's a real option if you want it.

 but seriously, there's no reason for the %#* lamenting:

 x - 1
 '-' = function(x,y) 0
 x - 2
 # 0

 .Primitive('-')(x,2)
 x
 # 2

 base::'-'(x, 3)
 x
 # 3

 base::'-'('-', base::'-')
 x - 4
 x
 # 4

 vQ


I'm still not sure if this can help solve my problem. If I want to
overwrite the `-` operator for a particular type of objects, but
preserve its effect for other regular objects (in other words, if I do
x-5 with my new -, x will be 5 and nothing strange happens), then
what should I put in the [ ] below?
old - `-`
old(`-`, function(x, value){
  if (value is my type) do something
  [ ] # to bind the object value to symbol x: no matter what you do
here, the binding/assignment is local within this function?!
})

Hope I have made myself clear. Thanks,
-- 
Yi

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

2009-01-22 Thread David Winsemius
And to do the input section of the task, you should first read an  
introductory text and then refer to the help pages:


?read.table
?read.csv   # same page

And don't forget:
http://www.R-project.org/posting-guide.html

--
David Winsemius

On Jan 22, 2009, at 4:33 PM, Mike Lawrence wrote:


n.means = with(my.data,aggregate(n_red,list(n=n),mean))

plot(n.means)

On Thu, Jan 22, 2009 at 5:17 PM,  o...@gmx.de wrote:

Hello,

I have the following csv file

n,  n_red
1,  0
1,  1
2,  1
2,  1
3,  0
4,  1
4,  2
4,  3

I would like to plot this data. On the x-axis there should be n and  
on the
y-axis the mean of all n_red where n is the according value on the  
x-axis.

The plot should look like plotting the following data:

n,  n_red
1,  0.5
2,  1
3,  0
4,  2

Is there any simple way to do this?

Greetings
odif

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





--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
www.thatmike.com

Looking to arrange a meeting? Check my public calendar:
http://www.thatmike.com/mikes-public-calendar

~ Certainty is folly... I think. ~

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


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


  1   2   >