Re: [R] A slight trap in read.table/read.csv.

2010-03-09 Thread Patrick Connolly
On Tue, 09-Mar-2010 at 08:14AM +0100, Petr PIKAL wrote:


| I would respectfully oppose it. It may be quite convenient for making code 
| for functions and other programming stuff but all using R more or less in 
| interactive way this change could be quite a burden especially when there 
| are many functions which use TRUE/FALSE for setting its parameters.
| 
| In those (and many others) instances I almost exclusively use T/F 
| shortcut.
| 
| read.delim(file, header = TRUE, sep = \t, quote=\, dec=., fill = 
| TRUE, comment.char=, ...)
| lm(formula, data, subset, weights, na.action,method = qr, model = TRUE, 
| x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, contrasts = NULL, 
| offset, ...)

If you use ESS, you have the benefit of completions.  Depending on
what else could begin with T or F, you can press the TAB key after
typing the first letter or two.  Admittedly, three keystrokes isn't
much shorter than TRUE -- but they are all with the left hand. You
always get at least a 40% discount with FALSE. :-) -- except in the
'unlikely event' that you have objects named FALLOW or something
else a lot like FALSE.






| 
| If this had to be changed I would vote for some change which allow users 
| some other shortcut for setting interactively parameters in functions.
| 
| Regards
| Petr
|  
| 
| 
|   
|   The only immediate solution to this accretion of overly clever
|   behavior would be for someone to write new functions (say,
|   Read.csv) that didn't do all those conversions behind the
|   scenes. I'm not about to do that. Are you?
|  
|  
| NFL!!!
|  
|cheers,
|  
|   Rolf
|  
|  ##
|  Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
|  
|  __
|  R-help@r-project.org mailing list
|  https://stat.ethz.ch/mailman/listinfo/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.

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

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

2010-03-09 Thread Albert-Jan Roskam
Hi Martin,
 
Thanks. Your remark about setValidity makes sense. One question about try() 
though. Isn't that a (crude) implementation of duck typing? Give a method some 
type of data, 'try' if it works with that type of data, and if not, do 
something else? I think I agree with you that if-then is less of a let's see 
what happens kind of statement.

Cheers!!
Albert-Jan

~~
In the face of ambiguity, refuse the temptation to guess.
~~

--- On Mon, 3/8/10, Martin Morgan mtmor...@fhcrc.org wrote:


From: Martin Morgan mtmor...@fhcrc.org
Subject: Re: [R] setClass or setValidity?
To: Albert-Jan Roskam fo...@yahoo.com
Cc: r-help@r-project.org
Date: Monday, March 8, 2010, 10:56 PM


On 03/08/2010 07:18 AM, Albert-Jan Roskam wrote:
 Sorry: there was an error in the last sentence:
 And, inside those validity checks, is most of the checking done with 'if' 
 'else' computations, or is it also common to use try()?

For me it's a matter of taste, and usual to use if... (because you know
explicitly what you're trying to validate, whereas try() implies a kind
of 'something might go wrong...'). I find myself using setValidity() to
separate out class definition from implementation.

Best,

Martin

 
 Cheers!!
 Albert-Jan
 
 ~~
 In the face of ambiguity, refuse the temptation to guess.
 ~~
 
 --- On Mon, 3/8/10, Albert-Jan Roskam fo...@yahoo.com wrote:
 
 
 From: Albert-Jan Roskam fo...@yahoo.com
 Subject: [R] setClass or setValidity?
 To: r-help@r-project.org
 Date: Monday, March 8, 2010, 4:14 PM
 
 
 Hi, 
  
 I'm reading up on S4 classes *). There seem to be at least two ways of input 
 validation:
 setClass() (using the 'validity' argument)  and setValidity(). Is it a matter 
 of taste which function is used? Or should more complex validation code 
 better be put in a setValiditity call?
 
 *) A (Not So) Short Introduction to S4 Object Oriented Programming in R 
 V0.5.1 Christophe Genolini August 20, 2008
  
 And, inside those validity checks, is most of the checking done with 'if' 
 'else' computations, or is it also common to use except()?
 
 Cheers!!
 Albert-Jan
 
 ~~
 In the face of ambiguity, refuse the temptation to guess.
 ~~
 
 
       
     [[alternative HTML version deleted]]
 
 
 -Inline Attachment Follows-
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



  
[[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 can I look at .Internal(model.matrix(t, data))?

2010-03-09 Thread Peter Ehlers

I imagine it's in

 https://svn.r-project.org/R/trunk/src/main/model.c

 -Peter Ehlers

On 2010-03-05 12:43, Werner W. wrote:

Hi,

I would like to see how model.matrix expands factor column to a set of dummy 
columns. I think that is done int .Internal(model.matrix(t, data)) which is 
called from model.matrix.default. But I have not idea how I can look at this 
function. How can I get to such internal functions?

Thanks so much!
   Werner



einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.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.




--
Peter Ehlers
University of Calgary

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


Re: [R] how can I look at .Internal(model.matrix(t, data))?

2010-03-09 Thread Romain Francois
Also see Uwe's article in R news : Accessing the source : 
http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf


On 03/09/2010 09:22 AM, Peter Ehlers wrote:


I imagine it's in

https://svn.r-project.org/R/trunk/src/main/model.c

-Peter Ehlers

On 2010-03-05 12:43, Werner W. wrote:

Hi,

I would like to see how model.matrix expands factor column to a set of
dummy columns. I think that is done int .Internal(model.matrix(t,
data)) which is called from model.matrix.default. But I have not idea
how I can look at this function. How can I get to such internal
functions?

Thanks so much!
Werner


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 for Sieve Bootstrap Methods

2010-03-09 Thread Andreas Klein
Hello R-users.

Is there a package which handles sieve bootstrap methods in various time series 
applications?

Method of Sieve Bootstrap by Bühlmann, P. (1995, Technical Report; published 
1997 in the Journal of the Bernoulli Society):
http://ftp.stat.berkeley.edu/tech-reports/431.pdf

Thank you in advance.


Sincerely,
Andreas.

__
Do You Yahoo!?
Sie sind Spam leid? 
 
http://mail.yahoo.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] A slight trap in read.table/read.csv.

2010-03-09 Thread Barry Rowlingson
On Tue, Mar 9, 2010 at 8:11 AM, Patrick Connolly
p_conno...@slingshot.co.nz wrote:

 If you use ESS, you have the benefit of completions.  Depending on
 what else could begin with T or F, you can press the TAB key after
 typing the first letter or two.  Admittedly, three keystrokes isn't
 much shorter than TRUE -- but they are all with the left hand. You
 always get at least a 40% discount with FALSE. :-) -- except in the
 'unlikely event' that you have objects named FALLOW or something
 else a lot like FALSE.

 FALSETTO? Anyone analysing choral music in R?

 I'd somehow got the impression that T and F were going to be removed
as values, but there's no mention of it in ?FALSE. The package check
utilities warn you if you use them.

 Just looking at the source for the underlying cause of the read.csv
behaviour, which is type.convert in R which is do_typecvt in C, and it
admits:

/* This is a horrible hack

There's a couple of instances of:

 if (strcmp(s, F) == 0 || strcmp(s, FALSE)

which are what do it. And are obviously not language-dependent - do
French people have 'VRAI' and 'FAUX' in their CSV files? Do they call
them DSV files:
http://translate.google.com/#en|fr|comma-separated%20file

Got to keep the Academie Francaise happy...

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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! I turned my data into junk!

2010-03-09 Thread Brienne

I posted my data for a midterm into notepad and it turned into symbols.  The
other bit I posted turned out just fine, but for some reason this one messed
up.  I need this stuff for a class.  Anyone know how to get my data back. 
Please help soon!
-- 
View this message in context: 
http://n4.nabble.com/Help-I-turned-my-data-into-junk-tp1585481p1585481.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] A slight trap in read.table/read.csv.

2010-03-09 Thread Ivan Calandra
To answer your questions, French people don't have 'Vrai' and 'Faux'. 
Since most of people have no idea what csv means, there's no use for 
using dsv! The Académie Française would not be happy indeed.


But to keep on the subject, I personally never had troubles using T or 
F. I sometimes use T/F, sometimes TRUE/FALSE, depending on my mood!
Looks like I should think about using TRUE/FALSE all the time, but since 
I've never had problems, I don't feel bad with it!


Ivan

Le 3/9/2010 10:00, Barry Rowlingson a écrit :

On Tue, Mar 9, 2010 at 8:11 AM, Patrick Connolly
p_conno...@slingshot.co.nz  wrote:

   

If you use ESS, you have the benefit of completions.  Depending on
what else could begin with T or F, you can press the TAB key after
typing the first letter or two.  Admittedly, three keystrokes isn't
much shorter than TRUE -- but they are all with the left hand. You
always get at least a 40% discount with FALSE. :-) -- except in the
'unlikely event' that you have objects named FALLOW or something
else a lot like FALSE.
 

  FALSETTO? Anyone analysing choral music in R?

  I'd somehow got the impression that T and F were going to be removed
as values, but there's no mention of it in ?FALSE. The package check
utilities warn you if you use them.

  Just looking at the source for the underlying cause of the read.csv
behaviour, which is type.convert in R which is do_typecvt in C, and it
admits:

/* This is a horrible hack

There's a couple of instances of:

  if (strcmp(s, F) == 0 || strcmp(s, FALSE)

which are what do it. And are obviously not language-dependent - do
French people have 'VRAI' and 'FAUX' in their CSV files? Do they call
them DSV files:
http://translate.google.com/#en|fr|comma-separated%20file

Got to keep the Academie Francaise happy...

Barry

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-03-09 Thread Jim Lemon

On 03/09/2010 01:37 AM, Petr PIKAL wrote:

Hi all

I know I probably reinvented wheel but it was maybe simpler then search in
docs or ask help before I did my part.

I made a simple function which can scale a vector between chosen values.
Do anybody know simpler/better approach?
...
x- c(5,30,50)

myscale(x)
[1] 0.500 0.778 1.000


Hi Petr,
Try this:

library(plotrix)
rescale(x,c(0.5,1))

Jim

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


[R] Removing Zeros from matrix

2010-03-09 Thread ogbos okike
Hi Everybody,
I have a matrix of about 45 columns. Some of the rows contain zeros. Using
data1-data[complete.cases(data),], I can remove the NA rows. But I am
unable to tackle that of zeros.
Can anybody give me an idea of how to remove rows containing zeros in a
matrix.
Thanks so much
Best
Ogbos

[[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] Removing Zeros from matrix

2010-03-09 Thread Dimitris Rizopoulos

one approach is the following:

mat - matrix(rnorm(100*45), 100, 45)
mat[sample(100*45, 50)] - 0

index - rowMeans(mat == 0) == 0
mat[index, ]


I hope it helps.

Best,
Dimitris


On 3/9/2010 11:05 AM, ogbos okike wrote:

Hi Everybody,
I have a matrix of about 45 columns. Some of the rows contain zeros. Using

data1-data[complete.cases(data),], I can remove the NA rows. But I am

unable to tackle that of zeros.
Can anybody give me an idea of how to remove rows containing zeros in a
matrix.
Thanks so much
Best
Ogbos

[[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 University 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] confused by classes and methods.

2010-03-09 Thread Albert-Jan Roskam
Hi Rob,
 
I just started reading about classes (and also learning R), so I apologize if 
the following code is confusing you more. I simplified the code somewhat in 
order to better understand what's going  on. I was wondering: are you 
deliberately reimplementing the builtin update() function?
 
setClass(Class=StatisticInfo,
    representation( oldData = data.frame,
newData = data.frame
   )
 )
# declare the update method, even though it exists already.
setGeneric (
  name=update,
  def=function(object){standardGeneric(update)}
)

setMethod(f=update, signature (StatisticInfo),
  definition = function(object){
    min = min(obj...@newdata, obj...@olddata, na.rm=T)
    avg = mean(mean(cbind(obj...@newdata, obj...@olddata)))
    max = max(obj...@newdata, obj...@olddata, na.rm=T)
    return(list(min, avg, max))
    }
)
old - data.frame(runif(10, 1, 10))
new - data.frame(runif(10, 1, 9))
instance - new(Class=StatisticInfo, oldData=old, newData=new)
update(instance)

Does this make sense to you?

Cheers!!
Albert-Jan

~~
In the face of ambiguity, refuse the temptation to guess.
~~

--- On Tue, 3/9/10, Rob Forler rfor...@uchicago.edu wrote:


From: Rob Forler rfor...@uchicago.edu
Subject: [R] confused by classes and methods.
To: r-help@r-project.org
Date: Tuesday, March 9, 2010, 12:09 AM


Hello, I have a simple class that looks like:

setClass(statisticInfo,
        representation( max = numeric,
                        min = numeric,
                        beg = numeric,
                        current = numeric,
                        avg = numeric,
                        obs = vector
                       )
         )

and the following function

updateStatistic - function(statistic, newData){
    statis...@obs = c(statis...@obs, newData)
    statis...@max = max(newData, statis...@max, na.rm=T)
    statis...@min = min(newData, statis...@min, na.rm=T)
    statis...@avg = mean(statis...@obs)
    statis...@current = newData
    if(length(statis...@obs)==1 || is.na(statis...@beg)){
        statis...@beg = newData
    }
    return(statistic)
}

Firstly,

I know you can use methods which seems to add some value. I looked at
http://developer.r-project.org/methodDefinition.html but I try

setMethod(update, signature(statistic=statisticInfo, newData=numeric),

function(statistic, newData){
    statis...@obs = c(statis...@obs, newData)
    statis...@max = max(newData, statis...@max, na.rm=T)
    statis...@min = min(newData, statis...@min, na.rm=T)
    statis...@avg = mean(statis...@obs)
    statis...@current = newData
    if(length(statis...@obs)==1 || is.na(statis...@beg)){
        statis...@beg = newData
    }
    return(statistic)
}
)

Creating a new generic function for update in .GlobalEnv
Error in match.call(fmatch, fcall) :
  unused argument(s) (statistic = statisticInfo, newData = numeric)
1: source(tca.init.R, chdir = T)
2: eval.with.vis(ei, envir)
3: eval.with.vis(expr, envir, enclos)
4: source(../../studies/tca.tradeClassifyFuncs.R)
5: eval.with.vis(ei, envir)
6: eval.with.vis(expr, envir, enclos)
7: setMethod(update, signature(statistic = statisticInfo, newData =
numeric), function(statistic, newData) {
8: isSealedMethod(f, signature, fdef, where = where)
9: getMethod(f, signature, optional = TRUE, where = where, fdef = fGen)
10: matchSignature(signature, f

I don't understand this any help would be appreciated.

Secondly, can anyone give any examples of where methods are used that makes
sense besides just checking the class inputs?

Thirdly, I've looked into passing by reference in R, and some options come
up, but in general they seem to be fairly complicated.

I would like update to work more like my update function to work without
having to return a a new object.

Something like
 statList = list(new(statisticInfo))
 updateStatistic(statList[[1]],3)
 statList[[1]]

#this would then have the updated one and not the old one.

Anyways,
The main reason I'm asking these questions is because I can't really find a
good online resource for this. Any help would be greatly appreciated.

Thanks,
Rob

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



  
[[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] Source code for the t-distribution

2010-03-09 Thread Ravi Kulkarni

I have tried looking for the source code for the pt() function in 

 https://svn.r-project.org/R/trunk/src/library/stats/

and am unable to find it there. Can someone please tell me where to find it?

Thanks,
  Ravi Kulkarni
-- 
View this message in context: 
http://n4.nabble.com/Source-code-for-the-t-distribution-tp1585875p1585875.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] Removing Zeros from matrix

2010-03-09 Thread Paul Hiemstra

Dimitris Rizopoulos wrote:

one approach is the following:

mat - matrix(rnorm(100*45), 100, 45)
mat[sample(100*45, 50)] - 0

index - rowMeans(mat == 0) == 0
mat[index, ]

Dimitris,

You use quite a complicated syntax to get the index. I think the 
following syntax using apply is more easy to understand:


# Note, MARGIN equal to 1 means loop over rows
# If any member of a row is zero
index = apply(mat == 0, MARGIN = 1, any)
# If all members of a row are zero
index = apply(mat == 0, MARGIN = 1, all)

cheers and hope it helps,
Paul



I hope it helps.

Best,
Dimitris


On 3/9/2010 11:05 AM, ogbos okike wrote:

Hi Everybody,
I have a matrix of about 45 columns. Some of the rows contain zeros. 
Using
data1-data[complete.cases(data),], I can remove the NA rows. But 
I am

unable to tackle that of zeros.
Can anybody give me an idea of how to remove rows containing zeros in a
matrix.
Thanks so much
Best
Ogbos

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






--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


[R] using near-zero probabilities in optimization

2010-03-09 Thread Benedikt Gehr

Hi there

I am using mle2 for a multinomial likelihood optimization problem. My 
function works fine when I'm using simulated data, however my cell 
probabilities of the true data for the multinomial likelihood are 
sometimes very small (in some cases 0.00...) and the estimated point 
estimates fit the true vlaues quite poorly. Is there a way how to handle 
near zero probabilities in maximum likelihood optimization?


Thanks a lot for the help

best wishes

Benedikt

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] IMPORTANT - To remove the null elements from a vector

2010-03-09 Thread Barbara . Rogo

I have a vector that have null elements. How to remove these elements?
For example:
x=[10 0 30 40 0 0] I want the vector y=[10 30 40]
Thanks
[[alternative HTML version deleted]]

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


[R] IMPORTANT - Add a plot to another plot

2010-03-09 Thread Barbara . Rogo

I have a graphic that I design with the command plot, and I want to add 
another graphic. If I use another time the command plot
with parameter add=TRUE It's wrong. Why? How I can resolve this problem?
Thanks
[[alternative HTML version deleted]]

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


Re: [R] IMPORTANT - Add a plot to another plot

2010-03-09 Thread jim holtman
try:

plot(0)  # first plot
par(new=TRUE)
plot(1)  # second plot
# need to make sure ranges agrees and whether to plot axes or not.

Or you probably really want to use 'lines'/'points'

On Tue, Mar 9, 2010 at 7:52 AM, barbara.r...@uniroma1.it wrote:


 I have a graphic that I design with the command plot, and I want to add
 another graphic. If I use another time the command plot
 with parameter add=TRUE It's wrong. Why? How I can resolve this problem?
 Thanks
[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

[[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] find out commands in package

2010-03-09 Thread Jannis
Dears,


I am trying to implement some R package which is still under construction and 
has not yet been submitted to CRAN (RSSA, 
http://anton.korobeynikov.info/software). Documentation is yet very poor (or i 
just did not find it), so I am wondering whether there is any way to retrieve a 
list of commands available in this package from within R? And to find out 
whether the package is successfully installed. After downloading the zip and 
installing it within R I only got the error message that it was created with an 
earlier R version and help would not work



Thanks for your help!
Jannis


__
D
usragenden Schutz gegen Massenmails. 
http://mail.yahoo.com

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


[R] Problem with mean

2010-03-09 Thread venkata kirankumar
Hi all,
I got one intresting problem with caliculating mean that is

while i am taking mean of values

*0.6, -0.8, 4, -3.8*

using
*val-c(0.6, -0.8, 4, -3.8)*
*mean(val)*
it given result as
*2.775558e-17*

but the actual result is  *0*

can any one suggest how can I get correct mean result in this case

can any one suggest how I can farward

thanks in regards

kiran

[[alternative HTML version deleted]]

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


[R] error in a function

2010-03-09 Thread weltbewohnerin1

Hallo!

I have the following function:

cLL_beta - function(beta){
sumterm=0
a=1
b=0
S=I_n-lambda*w
R=I_n-rho*w
det_R=det(S)
det_S=det(R)

for (i in 1:t){
b=i*n
y_ausgew=y_tilde[a:b]#y_ausgew ist numeric
y_aus=matrix(y_ausgew)#Typen anpassen
X_ausgew=X[a:b,]#X_ausgew ist eine Matrix
x_tilde=X_ausgew-1/t*x_t  #x_tilde ist auch eine Matrix
X_aus=matrix(X_ausgew)
V1=R%*%(S%*%y_aus-x_tilde%*%beta)
V11=t(V1)
V2=V11%*%J_n
V_tilde=V2%*%V1
sumterm=sumterm+V_tilde
a=b+1
}
-((n*t)/2)*log(2*pi*sigm_sq)+t*(log(det_S)+log(det_R))-1/(2*sigm_sq)*sumterm
}

where beta is a matrix (2x1), X is a matrix (n*tx1) and y is numeric with
length nt.

My error message is: X_ausgew%*%beta - non-conformable arguments 

Can anybody help me?

THANKS
-- 
View this message in context: 
http://n4.nabble.com/error-in-a-function-tp1585792p1585792.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] Odp: how to convert character variables into numeric variables directly

2010-03-09 Thread Xumin Zeng
Thanks!  Xumin




Petr PIKAL petr.pi...@precheza.cz 
03/09/2010 01:57 AM

To
Xumin Zeng xumin.z...@abbott.com
cc
r-help r-help@r-project.org
Subject
Odp: [R] how to convert character variables into numeric variables 
directly






Hi

r-help-boun...@r-project.org napsal dne 08.03.2010 18:55:10:

 Here is the example.
 
  age=18:29
  height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5)
  type=c(A, B, C, D,A, B, C, D,A, B, C, D)
  typec=c(0,4,2,9,0,7,2,3,0,1,2,3)
  typen=c(0,1,2,3,0,1,2,3,0,1,2,3)
  data1=data.frame(age=age,height=height, type=type, typec=typec, 
 typen=typen)

With

data1=data.frame(age=age,height=height, type=type, typec=typec, 
typen=typen, stringsAsFactors=F)

your conversion shall work

Regards
Petr


 
  data1[,3]=as.numeric(data1[,3])
  data1[,4]=as.numeric(data1[,4])
  data1[,5]=as.numeric(data1[,5])
 
  print(data1)
 
 and I got the output as:
 
age height type typec typen
 1   18   76.11 1 0
 2   19   77.02 5 1
 3   20   78.13 3 2
 4   21   78.24 7 3
 5   22   78.81 1 0
 6   23   79.72 6 1
 7   24   79.93 3 2
 8   25   81.14 4 3
 9   26   81.21 1 0
 10  27   81.82 2 1
 11  28   82.83 3 2
 12  29   83.54 4 3
 
 The typec is not what I expected. How can I get the direct conversion 
 from character to numeric and get the following output? 
 
age height type typec typen
 1   18   76.11 0 0
 2   19   77.02 4 1
 3   20   78.13 2 2
 4   21   78.24 9 3
 5   22   78.81 0 0
 6   23   79.72 7 1
 7   24   79.93 2 2
 8   25   81.14 3 3
 9   26   81.21 0 0
 10  27   81.82 1 1
 11  28   82.83 2 2
 12  29   83.54 3 3
 
 Thanks.
 
 Xumin
[[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.



[[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] IMPORTANT - To remove the null elements from a vector

2010-03-09 Thread Mario Valle

x - x[x != 0]
If for null elements you intend the value of zero.
Ciao!
mario

On 09-Mar-10 13:48, barbara.r...@uniroma1.it wrote:


I have a vector that have null elements. How to remove these elements?
For example:
x=[10 0 30 40 0 0] I want the vector y=[10 30 40]
Thanks
[[alternative HTML version deleted]]

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


--
Ing. Mario Valle
Data Analysis and Visualization Group| 
http://www.cscs.ch/~mvalle

Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] IMPORTANT - To remove the null elements from a vector

2010-03-09 Thread Paul Hiemstra

barbara.r...@uniroma1.it wrote:

I have a vector that have null elements. How to remove these elements?
For example:
x=[10 0 30 40 0 0] I want the vector y=[10 30 40]
Thanks
[[alternative HTML version deleted]]

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

and, to add to the options already posted:

subset(x, x != 0)

cheers,
Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] Removing Zeros from matrix

2010-03-09 Thread Paul Hiemstra

Dimitris Rizopoulos wrote:



On 3/9/2010 1:36 PM, Paul Hiemstra wrote:

Dimitris Rizopoulos wrote:

one approach is the following:

mat - matrix(rnorm(100*45), 100, 45)
mat[sample(100*45, 50)] - 0

index - rowMeans(mat == 0) == 0
mat[index, ]

Dimitris,

You use quite a complicated syntax to get the index. I think the
following syntax using apply is more easy to understand:


well, this way is much more efficient to compute, especially if you 
have many rows. Compare the following to see the difference:


mat - matrix(rnorm(2*1e06), 1e06, 2)
mat[sample(2*1e06, 50)] - 0

system.time(index1 - !apply(mat == 0, MARGIN = 1, any))

system.time(index2 - rowMeans(mat == 0) == 0 )

all.equal(index1, index2)
Point taken, I totally agree that for large matrices you should use your 
approach. Didn't know that it made such a difference, great to learn 
something new :). But I still like the other syntax more ;).


cheers,
Paul



Best,
Dimitris



# Note, MARGIN equal to 1 means loop over rows
# If any member of a row is zero
index = apply(mat == 0, MARGIN = 1, any)
# If all members of a row are zero
index = apply(mat == 0, MARGIN = 1, all)

cheers and hope it helps,
Paul



I hope it helps.

Best,
Dimitris


On 3/9/2010 11:05 AM, ogbos okike wrote:

Hi Everybody,
I have a matrix of about 45 columns. Some of the rows contain zeros.
Using

data1-data[complete.cases(data),], I can remove the NA rows. But
I am

unable to tackle that of zeros.
Can anybody give me an idea of how to remove rows containing zeros 
in a

matrix.
Thanks so much
Best
Ogbos

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











--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-09 Thread alison waller
Hi all,

Thanks for help with the paste and sprintf syntax.

So I've decided to use paste and or sprintf.  'gsubfn' looks like a
great package but unfortunately I've had problems installing it, as I
don't think it likes the version of tcltk that is installed.  I'm
working on a few unix clusters with many computers and there seems to be
problems with different versions of R and different versions of the
packages on different computers.

So, the other problem is that I want to rename the data.frames and names
of the output jpeg files resulting from the queries.  I've tried a few
different approaches but none seem to work, using sprintf and paste
turns the data frame into just a string of the name.

I have a complicated loop here as I'd like to do some summary output
after every 4 queries (ie. after MG1, MG 19, MG 37, MG 54) then I want
to start again and do for MG2, MG20 etc..

Here's my code below, there are probably error in the loop structure
that I can work out, but I need help with renaming the data frames based
on the parameters i and j

thanks


i-1
j-1

for (i=72 and j=4){{

sqlcmd_ScaffLen- paste(SELECT scaffold.length
FROM scaffold, scaffold2contig, contig2read
WHERE scaffold.scaffold_id=scaffold2contig.scaffold_id AND
scaffold2contig.contig_id=contig2read.contig_id AND
contig2read.read_id LIKE '%MG, i ,%', sep='')

sqlcmd_contigs-paste(SELECT length FROM contig WHERE external_id LIKE
'%MG,i,%',sep='' )

sqlcmd_singletons-paste(SELECT COUNT(*) FROM contig WHERE
read_count=1 AND external_id LIKE '%MG,i,%',sep='')

MGi_ScaffoldLen-dbGetQuery(con,sqlcmd_ScaffLen)
MGi_ContigsLen-dbGetQuery(con,sqlcmd_contigs)
MGi_SingletonsCount-dbGetQuery(con,sqlcmd_singletons)

MGi_ScaffoldLen_Summ-as.data.frame(c(summary(MGi_ScaffoldLen$length),MGi_SingletonsCount))
MGi_ContigsLen_Summ-summary(MGi_ContigsLen$length)

write.table(MGi_ScaffoldLen_Summ,file=ScaffoldLen_SummStats.txt,append=TRUE,sep='\t')

write.table(MGi_ContigsLen_Summ,file=ContigsLen_SummStats.txt,append=TRUE,sep='\t')

i-i+18
j-j+1

}

### Summary Plots For each Treatment ##

jpeg(file=sprintf(Boxplots_%d.jpeg,i)
boxplot(MGi_ScaffoldLen$length,MG(i+18*j)_ScaffoldLen$length,MG(i+_ScaffoldLen$length,MG59_ScaffoldLen$length,Main=400spec_10virus)
dev.off()

jpeg(file=sprintf(Scaffold_histograms_%d.jpeg,i)
hist(MGi_ScaffoldLen$length)
hist(MG(i+j*18)_ScaffoldLen$length)
hist(MG(i+j*18_ScaffoldLen$length)
hist(MG(i+j*18_ScaffoldLen$length)

dev.off()

jpeg(file=sprintf(Contig_histograms_%d.jpeg,i)
hist(MGi_ContigsLen$length)
hist(MG(i+j*18)_ContigsLen$length)
hist(MG(i+j*18_ContigsLen$length)
hist(MG(i+j*18_ContigsLen$length)

dev.off()

j-1
i-2
}


On 03/08/10 21:02, Don MacQueen wrote:
 I always use paste()

 i - 1
 sqlcmd_ScaffLen - paste(SELECT scaffold.length
 FROM scaffold, scaffold2contig, contig2read
 WHERE scaffold.scaffold_id=scaffold2contig.scaffold_id AND
 scaffold2contig.contig_id=contig2read.contig_id AND
 contig2read.read_id LIKE '%MG, i ,%', sep='')

 That should create bits like
LIKE '%MG1%'
LIKE '%MG2%'
 and so on.

 You just have to get the nesting of the single and double quotes
 correct - the SQL requires single quotes, so use double quotes for the
 fixed character strings insidte paste(). That, and use sep='' to get
 rid of unwanted space characters.

 Using paste is also effective for constructs like
   IN (3,4,5)
 or
   IN ('a','b','c')
 though it can be necessary to nest one paste within another

 -Don

 At 2:06 PM +0100 3/8/10, alison waller wrote:
 Hello,

 I am using RmySQL and would like to iterate through a few queries.

 I would like to use sprintf but I think I'm having problems mixing and
 matching the sprintf syntax and the SQL regex.

 I have checked my sqlcmd and it works when I wan to match %MG1% but how
 do I iterate for i 1-72?  Escape characters,?

 thanks in advance

 i-1
 sqlcmd_ScaffLen-sprintf('SELECT scaffold.length
 FROM scaffold,scaffold2contig,contig2read
 WHERE scaffold.scaffold_id=scaffold2contig.scaffold_id AND
 scaffold2contig.contig_id=contig2read.contig_id AND
 contig2read.read_id LIKE
 '%MG%s%' ,i)

 = Here is my vague error message

 Error: unexpected input in:

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



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


Re: [R] Help! I turned my data into junk!

2010-03-09 Thread Jim Lemon

On 03/09/2010 01:49 PM, Brienne wrote:


I posted my data for a midterm into notepad and it turned into symbols.  The
other bit I posted turned out just fine, but for some reason this one messed
up.  I need this stuff for a class.  Anyone know how to get my data back.
Please help soon!

Hi Brienne,
As far as I am aware, you can't post something into Notepad. You can 
open a file, and it almost always has to be a text file, otherwise you 
will see a mess of symbols. My guess is that you were supplied with a 
data file for an assignment, and when you opened it in Notepad, it was a 
mess. As Ravi noted, you can often work out what application to use by 
looking at the extension (the part of the filename after the last 
period). So .xls or .xlsx is for Excel, .doc or .docx is for Word, and 
.mdb is for Access. I'm pretty sure that you will find that one of these 
applications is the one you want.


Jim

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


[R] create picture (k -the nearest neighbours)

2010-03-09 Thread Grzesiek

Hi 
I want to create a nice picture about my result of k -the nearest neighbours
algorithm. Here is my easy code:
#
library(klaR)
library(ipred)
library(mlbench)

data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)

KNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)
KNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)

b= ifelse((a==1),'red','blue' )
a=as.numeric(KNN$learn$y)

plot(KNN$learn$X[,1], KNN$learn$X[,2],pch=a,col = ifelse((a==1),'red','blue'
))

#

and my problem is (it's difficult for me to explain it in english):
What I should do if I want to get in my picture area (in different colors)
which will be show my clasters. Like in picture (dark blue and bright
blue).

http://n4.nabble.com/file/n1585911/dec.jpg 
-- 
View this message in context: 
http://n4.nabble.com/create-picture-k-the-nearest-neighbours-tp1585911p1585911.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] Problem with mean

2010-03-09 Thread Erik Iverson

See FAQ 7.31

venkata kirankumar wrote:

Hi all,
I got one intresting problem with caliculating mean that is

while i am taking mean of values

*0.6, -0.8, 4, -3.8*

using
*val-c(0.6, -0.8, 4, -3.8)*
*mean(val)*
it given result as
*2.775558e-17*

but the actual result is  *0*

can any one suggest how can I get correct mean result in this case

can any one suggest how I can farward

thanks in regards

kiran

[[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] Deltas or changes

2010-03-09 Thread Henrique Dallazuanna
You can try this:

Reduce(/, as.data.frame(embed(x, 2)))

On Tue, Mar 9, 2010 at 10:37 AM, ManInMoon xmoon2...@googlemail.com wrote:

 How can I generate a vector of differences between each elemtn of an vector?

 i.e. a[i]=x[i]/x[i-1]
 --
 View this message in context: 
 http://n4.nabble.com/Deltas-or-changes-tp1585960p1585960.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.




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

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

2010-03-09 Thread Ista Zahn
round(mean(val), digits=16)

-Ista

On Tue, Mar 9, 2010 at 10:23 AM, venkata kirankumar
kiran4u2...@gmail.com wrote:
 Hi all,
 I got one intresting problem with caliculating mean that is

 while i am taking mean of values

 *0.6, -0.8, 4, -3.8*

 using
 *val-c(0.6, -0.8, 4, -3.8)*
 *mean(val)*
 it given result as
 *2.775558e-17*

 but the actual result is  *0*

 can any one suggest how can I get correct mean result in this case

 can any one suggest how I can farward

 thanks in regards

 kiran

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


[R] Help with ANOVA in R

2010-03-09 Thread Amit Patel
Hi

I am attempting Anova analysis to compare results from four groups
(Samp1-4) which are lists of intensities from the experiment. I am
doing this by first creating a structured list of the data and then
conducting the ANOVA (Script provided below). Im an R beginner so am
not sure if I am using this correctly. Two major questions I have are:

1)
Is using the code (zzz.aov - aov(Intensity ~ Group + Error(Sample),
data = zzzanova)) the correct method to calculate the variances between
the four groups (samp 1-4). I am unsure of the inclusion of the error
portion.

2) I beleive this method (aov) assumes equal variances. How can I adjust this 
to do an ANOVA with unequal variances




#SCRIPT STARTS
#Creates a structured list suitable for ANOVA analysis
# Intensity Group (1,2,3,4) Sample(1:62)
zzzanova -
structure(list(Intensity = c(t(Samp1), t(Samp2), t(Samp3), t(Samp4)), 
Group = structure(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
 3,3,3,3,3,3,3,3,3,3,3,3,3,3,
 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4), .Label = c(Group1, Group2, 
Group3, Group4), class = factor), 
Sample = structure(c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 
40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62)
))
, .Names = c(Intensity, 
Group, Sample), row.names = 
c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61,62),class = data.frame)

#Conducts the ANOVA for that PCI
zzz.aov - aov(Intensity ~ Group + Error(Sample), data = zzzanova)

#SCRIPT ENDS


THANKS IN ADVANCE




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

2010-03-09 Thread Henrique Dallazuanna
If the package is installed:

ls(findPackageEnv(package:RSSA))

On Tue, Mar 9, 2010 at 7:54 AM, Jannis bt_jan...@yahoo.de wrote:
 Dears,


 I am trying to implement some R package which is still under construction and 
 has not yet been submitted to CRAN (RSSA, 
 http://anton.korobeynikov.info/software). Documentation is yet very poor (or 
 i just did not find it), so I am wondering whether there is any way to 
 retrieve a list of commands available in this package from within R? And to 
 find out whether the package is successfully installed. After downloading the 
 zip and installing it within R I only got the error message that it was 
 created with an earlier R version and help would not work



 Thanks for your help!
 Jannis


 __
 D
 usragenden Schutz gegen Massenmails.
 http://mail.yahoo.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.




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Removing Zeros from matrix:Problem fixed

2010-03-09 Thread ogbos okike
Hey,
Thanks for your great inputs. While index = apply(mat == 0, MARGIN = 1,
any) gives you an idea of the rows containing zero(s),
index-data[!apply(data==0,MARGIN=1,any),] does the actual job of removing
the rows with zeros.
Kind regards
Ogbos

On 9 March 2010 15:12, Paul Hiemstra p.hiems...@geo.uu.nl wrote:

 Dimitris Rizopoulos wrote:



 On 3/9/2010 1:36 PM, Paul Hiemstra wrote:

 Dimitris Rizopoulos wrote:

 one approach is the following:

 mat - matrix(rnorm(100*45), 100, 45)
 mat[sample(100*45, 50)] - 0

 index - rowMeans(mat == 0) == 0
 mat[index, ]

 Dimitris,

 You use quite a complicated syntax to get the index. I think the
 following syntax using apply is more easy to understand:


 well, this way is much more efficient to compute, especially if you have
 many rows. Compare the following to see the difference:

 mat - matrix(rnorm(2*1e06), 1e06, 2)
 mat[sample(2*1e06, 50)] - 0

 system.time(index1 - !apply(mat == 0, MARGIN = 1, any))

 system.time(index2 - rowMeans(mat == 0) == 0 )

 all.equal(index1, index2)

 Point taken, I totally agree that for large matrices you should use your
 approach. Didn't know that it made such a difference, great to learn
 something new :). But I still like the other syntax more ;).

 cheers,
 Paul



 Best,
 Dimitris


  # Note, MARGIN equal to 1 means loop over rows
 # If any member of a row is zero
 index = apply(mat == 0, MARGIN = 1, any)
 # If all members of a row are zero
 index = apply(mat == 0, MARGIN = 1, all)

 cheers and hope it helps,
 Paul



 I hope it helps.

 Best,
 Dimitris


 On 3/9/2010 11:05 AM, ogbos okike wrote:

 Hi Everybody,
 I have a matrix of about 45 columns. Some of the rows contain zeros.
 Using

 data1-data[complete.cases(data),], I can remove the NA rows. But
 I am

 unable to tackle that of zeros.
 Can anybody give me an idea of how to remove rows containing zeros in a
 matrix.
 Thanks so much
 Best
 Ogbos

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







 --
 Drs. Paul Hiemstra
 Department of Physical Geography
 Faculty of Geosciences
 University of Utrecht
 Heidelberglaan 2
 P.O. Box 80.115
 3508 TC Utrecht
 Phone:  +3130 274 3113 Mon-Tue
 Phone:  +3130 253 5773 Wed-Fri
 http://intamap.geo.uu.nl/~paul http://intamap.geo.uu.nl/%7Epaul



[[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] MASS package not on CRAN ?

2010-03-09 Thread Uwe Ligges



On 09.03.2010 15:39, Ista Zahn wrote:

MASS is a recommended package, so is probably already installed on
your machine. Try



And if installation fails, it is either your internet connection that 
does not download the file in its original form or you have a broken 
installation of R (which would also be indicated if MASS is not already 
installed given you installed a released version of R).


Best,
Uwe Ligges





library(MASS)

-Ista

On Tue, Mar 9, 2010 at 9:32 AM, Markus Loechermarkus.loec...@gmail.com  wrote:

The MASS package is listed on the CRAN web site (
http://cran.r-project.org/web/packages/MASS/index.html) but I am unable to
install it via install.packages(). The error is that the package is
unavailable. When I manually download the source tar ball and try to
install it on a Linux machine, installation fails because it is not a valid
package.

Do I need to search different repositories ?
Thanks,
Markus

[[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] rcom package

2010-03-09 Thread Albert-Jan Roskam
Hi,
 
I would like to make a program that reads excel files, and writes the cells of 
which contents is not a formula to another file. I don't think this is possible 
with RODBC, but it may be possible with rcom.  
 
I read the documentation of the rcom package, but I was hoping somebody knows a 
good web resource for more eleborate info. I tried Googling, but alas (did you 
know rcom also is a kind of egg incubator? ;-). In particular, I would like to 
have a list of the possible values for the 'property' argument.

Thanks in advance!

Cheers!!
Albert-Jan

~~
In the face of ambiguity, refuse the temptation to guess.
~~


  
[[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] ggplot2 rose diagram

2010-03-09 Thread Tim Howard
Dear R gurus - 

consider this plot:

library(ggplot2)
dat - sample(1:8,100,replace=TRUE)
smp - ggplot(data.frame(dat), aes(x=factor(dat),fill=factor(dat))) + 
geom_bar(width=1)
smp + coord_polar() 


Q1. How do I change the font size and weight of bar labels (1,2,3...)?  I've 
been wallowing in the 'Themes' structure and I just can't figure out the 
correct place to change the definitions. Along these same lines, what does 
'strip' mean when referring to strip text? 

Q2. How can I move the legend defining bar height into the plot, so that it 
overlays the lines they refer to?


Consider the same figure using Circstats:

library(CircStats)
dat.rad - (dat*((2*pi)/8)) -(2*pi)/16
rose.diag(dat.rad, bins = 8)  #note the origin is to the right rather than on 
top

Q3. The key difference is that CircStats uses an area-based calculation for the 
size of each slice, which makes for a different presentation than ggplot2. Any 
suggestions on how to use this calculation method in the ggplot framework? 

Thanks in advance for your help.
Tim Howard
New York Natural Heritage Program

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 with adaboost: replacement has 186 rows, data has 62

2010-03-09 Thread Xumin Zeng
Hi, all,

When running  AB.fit=adaboost(ylearn, xlearn, xtest, presel=0) I got the 
following error: 

Error in `[[-.data.frame`(`*tmp*`, preds, value = c(4L, 6L, 6L, 6L, 3L, : 


  replacement has 186 rows, data has 62 

The data structure is attached below: 

[1] ylearn 
 [1] 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 

0 0 0 0 
[40] 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 

[1] xlearn 
rs2289472 rs1551398 rs7927894 
X18 CT  AA  CT 
X19 TT  AA  CC 
X33 TT  AG  TT 
X35 TT  AA  CT 
X36 CC  AA  CT 
X41 CT  AA  CT 
X46 TT  AA  CT 
X65 CT  AG  CT 
X77 CC  AA  CT 
X25 TT  AG  TT 
X26 CT  GG  CC 
X53 CT  GG  CC 
X55 CT  AG  CC 
X57 CT  AG  TT 
X71 CT  AA  CT 
X4  TT  AA  CT 
X7  CT  AG  CT 
X21 TT  AA  CT 
X22 TT  AA  TT 
X31 CT  AG  CT 
X32 CT  AG  TT 
X37 CT  AA  CT 
X50 TT  AA  CT 
X66 CC  AA  CC 
X28 CT  AG  CC 
X29 CT  AG  CT 
X30 CT  GG  CT 
X56 CT  AG  CC 
X62 CT  GG  CC 
X63 TT  GG  CT 
X1  CT  AG  CT 
X3  TT  AG  TT 
X8  CC  GG  CC 
X9  TT  AA  CT 
X38 CT  GG  TT 
X40 TT  AG  CT 
X43 CT  AG  CC 
X45 TT  AA  CC 
X47 TT  AA  TT 
X11 TT  AA  TT 
X13 CT  GG  CT 
X15 CT  AG  TT 
X16 TT  AA  CT 
X27 CT  AG  CC 
X58 TT  AG  CC 
X70 CT  AA  CC 
X2  CC  AA  CT 
X6  CT  AA  CT 
X10 CC  AA  CC 
X14 TT  AA  TT 
X39 TT  GG  CT 
X44 CT  AG  CT 
X49 TT  AG  TT 
X51 TT  AA  CT 
X67 CT  AA  CC 
X12 CT  AG  CT 
X54 CT  AG  CC 
X61 CT  AA  CC 
X68 CT  AG  CC 
X69 CT  AG  TT 
X73 TT  AA  CC 
X74 TT  GG  CT 

[1] xtest 
   rs2289472 rs1551398 rs7927894 
5  TT  AA  TT 
20 CT  AG  CC 
23 CT  AG  CT 
24 CC  GG  TT 
34 CC  AA  TT 
42 CT  AA  CT 
48 CC  AG  CC 
59 CT  AA  CC 
75 CT  AG  CT 
17 CT  AG  CT 
52 CT  AA  TT 
60 CT  AG  CT 
64 TT  AA  CT 
72 TT  AG  CT 
76 TT  AA  CT 

do you know what's the protential problem? Thanks in advance. 

Xumin 

[[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] MASS package not on CRAN ?

2010-03-09 Thread Markus Loecher
In fact, I must have a broken installation of R then (though I have not
noticed any other problems so far).
The library MASS is neither pre-installed nor can I explicitly install it
(though the internet connection is up and functional).

Thanks for all the help !

Markus

2010/3/9 Uwe Ligges lig...@statistik.tu-dortmund.de



 On 09.03.2010 15:39, Ista Zahn wrote:

 MASS is a recommended package, so is probably already installed on
 your machine. Try



 And if installation fails, it is either your internet connection that does
 not download the file in its original form or you have a broken installation
 of R (which would also be indicated if MASS is not already installed given
 you installed a released version of R).

 Best,
 Uwe Ligges





  library(MASS)

 -Ista

 On Tue, Mar 9, 2010 at 9:32 AM, Markus Loechermarkus.loec...@gmail.com
  wrote:

 The MASS package is listed on the CRAN web site (
 http://cran.r-project.org/web/packages/MASS/index.html) but I am unable
 to
 install it via install.packages(). The error is that the package is
 unavailable. When I manually download the source tar ball and try to
 install it on a Linux machine, installation fails because it is not a
 valid
 package.

 Do I need to search different repositories ?
 Thanks,
 Markus

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






[[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] Source code for the t-distribution

2010-03-09 Thread Sundar Dorai-Raj
Here it is.

https://svn.r-project.org/R/trunk/src/nmath/pt.c

--sundar

On Tue, Mar 9, 2010 at 4:24 AM, Ravi Kulkarni ravi.k...@gmail.com wrote:


 I have tried looking for the source code for the pt() function in

 https://svn.r-project.org/R/trunk/src/library/stats/

 and am unable to find it there. Can someone please tell me where to find
 it?

 Thanks,
  Ravi Kulkarni
 --
 View this message in context:
 http://n4.nabble.com/Source-code-for-the-t-distribution-tp1585875p1585875.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.


[[alternative HTML version deleted]]

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


[R] error with adaboost: replacement has 186 rows, data has 62

2010-03-09 Thread Xumin Zeng
When running  AB.fit=adaboost(ylearn, xlearn, xtest, presel=0) I got the 
following error:

Error in `[[-.data.frame`(`*tmp*`, preds, value = c(4L, 6L, 6L, 6L, 3L, : 

  replacement has 186 rows, data has 62

The data structure is attached below:

[1] ylearn
 [1] 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 
0 0 0 0
[40] 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1

[1] xlearn
rs2289472 rs1551398 rs7927894
X18 CT  AA  CT 
X19 TT  AA  CC 
X33 TT  AG  TT 
X35 TT  AA  CT 
X36 CC  AA  CT 
X41 CT  AA  CT 
X46 TT  AA  CT 
X65 CT  AG  CT 
X77 CC  AA  CT 
X25 TT  AG  TT 
X26 CT  GG  CC 
X53 CT  GG  CC 
X55 CT  AG  CC 
X57 CT  AG  TT 
X71 CT  AA  CT 
X4  TT  AA  CT 
X7  CT  AG  CT 
X21 TT  AA  CT 
X22 TT  AA  TT 
X31 CT  AG  CT 
X32 CT  AG  TT 
X37 CT  AA  CT 
X50 TT  AA  CT 
X66 CC  AA  CC 
X28 CT  AG  CC 
X29 CT  AG  CT 
X30 CT  GG  CT 
X56 CT  AG  CC 
X62 CT  GG  CC 
X63 TT  GG  CT 
X1  CT  AG  CT 
X3  TT  AG  TT 
X8  CC  GG  CC 
X9  TT  AA  CT 
X38 CT  GG  TT 
X40 TT  AG  CT 
X43 CT  AG  CC 
X45 TT  AA  CC 
X47 TT  AA  TT 
X11 TT  AA  TT 
X13 CT  GG  CT 
X15 CT  AG  TT 
X16 TT  AA  CT 
X27 CT  AG  CC 
X58 TT  AG  CC 
X70 CT  AA  CC 
X2  CC  AA  CT 
X6  CT  AA  CT 
X10 CC  AA  CC 
X14 TT  AA  TT 
X39 TT  GG  CT 
X44 CT  AG  CT 
X49 TT  AG  TT 
X51 TT  AA  CT 
X67 CT  AA  CC 
X12 CT  AG  CT 
X54 CT  AG  CC 
X61 CT  AA  CC 
X68 CT  AG  CC 
X69 CT  AG  TT 
X73 TT  AA  CC 
X74 TT  GG  CT 

[1] xtest
   rs2289472 rs1551398 rs7927894
5  TT  AA  TT 
20 CT  AG  CC 
23 CT  AG  CT 
24 CC  GG  TT 
34 CC  AA  TT 
42 CT  AA  CT 
48 CC  AG  CC 
59 CT  AA  CC 
75 CT  AG  CT 
17 CT  AG  CT 
52 CT  AA  TT 
60 CT  AG  CT 
64 TT  AA  CT 
72 TT  AG  CT 
76 TT  AA  CT 

do you know what's the protential problem? Thanks in advance.

Xumin
[[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] rcom package

2010-03-09 Thread Gabor Grothendieck
If you just want to read tabular data from Excel then there are many
options in R:
http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows

On Tue, Mar 9, 2010 at 10:35 AM, Albert-Jan Roskam fo...@yahoo.com wrote:
 Hi,

 I would like to make a program that reads excel files, and writes the cells 
 of which contents is not a formula to another file. I don't think this is 
 possible with RODBC, but it may be possible with rcom.

 I read the documentation of the rcom package, but I was hoping somebody knows 
 a good web resource for more eleborate info. I tried Googling, but alas (did 
 you know rcom also is a kind of egg incubator? ;-). In particular, I would 
 like to have a list of the possible values for the 'property' argument.

 Thanks in advance!

 Cheers!!
 Albert-Jan

 ~~
 In the face of ambiguity, refuse the temptation to guess.
 ~~



        [[alternative HTML version deleted]]


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



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


Re: [R] Help! I turned my data into junk!

2010-03-09 Thread Albin Blaschka

Am 09.03.2010 03:49, schrieb Brienne:


I posted my data for a midterm into notepad and it turned into symbols.  The
other bit I posted turned out just fine, but for some reason this one messed
up.  I need this stuff for a class.  Anyone know how to get my data back.
Please help soon!


Hello!

You copied it from where? With Ctrl-C / Ctrl-V, you are on windows, I 
assume? Just a wild guess: You have a problem with encodings: What 
happens if you copy it back from where ever you fetched the data?
But not to give hope place, I think you (better your data) are/is 
lost... But without knowing the source, nothing more can be said...


Albin

--
-
| Albin Blaschka, Mag. rer.nat - Salzburg, Austria
| http://www.albinblaschka.info   http://www.thinkanimal.info
| It's hard to live in the mountains, hard, but not hopeless!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] wavethresh: length must be power of two

2010-03-09 Thread Oscar Perpiñan Lamigueiro
Hello.

I am using the 4.2 version of the wavethresh package available from here: 
http://www.stats.bris.ac.uk/~wavethresh/ trying to follow the book of Nason 
(http://www.springer.com/978-0-387-75960-9). 

I am interested in the analysis of several years time series of daily data with 
wavelets methods. But the functions of this package only accept data whose 
lengths are power of two, even for non-decimated DWT. 

For example:

 data=rnorm(365)
 wdS - wd(data, type=station)
Error en wd(data, type = station) : Data length is not power of two

A possible solution is to analyse a window with a length power of two. For this 
example:

 data2=data[1:(2^trunc(log(365,2)))]
 wdS2 - wd(data2, type=station)

or pad with zeros:

 data3=data
 length(data3)-2^ceiling(log(length(data),2))
 data3[is.na(data3)]-0
 wdS3-wd(data3,type='station')

Is there any other solution?

By the way, does anybody knows why the wavethresh package at CRAN is not being 
updated?

Thank you very much!

Oscar Perpiñán Lamigueiro
Department of Electrical Engineering
Universidad Politécnica de Madrid

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] is there an inverse method for table()?

2010-03-09 Thread vincent laperriere
Hi,

In R, I know the method table(), which builds a contingency table of the counts 
y at each level for the factor x.
But I would like to know what is the inverse method of table(), if it exists, 
to obtain the vector z, from the two vectors x and y?

x - (86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 
146, 150, 154, 158, 162, 166, 170, 174)
y - c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 26, 17, 9, 
5, 2, 3, 7, 3)

 z
   [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94  94  94  98  
98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 102 102 102 102 
102
  [40] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 
102 102 102... 
  [976] ...170 170 170 170 170 170 170 174 174 174

If such a method does not exist, what code should I type to obtain the complete 
series quickly?

Thank you for your help.
I use version 2.10-1 2009-08-24 for Mac OS.

Vincent Laperrière.


  
[[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] counting the number of ones in a vector

2010-03-09 Thread Randall Wrong
Thank you Gavin and Bert

2010/3/4 Gavin Simpson gavin.simp...@ucl.ac.uk

 On Thu, 2010-03-04 at 00:03 +0100, Randall Wrong wrote:
  Thanks to all of you !
 
  (Benjamin Nutter, Henrique Dallazuanna, Tobias Verbeke, Jorge Ivan
  Velez, David Reinke and Gavin Simpson)
 
 
  x - c(1, 1, 1, NA, NA, 2, 1, NA)
 
   table(x)[1]
  1
  4
 
  Why do I get two numbers ?

 It is a printing a named vector. The 1 is the group of factor level,
 the 4 is the count, try:

 unname(table(x)[1])

 and

 str(table(x)[1])

 etc to see what is going on.

 HTH

 G

 
  Thanks,
  Randall
 
 
 
  2010/2/26 Nutter, Benjamin nutt...@ccf.org
  But if x has any missing values:
 
   x - c(1, 1, 1, NA, NA, 2, 1, NA)
  
   sum( x == 1)
  [1] NA
  
   sum(x==1, na.rm=TRUE)
  [1] 4
 
 
 
 
 
  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of Henrique
  Dallazuanna
  Sent: Friday, February 26, 2010 9:47 AM
  To: Randall Wrong
  Cc: r-help@r-project.org
  Subject: Re: [R] counting the number of ones in a vector
 
  Try:
 
  sum(x == 1)
 
  On Fri, Feb 26, 2010 at 11:40 AM, Randall Wrong
  randall.wr...@gmail.com wrote:
   Dear R users,
  
   I want to count the number of ones in a vector x.
  
   That's what I did : length( x[x==1] )
  
   Is that a good solution ?
   Thank you very much,
   Randall
  
  [[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.htmlhttp://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
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible
  code.
 
 
 
  ===
 
  P Please consider the environment before printing this e-mail
 
  Cleveland Clinic is ranked one of the top hospitals
  in America by U.S.News  World Report (2009).
  Visit us online at http://www.clevelandclinic.org for
  a complete listing of our services, staff and
  locations.
 
 
  Confidentiality Note:  This message is intended for use
 
 
  only by the individual or entity to which it is addressed
  and may contain information that is privileged,
  confidential, and exempt from disclosure under applicable
  law.  If the reader of this message is not the intended
  recipient or the employee or agent responsible for
  delivering the message to the intended recipient, you are
  hereby notified that any dissemination, distribution or
  copying of this communication is strictly prohibited.  If
  you have received this communication in error,  please
  contact the sender immediately and destroy the material in
  its entirety, whether electronic or hard copy.  Thank you.
 
 
 

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



[[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] is there an inverse method for table()?

2010-03-09 Thread Ravi Varadhan
z - rep(x, each = y)

Hope this helps,
Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: vincent laperriere vincent_laperri...@yahoo.fr
Date: Tuesday, March 9, 2010 10:59 am
Subject: [R] is there an inverse method for table()?
To: r-help@r-project.org


 Hi,
  
  In R, I know the method table(), which builds a contingency table of 
 the counts y at each level for the factor x.
  But I would like to know what is the inverse method of table(), if it 
 exists, to obtain the vector z, from the two vectors x and y?
  
  x - (86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 
 138, 142, 146, 150, 154, 158, 162, 166, 170, 174)
  y - c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 
 26, 17, 9, 5, 2, 3, 7, 3)
  
   z
 [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94  
 94  94  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 
  98 102 102 102 102 102
[40] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 
 102 102 102 102 102 102... 
[976] ...170 170 170 170 170 170 170 174 174 174
  
  If such a method does not exist, what code should I type to obtain 
 the complete series quickly?
  
  Thank you for your help.
  I use version 2.10-1 2009-08-24 for Mac OS.
  
  Vincent Laperrière.
  
  

   [[alternative HTML version deleted]]
   
 __
  R-help@r-project.org mailing list
  
  PLEASE do read the posting guide 
  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] Computation of AIC for gls models

2010-03-09 Thread Miguel Angel Rodríguez-Gironés Arbolí
Dear Colleagues,



We are using the phylog.gls.fit() function from the R package PHYLOGR 
(Diaz-Uriarte R, Garland T: PHYLOGR: Functions for phylogenetically based 
statistical analyses. 2007. Available at 
[http://cran.r-project.org/web/packages/PHYLOGR/index.html]) to correct for 
lack of independence between data points. (In our particular case, the lack of 
independence is due to common ancestry, hence the choice of PHYLOGR package.) 
The output provides P values for the variables included in the model, but 
according to Diaz-Uriarte and Garland (2007) the total F is unreliable.



Because there are a number of variables that we could potentially include in 
the analysis, we would want to use AIC values for model selection. We can 
obtain these values directly with the function AIC(), or from the 
log-likelihood obtained with the logLik() function. (The two methods give the 
same results.)



We have two questions concerning this procedure:



1. Does anybody know whether the output we obtain from the AIC() and logLik() 
functions is reliable? Does the algorithm used for calculating the model 
likelihood and AIC take into account the non-independence of data points? Or 
are the log-likelihood and AIC calculated using some standard R algorithm that 
is not valid for phylog.gls models or gls?



2. Is the logLik extracted from phylog.gls suitable for a type-III 
log-likelhood ratio test?



Thanks so much,



Miguel Rodriguez-Girones

Estación Experimental de Zonas Aridas, CSIC


[[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] is there an inverse method for table()?

2010-03-09 Thread Ravi Varadhan
Sorry, I mean to say:

z - rep(x, y)

Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Ravi Varadhan rvarad...@jhmi.edu
Date: Tuesday, March 9, 2010 11:02 am
Subject: Re: [R] is there an inverse method for table()?
To: vincent laperriere vincent_laperri...@yahoo.fr
Cc: r-help@r-project.org


 z - rep(x, each = y)
  
  Hope this helps,
  Ravi.
  
  
  
  Ravi Varadhan, Ph.D.
  Assistant Professor,
  Division of Geriatric Medicine and Gerontology
  School of Medicine
  Johns Hopkins University
  
  Ph. (410) 502-2619
  email: rvarad...@jhmi.edu
  
  
  - Original Message -
  From: vincent laperriere vincent_laperri...@yahoo.fr
  Date: Tuesday, March 9, 2010 10:59 am
  Subject: [R] is there an inverse method for table()?
  To: r-help@r-project.org
  
  
   Hi,

In R, I know the method table(), which builds a contingency table 
 of 
   the counts y at each level for the factor x.
But I would like to know what is the inverse method of table(), if 
 it 
   exists, to obtain the vector z, from the two vectors x and y?

x - (86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 
 134, 
   138, 142, 146, 150, 154, 158, 162, 166, 170, 174)
y - c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 
 51, 
   26, 17, 9, 5, 2, 3, 7, 3)

 z
   [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94 
  
   94  94  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  
 98 
98 102 102 102 102 102
  [40] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 
 
   102 102 102 102 102 102... 
  [976] ...170 170 170 170 170 170 170 174 174 174

If such a method does not exist, what code should I type to obtain 
 
   the complete series quickly?

Thank you for your help.
I use version 2.10-1 2009-08-24 for Mac OS.

Vincent Laperrière.


  
  [[alternative HTML version deleted]]
 
   __
R-help@r-project.org mailing list

PLEASE do read the posting guideand 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] is there an inverse method for table()?

2010-03-09 Thread Barry Rowlingson
On Tue, Mar 9, 2010 at 3:58 PM, vincent laperriere
vincent_laperri...@yahoo.fr wrote:
 Hi,

 In R, I know the method table(), which builds a contingency table of the 
 counts y at each level for the factor x.
 But I would like to know what is the inverse method of table(), if it exists, 
 to obtain the vector z, from the two vectors x and y?

 x - (86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 
 142, 146, 150, 154, 158, 162, 166, 170, 174)
 y - c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 26, 17, 
 9, 5, 2, 3, 7, 3)

 z
   [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94  94  94  98 
  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 102 102 102 
 102 102
  [40] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 
 102 102 102...
  [976] ...170 170 170 170 170 170 170 174 174 174

 If such a method does not exist, what code should I type to obtain the 
 complete series quickly?


rep(x,y)?

repeats each element in x the number of times in y. Looks about right.

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] IMPORTANT - To remove the null elements from a vector

2010-03-09 Thread Jorge Ivan Velez
Hi Barbara,

Try

x[ x != 0 ]

HTH,
Jorge


On Tue, Mar 9, 2010 at 7:48 AM,  wrote:


 I have a vector that have null elements. How to remove these elements?
 For example:
 x=[10 0 30 40 0 0] I want the vector y=[10 30 40]
 Thanks
[[alternative HTML version deleted]]

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


[[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] using sprintf to pass a variable to a RMySQL query

2010-03-09 Thread Gabor Grothendieck
On Tue, Mar 9, 2010 at 7:10 AM, alison waller alison.wal...@embl.de wrote:
 Hi all,

 Thanks for help with the paste and sprintf syntax.

 So I've decided to use paste and or sprintf.  'gsubfn' looks like a
 great package but unfortunately I've had problems installing it, as I
 don't think it likes the version of tcltk that is installed.  I'm
 working on a few unix clusters with many computers and there seems to be
 problems with different versions of R and different versions of the
 packages on different computers.

The fn$ functionality that I mentioned does not use the tcltk package
so the version of tcltk should not matter.

The only part of the package that uses tcltk is strapply, which is not
used here, and even in that case there is R code to it as well if you
use strapply(..., engine = R) or use ostrapply.

Also the older 0.3-9 version of the gsubfn package did not use tcltk at all.

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

2010-03-09 Thread ManInMoon

How can I generate a vector of differences between each elemtn of an vector?

i.e. a[i]=x[i]/x[i-1]
-- 
View this message in context: 
http://n4.nabble.com/Deltas-or-changes-tp1585960p1585960.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] Deltas or changes

2010-03-09 Thread Dimitris Rizopoulos

try this:

x - runif(100)

a - x[-1] / x[-length(x)]
a


I hope it helps.

Best,
Dimitris


On 3/9/2010 2:37 PM, ManInMoon wrote:


How can I generate a vector of differences between each elemtn of an vector?

i.e. a[i]=x[i]/x[i-1]


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University 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] Removing Zeros from matrix

2010-03-09 Thread Dimitris Rizopoulos



On 3/9/2010 1:36 PM, Paul Hiemstra wrote:

Dimitris Rizopoulos wrote:

one approach is the following:

mat - matrix(rnorm(100*45), 100, 45)
mat[sample(100*45, 50)] - 0

index - rowMeans(mat == 0) == 0
mat[index, ]

Dimitris,

You use quite a complicated syntax to get the index. I think the
following syntax using apply is more easy to understand:


well, this way is much more efficient to compute, especially if you have 
many rows. Compare the following to see the difference:


mat - matrix(rnorm(2*1e06), 1e06, 2)
mat[sample(2*1e06, 50)] - 0

system.time(index1 - !apply(mat == 0, MARGIN = 1, any))

system.time(index2 - rowMeans(mat == 0) == 0 )

all.equal(index1, index2)


Best,
Dimitris



# Note, MARGIN equal to 1 means loop over rows
# If any member of a row is zero
index = apply(mat == 0, MARGIN = 1, any)
# If all members of a row are zero
index = apply(mat == 0, MARGIN = 1, all)

cheers and hope it helps,
Paul



I hope it helps.

Best,
Dimitris


On 3/9/2010 11:05 AM, ogbos okike wrote:

Hi Everybody,
I have a matrix of about 45 columns. Some of the rows contain zeros.
Using

data1-data[complete.cases(data),], I can remove the NA rows. But
I am

unable to tackle that of zeros.
Can anybody give me an idea of how to remove rows containing zeros in a
matrix.
Thanks so much
Best
Ogbos

[[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 University 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] is there an inverse method for table()?

2010-03-09 Thread ONKELINX, Thierry
rep() is your friend.

HTH,

Thierry

 x - c(86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 
 142, 146, 150, 154, 158, 162, 166, 170, 174)
 y - c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 26, 17, 
 9, 5, 2, 3, 7, 3)
 rep(x, y)
   [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94  94  94  98
  [19]  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 102 102
  [37] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102
  [55] 102 102 102 102 102 102 106 106 106 106 106 106 106 106 106 106 106 106
  [73] 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106
  [91] 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106
 [109] 106 106 106 106 106 106 106 106 106 106 106 106 110 110 110 110 110 110
 [127] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [145] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [163] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [181] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [199] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 114 114
 [217] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [235] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [253] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [271] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [289] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [307] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [325] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [343] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [361] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [379] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [397] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [415] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [433] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [451] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [469] 118 118 118 118 118 118 118 118 118 118 118 122 122 122 122 122 122 122
 [487] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [505] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [523] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [541] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [559] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [577] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [595] 122 122 122 122 122 122 122 122 122 122 122 122 122 126 126 126 126 126
 [613] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [631] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [649] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [667] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [685] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
 [703] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
 [721] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
 [739] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 134 134 134 134
 [757] 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134
 [775] 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134
 [793] 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134
 [811] 134 134 134 134 134 134 134 138 138 138 138 138 138 138 138 138 138 138
 [829] 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138
 [847] 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138
 [865] 138 138 138 138 138 138 138 138 138 138 138 138 138 142 142 142 142 142
 [883] 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142
 [901] 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142
 [919] 142 142 142 142 142 142 142 142 142 142 146 146 146 146 146 146 146 146
 [937] 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146
 [955] 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 154
 [973] 154 154 154 154 154 154 154 154 158 158 158 158 158 162 162 166 166 166
 [991] 170 170 170 170 170 170 170 174 174 174


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie  Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics  Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 

Re: [R] is there an inverse method for table()?

2010-03-09 Thread Gabor Grothendieck
Try

  as.data.frame.table(mytable)

On Tue, Mar 9, 2010 at 10:58 AM, vincent laperriere
vincent_laperri...@yahoo.fr wrote:
 Hi,

 In R, I know the method table(), which builds a contingency table of the 
 counts y at each level for the factor x.
 But I would like to know what is the inverse method of table(), if it exists, 
 to obtain the vector z, from the two vectors x and y?

 x - (86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 
 142, 146, 150, 154, 158, 162, 166, 170, 174)
 y - c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 26, 17, 
 9, 5, 2, 3, 7, 3)

 z
   [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94  94  94  98 
  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 102 102 102 
 102 102
  [40] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 
 102 102 102...
  [976] ...170 170 170 170 170 170 170 174 174 174

 If such a method does not exist, what code should I type to obtain the 
 complete series quickly?

 Thank you for your help.
 I use version 2.10-1 2009-08-24 for Mac OS.

 Vincent Laperrière.



        [[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] A list of data.frames merged together

2010-03-09 Thread Daniel Brewer
Hello,

I have for a long list of data.frames that I would like to get merged.
Each data.frame have two columns with the same names (Date and Value).
What I would like is for the objects in the list to be merged on Only
date with the column header being the name in the list.

For example

A - data.frame(Date=c(03/15/10,04/15/10,05/15/10),
Value=c(1,2,3))
B - data.frame(Date=c(03/15/10,04/15/10,06/15/10),
Value=c(5,5,5))
...

yoda - list(A=A,B=B,...)

Result:

DateA   B   C
03/15/101   5   ...
04/15/102   5
05/15/103   NA
06/15/10NA  5

Any ideas? I have been fiddling around with plyr and reshape without success

Thanks

Dan

-- 
**

Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom

Tel: +44 (0) 20 8722 4109

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] penalized maximum likelihood estimation and logistf

2010-03-09 Thread xiaoyan yu
Hi, I got two questions and would really appreciate any help from here.
First, is the penalized maximum likelihood estimation(Firth Type Estimation)
only fit for binary response (0,1 or TRUE, FALSE)? Can it be applied to
multinomial logistic regression?
If yes, what's the formula for LL and  U(beta_i)? Can someone point me to
the right reference?
Second, when I used *logistf *on a dataset with binary response, I got the
following error msg:
Error in if (mx  1) delta - delta/mx :
  missing value where TRUE/FALSE needed

What does this msg mean? does it mean the dataset includes missing response?
I  checked my dataset several times and didn't find anything other than TRUE
or FALSE for the response. Please shed light on this.

Thanks,
Xiaoyan

[[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] ncdf installation

2010-03-09 Thread Bala subramanian
Friends,

I tried to install ncdf package in ubuntu with the following command.

R CMD INSTALL
--configure-args=-with-netcdf_incdir=/apps/netcdf/4.0.1/gcc/include
-with-netcdf_libdir=/apps/netcdf/4.0.1/gcc/lib ncdf_1.6.tar.gz

The installation was stopped throwing the following error. I tried to google
it but didnt find any solution. someone kindly write me what is going wrong.

** libs
gcc -std=gnu99 -I/usr/share/R/include -I/apps/netcdf/4.0.1/gcc/include
-fpic  -g -O2 -c ncdf.c -o ncdf.o
ncdf.c: In function ‘R_nc_get_vara_double’:
ncdf.c:196: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3
has type ‘size_t’
ncdf.c:202: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3
has type ‘size_t’
ncdf.c: In function ‘R_nc_get_vara_int’:
ncdf.c:239: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3
has type ‘size_t’
ncdf.c:245: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3
has type ‘size_t’
ncdf.c: In function ‘R_nc_get_vara_text’:
ncdf.c:296: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3
has type ‘size_t’
ncdf.c:302: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3
has type ‘size_t’
ncdf.c: In function ‘R_nc_ttc_to_nctype’:
ncdf.c:424: warning: implicit declaration of function ‘exit’
ncdf.c:424: warning: incompatible implicit declaration of built-in function
‘exit’
ncdf.c: In function ‘R_nc_put_vara_double’:
ncdf.c:582: warning: format ‘%d’ expects type ‘int’, but argument 3 has type
‘size_t’
ncdf.c:585: warning: format ‘%d’ expects type ‘int’, but argument 3 has type
‘size_t’
gcc -std=gnu99 -I/usr/share/R/include -I/apps/netcdf/4.0.1/gcc/include
-fpic  -g -O2 -c ncdf2.c -o ncdf2.o
gcc -std=gnu99 -I/usr/share/R/include -I/apps/netcdf/4.0.1/gcc/include
-fpic  -g -O2 -c ncdf3.c -o ncdf3.o
ncdf3.c: In function ‘R_nc_get_vara_charvarid’:
ncdf3.c:221: warning: assignment discards qualifiers from pointer target
type
ncdf3.c: In function ‘R_nc_get_vara_numvarid’:
ncdf3.c:267: warning: assignment discards qualifiers from pointer target
type
gcc -std=gnu99 -shared -o ncdf.so ncdf.o ncdf2.o ncdf3.o
-L/apps/netcdf/4.0.1/gcc/lib -lnetcdf -L/usr/lib64/R/lib -lR
/usr/bin/ld: /apps/netcdf/4.0.1/gcc/lib/libnetcdf.a(attr.o): relocation
R_X86_64_32 against `.rodata' can not be used when making a shared object;
recompile with -fPIC
/apps/netcdf/4.0.1/gcc/lib/libnetcdf.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [ncdf.so] Errore 1
ERROR: compilation failed for package ‘ncdf’
* Removing ‘/usr/local/lib/R/site-library/ncdf’

[[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] rcom package

2010-03-09 Thread Erich Neuwirth
rcom allows you to access the full object model of any COM server.
The object browser in Excel allows you to investigate Excel's object
model. It also tells you which properties are accessible. There
are a few hundreds of them.





On 3/9/2010 4:35 PM, Albert-Jan Roskam wrote:
 Hi,
  
 I would like to make a program that reads excel files, and writes the cells 
 of which contents is not a formula to another file. I don't think this is 
 possible with RODBC, but it may be possible with rcom.  
  
 I read the documentation of the rcom package, but I was hoping somebody knows 
 a good web resource for more eleborate info. I tried Googling, but alas (did 
 you know rcom also is a kind of egg incubator? ;-). In particular, I would 
 like to have a list of the possible values for the 'property' argument.
 
 Thanks in advance!
 
 Cheers!!
 Albert-Jan
 
 ~~
 In the face of ambiguity, refuse the temptation to guess.
 ~~
 
 
   
   [[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.

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A list of data.frames merged together

2010-03-09 Thread Gabor Grothendieck
This will do it:

 merge(A, B, by = 1, all = TRUE)
  Date Value.x Value.y
1 03/15/10   1   5
2 04/15/10   2   5
3 05/15/10   3  NA
4 06/15/10  NA   5

but you probably really want to be using time series for this so that
you can easily perform other operations too. See ?merge.zoo and the
three zoo vignettes for more.

 library(zoo)
 library(chron)
 za - zoo(A$Value, chron(as.character(A$Date)))
 zb - zoo(B$Value, chron(as.character(B$Date)))
 merge(za, zb)
 za zb
03/15/10  1  5
04/15/10  2  5
05/15/10  3 NA
06/15/10 NA  5

 zm - merge(za, zb)

 # convert to data frame
 cbind(Date = time(zm), as.data.frame(zm))
 Date za zb
03/15/10 03/15/10  1  5
04/15/10 04/15/10  2  5
05/15/10 05/15/10  3 NA
06/15/10 06/15/10 NA  5

 # handle more than two at a time
 merge(za, za2 = za, zb)
 za za2 zb
03/15/10  1   1  5
04/15/10  2   2  5
05/15/10  3   3 NA
06/15/10 NA  NA  5

 # same but series are in a list
 do.call(merge, list(za = za, za2 = za, zb = zb))
 za za2 zb
03/15/10  1   1  5
04/15/10  2   2  5
05/15/10  3   3 NA
06/15/10 NA  NA  5

On Tue, Mar 9, 2010 at 11:21 AM, Daniel Brewer daniel.bre...@icr.ac.uk wrote:
 Hello,

 I have for a long list of data.frames that I would like to get merged.
 Each data.frame have two columns with the same names (Date and Value).
 What I would like is for the objects in the list to be merged on Only
 date with the column header being the name in the list.

 For example

 A - data.frame(Date=c(03/15/10,04/15/10,05/15/10),
 Value=c(1,2,3))
 B - data.frame(Date=c(03/15/10,04/15/10,06/15/10),
 Value=c(5,5,5))
 ...

 yoda - list(A=A,B=B,...)

 Result:

 Date            A       B       C
 03/15/10        1       5       ...
 04/15/10        2       5
 05/15/10        3       NA
 06/15/10        NA      5

 Any ideas? I have been fiddling around with plyr and reshape without success

 Thanks

 Dan

 --
 **

 Daniel Brewer, Ph.D.

 Institute of Cancer Research
 Molecular Carcinogenesis
 MUCRC
 15 Cotswold Road
 Sutton, Surrey SM2 5NG
 United Kingdom

 Tel: +44 (0) 20 8722 4109

 **

 The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
 Limited by Guarantee, Registered in England under Company No. 534147 with its 
 Registered Office at 123 Old Brompton Road, London SW7 3RP.

 This e-mail message is confidential and for use by the a...{{dropped:2}}

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

2010-03-09 Thread Markus Loecher
Dear all,
the examples in the pdf files that are automatically built from the examples
in package help files are poorly formatted; they frequently do not wrap to
the next line and are cut off. While there is an easy work around by looking
at the examples in the corresponding help files, I do wonder if there is a
way to ensure proper line wrappiong when creating a package.

Thanks,

Markus

[[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 with adding points to allEffects plot

2010-03-09 Thread Grant Gillis
Thanks in advance for any help.

I am attempting to add points to a plot using the allEffects command in the
effects package.  When I try to add the points I get the following error
message:

Error in plot.xy(xy.coords(x, y), type = type, ...) :
  plot.new has not been called yet

Strangely, using the code I've pasted below this has worked for me in the
past however figuring out what has changed has proved to be beyond me.

Cheers,

Grant

 y-c(1,3,2,4,5)
 x-c(1,2,3,4,5)


 GSMOD-lm(y~x)

 plot(allEffects(GSMOD), ask=F)
 points(y, x)
Error in plot.xy(xy.coords(x, y), type = type, ...) :
  plot.new has not been called yet

[[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] MASS package not on CRAN ?

2010-03-09 Thread Markus Loecher
The MASS package is listed on the CRAN web site (
http://cran.r-project.org/web/packages/MASS/index.html) but I am unable to
install it via install.packages(). The error is that the package is
unavailable. When I manually download the source tar ball and try to
install it on a Linux machine, installation fails because it is not a valid
package.

Do I need to search different repositories ?
Thanks,
Markus

[[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] Possible error in anova.lm?

2010-03-09 Thread rkevinburton
Perhaps those more in the know than I could clarify some confusion. In the 
ANOVA 'R' code I see:

mss - sum(if (is.null(w)) object$fitted.values^2 else w * 
object$fitted.values^2)
if (ssr  1e-10 * mss) 
warning(ANOVA F-tests on an essentially perfect fit are unreliable)

But in the summary.lm I see:

mss - if (attr(z$terms, intercept)) 
sum((f - mean(f))^2)
else sum(f^2)

or

mss - if (attr(z$terms, intercept)) {
m - sum(w * f/sum(w))
sum(w * (f - m)^2)
}

At the very least the ANOVA code seems to be inefficient to calculate mss then 
only use it for a warning. But it seems that it is being calculated 
incorrectly. It is hard to tell since it is only used to issue the warning. But 
it may be that the warning is incorrect in some cases if mss is not calculated 
correctly. Ideas?

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A list of data.frames merged together

2010-03-09 Thread Phil Spector

Daniel -
   Reduce may be handy here:

ans = Reduce(function(a,b)merge(a,b,by=1),yoda)
names(ans)[2:ncol(ans)] = names(yoda)

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu




On Tue, 9 Mar 2010, Daniel Brewer wrote:


Hello,

I have for a long list of data.frames that I would like to get merged.
Each data.frame have two columns with the same names (Date and Value).
What I would like is for the objects in the list to be merged on Only
date with the column header being the name in the list.

For example

A - data.frame(Date=c(03/15/10,04/15/10,05/15/10),
Value=c(1,2,3))
B - data.frame(Date=c(03/15/10,04/15/10,06/15/10),
Value=c(5,5,5))
...

yoda - list(A=A,B=B,...)

Result:

DateA   B   C
03/15/101   5   ...
04/15/102   5
05/15/103   NA
06/15/10NA  5

Any ideas? I have been fiddling around with plyr and reshape without success

Thanks

Dan

--
**

Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom

Tel: +44 (0) 20 8722 4109

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

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

2010-03-09 Thread Karl Ove Hufthammer
On Tue, 9 Mar 2010 05:37:52 -0800 (PST) ManInMoon xmoon2000
@googlemail.com wrote:
 How can I generate a vector of differences between each elemtn of an vector?

diff(x)

-- 
Karl Ove Hufthammer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] IMPORTANT - To remove the null elements from a vector

2010-03-09 Thread Matthew Dowle
Welcome to R Barbara.  Its quite an incredible community from all walks of 
life.

Your beginner questions are answered in the manual. See Introduction to R. 
Please read the posting guide again because it contains lots of good advice 
for you. Some people read it three times before posting because they have so 
much respect for the community.  Sometimes they trip up over themselves to 
show they have read it.

Btw - just to let you know that starting your subject lines with IMPORTANT 
is considered by some people a demanding tone for free help. Not everyone, 
but some people. Two posts starting IMPORTANT within 5 minutes is another 
thing that a very large number of people around the world may have just seen 
you do.  I'm just letting you know, in case you were not aware of this.

You received answers from four people who clearly don't mind, and you have 
your answers. Was that your only goal in posting?  Did you consider there 
might be downsides?  This is a public list read by many people and one thing 
the posting guide says is that your questions are saved in the archives 
forever.  Just checking you knew that.  I wouldn't want you to reduce your 
reputation accidentally.  A future employer (it might be a company, or it 
might be a university) anywhere in the world might do a simple search on 
your name, and thats why you might not get an interview, because you had 
showed (in their minds) that you didn't have respect for guidlines. I would 
hate for something like that to happen, all just because you didn't know you 
were supposed to read the posting guide, it wouldn't be fair on you. So it 
would be very unfair of me to know that, and suspect that you don't, but not 
tell you about the posting guide, wouldn't it ?  I hope this information 
helps you.  It is entirely up to you.

r-help is a great way to increase your reputation, but it can reduce your 
reputation too.  By asking great questions, or even contributing, you can 
proudly put that on your CV and increase your chances of getting that 
interview, or getting that position.  I have seen on several CVs from 
students the text please search for my name on r-help.  Just like 
everything you do in public, r-help is very similar. What you write, you 
write in the public domain, and you write it free of charge, and free of 
restriction.

All this applies to all us. When asking for help, and when giving help.

Matthew


barbara.r...@uniroma1.it wrote in message 
news:of1a8063a1.fc14f5ff-onc12576e1.00466053-c12576e1.00466...@uniroma1.it...

 I have a vector that have null elements. How to remove these elements?
 For example:
 x=[10 0 30 40 0 0] I want the vector y=[10 30 40]
 Thanks
 [[alternative HTML version deleted]]


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


Re: [R] Computation of AIC for gls models

2010-03-09 Thread Ben Bolker
Miguel Angel Rodríguez-Gironés Arbolí rgirones at eeza.csic.es writes:

 
 Dear Colleagues,
 
 We are using the phylog.gls.fit() function from the R package 
 PHYLOGR (Diaz-Uriarte R, Garland T:
 PHYLOGR: Functions for phylogenetically based statistical
 analyses. 2007. 
 
 [snip]

 ... we would want to
 use AIC values for model selection. We can obtain
 these values directly with the function AIC(), or from
 the log-likelihood obtained with the logLik() function.
 (The two methods give the same results.)
 
 We have two questions concerning this procedure:
 
 1. Does anybody know whether the output we
  obtain from the AIC() and logLik() functions is reliable? Does
 the algorithm used for calculating the model
  likelihood and AIC take into account the non-independence
 of data points? Or are the log-likelihood and 
 AIC calculated using some standard R algorithm that is not
 valid for phylog.gls models or gls?

  Looking at the guts of phylog.gls.fit, I see that it
is using lm() on transformed data (haven't read the paper
referenced in the documentation, or at least not recently),
so I doubt it is OK.
 
 2. Is the logLik extracted from phylog.gls 
 suitable for a type-III log-likelhood ratio test?

  What is a type III log-likelihood ratio test?

  I suggest that you send this query to r-sig-ph...@r-project.org
instead; that is the special-interest list for phylogenetic
and comparative methods ... Ted Garland even reads that list
sometimes.

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

2010-03-09 Thread Ben Bolker
Henrique Dallazuanna wwwhsd at gmail.com writes:

 Reduce(/, as.data.frame(embed(x, 2)))
 
 ManInMoon xmoon2000 at googlemail.com wrote:
 
  How can I generate a vector of differences between each 
 elemtn of an vector?

  (you mean ratios, right?)

 
  i.e. a[i]=x[i]/x[i-1]


  x[-1]/x[-length(x)]

might be a little easier to understand.

exp(diff(log(x)))  should work too (although
a big waste of computational power ...)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] penalized maximum likelihood estimation and logistf

2010-03-09 Thread Ravi Varadhan

Let us look at a piece of the relevant code from logistf package:

iter - iter + 1
XW2 - crossprod(x, diag(pi * (1 - pi))^0.5)
Fisher - crossprod(t(XW2))
covs - solve(Fisher)
H - crossprod(XW2, covs) %*% XW2
if (firth) 
U.star - crossprod(x, y - pi + diag(H) * (0.5 - 
pi))
else U.star - crossprod(x, y - pi)
delta - as.vector(covs %*% U.star)
mx - max(abs(delta))/maxstep
if (mx  1) 
delta - delta/mx
 
First, note that this is inside an iterative loop.  The Fisher information 
matrix is first formed, and then it is inverted to get `covs'.  This is where 
it can get troublesome.  It is very likely in your case that the `Fisher' 
information matrix is ill-conditioned, and hence `covs' cannot be computed.  
Consequently, the steplength `delta' for the Newton method cannot be 
determined. 


Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: xiaoyan yu xiaoyan...@gmail.com
Date: Tuesday, March 9, 2010 11:26 am
Subject: [R] penalized maximum likelihood estimation and logistf
To: r-help@r-project.org


 Hi, I got two questions and would really appreciate any help from here.
  First, is the penalized maximum likelihood estimation(Firth Type Estimation)
  only fit for binary response (0,1 or TRUE, FALSE)? Can it be applied 
 to
  multinomial logistic regression?
  If yes, what's the formula for LL and  U(beta_i)? Can someone point 
 me to
  the right reference?
  Second, when I used *logistf *on a dataset with binary response, I 
 got the
  following error msg:
  Error in if (mx  1) delta - delta/mx :
missing value where TRUE/FALSE needed
  
  What does this msg mean? does it mean the dataset includes missing response?
  I  checked my dataset several times and didn't find anything other 
 than TRUE
  or FALSE for the response. Please shed light on this.
  
  Thanks,
  Xiaoyan
  
   [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  
  PLEASE do read the posting guide 
  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] using near-zero probabilities in optimization

2010-03-09 Thread Ben Bolker
Benedikt Gehr benedikt.gehr at ieu.uzh.ch writes:

 
 Hi there
 
 I am using mle2 for a multinomial likelihood optimization problem. My 
 function works fine when I'm using simulated data, however my cell 
 probabilities of the true data for the multinomial likelihood are 
 sometimes very small (in some cases 0.00...) and the estimated point 
 estimates fit the true vlaues quite poorly. Is there a way how to handle 
 near zero probabilities in maximum likelihood optimization?
 

  Hard to say without more detail.  Can you send a reproducible
example (your data, or a small subset of your data, or
some way of simulating the data that *does* create the problem)?

  Since you're using log-likelihoods already (within mle2) the
problem is unlikely (?) to be numerical -- R doesn't have any
problem with very large negative log-likelihoods.  Do your
likelihood profiles look reasonable?  If so then the problem
is more likely that your model doesn't fit the data well than
that you are having convergence problems.

  Have you considered the possibility of overdispersion
(non-homogeneity/non-independence), e.g. via a Dirichlet-multinomial
model?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 with adding points to allEffects plot

2010-03-09 Thread Peter Ehlers

As you can see on ?effects help page, plot.eff() uses
lattice graphics. You can't mix those with traditional
graphics commands. This should work:

 plot(allEffects(GSMOD), ask=FALSE)
 trellis.focus(panel, 1, 1)
   panel.points(y, x)
 trellis.unfocus()

 -Peter Ehlers

On 2010-03-09 9:37, Grant Gillis wrote:

Thanks in advance for any help.

I am attempting to add points to a plot using the allEffects command in the
effects package.  When I try to add the points I get the following error
message:

Error in plot.xy(xy.coords(x, y), type = type, ...) :
   plot.new has not been called yet

Strangely, using the code I've pasted below this has worked for me in the
past however figuring out what has changed has proved to be beyond me.

Cheers,

Grant


y-c(1,3,2,4,5)
x-c(1,2,3,4,5)


GSMOD-lm(y~x)

plot(allEffects(GSMOD), ask=F)
points(y, x)

Error in plot.xy(xy.coords(x, y), type = type, ...) :
   plot.new has not been called yet

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




--
Peter Ehlers
University of Calgary

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

2010-03-09 Thread Duncan Murdoch

On 09/03/2010 9:28 AM, Markus Loecher wrote:

Dear all,
the examples in the pdf files that are automatically built from the examples
in package help files are poorly formatted; they frequently do not wrap to
the next line and are cut off. While there is an easy work around by looking
at the examples in the corresponding help files, I do wonder if there is a
way to ensure proper line wrappiong when creating a package.
  


R will keep whatever formatting the package author puts in the source, 
so the author simply needs to format the source code nicely.  I imagine 
there are automatic tools to do that (e.g. in ESS or Eclipse).  Perhaps 
the manuals could say how many characters fit on a line on A4 paper. 
(North Americans get slightly more width on letter-sized paper).  It 
looks to me as though the limit is around 68 characters, though it's 
still readable if it extends into the margin a little.  I tend to set my 
margins to 70 characters.


Duncan Murdoch

Thanks,

Markus

[[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] Cox Calibration regression test double graphs

2010-03-09 Thread paaventhan jeyaganth

Dear All,

How can i do the bootstrap and calibration plot after surival analysis

, i don't know how to do it after that please help me.

Thanks
 

here is my syntex

 

library(survival)
mfit - survfit(Surv(days, status == 1)~drug, data = melanom)

 

#how can i do the bootstra

#Cox Calibration regression test

#and the calibration plot

 

 

paaveen
  
_


[[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 in a function

2010-03-09 Thread jim holtman
Print out the 'str' of the two objects and look at it.  Are the matrices the
appropriate sizes to do the operation?  The error message indicates they are
not.  This is an opportunity to learn how to debug a function.  Look at the
'debug' package.

On Tue, Mar 9, 2010 at 5:59 AM, weltbewohnerin1 
franziska.schu...@wiwi.hu-berlin.de wrote:


 Hallo!

 I have the following function:

 cLL_beta - function(beta){
 sumterm=0
 a=1
 b=0
 S=I_n-lambda*w
 R=I_n-rho*w
 det_R=det(S)
 det_S=det(R)

 for (i in 1:t){
 b=i*n
 y_ausgew=y_tilde[a:b]#y_ausgew ist numeric
 y_aus=matrix(y_ausgew)#Typen anpassen
 X_ausgew=X[a:b,]#X_ausgew ist eine Matrix
 x_tilde=X_ausgew-1/t*x_t  #x_tilde ist auch eine Matrix
 X_aus=matrix(X_ausgew)
 V1=R%*%(S%*%y_aus-x_tilde%*%beta)
 V11=t(V1)
 V2=V11%*%J_n
 V_tilde=V2%*%V1
 sumterm=sumterm+V_tilde
 a=b+1
 }

 -((n*t)/2)*log(2*pi*sigm_sq)+t*(log(det_S)+log(det_R))-1/(2*sigm_sq)*sumterm
 }

 where beta is a matrix (2x1), X is a matrix (n*tx1) and y is numeric with
 length nt.

 My error message is: X_ausgew%*%beta - non-conformable arguments

 Can anybody help me?

 THANKS
 --
 View this message in context:
 http://n4.nabble.com/error-in-a-function-tp1585792p1585792.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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[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] sorting data whilst ignoring NA's

2010-03-09 Thread emwater

Hello,

I am very new to R and have hit my first main problem that I hope someone
can easily resolve.

I have some data that looks like this (there are 20,000 rows):

 qdata
day month yearflow
   [1,]   210 1945  NA
   [2,]   310 1945  NA
   [3,]   410 1945  NA
   [4,]   510 1945  NA
   [5,]   610 1945   2.973
   [6,]   710 1945  NA
   [7,]   810 1945  NA
   [8,]   910 1945   2.973
   [9,]  1010 1945  NA
  [10,]  1110 1945  NA
  [11,]  1210 1945  NA
  [12,]  1310 1945  NA
  [13,]  1410 1945   2.973
  [14,]  1510 1945  NA


I want to sort the data in descending order by flow but with all the NA
results sent to the bottom. I have managed to sort the data using: 

topflows - qdata[order(-flow, na.last=TRUE),] 

But this sorts the data by flow value and then year I think giving:

 day month year   flow
 [1,]  14 3 1947 222.40
 [2,]  15 3 1947 NA
 [3,]  18 3 1947 NA
 [4,]  17 3 1947 NA
 [5,]  19 3 1947 NA
 [6,]  12 3 1947 NA
 [7,]  13 3 1947 NA
 [8,]  16 3 1947 NA
 [9,]  20 3 1947 NA
[10,]  3011 1946 106.50
[11,]  30 3 1947 105.60
[12,]  2911 1946 NA
[13,]  11 3 1947 NA
[14,]  2211 1946  99.96
[15,]  2111 1946 NA

I want my data to come out like this:
[1,] 14  3  1947  222.3
[2,] 30  11 1946 106.50
[3,] 30  3  1947  105.60
[4,] 22 11 1946  99.96 and so on...


Any help would be greatly valued. 

Thanks

Emma



-- 
View this message in context: 
http://n4.nabble.com/sorting-data-whilst-ignoring-NA-s-tp1586277p1586277.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.


[R] Help! I need to use R to calculate a recursive function!

2010-03-09 Thread anan1986

hi,all

Z(i)=0.05X(i)+0.95Z(i-1), where i = 1.32, and X's are given data, the
question is how to use r to get the 32 values of Z. 

I couldn't do this in R and wish somebody can help me.

thanks in regards 

-- 
View this message in context: 
http://n4.nabble.com/Help-I-need-to-use-R-to-calculate-a-recursive-function-tp1586189p1586189.html
Sent from the R help mailing list archive at Nabble.com.

[[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] Is it possible to recursively update a function?

2010-03-09 Thread Seeker
Thanks for the input, Uwe. Unfortunately, I need to iteratively update
functions from f1 to f25. Seems I have no choice but set each one
manually.

On Mar 6, 11:45 am, Uwe Ligges lig...@statistik.tu-dortmund.de
wrote:
 It is not obvious to me if you can calculate f1, ..., f4, ...
 automatically or have to set them manually. Looks like you need to do it
 manually. In that case I'd suggest to write something along the lines:

 dose - c(-1.47, -1.1, -0.69, -0.42, 0.0, 0.42)

 f1 - function(x) exp(-x)
 f2 - function(x) f1(x) * (1 - 0.2^x)
 f3 - function(x) f2(x) * (1 - 0.3^x)
 f4 - function(x) f3(x) * 0.3^x

 calcid - function(f, dose){
      denom - integrate(f, 0, 100)$value
      alpha - integrate(function(x) x * f(x), 0, 100)$value / denom
      which.min(abs(-0.5 * log(0.2^(-1/alpha) - 1) - dose))

 }

 calcid(f2, dose)
 calcid(f3, dose)
 calcid(f4, dose)

 If the hierarchy becomes deeper (i.e. 10 functions or so, it might make
 sense to reduce the number of hierarchical calls for efficiency, but
 that is not necessary for the current setup.

 Uwe Ligges

 On 05.03.2010 17:34, Ming Zhong wrote:





  I was trying to replicate one CRM simulation. The following code works but
  seems redundant so I want to create a loop.

  O'Quigley CRM example 1#
  f1-function(x) exp(-x)
  dose-c(-1.47,-1.1,-.69,-.42,0.0,.42)
  p-c(0.05,0.1,0.2,0.3,0.5,0.7)
  y-c(0,0,1,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,1)

  f2-function(x) f1(x)*(1-0.2^x)
  denom2-integrate(f2,0,100)$value
  alpha2-integrate(function(x) x*f2(x),0,100)$value/denom2
  id-which.min(abs(-.5*log(0.2^(-1/alpha2)-1)-dose))  ### id is used to
  locate the next prob.

  f3-function(x) f2(x)*(1-.3^x)
  denom3-integrate(f3,0,100)$value
  alpha3-integrate(function(x) x*f3(x),0,100)$value/denom3
  id-which.min(abs(-.5*log(0.2^(-1/alpha3)-1)-dose))

  f4-function(x) f3(x)*.3^x
  denom4-integrate(f4,0,100)$value
  alpha4-integrate(function(x) x*f4(x),0,100)$value/denom4
  id-which.min(abs(-.5*log(0.2^(-1/alpha4)-1)-dose))

  2010/3/5 Uwe Liggeslig...@statistik.tu-dortmund.de

  On 05.03.2010 01:40, Carl Witthoft wrote:

  My foolish move for this week: I'm going to go way out on a limb and
  guess what the OP wanted was something like this.

  i=1, foo = x*exp(-x)

  i=2, foo= x^2*exp(-x)
  i=3, foo = x^3*exp(-x)
  .
  .
  .

  In which case he really should create a vector bar-rep(na,5) ,
  and then inside the loop,

  bar[i]-x^i*foo(x)

  Since in this case foo(x) is independent of i, you are wasting resources.
  Moreover you could calculate it for a whole matrix at once. Say you want to
  calculate this for i=1, ..., n with n=5 for some (here pseudo random x),
  then you could do it simpler after defining some data as in:

  set.seed(123)
  x- rnorm(10)
  n- 5

  using the single and probably most efficient line:

    outer(x, 1:n, ^) * exp(-x)

  or if x is a length 1 vector then even simpler:

  set.seed(123)
  x- rnorm(1)
  n- 5

    x^(1:5) * exp(-x)

  But we still do not know if this is really the question ...

  Uwe Ligges

  Carl

  quoted material:
  Date: Thu, 04 Mar 2010 11:37:23 -0800 (PST)

  I need to update posterior dist function upon the coming results and
  find the posterior mean each time.

  On Mar 4, 1:31 pm, jim holtmanjholt..._at_gmail.com  wrote:
      What exactly are you trying to do? 'foo' calls 'foo' calls 'foo' 
      How did you expect it to stop the recursive calls?

      On Thu, Mar 4, 2010 at 2:08 PM, Seekerzhongm..._at_gmail.com  
  wrote:
        Here is the test code.

        foo-function(x) exp(-x)
        for (i in 1:5)
        {
        foo-function(x) foo(x)*x
        foo(2)
        }

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

 __
 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.- Hide 
 quoted text -

 - Show quoted text -

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Monetary support to the R-project (Was: Re: Executable for Production Use)

2010-03-09 Thread Jaroslaw Piskorski
I would have become a member a long time ago if the money transfer 
process was more standard. I am not comfortable sending the details of 
my credit card via snail-mail or fax. Perhaps you could set up a 
proper Internet service or give people the chance to pay by paypal? I 
realize that could mean some initial outlay, but maybe it would be 
worth your while?

jarek p

Henrik Bengtsson wrote:

 On Mon, Mar 8, 2010 at 8:46 PM, Barry Rowlingson
 b.rowling...@lancaster.ac.uk wrote:
 On Mon, Mar 8, 2010 at 6:44 PM, Ma Ismail - NewYork-MEAG-NY
 i...@meag-ny.com wrote:
 Hi,

 A few of the developers on our Quant team are using R for data
 calculation and to generate a
 
 [snip]
 
 I've noticed a lot of financial corporates getting into R and 
getting
 free help from R-help. From now on, I'm charging $50 per email to
 answer questions from anyone advertising as a 'quant'. Who do I
 invoice?
 
 For companies and others wondering how to give something back, it 
is
 possible to support R and the R Foundation either through a 
donation:
 
 http://www.r-project.org/ - Foundation - Donations
 [http://www.r-project.org/foundation/donations.html]
 
 or via a membership:
 
 http://www.r-project.org/ - Foundation - Membership
 [http://www.r-project.org/foundation/membership.html]
 
 or both.
 
 /Henrik
 

 Barry

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] penalized maximum likelihood estimation and logistf

2010-03-09 Thread xiaoyan yu
Thanks for your help. I can follow your explanation.  Have you tried logistf
and met the same problem?
Are there any ways to locate which part of data causes the failure or other
R code to build the model from the data?

Thanks
Xiaoyan

On Tue, Mar 9, 2010 at 12:22 PM, Ravi Varadhan rvarad...@jhmi.edu wrote:


 Let us look at a piece of the relevant code from logistf package:

iter - iter + 1
XW2 - crossprod(x, diag(pi * (1 - pi))^0.5)
Fisher - crossprod(t(XW2))
covs - solve(Fisher)
H - crossprod(XW2, covs) %*% XW2
if (firth)
U.star - crossprod(x, y - pi + diag(H) * (0.5 -
pi))
else U.star - crossprod(x, y - pi)
delta - as.vector(covs %*% U.star)
mx - max(abs(delta))/maxstep
if (mx  1)
delta - delta/mx

 First, note that this is inside an iterative loop.  The Fisher information
 matrix is first formed, and then it is inverted to get `covs'.  This is
 where it can get troublesome.  It is very likely in your case that the
 `Fisher' information matrix is ill-conditioned, and hence `covs' cannot be
 computed.  Consequently, the steplength `delta' for the Newton method cannot
 be determined.


 Ravi.

 

 Ravi Varadhan, Ph.D.
 Assistant Professor,
 Division of Geriatric Medicine and Gerontology
 School of Medicine
 Johns Hopkins University

 Ph. (410) 502-2619
 email: rvarad...@jhmi.edu


 - Original Message -
 From: xiaoyan yu xiaoyan...@gmail.com
 Date: Tuesday, March 9, 2010 11:26 am
 Subject: [R] penalized maximum likelihood estimation and logistf
 To: r-help@r-project.org


  Hi, I got two questions and would really appreciate any help from here.
   First, is the penalized maximum likelihood estimation(Firth Type
 Estimation)
   only fit for binary response (0,1 or TRUE, FALSE)? Can it be applied
  to
   multinomial logistic regression?
   If yes, what's the formula for LL and  U(beta_i)? Can someone point
  me to
   the right reference?
   Second, when I used *logistf *on a dataset with binary response, I
  got the
   following error msg:
   Error in if (mx  1) delta - delta/mx :
 missing value where TRUE/FALSE needed
 
   What does this msg mean? does it mean the dataset includes missing
 response?
   I  checked my dataset several times and didn't find anything other
  than TRUE
   or FALSE for the response. Please shed light on this.
 
   Thanks,
   Xiaoyan
 
[[alternative HTML version deleted]]
 
   __
   R-help@r-project.org mailing list
 
   PLEASE do read the posting guide
   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.


[R] plotlmer graphics/x-axis and legend options

2010-03-09 Thread Sandra . Schwab

Hi,

I am Using R.2.9.2 and I am trying to make nicer some graphics, which  
are constructed with plotmer.fnc. In particular, I have two questions:


1. Is is a way to decide in which order we want the labels on the  
x-axis. For now, the reference value label is the first one, and the  
other labels appear in the alphabetical order. I would like them to be  
sorted in the ascending way. Here is my code:


plotLMER.fnc(idtt_lmer7bis, xlabel =, xlabs =NA, ylabel = Reaction  
time (ms), fun = NA, pred = Condition, n = 100, , mcmcMat = NA,  
lockYlim = TRUE, addlines = TRUE, withList = FALSE, cexsize = 0.7,  
lwd=2, font=2, cex.lab=1.25, tcl=-0.5, las=2, cex.axis=0.7)


2. In the plotlmer graphic with an interaction, is it possible to  
remove the legend of the interacted factor? Again here is my code:


plotLMER.fnc(idbase_lmer22bis, xlabel = Competence in L2, xlabs =  
NA, ylabel = Reaction time (ms), ylimit =c(300,1300), fun = NA, pred  
= Groupe, n = 100, intr=list(Lexical_status, c(Word,  
PseudoWord), end, list(c(red,  blue), lty=c(1,4), rep(1,2))),  
mcmcMat = NA, lockYlim = TRUE, addlines = TRUE, withList = FALSE,  
cexsize = 1, lwd=2, font=2, cex.lab=1.25, tcl=-0.5).


Sorry if these questions are trivial, but I am been looking for an  
answer for two entire days now, and I would really appreciate your  
help!!


Sandra Schwab


*
Sandra Schwab
Chargée d'enseignement
Université de Genève
ELCF/LATL
Uni Bastions
5, rue de Candolle
1211 Genève 4
http://www.unige.ch/lettres/elcf/contact/Pageenseignants/Schwab.html

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


Re: [R] Help! I need to use R to calculate a recursive function!

2010-03-09 Thread Barry Rowlingson
On Tue, Mar 9, 2010 at 4:01 PM, anan1986 ayc_...@hotmail.com wrote:

 hi,all

 Z(i)=0.05X(i)+0.95Z(i-1), where i = 1.32, and X's are given data, the
 question is how to use r to get the 32 values of Z.

 I couldn't do this in R and wish somebody can help me.

 Can you do anything in R? Have you tried? Have you read any of the
introductory R tutorials? All this needs is a for() loop and some
vector indexing. You'll do it if you read the first five pages of any
introductory R guide.

Barry

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


[R] data frame select max group by like function

2010-03-09 Thread Tan, Richard
Hi, I have a data frame with 3 columns: ID, year and score.  How can I
select for each unique ID, the year that has the max score?  For
example, for data frame
 
ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 2000, 97
tom, 1998, 60
mary, 1998,100
 
I shall have
ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 1998,100
 
Thanks,
Richard

[[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] Cox Calibration regression test double graphs

2010-03-09 Thread David Winsemius

A) Please do not highjack threads. Post new topics for new questions.

B) Calibration plots are very easy for either logistic regression or  
Cox models when using the calibrate function in either Harrell's rms  
or Design packages. (Not sure about how well they play with survfit  
objects, but you ought to be able to apply the same methods.)


--
David.

On Mar 9, 2010, at 12:52 PM, paaventhan jeyaganth wrote:



Dear All,

How can i do the bootstrap and calibration plot after surival analysis

, i don't know how to do it after that please help me.

Thanks


here is my syntex



library(survival)
mfit - survfit(Surv(days, status == 1)~drug, data = melanom)



#how can i do the bootstra

#Cox Calibration regression test

#and the calibration plot





paaveen

_


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


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sorting data whilst ignoring NA's

2010-03-09 Thread David Winsemius


On Mar 9, 2010, at 11:57 AM, emwater wrote:



Hello,

I am very new to R and have hit my first main problem that I hope  
someone

can easily resolve.

I have some data that looks like this (there are 20,000 rows):


qdata

   day month yearflow
  [1,]   210 1945  NA
  [2,]   310 1945  NA
  [3,]   410 1945  NA
  [4,]   510 1945  NA
  [5,]   610 1945   2.973
  [6,]   710 1945  NA
  [7,]   810 1945  NA
  [8,]   910 1945   2.973
  [9,]  1010 1945  NA
 [10,]  1110 1945  NA
 [11,]  1210 1945  NA
 [12,]  1310 1945  NA
 [13,]  1410 1945   2.973
 [14,]  1510 1945  NA


I want to sort the data in descending order by flow but with all the  
NA

results sent to the bottom. I have managed to sort the data using:

topflows - qdata[order(-flow, na.last=TRUE),]


Try (untested):

topflows - qdata[order(-qdata$flow, na.last=TRUE),]





But this sorts the data by flow value and then year I think giving:

day month year   flow
[1,]  14 3 1947 222.40
[2,]  15 3 1947 NA
[3,]  18 3 1947 NA
[4,]  17 3 1947 NA
[5,]  19 3 1947 NA
[6,]  12 3 1947 NA
[7,]  13 3 1947 NA
[8,]  16 3 1947 NA
[9,]  20 3 1947 NA
[10,]  3011 1946 106.50
[11,]  30 3 1947 105.60
[12,]  2911 1946 NA
[13,]  11 3 1947 NA
[14,]  2211 1946  99.96
[15,]  2111 1946 NA

I want my data to come out like this:
[1,] 14  3  1947  222.3
[2,] 30  11 1946 106.50
[3,] 30  3  1947  105.60
[4,] 22 11 1946  99.96 and so on...


Any help would be greatly valued.

Thanks

Emma



--
View this message in context: 
http://n4.nabble.com/sorting-data-whilst-ignoring-NA-s-tp1586277p1586277.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.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sorting data whilst ignoring NA's

2010-03-09 Thread Peter Ehlers

On 2010-03-09 9:57, emwater wrote:


Hello,

I am very new to R and have hit my first main problem that I hope someone
can easily resolve.

I have some data that looks like this (there are 20,000 rows):


qdata

 day month yearflow
[1,]   210 1945  NA
[2,]   310 1945  NA
[3,]   410 1945  NA
[4,]   510 1945  NA
[5,]   610 1945   2.973
[6,]   710 1945  NA
[7,]   810 1945  NA
[8,]   910 1945   2.973
[9,]  1010 1945  NA
   [10,]  1110 1945  NA
   [11,]  1210 1945  NA
   [12,]  1310 1945  NA
   [13,]  1410 1945   2.973
   [14,]  1510 1945  NA


I want to sort the data in descending order by flow but with all the NA
results sent to the bottom. I have managed to sort the data using:

topflows- qdata[order(-flow, na.last=TRUE),]


Am I missing something? Or do you just want:

 qdata[order(qdata$flow, decreasing=TRUE), ]

 -Peter Ehlers



But this sorts the data by flow value and then year I think giving:

  day month year   flow
  [1,]  14 3 1947 222.40
  [2,]  15 3 1947 NA
  [3,]  18 3 1947 NA
  [4,]  17 3 1947 NA
  [5,]  19 3 1947 NA
  [6,]  12 3 1947 NA
  [7,]  13 3 1947 NA
  [8,]  16 3 1947 NA
  [9,]  20 3 1947 NA
[10,]  3011 1946 106.50
[11,]  30 3 1947 105.60
[12,]  2911 1946 NA
[13,]  11 3 1947 NA
[14,]  2211 1946  99.96
[15,]  2111 1946 NA

I want my data to come out like this:
[1,] 14  3  1947  222.3
[2,] 30  11 1946 106.50
[3,] 30  3  1947  105.60
[4,] 22 11 1946  99.96 and so on...


Any help would be greatly valued.

Thanks

Emma





--
Peter Ehlers
University of Calgary

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


Re: [R] data frame select max group by like function

2010-03-09 Thread Henrique Dallazuanna
Try this:

library(sqldf)
sqldf(SELECT ID, Year, MAX(score) FROM DF GROUP BY ID)

Or

do.call(rbind, lapply(split(DF - DF[order(DF$score),], DF$ID), tail, 1))

On Tue, Mar 9, 2010 at 3:35 PM, Tan, Richard r...@panagora.com wrote:
 Hi, I have a data frame with 3 columns: ID, year and score.  How can I
 select for each unique ID, the year that has the max score?  For
 example, for data frame

 ID, year, score
 tom, 1995, 88
 rick, 1994, 90
 mary, 2000, 97
 tom, 1998, 60
 mary, 1998,100

 I shall have
 ID, year, score
 tom, 1995, 88
 rick, 1994, 90
 mary, 1998,100

 Thanks,
 Richard

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

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


Re: [R] data frame select max group by like function

2010-03-09 Thread Ista Zahn
Hi Richard,
There are probably better ways, but here is one approach:

Dat - read.table(textConnection(ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 2000, 97
tom, 1998, 60
mary, 1998,100), header=TRUE, sep=,)

MaxScore - aggregate(Dat$score, list(Dat$ID), max)
names(MaxScore) - c(ID, score)
MaxYear - merge(Dat, MaxScore)

Best,
Ista


On Tue, Mar 9, 2010 at 1:35 PM, Tan, Richard r...@panagora.com wrote:
 Hi, I have a data frame with 3 columns: ID, year and score.  How can I
 select for each unique ID, the year that has the max score?  For
 example, for data frame

 ID, year, score
 tom, 1995, 88
 rick, 1994, 90
 mary, 2000, 97
 tom, 1998, 60
 mary, 1998,100

 I shall have
 ID, year, score
 tom, 1995, 88
 rick, 1994, 90
 mary, 1998,100

 Thanks,
 Richard

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] data frame select max group by like function

2010-03-09 Thread Peter Ehlers

I find ddply() in package plyr handy for this sort of thing:

 library(plyr)
 f - function(x) x[which.max( x[[score]] ), ]
## x will be a subset of Dat according to ID
 ddply(Dat, ID, f)

 -Peter Ehlers

On 2010-03-09 11:59, Ista Zahn wrote:

Hi Richard,
There are probably better ways, but here is one approach:

Dat- read.table(textConnection(ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 2000, 97
tom, 1998, 60
mary, 1998,100), header=TRUE, sep=,)

MaxScore- aggregate(Dat$score, list(Dat$ID), max)
names(MaxScore)- c(ID, score)
MaxYear- merge(Dat, MaxScore)

Best,
Ista


On Tue, Mar 9, 2010 at 1:35 PM, Tan, Richardr...@panagora.com  wrote:

Hi, I have a data frame with 3 columns: ID, year and score.  How can I
select for each unique ID, the year that has the max score?  For
example, for data frame

ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 2000, 97
tom, 1998, 60
mary, 1998,100

I shall have
ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 1998,100

Thanks,
Richard

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







--
Peter Ehlers
University of Calgary

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

2010-03-09 Thread Uwe Ligges



On 08.03.2010 22:13, Stefan wrote:

Ma Ismail - NewYork-MEAG-NYimaat  meag-ny.com  writes:



Hi,

A few of the developers on our Quant team are using R for data

calculation andto generate a resulting CSV file. They have R
installed on their workstations. We are interested in having this
deployed to user workstations where the users will not have R
installed on their workstations. Is there a way to create an
executable that the users can  just run without R installed on
their workstation?


Thanks in advance for your help.

Ismail Ma
Head of IT Applications
MEAG New York Corporation
Telephone: (212) 583-4850
Fax: (646) 521-7950
E-Mail: imaat  meag-ny.commailto:imaat  meag-ny.com






Maybe I've misunderstood You, but You can manage a single R
installation on a central server, and let clients hook up to
it from Emacs+ESS or Eclipse+StatET. I've used both solutions,
and they work like a charm... The emacs solution uses SSH and
Eclipse a Java server thingy.

Plz note that I'm from the Linux side of things. So my server
is a Debian, and my clients are all Ubuntu. I have no clue how
(or even if) these setups work on windows.



Yes, they also do work on Windows.

Anyway, to answer the question: No, it is not possible to have a single 
executable that allows to run R code.


Best,
uwe Ligges






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

2010-03-09 Thread claytonmccandless

I want to shade the area under the curve of the standard normal density.
Specifically color to the left of -2 and on. How might i go about doing
this?

Thanks
-- 
View this message in context: 
http://n4.nabble.com/Shade-area-under-curve-tp1586439p1586439.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.


[R] How To Display Current/Next Line Using browser()

2010-03-09 Thread xallanmillerx

Hi,

I'm running R 2.10 on a Linux console, inserted a call to browser() in an R
script that I source() form the R command line.  Two quick questions:

(1) Once you are in the browser prompt, is there any way to display the
current/next line to be executed without executing it?  I can issue an n
command to view the line, but was wondering if there's a simple display
current line command to view the source code before I execute it.

(2) Is there any way to exit the browser() prompt to go back to the R prompt
without typing c to continue execution?  I tried using Ctl-C, but this
stays within the browser.

I searched for other posts on these but couldn't find anything.

Thanks!
-- 
View this message in context: 
http://n4.nabble.com/How-To-Display-Current-Next-Line-Using-browser-tp1586434p1586434.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.


[R] Moving Average Model

2010-03-09 Thread testuser

Using the forecast package in R, auto.arima returns a model of type (0,0,3)
with coefficients. To forecast the value at any point of time t, I can use
the coefficients along with the white noise values e(t). How can we get the
value for white noise?
-- 
View this message in context: 
http://n4.nabble.com/Moving-Average-Model-tp1586447p1586447.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] rcom package

2010-03-09 Thread Albert-Jan Roskam
Hi Erich and Gabor,

Thank you for your replies. I wanted to write *only* non-formulae cells. I have 
dozens of sheets with a mix of raw input (ie, no formulae) en calculated 
values. I want to separate this, In a later stage, I want to let R do all the 
calculations that with the current system are done with xls.

So I need to conditionally write the data using something like (pseudocode): if 
(!IsFormula(cell)) xls.write(rowno, colno, cell) (...see also the vb code 
below). I have to study this in more detail, but i still don't think this is 
possible with the rodbc package. I hope I don;t need to, but I may need to dive 
into COM and the excel object model.



Function IsFormula(Cell As Range) As Boolean
If Len(Cell.Formula) = 0 Then
IsFormula = False
Else
IsFormula = (Left(Cell.Formula, 1) = =)
End If
End Function


source: http://www.triskele.com/2008/04/26/excels-missing-isformula-function

Thanks again!

Cheers!!

Albert-Jan



~~

In the face of ambiguity, refuse the temptation to guess.

~~

--- On Tue, 3/9/10, Erich Neuwirth erich.neuwi...@univie.ac.at wrote:

From: Erich Neuwirth erich.neuwi...@univie.ac.at
Subject: Re: [R] rcom package
To: r-help@r-project.org
Date: Tuesday, March 9, 2010, 5:28 PM

rcom allows you to access the full object model of any COM server.
The object browser in Excel allows you to investigate Excel's object
model. It also tells you which properties are accessible. There
are a few hundreds of them.





On 3/9/2010 4:35 PM, Albert-Jan Roskam wrote:
 Hi,
  
 I would like to make a program that reads excel files, and writes the cells 
 of which contents is not a formula to another file. I don't think this is 
 possible with RODBC, but it may be possible with rcom.  
  
 I read the documentation of the rcom package, but I was hoping somebody knows 
 a good web resource for more eleborate info. I tried Googling, but alas (did 
 you know rcom also is a kind of egg incubator? ;-). In particular, I would 
 like to have a list of the possible values for the 'property' argument.
 
 Thanks in advance!
 
 Cheers!!
 Albert-Jan
 
 ~~
 In the face of ambiguity, refuse the temptation to guess.
 ~~
 
 
       
     [[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.

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] How To Display Current/Next Line Using browser()

2010-03-09 Thread Duncan Murdoch

On 09/03/2010 1:45 PM, xallanmillerx wrote:

Hi,

I'm running R 2.10 on a Linux console, inserted a call to browser() in an R
script that I source() form the R command line.  Two quick questions:

(1) Once you are in the browser prompt, is there any way to display the
current/next line to be executed without executing it?  I can issue an n
command to view the line, but was wondering if there's a simple display
current line command to view the source code before I execute it.
  


I don't know of a way.  If the code was sourced with source references, 
it may tell you the line number, and you could look it up from that, but 
I don't think there's any way to just say show me the next line.

(2) Is there any way to exit the browser() prompt to go back to the R prompt
without typing c to continue execution?  I tried using Ctl-C, but this
stays within the browser.
  


Q will quit the browser.  The ?browser help page gives the full list of 
commands.


Duncan Murdoch

I searched for other posts on these but couldn't find anything.

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] data frame select max group by like function

2010-03-09 Thread Bert Gunter
An alternative base R version:

?by

by(Dat,Dat$ID,function(frm)frm$year[which.max(frm$score)])

by() is a wrapper for tapply(), one of the base R apply family of
functions (lapply, mapply, etc.) for which many find the plyr package
provides a simpler and more consistent interface. I'm used to the base R
versions, however, and in fact my preferred approach to this is simply:

with(Dat,
tapply(seq_len(nrow(Dat)),ID,function(i)year[i][which.max(score[i])]))

In any case, you should invest the time to learn either (or both) the base R
or plyr version of the apply() functions.

Bert Gunter
Genentech Nonclinical Biostatistics
 
 -Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Ista Zahn
Sent: Tuesday, March 09, 2010 11:00 AM
To: Tan, Richard
Cc: r-help@r-project.org
Subject: Re: [R] data frame select max group by like function

Hi Richard,
There are probably better ways, but here is one approach:

sc

MaxScore - aggregate(Dat$score, list(Dat$ID), max)
names(MaxScore) - c(ID, score)
MaxYear - merge(Dat, MaxScore)

Best,
Ista


On Tue, Mar 9, 2010 at 1:35 PM, Tan, Richard r...@panagora.com wrote:
 Hi, I have a data frame with 3 columns: ID, year and score.  How can I
 select for each unique ID, the year that has the max score?  For
 example, for data frame

 ID, year, score
 tom, 1995, 88
 rick, 1994, 90
 mary, 2000, 97
 tom, 1998, 60
 mary, 1998,100

 I shall have
 ID, year, score
 tom, 1995, 88
 rick, 1994, 90
 mary, 1998,100

 Thanks,
 Richard

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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

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

2010-03-09 Thread Stephan Kolassa

Hi,

use dnorm() for the density and polygon() to shade the area underneath, 
with suitably many x values so your density looks smooth.


HTH,
Stephan


claytonmccandless schrieb:

I want to shade the area under the curve of the standard normal density.
Specifically color to the left of -2 and on. How might i go about doing
this?

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] Moving Average Model

2010-03-09 Thread David Winsemius


On Mar 9, 2010, at 1:54 PM, testuser wrote:



Using the forecast package in R, auto.arima returns a model of type  
(0,0,3)
with coefficients. To forecast the value at any point of time t, I  
can use
the coefficients along with the white noise values e(t). How can we  
get the

value for white noise?


Teach a man to fish:

 RSiteSearch(shade the area under a curve)
A search query has been submitted to http://search.r-project.org
The results page should open in your browser shortly



--
View this message in context: 
http://n4.nabble.com/Moving-Average-Model-tp1586447p1586447.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.


David Winsemius, MD
West Hartford, CT

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