Re: [R] Variable Wildcard Value

2009-04-01 Thread Dieter Menne
Francis Smart fsmart at gmail.com writes:

 Is there a wildcard value for vector values in r?
 
 For instance:
 
  M - *wildcard
 
  (M==1)
 TRUE
 
 (M==peanut butter)
 TRUE
 
 is.na(M)
 FALSE

If grep on a vector does not help, maybe the following comes closer?
Finding all variables 

rm(list=ls(all=TRUE))
a = 33
aa = 44
dd = 33
c = 3

names = ^a.*
Vars - ls()
r - Vars[grep(names,Vars)]
r # not really correct for names.* and Vars.*

Dieter

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

2009-04-01 Thread ronggui
you can use source() to Read R Code from a File.

2009/4/1 minben minb...@gmail.com:
  Suppose I have written a R program and saved it in test.R . How can I
 call the program in the command line?

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




-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

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


[R] problem with 'loading file size'

2009-04-01 Thread venkata kirankumar
Hi all,
I am working in a project which needed to load *.csv files of size more than
200MB
is it posible to load 200MB size file to r-project and do subsetting as per
requirement
i am able to load maximum of 90 mb
is there any way to increase memory limits and how much maximum memory we
can exten
please some one help me to get it work

thanks in advance.

[[alternative HTML version deleted]]

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


Re: [R] Variable Wildcard Value

2009-04-01 Thread Patrick Burns

I would be truly amazed if the answer were yes.

I find this the most fascinating question on R-help
for a long time, maybe ever.  Can you tell us what
you have in mind and what your ultimate purpose is?

Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Francis Smart wrote:

Is there a wildcard value for vector values in r?

For instance:

  

M - *wildcard



  

(M==1)


TRUE

  

(M==peanut butter)


TRUE

  

is.na(M)


FALSE

thanks,
Francis




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

2009-04-01 Thread Wacek Kusnierczyk
Stavros Macrakis wrote:
 On Tue, Mar 31, 2009 at 3:41 PM, Wacek Kusnierczyk 
 waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

   
 Stavros Macrakis wrote:
 
 ...All that being said, programming with global variables makes certain
   
 classes of bug much more likely

 ... in a language like r, that heavily relies on setting global variables
 (par(), options(), ...).

 

 Yes, par, options, etc. are problematic, too, especially since there's no
 easy way I know of to make them local (like dynamic binding in old Lisps).
   

indeed, i too was thinking about something like perl's local:

print $$;
# 123456
{ local $$;
   print $$; }
# (empty string)

or fluid-let in scheme.

i don't know of any construct in r that would localize global variables
in this manner, but for options, par, etc., you do have an option, the
(arguably ugly) idiom with storing the previous value and restoring it
on exit:

print(getOption('digits'))
# 7

local({
   options = options(digits=1)
   on.exit(options(options))
   print(getOption('digits')) })
# 1

print(getOption('digits'))
# 7

it's like manually localizing a global variable.

vQ

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


[R] Plotting lines(...type=b, pch=1) vs. legend(pch=1)

2009-04-01 Thread Michael R. Head
I'd like to do a lineplot with type=b (both lines and points), opposed
to type=o (points overplotted on lines). I'd like the legend to match
the line, with the point character plotted distinctly from the line, but
I can't figure out from the manual
( http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/legend.html ) 
which option to set on the legend() call.

Is there a way to get the legend to plot lines and point characters
without overplotting the character that I'm missing?

-- 
Michael R. Head bur...@suppressingfire.org
http://www.cs.binghamton.edu/~mike/

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


Re: [R] How to generate natural cubic spline in R?

2009-04-01 Thread Martin Maechler
 SK == Stephan Kolassa stephan.kola...@gmx.de
 on Tue, 31 Mar 2009 22:20:50 +0200 writes:

SK Hi David,
SK David Winsemius schrieb:
 The splinefun documentation indicates that natural is one of the types 
 of cubic spline options available.

SK That sounds good, didn't know that... rcs() has the advantage of coming 
SK with a book (Harrell's Regression Modeling Strategies).

well,  and  splinefun() comes with R !!!

 Does rcs actually do fitting? Such would not be my expectation on 
 reading the documentation and I do not see any examples of such 
 functionality in the help pages.

SK Nope, but you can include rcs() within fitting functions, 
SK lm(foo~rcs(bar,3)), which makes more sense to me than having a spline 
SK function fit... Looks like better encapsulation to me.

well,  but  ns()  has been part of the S language for ages, and
part of R since its very early days,
exactly for the purpose to be used in something like  
lm(y ~ ns(.) + ..)

So while rcs() may have extra merits, (I assume it does, as I
assume Frank Harrell will have known about ns()),
in order to solve the OP's problem, I still believe that
standard R [and good old S version 3 for that matter]
contains all functionality needed.

Martin Maechler, ETH Zurich

SK Best,
SK Stephan

SK __
SK R-help@r-project.org mailing list
SK https://stat.ethz.ch/mailman/listinfo/r-help
SK PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
SK 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] How can I use R through command line?

2009-04-01 Thread Dieter Menne
minben minbenh at gmail.com writes:

 
  Suppose I have written a R program and saved it in test.R . How can I
 call the program in the command line?

Assuming Windows (might work under linux)

rterm --vanilla --no-save  myrfile.r

Dieter

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

2009-04-01 Thread Martin Maechler
 r == ronggui  ronggui.hu...@gmail.com
 on Wed, 1 Apr 2009 16:00:16 +0800 writes:

r you can use source() to Read R Code from a File.

yes, but that's not in the command line. 
Slightly more closely to the OP's question:

  R CMD BATCH test.R
or
  Rscript test.R

(orr  test.Rif you have installed  'littler' )

Martin Maechler, ETH Zurich 

r 2009/4/1 minben minb...@gmail.com:

  Suppose I have written a R program and saved it in test.R . How can I
 call the program in the command line?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Generating EPS figures automatically (like Sweave)

2009-04-01 Thread Dieter Menne
eariasca eariasca at math.ucsd.edu writes:

 Is there a way to generate EPS figures automatically out of a chunk  
 of code?  Basically, I would like to do something like Sweave does (I  
 just find it a little cumbersome to create a .Rnw file and then keep  
 track of the figure numbering).  

I normally use this type of code when not using Sweave

ToPostscript = TRUE
if (ToPostscript){
  trellis.device(postscript,file=myfile.ps,width=6,height=4,color=FALSE)
} else
{
  windows( height=4,width=6)
}
# Do the plot-works

if (ToPostscript){
  dev.off()
  sink()
}


## And use GhostFriend from 
http://www.noliturbare.com/ReadGhostFriend.htm 
to create TIFF if your publisher asks for it.

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

2009-04-01 Thread V Prasanth
Dear Duncan Murdoch:

Thanks for your tips. By the way, I think I didn't mentioned my question
very clear. What I mean to say is that, in Excel one could decide upon the
axis interval unit. Please see the attached file. Likewise, is it possible
in R...?

Regards,
Prasanth.

-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca]
Sent: Tuesday, March 31, 2009 6:25 PM
To: V Prasanth
Cc: r-help@r-project.org
Subject: Re: [R] How to specify axis interval unit...

On 3/31/2009 5:08 AM, V Prasanth wrote:
 Dear R Users:
 
  
 
 Greetings!
 
  
 
 Is there any way to specify the axis interval unit for barplots in R.? 
 Any help is deeply appreciated.

You can set axes=FALSE, names= and then use whatever axes you like. 
Modifying the first example in examples(barplot):

tN - table(Ni - stats::rpois(100, lambda=5)) r - barplot(tN,
col=rainbow(20), axes=F, names=) axis(2, at=2^(0:5)) axis(1, at=r,
labels=letters[1:length(tN)])

Duncan Murdoch
 
  
 
 Thanks in advance!
 
 Prasanth VP,
 Global Manager - Biometrics,
 Delta Technology  Management Services Pvt Ltd, Plot No: 13/2, Sector 
 - I, Third Floor, HUDA Techno Enclave, Madhapur, Hyderabad - 500 033.
 Office: +91-40-3028 0659 
 Mobile   : +91-9848 290025 
  http://www.deltaintech.com/ www.deltaintech.com
 
  
 
  http://www.deltaintech.com/
 **
 **
 **
 
  http://www.deltaintech.com/ 'The information contained in this 
 email is confidential and may contain proprietary information. It is 
 meant solely for the intended recipient. Access to this email by anyone
else is unauthorized.
 If you are not the intended recipient, any disclosure, copying, 
 distribution or any action taken or omitted in reliance on this, is 
 prohibited and may be unlawful. No liability or responsibility is 
 accepted if information or data is, for whatever reason corrupted or does
not reach its intended recipient.
 No warranty is given that this email is free of viruses. The views 
 expressed in this email are, unless otherwise stated, those of the 
 author and not those of DELTA Technology and Management Services pvt ltd
or its management.
 DELTA Technology and Management Services pvt ltd reserves the right to 
 monitor intercept and block emails addressed to its users or take any 
 other action in accordance with its email use policy'
 
  http://www.deltaintech.com/ Thank you in advance for your cooperation.
 
  http://www.deltaintech.com/
 **
 **
 **
 
  http://www.deltaintech.com/ P Please don't print this e-mail unless 
 you really need to.
 
  
 
 
   [[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.


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


Re: [R] Variable Wildcard Value

2009-04-01 Thread Romain Francois

Hi,

Since you insist, here is something that I think matches the 
specifications :


wildcard - function( ) structure( NULL, class = wildcard )
Ops.wildcard - function (e1, e2){
   if (nargs() == 1L)
   return( e1 )
   result - switch(.Generic,
   `` = , `` = , `==` = ,
   `=` = , `=` = TRUE, `!=` = FALSE)
   result
}
is.na.wildcard - function( x ) FALSE


 w == 1
[1] TRUE
 w == peanut butter
[1] TRUE
 is.na( w )
[1] FALSE
 peanut butter == w
[1] TRUE
 w == w
[1] TRUE
 w != w
[1] FALSE

# Is negation of a wildcard also a wildcard, or should it be a bizarro 
wildcard ?

 (!w) == 2
[1] TRUE


Not really sure how this could be useful though, and would also be 
interested in Francis end game.


Romain


Patrick Burns wrote:

I would be truly amazed if the answer were yes.

I find this the most fascinating question on R-help
for a long time, maybe ever.  Can you tell us what
you have in mind and what your ultimate purpose is?

Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Francis Smart wrote:

Is there a wildcard value for vector values in r?

For instance:

 

M - *wildcard



 

(M==1)


TRUE

 

(M==peanut butter)


TRUE

 

is.na(M)


FALSE

thanks,
Francis




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

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






--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

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

2009-04-01 Thread Wacek Kusnierczyk
Patrick Burns wrote:
 I would be truly amazed if the answer were yes.

 I find this the most fascinating question on R-help
 for a long time, maybe ever.  Can you tell us what
 you have in mind and what your ultimate purpose is?


this seems a request for a 'match all' value, somewhat the inverse of NA
(~'match nothing').  i could think of this being useful when you want to
check for duplicates, and want to mark that some entries (e.g., the
unknown ones) are irrelevant for the comparison (i.e., they should match
everything):

identical(c(1, NA), c(1, 2))
# FALSE

identical(c(1, NA), c(1, NA))
# TRUE
# confusing!

# hypothetical
identical(c(1, *), c(1, 2))
# TRUE
identical(c(1, *), c(1, NA))
# TRUE

not sure about the last one, though, since the original post demanded
that is.na(*) == FALSE

i don't claim this would be useful in practice, just speculating.

vQ

 Patrick Burns
 patr...@burns-stat.com
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of The R Inferno and A Guide for the Unwilling S User)

 Francis Smart wrote:
 Is there a wildcard value for vector values in r?

 For instance:

  
 M - *wildcard
 

  
 (M==1)
 
 TRUE

  
 (M==peanut butter)
 
 TRUE

  
 is.na(M)
 
 FALSE

 thanks,
 Francis



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

2009-04-01 Thread Jim Lemon

V Prasanth wrote:

Dear R Users:

 


Greetings!

 


Is there any way to specify the axis interval unit for barplots in R.? Any
help is deeply appreciated.
  

Hi Prasanth,
If I understand your question, you might want to look at the barp 
function in the plotrix package that automatically centers bars and 
groups of bars on integer values.


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.


Re: [R] Variable Wildcard Value

2009-04-01 Thread Francis Smart
 Sure thing.  I realize that it is an unusual request and not the type
 of thing that I have seen used in any other language that I know of.

So right now I am using some of the statistical functions of R to get
some summary statistics and visual output from this historic data set.
I have a lot functions that look something like this:

 
summary(lm(SLV_DIE_PER[tontype==TONNAGE_TYPE]~SLV_PER_TON[tontype==TONNAGE_TYPE]))

 SLV_DIE_PER - being the percent of slaves that died between purchase
 and delivery
 SLV_PER_TON - being the number of slaves per standardized ton (ship capacity)
 tontype - being the type of ton that the ship capacity was recorded
 as.  There are various factors mostly in the form of 1,2,3,4,5...
 representing Spanish Ton, British Ton, etc.

 Now I want to run a simple linear model and graphs and other things by
 specifying TONNAGE_TYPE=1 or 2 etc.  Giving me a regression that is
 only using looking at a particular type of tonnage over that of
 another.

 All of that works fine.  But, it gets a little ugly when I want to
 generalize the linear model to include all values irrespective of
 tontype.  Of course I could duplicate and trim the statement as such:

 summary(lm(SLV_DIE_PER~SLV_PER_TON))

 I am sure you can see how a wildcard could be more important given a series
 of similar expressions.  Perhaps something that looks like this:

 
summary(SLV_DIE_PER[(SLV_DIE_PER=SLV_Min_Value)(Nationality==Select_Nationality)((SLV_PER_TON=SLV_Max_Value))(tontype==TONNAGE_TYPE)]))

 Well thanks for your interest.  Any suggestions that can help clean up
 my code could be extremely helpful right now.

 Btw thanks Dieter for that hint.  Not exactly what I was looking for
 but I am sure to use it in the future.

Romain.  Thanks for your code, though I don't see readily how to fit
w into your functions.  Perhaps you could add an additional line
between:

is.na.wildcard - function( x ) FALSE
and
 w == 1

Thanks!
Francis



 On Wed, Apr 1, 2009 at 2:02 AM, Patrick Burns pbu...@pburns.seanet.com 
 wrote:
 I would be truly amazed if the answer were yes.

 I find this the most fascinating question on R-help
 for a long time, maybe ever.  Can you tell us what
 you have in mind and what your ultimate purpose is?

 Patrick Burns
 patr...@burns-stat.com
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of The R Inferno and A Guide for the Unwilling S User)

 Francis Smart wrote:

 Is there a wildcard value for vector values in r?

 For instance:



 M - *wildcard




 (M==1)


 TRUE



 (M==peanut butter)


 TRUE



 is.na(M)


 FALSE

 thanks,
 Francis






 --
 Francis Smart
 (406) 223-8108 cell




-- 
Francis Smart
(406) 223-8108 cell

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] use R Group SFBA April meeting reminder; video of Feb k

2009-04-01 Thread Gad Abraham

Rolf Turner wrote:


I get to the video screen OK --- there's a large greenish sideways
triangle waiting to be clicked on.  I do so; there's a message that
says it's downloading, with a little progress bar.  That seems to
complete quite rapidly.  Then nothing for a while.  Then an error
message on the video screen saying ``Fatal error --- video source
not ready.''  Then that error message goes away.  Long wait.  Then
I get audio, but never any video.  Give up.

I'm using Firefox on an Imac; the ``About Mozilla Firefox'' button
on the Firefox dropdown menu says I've got Mozilla 5.0, Firefox 2.0.0.2
--- whatever that means.

Bottom line --- I can't watch the video.


Firefox 3.0.8 on OS X doesn't work either.

But you can go directly to 
http://www.lecturemaker.com/wp-content/uploads/2009/02/lmpremovie.swf 
and it will work.


--
Gad Abraham
MEng Student, Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: gabra...@csse.unimelb.edu.au
web: http://www.csse.unimelb.edu.au/~gabraham

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


Re: [R] Does R support double-exponential smoothing?

2009-04-01 Thread Gerard M. Keogh
Fit an ARIMA(0,2,2) model - it's the same thing and you'll get the MLE of
the smoothing parameter for free.
Use logs if you want a multiplicative model.

Gerard



   
 Stephan Kolassa   
 Stephan.Kolassa@ 
 gmx.deTo 
 Sent by:  minben minb...@gmail.com  
 r-help-boun...@r-  cc 
 project.org   r-help@r-project.org
   Subject 
   Re: [R] Does R support  
 31/03/2009 11:11  double-exponential smoothing?   
   
   
   
   
   
   




Hi,

ets() in Hyndman's forecast package allows you to specify which one of
the many smoothing variants (additive/multiplicative season, damped
trend, additive/multiplicative errors) you want.

HTH,
Stephan


minben schrieb:
 I want to use double-exponential smoothing to forecast time series
 datas,but I couldn't find it in the document,does R support this
 method?

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



**
The information transmitted is intended only for the person or entity to which 
it is addressed and may contain confidential and/or privileged material. Any 
review, retransmission, dissemination or other use of, or taking of any action 
in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any computer.  It is the policy of the 
Department of Justice, Equality and Law Reform and the Agencies and Offices 
using its IT services to disallow the sending of offensive material.
Should you consider that the material contained in this message is offensive 
you should contact the sender immediately and also mailminder[at]justice.ie.

Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh 
an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh 
agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. 
Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an 
bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a dhéanamh ar a 
hiontaoibh, ag daoine nó ag eintitis seachas an faighteoir beartaithe. Má fuair 
tú é seo trí dhearmad, téigh i dteagmháil leis an seoltóir, le do thoil, agus 
scrios an t-ábhar as aon ríomhaire. Is é beartas na Roinne Dlí agus Cirt, 
Comhionannais agus Athchóirithe Dlí, agus na nOifígí agus na nGníomhaireachtaí 
a úsáideann seirbhísí TF na Roinne, seoladh ábhair cholúil a dhícheadú.
Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa teachtaireacht 
seo is ceart duit dul i dteagmháil leis an seoltóir láithreach agus le 
mailminder[ag]justice.ie chomh maith. 
***



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Discussion on hosting of local user group web portals under r-project

2009-04-01 Thread Usuario R
Hi all,

Driven by the success of R, a number of local R users groups have been
formed in several places (London, NY, etc.). We are also currently
considering setting up our own local group in Spain.

We have found that setting up a web page in order to centralise the
information relevant to the group members, keep a calendar of events,
and other functionalities is very important as a tool to keep the
community together and active. Other local groups have developed
their own web portals. We are discussing the implementations details
of our own.

We believe that nurturing these local communities could help to build
stronger user base. We are aware that r-forge and r-wiki projects,
currently under the r-project umbrella, started from discussions on
this list.

Therefore, we would like to propose that a new discussion were open in
the list in order to consider the convenience of setting up a new
environment under r-project (and parallel to r-forge and r-wiki)
where local user groups could build their web pages and provide their
members the required services under a common architecture and sharing
a number of tools.

We believe that this would be a great addition to the community and we
would be delighted to hear the community express their views on the
topic.

Best regards.

[[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] use R Group SFBA April meeting reminder; video of Feb k

2009-04-01 Thread Ted Harding
On 01-Apr-09 09:37:49, Gad Abraham wrote:
 Rolf Turner wrote:
 
 I get to the video screen OK --- there's a large greenish sideways
 triangle waiting to be clicked on.  I do so; there's a message that
 says it's downloading, with a little progress bar.  That seems to
 complete quite rapidly.  Then nothing for a while.  Then an error
 message on the video screen saying ``Fatal error --- video source
 not ready.''  Then that error message goes away.  Long wait.  Then
 I get audio, but never any video.  Give up.
 
 I'm using Firefox on an Imac; the ``About Mozilla Firefox'' button
 on the Firefox dropdown menu says I've got Mozilla 5.0, Firefox
 2.0.0.2
 --- whatever that means.
 
 Bottom line --- I can't watch the video.
 
 Firefox 3.0.8 on OS X doesn't work either.
 
 But you can go directly to 
 http://www.lecturemaker.com/wp-content/uploads/2009/02/lmpremovie.swf 
 and it will work.
 -- 
 Gad Abraham

AND it works beautfully using FlashPlayer v.9 on Linux too!

This was the version I already had installed when I first failed
to locate the video -- instead seeing the little panel for installing
FlashPlayer, which I ignored, since I already had it, not realising
that it was telling me I should install FlashPhayer 10.

It is now clear that this advice was erroneous, since version 9
in fact works fine!

Furthermore, when (as I previously reported) I did install version 10,
that didn't work either. I later found that version 10 was looking
for versions of Linux libraries which I didn't have; and also that
FlashPlayer no longer worked (e.g.) on the BBC website.

So I re-installed version 9, and everything again worked on the BBC
and for videos in Press reports, etc. But of course still the same
failure for the SFBA video. Now, using the direct URL for the same
video as kindly revealed by Gad, it works and could have worked
all along!

It is, therefore, clear that the HTML in the original URL is doing
the wrong thing, by somehow detecting a version  10 of FlashPlayer
and refusing to cooperate, when this was erroneous.

I (and Jim Porzak and Mike Driscoll) received a private email from
  Ron Fredericks
  Video director and Multimedia expressionist
  http://www.lecturemaker.com
  Ron @ Lecturemaker r...@lecturemaker.com
(whom I'm adding to the address-list for this mail) which stated:


  The video may be hard find, admittedly, if you do not have
  version 10 of flash player installed. If you do not have a
  recent version of Flash in your web browser, I present a
  smallish Adobe image with the words you do not have
  version 10 of flash installed, click to install. 

  Attached is a screenshot of what you should be seeing at this link
  http://www.lecturemaker.com/2009/02/r-kickoff-video/

  I'll take your feedback from the R User Group list server
  as a suggestion to make the need to update your flash player
  a lot bigger on the screen. 

  Ron Fredericks

So, message to Ron Fredericks: The video works with version 9.
If (for some reason) it is essential for the original URL to
detect when version 10 is not installed, then there should be
a pointer on the folloowing lines:

  You appear not to have version 10 of Flach Player installed.
   If you are using an earlier version, please click on the
   following link . 

which would take people to the URL provided by Gad, which does work
on earlier versions (well, version 9 at least). Then it would no
longer be the case that The video may be hard find, admittedly,
if you do not have version 10 of flash player installed.!

My thanks to everyone who hsd helped to delve into this tangle,
and especially to Gad who found where the solution was lurking!

Best wishes to all,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Apr-09   Time: 11:17:02
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS Institute to invest upto $20 m with R Project

2009-04-01 Thread Ajay ohri
A SAS spokesperson has confirmed to this blog that they have invested
in the R –Core project to help build next generation algorithms .
Details are sketchy but indications of some shift on cloud hosted SAS
,called SaaS are emerging.Also includes some details on Jim Davis ,SVP
SAS marketing's statement on BI and Anne Milley having a new
assignment within SAS Institute.

Read more here -
http://www.decisionstats.com/2009/04/sas-institute-invests-in-r-project/

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

2009-04-01 Thread Romain Francois

Francis Smart wrote:

 Sure thing.  I realize that it is an unusual request and not the type
 of thing that I have seen used in any other language that I know of.

So right now I am using some of the statistical functions of R to get
some summary statistics and visual output from this historic data set.
I have a lot functions that look something like this:

 
summary(lm(SLV_DIE_PER[tontype==TONNAGE_TYPE]~SLV_PER_TON[tontype==TONNAGE_TYPE]))

 SLV_DIE_PER - being the percent of slaves that died between purchase
 and delivery
 SLV_PER_TON - being the number of slaves per standardized ton (ship capacity)
 tontype - being the type of ton that the ship capacity was recorded
 as.  There are various factors mostly in the form of 1,2,3,4,5...
 representing Spanish Ton, British Ton, etc.

 Now I want to run a simple linear model and graphs and other things by
 specifying TONNAGE_TYPE=1 or 2 etc.  Giving me a regression that is
 only using looking at a particular type of tonnage over that of
 another.

 All of that works fine.  But, it gets a little ugly when I want to
 generalize the linear model to include all values irrespective of
 tontype.  Of course I could duplicate and trim the statement as such:

 summary(lm(SLV_DIE_PER~SLV_PER_TON))

 I am sure you can see how a wildcard could be more important given a series
 of similar expressions.  Perhaps something that looks like this:

 
summary(SLV_DIE_PER[(SLV_DIE_PER=SLV_Min_Value)(Nationality==Select_Nationality)((SLV_PER_TON=SLV_Max_Value))(tontype==TONNAGE_TYPE)]))

 Well thanks for your interest.  Any suggestions that can help clean up
 my code could be extremely helpful right now.

 Btw thanks Dieter for that hint.  Not exactly what I was looking for
 but I am sure to use it in the future.

Romain.  Thanks for your code, though I don't see readily how to fit
w into your functions.  Perhaps you could add an additional line
between:

is.na.wildcard - function( x ) FALSE
  


w - wildcard()

Note that it answers your previous question, but not this one.

This is untested because we do not have your data, but you could go with 
something like that, assuming the variables tontype, SLV_DIE_PER, 
SLV_PER_TON are in the data frame data. That way, you seperate your 
model to the data it is applied to:


with( subset( data, tontype == TONNAGE_TYPE ), lm( SLV_DIE_PER ~ 
SLV_PER_TON ) )


Not sure how the wildcard you asked for in your first email fits into this.

Romain


and
 w == 1

Thanks!
Francis


  

On Wed, Apr 1, 2009 at 2:02 AM, Patrick Burns pbu...@pburns.seanet.com wrote:


I would be truly amazed if the answer were yes.

I find this the most fascinating question on R-help
for a long time, maybe ever.  Can you tell us what
you have in mind and what your ultimate purpose is?

Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Francis Smart wrote:
  

Is there a wildcard value for vector values in r?

For instance:




M - *wildcard

  


(M==1)

  

TRUE




(M==peanut butter)

  

TRUE




is.na(M)

  

FALSE

thanks,
Francis





--
Francis Smart
(406) 223-8108 cell






  



--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fedora 10 KDE plasma font rendering issue

2009-04-01 Thread José Matos
On Tuesday 31 March 2009 21:02:23 dfermin wrote:
 Hello.

 I've got a new workstation running Fedora 10 linux and I use the KDE 4.2
 desktop which uses some kind of new desktop environment called 'plasma'.

 If I start up R and generate a plot (for example: hist(rnorm(1, mean=0,
 sd=1), breaks=100) ). The plot appears but all text (the x/y axes, title,
 etc..) is replaced by a square box. No font is rendered at all.

 Has anyone else got this problem? If so do you have a work around or a
 solution?

What graphics card do you have?

I saw recently reports about this happening on grace when using intel graphic 
cards. I am starting to suspect that this could be the same problem.

 I'm using R version 2.8.1 installed from the Fedora 10 repositories if that
 helps.

 Thanks in advance.

-- 
José Abílio

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 message obtained when plotting survival curves (error not previously obtained)

2009-04-01 Thread Bob Green

Hello Thomas,

I had been using both survival  design packages. I have just tested 
both packages and can report that the error only appears after 
loading Design. If I just run survival there is no error.


regards

Bob
At 06:08 PM 1/04/2009, Thomas Lumley wrote:

On Wed, 1 Apr 2009, Bob Green wrote:



Hello,

I now receive an error message when obtaining a survival plot, 
which was not previously received with the same code. I recently 
updated all my packages. It does not seem to be a peculiarity of my 
data as I receive the error using data available in R. A plot is 
produced but I am uncertain regarding the error message.





library(surv2sample)
data(gastric)
fit - survfit(Surv(time, event) ~ treatment, data = gastric)

Error in get(x, envir = ns, inherits = FALSE) :
 variable survfit.km was not found

#Default plot:
plot(fit)


You don't show what packages you have loaded.  My guess would be 
that you are calling Design::survfit rather than survival::survfit, 
and the problem is due to the incompatibility between the most 
recent versions of Design and survival. Frank Harrell and the folks 
at Vanderbilt are working on a new version of Design.


  -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fedora 10 KDE plasma font rendering issue

2009-04-01 Thread Martyn Plummer
On Tue, 2009-03-31 at 18:36 -0700, dfermin wrote:
 Nope. I checked this. Both those fonts are installed.

Well it is some kind of font rendering problem. The default device is
the Cairo X11 device, which uses the Pango layout engine for font
rendering. 

If you set the environment variable FC_DEBUG to 1 before launching your
R session, you will get some debugging information. It is very verbose,
but we only need to see this bit:

First font Pattern has 15 elts (size 15)
family: Nimbus Sans L(w)
style: Regular(w)
slant: 0(i)(w)
weight: 80(i)(w)
width: 100(i)(w)
foundry: urw(w)
file: /usr/share/fonts/default/Type1/n019003l.pfb(w)
index: 0(i)(w)
outline: FcTrue(w)
scalable: FcTrue(w)



 
 Martyn Plummer-2 wrote:
  
  Quoting dfermin dfer...@umich.edu:
 
  Hello.
 
  I've got a new workstation running Fedora 10 linux and I use the KDE 4.2
  desktop which uses some kind of new desktop environment called 'plasma'.
 
  If I start up R and generate a plot (for example: hist(rnorm(1,
  mean=0,
  sd=1), breaks=100) ). The plot appears but all text (the x/y axes, title,
  etc..) is replaced by a square box. No font is rendered at all.
 
  Has anyone else got this problem? If so do you have a work around or a
  solution?
 
  I'm using R version 2.8.1 installed from the Fedora 10 repositories if
  that
  helps.
 
  Thanks in advance.
  
  It sounds like you are missing some fonts. Check that the urw-fonts and
  liberation-fonts RPMs are installed.


---
This message and its attachments are strictly confidenti...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] re commended computing server for R (March 2009)?

2009-04-01 Thread Ajay Ohri Decisionstats

A SAS spokesperson has confirmed to this blog that they have invested
in the R –Core project to help build next generation algorithms .
Details are sketchy but indications of some shift on cloud hosted SAS
,called SaaS are emerging.Also includes some details on Jim Davis ,SVP
SAS marketing's statement on BI and Anne Milley having a new
assignment within SAS Institute.

Read more here -
http://www.decisionstats.com/2009/04/sas-institute-invests-in-r-project/



ivowel wrote:
 
 dear r-experts:
 
 I need to speed up my monte-carlo simulations. my code is written in R
 (and  
 it was also the cause of my many questions here over the last few days).
 my  
 code is almost all matrix/vector algebra on panel data  
 sets---long-difference, fixed-effects, blundell-bond, etc.. the data set
 is  
 about 10MB, so 1GB per CPU core should be plenty for my operations, and  
 with $10/GB of DRAM, this is no longer a bottleneck. For my application,  
 parallelism is a given, since most of it is monte-carlo simulations. (I  
 guess the diametrically opposite need would be when one cannot
 parallelize,  
 in which case the recommendations would be quite different.)
 
 My operating system will probably be ubuntu. (I also run a little of it on  
 an OSX Mac Pro I own.)
 
 I want to use an Intel/AMD system with a prebuilt R executable. I do not  
 want to fiddle (too much) with building R myself, unless it is real easy  
 and makes a real speed difference. I wish I could ask R to load something  
 exotic like CUDA, but I presume that this is not yet ready for prime-time.  
 PS3 is probably silly, too. in fact, if I am not mistaken (and I may well  
 be), R pre-built does not even take advantage of SSE3 out-of-the-box.
 
 software-wise, is there anything unusual that I should heed, or should I  
 just pick of R 2.8.1 from the CRAN archives and be done with it?
 
 now, I also have to make some simple hardware decisions. Right now, a  
 dual-socket quad-core AMD opteron shanghai 2.3GHz system seems cheap.  
 $174/CPU + $70/motherboard. is there a system that dominates this in terms  
 of $/MFlops? (I presume the fact that core i7 has threads is irrelevant to  
 R.) I am not trying to ignite a flame-war---in fact, I don't care about
 any  
 other features that AMD or Intel or anything might have for this
 particular  
 computer. Other needs may warrant different choices.
 
 Any other thoughts would be appreciated. Although you can just email them  
 to me, I presume that this question has enough interest to others that  
 posting it is ok.
 
 regards,
 
 /ivo welch
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/recommended-computing-server-for-R-%28March-2009%29--tp22756946p22824049.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] SAS Institute to invest upto $20 m with R Project

2009-04-01 Thread Daniel Viar
And a happy April Fools day to you to...

On Wed, Apr 1, 2009 at 5:44 AM, Ajay ohri ohri2...@gmail.com wrote:
 A SAS spokesperson has confirmed to this blog that they have invested
 in the R –Core project to help build next generation algorithms .
 Details are sketchy but indications of some shift on cloud hosted SAS
 ,called SaaS are emerging.Also includes some details on Jim Davis ,SVP
 SAS marketing's statement on BI and Anne Milley having a new
 assignment within SAS Institute.

 Read more here -
 http://www.decisionstats.com/2009/04/sas-institute-invests-in-r-project/

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] repeated measures ANOVA - among group differences

2009-04-01 Thread Mike Lawrence
If Month is nested within Quadrat I think you want:
aov(ProportioninTreatment ~ Treatment*Month +Error(Quadrat/Month), RM)

If Treatment is also nested within Quadrat, you want:
aov(ProportioninTreatment ~ Treatment*Month
+Error(Quadrat/(Treatment*Month)), RM)


On Wed, Apr 1, 2009 at 12:42 AM, Jessica L Hite/hitejl/O/VCU
hit...@vcu.edu wrote:


 I have data on the proportion of clutches experiencing different fates
 (e.g., 4 different sources of mortality) for 5 months . I need to test 1)
 if the overall proportion of these different fates is different over the
 entire study and 2) to see if there are monthly differences within (and
 among) fate types. Thus, I am pretty sure this is an RM analysis -( I
 measure the same quadrats each month).

 I am fine running the analysis in R - with the code below, however, there
 is no output for the among group variation...this is an important component
 - any ideas on how to solve this problem?

 I have included code and sample data below.

 Many thanks in advance for help and suggestions.

 J

  both.aov - aov(ProportioninTreatment ~ factor(Treatment)*factor(Month) +
 Error(factor(Quadrat)), RM)

 Error: factor(id)
          Df  Sum Sq Mean Sq F value Pr(F)
 Residuals  3 0.51619 0.17206               #why only partial output
 here? ###

 Error: Within
                   Df Sum Sq Mean Sq F value   Pr(F)
 factor(Fate1)       3 1.2453  0.4151  3.5899 0.017907 *
 time                1 0.9324  0.9324  8.0637 0.005929 **
 factor(Fate1):time  3 0.9978  0.3326  2.8763 0.042272 *
 Residuals          69 7.9783  0.1156




 Fate1 Proportion in Fate      ASIN  Month Quadrat
 1     0.117647059 0.350105778 1     1
 1     0     0     2     1
 1     0.1 0.339836909 3     1
 1     0     0     4     1
 1     0     0     5     1
 1     0     0     1     2
 1     0     0     2     2
 1     0.2   0.463647609 3     2
 1     0.25  0.523598776 4     2
 1     0.1 0.339836909 5     2
 1     0     0     1     3
 1     0     0     2     3
 1     0     0     3     3
 1     0.384615385 0.668964075 4     3
 1     0     0     5     3
 1     0     0     1     4
 1     0     0     2     4
 1     0     0     3     4
 1     0.16667 0.420534336 4     4
 1     0     0     5     4
 2     0.352941176 0.636132062 1     1
 2     0.2   0.463647609 2     1
 2     0.3 0.615479708 3     1
 2     1     1.570796327 4     1
 2     0     0     5     1
 2     0.5   0.785398163 1     2
 2     0     0     2     2
 2     0.6   0.886077124 3     2
 2     0.41667 0.701674124 4     2
 2     0.2 0.490882678 5     2
 2     0     0     1     3
 2     0.2   0.463647609 2     3
 2     0     0     3     3
 2     0.461538462 0.746898594 4     3
 2     0     0     5     3
 2     0     0     1     4
 2     0     0     2     4
 2     0.307692308 0.588002604 3     4
 2     0.7 0.955316618 4     4
 2     0     0     5     4
 3     0     0     1     1
 3     0     0     2     1
 3     0.4 0.729727656 3     1
 3     0     0     4     1
 3     1     1.570796327 5     1
 3     0.5   0.785398163 1     2
 3     0     0     2     2
 3     0     0     3     2
 3     0.25  0.523598776 4     2
 3     0.6 0.841068671 5     2
 3     0     0     1     3
 3     0     0     2     3
 3     0     0     3     3
 3     0.153846154 0.403057075 4     3
 3     0.7 0.955316618 5     3
 3     0     0     1     4
 3     0     0     2     4
 3     0     0     3     4
 3     0     0     4     4
 3     0.875 1.209429203 5     4
 4     0.294117647 0.573203309 1     1
 4     0.2   0.463647609 2     1
 4     0     0     3     1
 4     0     0     4     1
 4     0     0     5     1
 4     0     0     1     2
 4     0     0     2     2
 4     0     0     3     2
 4     0.08333 0.292842771 4     2
 4     0.1 0.339836909 5     2
 4     0     0     1     3
 4     0     0     2     3
 4     0     0     3     3
 4     0     0     4     3
 4     0.16667 0.420534336 5     3
 4     0     0     1     4
 4     0     0     2     4
 4     0.461538462 0.746898594 3     4
 4     0     0     4     4
 4     0.125 0.361367124 5     4
        [[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.




-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

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

~ Certainty is folly... I think. ~

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


Re: [R] DCT function?

2009-04-01 Thread Uwe Ligges
Not in signal, indeed, but there are functions dct() and dst() in 
package dtt.


Uwe Ligges

Red Roo wrote:

Looking for the DCT function, but don't see it in the signal pkg.
http://rss.acs.unt.edu/Rdoc/library/signal/html/signal.package.html
http://rss.acs.unt.edu/Rdoc/library/signal/html/00Index.html

As I understand it, the 'signal' functions are ports of the corresponding 
matlab/octave code, where the DCT exists. Did I miss it (different name?) or is 
someone working on a port for 'signal'?

--RR

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


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


Re: [R] problem with 'loading file size'

2009-04-01 Thread David Winsemius
It is certainly possible since I loaded a 825 MB csv file yesterday  
that had 1,5 milion lines, but the answer about how might very  
system specific. Please re-read the Posting Guide and offer the  
requested information and any error reports. You could try to do a bit  
os self-education:


?Memory


On Apr 1, 2009, at 4:03 AM, venkata kirankumar wrote:


Hi all,
I am working in a project which needed to load *.csv files of size  
more than

200MB
is it posible to load 200MB size file to r-project and do subsetting  
as per

requirement
i am able to load maximum of 90 mb
is there any way to increase memory limits and how much maximum  
memory we

can exten
please some one help me to get it work

thanks in advance.


David Winsemius, MD
Heritage Laboratories
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] repeated measures ANOVA - among group differences

2009-04-01 Thread Mike Lawrence
Hm, it seems I possibly used the technical term nested
inappropriately in my response. I meant:

If Month is a repeated measure within each Quadrat...
and
If Treatment is also a repeated measure within each Quadrat...

On Wed, Apr 1, 2009 at 8:21 AM, Mike Lawrence mike.lawre...@dal.ca wrote:
 If Month is nested within Quadrat I think you want:
 aov(ProportioninTreatment ~ Treatment*Month +Error(Quadrat/Month), RM)

 If Treatment is also nested within Quadrat, you want:
 aov(ProportioninTreatment ~ Treatment*Month
 +Error(Quadrat/(Treatment*Month)), RM)


 On Wed, Apr 1, 2009 at 12:42 AM, Jessica L Hite/hitejl/O/VCU
 hit...@vcu.edu wrote:


 I have data on the proportion of clutches experiencing different fates
 (e.g., 4 different sources of mortality) for 5 months . I need to test 1)
 if the overall proportion of these different fates is different over the
 entire study and 2) to see if there are monthly differences within (and
 among) fate types. Thus, I am pretty sure this is an RM analysis -( I
 measure the same quadrats each month).

 I am fine running the analysis in R - with the code below, however, there
 is no output for the among group variation...this is an important component
 - any ideas on how to solve this problem?

 I have included code and sample data below.

 Many thanks in advance for help and suggestions.

 J

  both.aov - aov(ProportioninTreatment ~ factor(Treatment)*factor(Month) +
 Error(factor(Quadrat)), RM)

 Error: factor(id)
          Df  Sum Sq Mean Sq F value Pr(F)
 Residuals  3 0.51619 0.17206               #why only partial output
 here? ###

 Error: Within
                   Df Sum Sq Mean Sq F value   Pr(F)
 factor(Fate1)       3 1.2453  0.4151  3.5899 0.017907 *
 time                1 0.9324  0.9324  8.0637 0.005929 **
 factor(Fate1):time  3 0.9978  0.3326  2.8763 0.042272 *
 Residuals          69 7.9783  0.1156




 Fate1 Proportion in Fate      ASIN  Month Quadrat
 1     0.117647059 0.350105778 1     1
 1     0     0     2     1
 1     0.1 0.339836909 3     1
 1     0     0     4     1
 1     0     0     5     1
 1     0     0     1     2
 1     0     0     2     2
 1     0.2   0.463647609 3     2
 1     0.25  0.523598776 4     2
 1     0.1 0.339836909 5     2
 1     0     0     1     3
 1     0     0     2     3
 1     0     0     3     3
 1     0.384615385 0.668964075 4     3
 1     0     0     5     3
 1     0     0     1     4
 1     0     0     2     4
 1     0     0     3     4
 1     0.16667 0.420534336 4     4
 1     0     0     5     4
 2     0.352941176 0.636132062 1     1
 2     0.2   0.463647609 2     1
 2     0.3 0.615479708 3     1
 2     1     1.570796327 4     1
 2     0     0     5     1
 2     0.5   0.785398163 1     2
 2     0     0     2     2
 2     0.6   0.886077124 3     2
 2     0.41667 0.701674124 4     2
 2     0.2 0.490882678 5     2
 2     0     0     1     3
 2     0.2   0.463647609 2     3
 2     0     0     3     3
 2     0.461538462 0.746898594 4     3
 2     0     0     5     3
 2     0     0     1     4
 2     0     0     2     4
 2     0.307692308 0.588002604 3     4
 2     0.7 0.955316618 4     4
 2     0     0     5     4
 3     0     0     1     1
 3     0     0     2     1
 3     0.4 0.729727656 3     1
 3     0     0     4     1
 3     1     1.570796327 5     1
 3     0.5   0.785398163 1     2
 3     0     0     2     2
 3     0     0     3     2
 3     0.25  0.523598776 4     2
 3     0.6 0.841068671 5     2
 3     0     0     1     3
 3     0     0     2     3
 3     0     0     3     3
 3     0.153846154 0.403057075 4     3
 3     0.7 0.955316618 5     3
 3     0     0     1     4
 3     0     0     2     4
 3     0     0     3     4
 3     0     0     4     4
 3     0.875 1.209429203 5     4
 4     0.294117647 0.573203309 1     1
 4     0.2   0.463647609 2     1
 4     0     0     3     1
 4     0     0     4     1
 4     0     0     5     1
 4     0     0     1     2
 4     0     0     2     2
 4     0     0     3     2
 4     0.08333 0.292842771 4     2
 4     0.1 0.339836909 5     2
 4     0     0     1     3
 4     0     0     2     3
 4     0     0     3     3
 4     0     0     4     3
 4     0.16667 0.420534336 5     3
 4     0     0     1     4
 4     0     0     2     4
 4     0.461538462 0.746898594 3     4
 4     0     0     4     4
 4     0.125 0.361367124 5     4
        [[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.




 --
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University

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

 ~ Certainty is folly... I think. ~




-- 
Mike Lawrence

[R] How to prevent inclusion of intercept in lme with interaction

2009-04-01 Thread Dieter Menne
Dear friends of lme,

After so many year with lme, I feel ashamed that I cannot get this to work.
Maybe it's a syntax problem, but possibly a lack of understanding.

We have growth curves of new dental bone that can well be modeled by a
linear growth curve, for two different treatments and several subjects as
random parameter. By definition, newbone is zero at t=0, so I tried to force
the curve through 0. In Pinheiro/Bates, this is done by including the -1
term, and it works well when treatment is not included (newbone~t-1), but
seems to have no effect in (newone ~ t*treat-1).

What's wrong? Some bracket missing? I tried a few variants.

Dieter Menne
#
library(nlme)
library(lattice)
# Generated data
set.seed(4711)
subject = as.factor(letters[1:5])
varslope = rnorm(length(subject),0,0.02)
cslope = c (0.1,0.15)
grd = expand.grid(t=seq(5,15,by=5), 
 subject=subject,treat=c(contr,test))
grd$slope = varslope[grd$subject] + cslope[grd$treat]
grd$newbone = grd$slope*grd$t+rnorm(nrow(grd),0,0.2)

xyplot(newbone~t|treat,groups=subject,data=grd,
   type=l,xlim=c(0,20),ylim=c(0,3))

# With intercept
grd.lme1 = lme(newbone~t*treat,data=grd,random=~1|subject)
grd$pred1 = predict(grd.lme1,level=0)
summary(grd.lme1)

# How go force intercept = 0 ???
grd.lme0 = lme(newbone~t*treat-1,data=grd,random=~1|subject)
grd$pred0 = predict(grd.lme0,level=0)
summary(grd.lme0)
# Gives true,
all.equal(grd$pred1,grd$pred0)

# Everything as expected without treat
grd.lme2 = lme(newbone~t,data=grd,random=~1|subject)
grd$pred2 = predict(grd.lme2,level=0)
summary(grd.lme2)

# Forced intercept = 0
grd.lme3 = lme(newbone~t-1,data=grd,random=~1|subject)
grd$pred3 = predict(grd.lme3,level=0)
summary(grd.lme3)
# As expected: not equal
all.equal(grd$pred2,grd$pred3)

#---
R version 2.9.0 Under development (unstable) (2009-03-13 r48127) 
i386-pc-mingw32 

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

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

other attached packages:
[1] lattice_0.17-20 nlme_3.1-90

loaded via a namespace (and not attached):
[1] grid_2.9.0  tools_2.9.0


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


[R] R.matlab_1.2.4.tgz best library for loading *.mat files?

2009-04-01 Thread Jason Rupert

Just curious - Is R.matlab_1.2.4.tgz still the best library for loading *.mat 
files?

Want to start using R to process some *.mat files.

Thanks again for any feedback and insight provided. 

Jason

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 prevent inclusion of intercept in lme with interaction

2009-04-01 Thread ONKELINX, Thierry
Dear Dieter,

With t*treat the model allows for a different slope AND a different
intercept for each treatment. If you only want different slopes and all
intercepts equal to 0, then t:treat - 1 or t + t:treat - 1 is the model
you are looking for.

HTH,

Thierry




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

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

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Dieter Menne
Verzonden: woensdag 1 april 2009 14:11
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] How to prevent inclusion of intercept in lme with
interaction

Dear friends of lme,

After so many year with lme, I feel ashamed that I cannot get this to
work.
Maybe it's a syntax problem, but possibly a lack of understanding.

We have growth curves of new dental bone that can well be modeled by a
linear growth curve, for two different treatments and several subjects
as
random parameter. By definition, newbone is zero at t=0, so I tried to
force
the curve through 0. In Pinheiro/Bates, this is done by including the -1
term, and it works well when treatment is not included (newbone~t-1),
but
seems to have no effect in (newone ~ t*treat-1).

What's wrong? Some bracket missing? I tried a few variants.

Dieter Menne
#
library(nlme)
library(lattice)
# Generated data
set.seed(4711)
subject = as.factor(letters[1:5])
varslope = rnorm(length(subject),0,0.02)
cslope = c (0.1,0.15)
grd = expand.grid(t=seq(5,15,by=5), 
 subject=subject,treat=c(contr,test))
grd$slope = varslope[grd$subject] + cslope[grd$treat]
grd$newbone = grd$slope*grd$t+rnorm(nrow(grd),0,0.2)

xyplot(newbone~t|treat,groups=subject,data=grd,
   type=l,xlim=c(0,20),ylim=c(0,3))

# With intercept
grd.lme1 = lme(newbone~t*treat,data=grd,random=~1|subject)
grd$pred1 = predict(grd.lme1,level=0)
summary(grd.lme1)

# How go force intercept = 0 ???
grd.lme0 = lme(newbone~t*treat-1,data=grd,random=~1|subject)
grd$pred0 = predict(grd.lme0,level=0)
summary(grd.lme0)
# Gives true,
all.equal(grd$pred1,grd$pred0)

# Everything as expected without treat
grd.lme2 = lme(newbone~t,data=grd,random=~1|subject)
grd$pred2 = predict(grd.lme2,level=0)
summary(grd.lme2)

# Forced intercept = 0
grd.lme3 = lme(newbone~t-1,data=grd,random=~1|subject)
grd$pred3 = predict(grd.lme3,level=0)
summary(grd.lme3)
# As expected: not equal
all.equal(grd$pred2,grd$pred3)

#---
R version 2.9.0 Under development (unstable) (2009-03-13 r48127) 
i386-pc-mingw32 

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

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


other attached packages:
[1] lattice_0.17-20 nlme_3.1-90

loaded via a namespace (and not attached):
[1] grid_2.9.0  tools_2.9.0


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

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

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


Re: [R] How to prevent inclusion of intercept in lme with interaction

2009-04-01 Thread Christian Ritz
Hi Dieter,

the following model assumes a linear relationship between the response 
newbone and the
independent variable t with a common intercept equal to 0 and 
treatment-dependent slopes:


grd.lme0 - lme(newbone~t:treat-1, data=grd, random=~1|subject)

summary(grd.lme0)




Christian

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


Re: [R] How to prevent inclusion of intercept in lme with interaction

2009-04-01 Thread Dieter Menne
ONKELINX, Thierry Thierry.ONKELINX at inbo.be writes:

 With t*treat the model allows for a different slope AND a different
 intercept for each treatment. If you only want different slopes and all
 intercepts equal to 0, then t:treat - 1 or t + t:treat - 1 is the model
 you are looking for.

Thanks Thierry and Christian, I knew it was something stupid.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Obtaining average ranking from matrix of frequencies

2009-04-01 Thread bwgoudey

I have a small matrix where the columns represents a ranking and the values
are the number of times each ranking was obtained eg 

 1  2  3
x   1  2  0
y   0  1  2
z   2  0  1

I'd like to be able to return an average of the ranking obtained
   average
x  1.67
y  2.67
z  1.67

Whats the nicest way to do this? I'm new to the language and looking for an
elegant solution :)

Thanks
  Ben




-- 
View this message in context: 
http://www.nabble.com/Obtaining-average-ranking-from-matrix-of-frequencies-tp22825754p22825754.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] Obtaining average ranking from matrix of frequencies

2009-04-01 Thread Dimitris Rizopoulos

say 'm' is your matrix, then try

rowMeans(m * col(m))


I hope it helps.

Best,
Dimitris


bwgoudey wrote:

I have a small matrix where the columns represents a ranking and the values
are the number of times each ranking was obtained eg 


 1  2  3
x   1  2  0
y   0  1  2
z   2  0  1

I'd like to be able to return an average of the ranking obtained
   average
x  1.67
y  2.67
z  1.67

Whats the nicest way to do this? I'm new to the language and looking for an
elegant solution :)

Thanks
  Ben






--
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] Obtaining average ranking from matrix of frequencies

2009-04-01 Thread Benjamin Goudey
Thanks heaps. Is there a neat way to do the same for the standard deviation?

Cheers
  Ben

On Wed, Apr 1, 2009 at 11:59 PM, Dimitris Rizopoulos
d.rizopou...@erasmusmc.nl wrote:
 say 'm' is your matrix, then try

 rowMeans(m * col(m))


 I hope it helps.

 Best,
 Dimitris


 bwgoudey wrote:

 I have a small matrix where the columns represents a ranking and the
 values
 are the number of times each ranking was obtained eg
     1  2  3
 x   1  2  0
 y   0  1  2
 z   2  0  1

 I'd like to be able to return an average of the ranking obtained
   average
 x  1.67
 y  2.67
 z  1.67

 Whats the nicest way to do this? I'm new to the language and looking for
 an
 elegant solution :)

 Thanks
  Ben





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


[R] Need Advice on Matrix Not Positive Semi-Definite with cholesky decomposition

2009-04-01 Thread Gottlieb, Neil
Dear fellow R Users:

I am doing a Cholesky decomposition on a correlation matrix and get error 
message 
the matrix is not semi-definite.

Does anyone know: 
1- a work around to this issue?
2- Is there any approach to try and figure out what vector might be co-linear 
with another in thr Matrix?
3- any way to perturb the data to work around this?

Thanks for any suggestions.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Principal components vs. raw variables

2009-04-01 Thread Manuel Ramon

Hello to everyone,

I am starting to work on classification procedures. I usualy do a principal
component analysis (PCA) as a previous step in order to reduce variables and
after I apply a cluster procedure. My question is if it will be better to
use raw variables instead of use principal components obtained from these
variables since the original variables keep all the variability.

Now i am thinking to use a variable group analysis (VGA) and a correlation
analysis together in order to identify which of my original variables could
explain differences on my data better, and after apply a cluster analysis on
selected variables. 

What do you think about it? What would be better: work with PCA or with raw
variables.

Thanks in advance.

Manuel



-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://www.nabble.com/Principal-components-vs.-raw-variables-tp22824280p22824280.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] Fwd: 'for Loop'

2009-04-01 Thread Alan O'Loughlin
Hello,
 
A nice guy call Jun Shen was helping me out with this, but I require a bit more 
help. Below is my data set or list called 'test'. I'm trying to calculate the 
%RSD for each pair of index and keep it in cronological order if you can 
imagine a 3rd column with 'date' beside index.
 
Result Index
1   0.290117
2   0.292817
3   0.291318
4   0.289318
5   0.3526 9
6   0.3316 9
7   0.349210
8   0.346710
9   0.338511
10  0.334111
11  0.344912
12  0.340612
13  0.369013
14  0.332713
15  0.332414
16  0.324514
17  0.324515
18  0.322915
19  0.333116
20  0.320816

 
now this bit of programming works for it how ever it puts the mean of my index 
back into numeric order.
 
aggregate(test[1],test[2],mean)-inter
names(inter)[2]='mean'
merge(test,inter,all=T)-inter2
inter2$RSV=inter2$Result/inter2$mean

Would anyone know away around this so I could keep the data in cronological 
order?
 
Kind Regards,
Al


[[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] R hangs when trying to invoke through java in linux environment

2009-04-01 Thread pravesh

Hello,

I have a .R file which I am trying to invoke via java with command line
parameters. Basically java invokes the command as follows:

Path to R binary --slave --args Path to CSV File Direcotry path
Date  Script path

I am using Rutime class of Java to execute this command. 

I have written a test program to do this. This program works well in
windows, generating the .png file. While in linux this leaves the java
console hung i.e. waiting for something.

I had tried to change the --slave arguements to --vanilla in both the
windows and linux version of the program and compared the output. The output
in windows version confirmed that it had completed successfully. While for
the linux version of the program, the last line that was printed was 

Type 'q()' to quit R.. After this it remained hung. 

My assumption is that after this R tries to read the graph file and outputs
that to the console and this task is failing in linux.  

However if I manually type the same command in the command prompt for linux,
it executes properly, generating the .png file.

Has anyone had similar problems in invoking R via java in linux? 

Any information regarding this issue will be appreciated.
-- 
View this message in context: 
http://www.nabble.com/R-hangs-when-trying-to-invoke-through-java-in-linux-environment-tp22825081p22825081.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] list substring

2009-04-01 Thread calpeda

hi
I ve a list of item x = ( x1
   x2
   x3)

I need to extract a new vector y  = ( ,
   ,
   
)
I mean, for each item I need to extract the first 4 digit
How is that possible?

Thank you
 
-- 
View this message in context: 
http://www.nabble.com/list-substring-tp22826435p22826435.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] Request: Optimum value of cost complexity parameter k in tree package

2009-04-01 Thread Muhammad Azam
Dear R community
I have a question regarding the value of cost complexity parameter k used in 
tree package for pruning purpose. Any help in finding the optimum value of 
k is requested. Please give some suggestion in this regard. In the example 
below i used k=0 but i don't know why? But if i use k=NULL, then it will not 
plot the resultant tree.  

library(tree)
ds=iris; iris=transform(iris, Species = factor(Species, labels = letters[1:3]))
miris - tree(Species ~ ., data = iris, control=tree.control(nobs = 150, 
minsize = 5, mincut = 2)); iris.prun=prune.tree(miris, method=c(misclass), 
best = NULL, k=0); iris.prun; summary(iris.prun); plot(iris.prun)


 
best regards

Muhammad Azam 



  
[[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] list substring

2009-04-01 Thread Wacek Kusnierczyk
calpeda wrote:
 hi
 I ve a list of item x = ( x1
x2
x3)

 I need to extract a new vector y  = ( ,
,

 )
 I mean, for each item I need to extract the first 4 digit
 How is that possible?
   

sub('^(\\d{4}).*', '\\1', x, perl=TRUE)

vQ

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


Re: [R] list substring

2009-04-01 Thread Dimitris Rizopoulos

try this:

x - c(x1, x2, x3)
substr(x, 1, 4)


Best,
Dimitris


calpeda wrote:

hi
I ve a list of item x = ( x1
   x2
   x3)

I need to extract a new vector y  = ( ,
   ,
   
)
I mean, for each item I need to extract the first 4 digit
How is that possible?

Thank you
 


--
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] list substring

2009-04-01 Thread Jorge Ivan Velez
Dear celpeda,
Try this:
 x = c( x1, x2, x3)
substr(x,1,4)
[1]   

See ?substr for more details.

HTH,

Jorge


On Wed, Apr 1, 2009 at 9:30 AM, calpeda mauro.bias...@calpeda.it wrote:


 hi
 I ve a list of item x = ( x1
   x2
   x3)

 I need to extract a new vector y  = ( ,
   ,
   
 )
 I mean, for each item I need to extract the first 4 digit
 How is that possible?

 Thank you

 --
 View this message in context:
 http://www.nabble.com/list-substring-tp22826435p22826435.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.


Re: [R] Constrined dependent optimization.

2009-04-01 Thread rkevinburton
Thank you I had not considered using gradient in this fashion. Now as an add 
on question. You (an others) have suggested using SANN. Does your answer change 
if instead of 100 variables or bins there are 20,000? From the documentation 
L-BFGS-B is designed for a large number of variables. But maybe SANN can handle 
this as well.

Kevin

 Paul Smith phh...@gmail.com wrote: 
 Apparently, the convergence is faster if one uses this new swap function:
 
 swapfun - function(x,N=100) {
  loc - c(sample(1:(N/2),size=1,replace=FALSE),sample((N/2):100,1))
  tmp - x[loc[1]]
  x[loc[1]] - x[loc[2]]
  x[loc[2]] - tmp
  x
 }
 
 It seems that within 20 millions of iterations, one gets the exact
 optimal solution, which does not take too long.
 
 Paul
 
 
 On Mon, Mar 30, 2009 at 5:11 PM, Paul Smith phh...@gmail.com wrote:
  Optim with SANN also solves your example:
 
  ---
 
  f - function(x) sum(c(1:50,50:1)*x)
 
  swapfun - function(x,N=100) {
   loc - sample(N,size=2,replace=FALSE)
   tmp - x[loc[1]]
   x[loc[1]] - x[loc[2]]
   x[loc[2]] - tmp
   x
  }
 
  N - 100
 
  opt1 - 
  optim(fn=f,par=sample(1:N,N),gr=swapfun,method=SANN,control=list(maxit=5,fnscale=-1,trace=10))
  opt1$par
  opt1$value
 
  ---
 
  We need to specify a large number of iterations to get the optimal
  solution. The objective function at the optimum is 170425, and one
  gets a close value with optim and SANN.
 
  Paul
 
 
  On Mon, Mar 30, 2009 at 2:22 PM, Hans W. Borchers
  hwborch...@googlemail.com wrote:
 
  Image you want to minimize the following linear function
 
     f - function(x) sum( c(1:50, 50:1) * x / (50*51) )
 
  on the set of all permutations of the numbers 1,..., 100.
 
  I wonder how will you do that with lpSolve? I would simply order
  the coefficients and then sort the numbers 1,...,100 accordingly.
 
  I am also wondering how optim with SANN could be applied here.
 
  As this is a problem in the area of discrete optimization resp.
  constraint programming, I propose to use an appropriate program
  here such as the free software Bprolog. I would be interested to
  learn what others propose.
 
  Of course, if we don't know anything about the function f then
  it amounts to an exhaustive search on the 100! permutations --
  probably not a feasible job.
 
  Regards,  Hans Werner
 
 
 
  Paul Smith wrote:
 
  On Sun, Mar 29, 2009 at 9:45 PM,  rkevinbur...@charter.net wrote:
  I have an optimization question that I was hoping to get some suggestions
  on how best to go about sovling it. I would think there is probably a
  package that addresses this problem.
 
  This is an ordering optimzation problem. Best to describe it with a
  simple example. Say I have 100 bins each with a ball in it numbered
  from 1 to 100. Each bin can only hold one ball. This optimization is that
  I have a function 'f' that this array of bins and returns a number. The
  number returned from f(1,2,3,4) would return a different number from
  that of f(2,1,3,4). The optimization is finding the optimum order of
  these balls so as to produce a minimum value from 'f'.I cannot use the
  regular 'optim' algorithms because a) the values are discrete, and b) the
  values are dependent ie. when the variable representing the bin
  location is changed (in this example a new ball is put there) the
  existing ball will need to be moved to another bin (probably swapping
  positions), and c) each variable is constrained, in the example above
  the only allowable values are integers from 1-100. So the problem becomes
  finding the optimum order of the balls.
 
  Any suggestions?
 
  If your function f is linear, then you can use lpSolve.
 
  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.
 
 
 
  --
  View this message in context: 
  http://www.nabble.com/Constrined-dependent-optimization.-tp22772520p22782922.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@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 

Re: [R] Need Advice on Matrix Not Positive Semi-Definite with cholesky decomposition

2009-04-01 Thread Ravi Varadhan
Look at the nearPD() function in the package Matrix.

require(Matrix)
?nearPD

In particular, pay attention to the arguments eig.tol and posd.tol,
which you can tweak to define how much positiveness you would like to
have.

Ravi. 



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Gottlieb, Neil
Sent: Wednesday, April 01, 2009 9:57 AM
To: 'r-help@r-project.org'
Subject: [R] Need Advice on Matrix Not Positive Semi-Definite with cholesky
decomposition

Dear fellow R Users:

I am doing a Cholesky decomposition on a correlation matrix and get error
message the matrix is not semi-definite.

Does anyone know: 
1- a work around to this issue?
2- Is there any approach to try and figure out what vector might be
co-linear with another in thr Matrix?
3- any way to perturb the data to work around this?

Thanks for any suggestions.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Definition of = vs. -

2009-04-01 Thread Stavros Macrakis
NOTA BENE: This email is about `=`, the assignment operator (e.g. {a=1}
which is equivalent to { `=`(a,1) } ), not `=` the named-argument syntax
(e.g. f(a=1), which is equivalent to
eval(structure(quote(f(1)),names=c('','a'))).

As far as I can tell from the documentation, assignment with = is precisely
equivalent to assignment with -.  Yet they call different primitives:

 `=`
.Primitive(=)
 `-`
.Primitive(-)

(Perhaps these are different names for the same internal function?)

Also, the difference is preserved by the parser:

 quote({a=b})
{
a = b
}
 quote({a-b})
{
a - b
}

even though in other cases the parser canonicalizes variant syntax, e.g. -
to -:

 quote({a-b})
{
b - a
}
 `-`
Error: object - not found

Is there in fact some semantic difference between = and - ?

If not, why do they use a different operator internally, each calling a
different primitive?

Or is this all just accidental inconsistency resulting from the '=', '-',
and '-' features being added at different times by different people working
off different stylistic conventions?

-s

[[alternative HTML version deleted]]

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


[R] Learning development concepts in R for newbie users

2009-04-01 Thread Harsh
Hi R users,

I apologize for a seemingly trivial question, but I felt this forum would be
the best place to seek advice.

I have been an R user for a year now, but I am limited to using R and its
various contributed packages. I strongly feel that users of a free and open
source software tool must eventually provide development expertise.

I am aware of the extensive documentation available on the R project page
regarding Internals, Language definitions and the like, but I would like to
find tutorials on R development, much the same way as there are tutorials
for the use of R in statistics and data analysis.

Information on Book titles, online sources, etc that you maybe aware of
which could allow a user of R to also develop R (packages, improvise on
functions, etc) would be much appreciated.

For example, I have used the adf.test in package 'tseries' but the test
assumes a certain form the the time series process. There are 3 forms in
literature, and the other 2 are not used. I would like to modify the
adf.test to incorporate the other two forms as well.

Thanks
Harsh Singhal

[[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] Need Advice on Matrix Not Positive Semi-Definite with cholesky decomposition

2009-04-01 Thread sten...@go.com

   Neil,
   pls  tell why do you need the correlation matrix? if you are trying to
   simulate correlated variables then you can go around the cholesky by using
   svd.
   if you really need the correlation ( I think it is always possible to avoid
   it  )  then Rmetrics have a function to turn your matrix into positive
   semi-definite.
   you can also consider a factor model which will reduce the dimensionality
   tremendously.
   Stephen C. Bond

   On Apr 1, 2009, ngottl...@marinercapital.com wrote:

 Dear fellow R Users:
 I am doing a Cholesky decomposition on a correlation matrix and get error
 message
 the matrix is not semi-definite.
 Does anyone know:
 1- a work around to this issue?
 2- Is there any approach to try and figure out what vector might be
 co-linear with another in thr Matrix?
 3- any way to perturb the data to work around this?
 Thanks for any suggestions.
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Need Advice on Matrix Not Positive Semi-Definite with cholesky decomposition

2009-04-01 Thread Gottlieb, Neil
Hi Stephen:

It's the inputs given to me by a end-user. Ultimately trying to fit a student-t 
copula to a bunch of simulated price returns
while maintaining the structure of the estimated correlation matrix.

The other challenge is I use R to test and work a solution but then have also 
done in matlab as I had to write a  C# wrapper around the code for the end-user.

In a way I am stuck with Matalb but was hoping to try and solve with R which is 
great.

I appreciate your responding to my email help request.

Neil


From: sten...@go.com [mailto:sten...@go.com]
Sent: Wednesday, April 01, 2009 10:47 AM
To: Gottlieb, Neil; r-help@r-project.org
Subject: Re: [R] Need Advice on Matrix Not Positive Semi-Definite with cholesky 
decomposition

Neil,

pls tell why do you need the correlation matrix? if you are trying to simulate 
correlated variables then you can go around the cholesky by using svd.
if you really need the correlation ( I think it is always possible to avoid it 
) then Rmetrics have a function to turn your matrix into positive semi-definite.
you can also consider a factor model which will reduce the dimensionality 
tremendously.

Stephen C. Bond



On Apr 1, 2009, ngottl...@marinercapital.com wrote:

Dear fellow R Users:

I am doing a Cholesky decomposition on a correlation matrix and get error 
message
the matrix is not semi-definite.

Does anyone know:
1- a work around to this issue?
2- Is there any approach to try and figure out what vector might be co-linear 
with another in thr Matrix?
3- any way to perturb the data to work around this?

Thanks for any suggestions.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Definition of = vs. -

2009-04-01 Thread Duncan Murdoch

On 4/1/2009 10:38 AM, Stavros Macrakis wrote:

NOTA BENE: This email is about `=`, the assignment operator (e.g. {a=1}
which is equivalent to { `=`(a,1) } ), not `=` the named-argument syntax
(e.g. f(a=1), which is equivalent to
eval(structure(quote(f(1)),names=c('','a'))).

As far as I can tell from the documentation, assignment with = is precisely
equivalent to assignment with -.  Yet they call different primitives:


The parser does treat them differently:

 if (x - 2) cat(assigned\n)
assigned
 if (x = 2) cat(assigned\n)
Error: unexpected '=' in if (x =

The ?= man page explains this:

 The  operator '-' can be used anywhere,
 whereas the operator '=' is only allowed at the top level (e.g.,
 in the complete expression typed at the command prompt) or as one
 of the subexpressions in a braced list of expressions. 

though the restriction on '=' seems to be described incorrectly:

 if ((x = 2)) cat(assigned\n)
assigned

in which the assignment is in parentheses, not a braced list.

As to the difference between the operations of the two primitives:  see 
do_set in src/main/eval.c.  The facility is there to distinguish between 
them, but it is not used.


Duncan Murdoch





`=`

.Primitive(=)

`-`

.Primitive(-)

(Perhaps these are different names for the same internal function?)

Also, the difference is preserved by the parser:


quote({a=b})

{
a = b
}

quote({a-b})

{
a - b
}

even though in other cases the parser canonicalizes variant syntax, e.g. -
to -:


quote({a-b})

{
b - a
}

`-`

Error: object - not found

Is there in fact some semantic difference between = and - ?

If not, why do they use a different operator internally, each calling a
different primitive?

Or is this all just accidental inconsistency resulting from the '=', '-',
and '-' features being added at different times by different people working
off different stylistic conventions?

-s

[[alternative HTML version deleted]]

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


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


[R] Discriminant analyse

2009-04-01 Thread Benedikt Niesterok
Hi everyone,
I intend to do a discriminant analyse for 2 measures(eye diameter and body 
length) and for different areas to show differences between those areas if 
there are any. The raw data (eye diameter, body length) make one cloud of 
points so it seems there aren't any differences between those areas.
If I take the mean values (eye diameter) for length classes, I nearly get
linear functions that differ in slope and intercept.
The question is:
Can I do something like a discriminant analyse for those lines to statistically 
separate them from each other or is there a totally different method for this 
case.
If you know any method, please, could you let me know.
Thanks,Ben 
--

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

2009-04-01 Thread woodbomb

I'm running brglm to do binomial loguistic regression.

The perhaps multicollinearity-related feature(s) are: 

(1) the k IVs are all binary categorical, coded as 0 or 1; 
(2) each row of the IVs contains exactly C ( k) 1's; (I think this is the
source of the problem)
(3) there are n * k unique rows, where n is as much as 10; 
(4) when brglm is run, at least 1 IV is reported as involving a singularity
and this occurs for nearly every choice of k, n.

How should I go about computing estimates for the offending IVs? I'm
interested primarily in the reliability of the parameter estimates.


-- 
View this message in context: 
http://www.nabble.com/Multicollinearity-with-brglm--tp22814696p22827727.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] smv() in e1071 and the BreastCancer data from mlbench

2009-04-01 Thread Brandon . J . Whitcher
R-help,

I am trying to perform a basic anlaysis of the BreastCancer data from 
mlbench using the svm() function in e1071.  I use the following code

library(e1071)
library(mlbench)

data(BreastCancer)
BC - subset(BreastCancer, select=-Id)
pairs(BC)
model - svm(Class ~ ., data=BC, cross=10)
## plot(model, BC, )
tobj - tune.svm(Class ~ ., data=BC, gamma=seq(0.0001,0.2,length=3),
 cost=seq(10,100,length=3))

...And here are the results from my session (with contextual information)

 system(uname -a)
Linux hmhuw015 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28 EST 2006 x86_64 
x86_64 x86_64 GNU/Linux
 version
   _ 
platform   x86_64-unknown-linux-gnu 
arch   x86_64 
os linux-gnu 
system x86_64, linux-gnu 
status 
major  2 
minor  8.1 
year   2008 
month  12 
day22 
svn rev47281 
language   R 
version.string R version 2.8.1 (2008-12-22)
 tobj - tune.svm(Class ~ ., data=BC, gamma=seq(0.0001,0.2,length=3),
+  cost=seq(1,100,length=3))
Error in names(ret2) - rowns : 
  'names' attribute [70] must be the same length as the vector [68]

Sorry, but could someone tell me what the error is trying to get at? 

thanks,

Brandon


---
This e-mail was sent by GlaxoSmithKline Services Unlimited 
(registered in England and Wales No. 1047315), which is a 
member of the GlaxoSmithKline group of companies. The 
registered address of GlaxoSmithKline Services Unlimited 
is 980 Great West Road, Brentford, Middlesex TW8 9GS.
---

[[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] list substring

2009-04-01 Thread calpeda

thank you,
but I m importing data from a txt file and I have a matrix of n*1
The function str seems to work only from 1*n





Wacek Kusnierczyk wrote:
 
 calpeda wrote:
 hi
 I ve a list of item x = ( x1
x2
x3)

 I need to extract a new vector y  = ( ,
,

 )
 I mean, for each item I need to extract the first 4 digit
 How is that possible?
   
 
 sub('^(\\d{4}).*', '\\1', x, perl=TRUE)
 
 vQ
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/list-substring-tp22826435p22827874.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] Package tcltk

2009-04-01 Thread Rita Sousa
Hi,
 
When I type library(tcltk) under R 2.8.1 I get the error message:
 
Loading Tcl/Tk interface ...Error in inDL(x, as.logical(local),
as.logical(now), ...) : 
  unable to load shared library
'C:/PROGRA~1/R/R-28~1.1/library/tcltk/libs/tcltk.dll':
  LoadLibrary failure:  The specified module could not be found.
 
Error : .onLoad failed in 'loadNamespace' for 'tcltk'
Error: package/namespace load failed for 'tcltk' 
 
I have the same problem with 2.7.0 but not in R 2.6.2. This problem
appeared from the R 2.8.1 installation.
Can you help me?
 
Many Thanks,

---
Rita Sousa
Departamento de Metodologia e Sistemas de Informação 

INE - DP: Instituto Nacional de Estatística - Delegação do Porto 

Tel.: 22 6072016 (Extensão: 4116)
--- 





[[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] Learning development concepts in R for newbie users

2009-04-01 Thread markleeds

   Hi:  I  have  had a similar issue so below are  ways that I deal with
   that.   i don't think there are manuals/ documentation for
   becoming more of a developer ( someone can correct me if I'm wrong and I'd
   be happy to be wrong )  but there are other  ways:
   1) Staying on this list as much as possible and watching what people send as
   solutions and trying to solve them yourself
   2) printing out package source code. For adf.test, look at the source and
   then try to figure out from that what you want to do.
   Most of the code from packages is written beautifully and therefore it's
   often not that difficult to understand.
   3) Reading the  R Language Defintion manual. I found that about 6 months
   ago and it was really interesting and helpful.
   4) Asking the R guRus questions without overwhelming/annoying them. If you
   stay on this list, you will fquickly figure out who they are.
   Â Â  There are many and some know everything and others are experts in
   specific areas.  They are  quite generous with
   Â Â  their expertise and time. But, you should keep in mind that they help
   for free and it's not their job so try to minimize your
   Â Â  bothers.
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Good luck.

   On Apr 1, 2009, Harsh singhal...@gmail.com wrote:

 Hi R users,
 I apologize for a seemingly trivial question, but I felt this forum would
 be
 the best place to seek advice.
 I have been an R user for a year now, but I am limited to using R and its
 various contributed packages. I strongly feel that users of a free and
 open
 source software tool must eventually provide development expertise.
 I am aware of the extensive documentation available on the R project page
 regarding Internals, Language definitions and the like, but I would like
 to
 find tutorials on R development, much the same way as there are tutorials
 for the use of R in statistics and data analysis.
 Information on Book titles, online sources, etc that you maybe aware of
 which could allow a user of R to also develop R (packages, improvise on
 functions, etc) would be much appreciated.
 For example, I have used the adf.test in package 'tseries' but the test
 assumes a certain form the the time series process. There are 3 forms in
 literature, and the other 2 are not used. I would like to modify the
 adf.test to incorporate the other two forms as well.
 Thanks
 Harsh Singhal
 [[alternative HTML version deleted]]
 __
 [1]r-h...@r-project.org mailing list
 [2]https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 [3]http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

References

   1. mailto:R-help@r-project.org
   2. https://stat.ethz.ch/mailman/listinfo/r-help
   3. http://www.R-project.org/posting-guide.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] Definition of = vs. -

2009-04-01 Thread Martin Morgan
Duncan Murdoch murd...@stats.uwo.ca writes:

 On 4/1/2009 10:38 AM, Stavros Macrakis wrote:
 NOTA BENE: This email is about `=`, the assignment operator (e.g. {a=1}
 which is equivalent to { `=`(a,1) } ), not `=` the named-argument syntax
 (e.g. f(a=1), which is equivalent to
 eval(structure(quote(f(1)),names=c('','a'))).
 As far as I can tell from the documentation, assignment with = is
 precisely
 equivalent to assignment with -.  Yet they call different primitives:

 The parser does treat them differently:

   if (x - 2) cat(assigned\n)
 assigned
   if (x = 2) cat(assigned\n)
 Error: unexpected '=' in if (x =

 The ?= man page explains this:

  The  operator '-' can be used anywhere,
   whereas the operator '=' is only allowed at the top level (e.g.,
   in the complete expression typed at the command prompt) or as one
   of the subexpressions in a braced list of expressions. 

 though the restriction on '=' seems to be described incorrectly:

   if ((x = 2)) cat(assigned\n)
 assigned

 in which the assignment is in parentheses, not a braced list.

 As to the difference between the operations of the two primitives:
 see do_set in src/main/eval.c.  The facility is there to distinguish
 between them, but it is not used.

10.4.2 of R-lang shows they differ in precedence

 x = y - 1
 rm(x,y)
 x - y = 1
Error in (x - y) = 1 : object 'x' not found

as reflected in main/names.c (PREC_LEFT vs. PREC_EQ)

{-,  do_set, 1,  100,-1, {PP_ASSIGN,  PREC_LEFT, 
  1}},
{=,   do_set, 3,  100,-1, {PP_ASSIGN,  PREC_EQ,   
  1}},

and include/Defn.h

PREC_LEFT= 1,
PREC_EQ  = 2,

Martin


 Duncan Murdoch


 
 `=`
 .Primitive(=)
 `-`
 .Primitive(-)
 (Perhaps these are different names for the same internal function?)
 Also, the difference is preserved by the parser:
 
 quote({a=b})
 {
 a = b
 }
 quote({a-b})
 {
 a - b
 }
 even though in other cases the parser canonicalizes variant syntax,
 e.g. -
 to -:
 
 quote({a-b})
 {
 b - a
 }
 `-`
 Error: object - not found
 Is there in fact some semantic difference between = and - ?
 If not, why do they use a different operator internally, each
 calling a
 different primitive?
 Or is this all just accidental inconsistency resulting from the '=',
 -',
 and '-' features being added at different times by different people working
 off different stylistic conventions?
 -s
  [[alternative HTML version deleted]]
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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

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

2009-04-01 Thread Stavros Macrakis
On Wed, Apr 1, 2009 at 10:55 AM, Duncan Murdoch murd...@stats.uwo.cawrote:

 On 4/1/2009 10:38 AM, Stavros Macrakis wrote:

 As far as I can tell from the documentation, assignment with = is
 precisely
 equivalent to assignment with -.  Yet they call different primitives:


 The parser does treat them differently:

  if (x - 2) cat(assigned\n)
 assigned
  if (x = 2) cat(assigned\n)
 Error: unexpected '=' in if (x =


Interesting way of handling the classic C glitch (some of us would say
design flaw in C, but...)


 The ?= man page explains this:

  The  operator '-' can be used anywhere,
 whereas the operator '=' is only allowed at the top level (e.g.,
 in the complete expression typed at the command prompt) or as one
 of the subexpressions in a braced list of expressions. 

 though the restriction on '=' seems to be described incorrectly:


  if ((x = 2)) cat(assigned\n)
 assigned


The restriction is incorrect in many other cases as well, e.g. the following
are all assignments: function()a=3; if(...)a=3; while(...)a=3; a=b=3 (two
assignments), and even a*b=3 (parses as assignment, but `*-` happens not to
be defined in the default environment).

In fact, the only cases I have found where = does *not* mean assignment is
in functional or array argument position (f(a=2) and f[a=2]), the following
contexts with function-like syntax: function(XXX)..., if(XXX)..., and
while(XXX)...; and for (i in XXX)  Are there any others? Perhaps the
documentation could be updated?

As to the difference between the operations of the two primitives:  see
 do_set in src/main/eval.c.  The facility is there to distinguish between
 them, but it is not used.


So are you saying that it is planned to make = and - non-synonymous, unlike
a-b and b-a, which parse the same and are therefore guaranteed to be
synonymous?

-s

[[alternative HTML version deleted]]

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


[R] Odp: Fwd: 'for Loop'

2009-04-01 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 01.04.2009 11:16:26:

 Hello,
 
 A nice guy call Jun Shen was helping me out with this, but I require a 
bit 
 more help. Below is my data set or list called 'test'. I'm trying to 
calculate
 the %RSD for each pair of index and keep it in cronological order if you 
can 
 imagine a 3rd column with 'date' beside index.
 
 Result Index
 1   0.290117
 2   0.292817
 3   0.291318
 4   0.289318
 5   0.3526 9
 6   0.3316 9
 7   0.349210
 8   0.346710
 9   0.338511
 10  0.334111
 11  0.344912
 12  0.340612
 13  0.369013
 14  0.332713
 15  0.332414
 16  0.324514
 17  0.324515
 18  0.322915
 19  0.333116
 20  0.320816
 
 
 now this bit of programming works for it how ever it puts the mean of my 
index
 back into numeric order.
 
 aggregate(test[1],test[2],mean)-inter
 names(inter)[2]='mean'
 merge(test,inter,all=T)-inter2
 inter2$RSV=inter2$Result/inter2$mean
 

?ave was also recommended and for your case it is strightforward

test$mean-ave(test$Result, test$Index)
test$RSV-test$Result/test$mean

Regards
Petr

 Would anyone know away around this so I could keep the data in 
cronological order?
 
 Kind Regards,
 Al
 
 
[[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] Still confused about R method of data exchanging between caller and called function

2009-04-01 Thread mauede
First of all I'd like to thank all those who answered me back teaching me 
different ways to get the calledfunction modify global data rather than its 
own. I fixed that.

Now I have a similar pproblem. Whenever the caller passes a matrix to the 
called function I thought  the called function would make a copy of the passed 
array in its own memory frame, modify its own copy, but be able to pass back 
the results to the caller as follows ... but I am mistaken (I find all NA on 
the second call ... how caome ?


ford - function(X,N,Nfour,Kfour,LevMin,LevMax) {
  

   Y - X
   Nord - Kord
   if(Nord == 2){
cat(\n call HAAR \n)
  Y - Haar(Y,Nfour,1)
   }else{
cat(\n call pwtset \n)
  pwtset(Nord)
cat(\n call wt1 \n)
  Y - wt1(Y,Nfour,1)
cat(\n function 'ford' Y = ,Y,\n)
   }

#
wt1 - function (a,n,isign){

cat(\n BEGIN 'wt1' \n)
cat(\n 'wt1': n = ,n,\n)
cat(\n 'wt1': a = ,a,\n)

  if (n  4){
cat(\n function 'wt1':  WRONG INPUT SIGNAL LENGTH \n)
return()
  }
  if(isign = 0){
 nn - n
 while(nn = 4){
cat(\n call pwt \n)
a - pwt(a,nn,isign)
nn - nn/2
 }
...

cat(\n END 'wt1' \n)
  a   #RETURN WAVELET COEFFICIENTS
}#  end function wt1 




tutti i telefonini TIM!


[[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] Fit unequal variance model in R

2009-04-01 Thread Feng, Jingyu
I'am trying to develop some code if R, which would correspond to what I did in 
SAS.

The data look like:

TreatmentReplicategroup1  GSI

  Control A   1  0.81301
  Control B   1  1.06061
  Control C   1  1.26350
  Control D   1  0.93284
  Low A   2  0.79359
  Low B   2  0.89111
  Low C   2  1.03485
  Low D   2  1.29166
  Mid A   3  1.26900
  Mid B   3   .
  Mid C   3  1.58666
  Mid D   3  1.35759
  HighA   4  2.02680
  HighB   4  1.52372
  HighC   4  2.19167
  HighD   4  1.29949


The SAS code is:
proc mixed data=data_name order=data method=ml; *scoring=10;
  classes group1;
  model GSI=group1/residual influence solution;
  repeated /group=group1;

run;

Basically, I need different variance for each treatment group. I want to do the 
similar thing in R.

Here is what I get so far:
lm1-lme(response~treatment,data=o,random=~1|as.factor(dummy),weights=varIdent(form=~1|treatment),method=ML)

There should no random term in the model. However If I don't specify one, lme 
won't work, so I made a dummy variable, which equals to 1 for every observation.

If anyone could help, it will be greatly appreciated.

Thanks,
Jingyu



[[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] A query about na.omit

2009-04-01 Thread Jose Iparraguirre D'Elia
Dear all,
 
Say I have the following dataset:
 
 DF
x y z
[1]   1 1 1
[2]   2 2 2
[3]   3 3NA
[4]   4   NA   4
[5]  NA  5 5
 
And I want to omit all the rows which have NA, but only in columns X and Y, so 
that I get:
 
 x  y  z
1  1  1
2  2  2
3  3  NA
 
If I use na.omit(DF), I would delete the row for which z=NA, obtaining thus
 
x y z
1 1 1
2 2 2
 
But this is not what I want, of course. 
If I use na.omit(DF[,1:2]), then I obtain
 
x y 
1 1
2 2
3 3
 
which is OK for x and y columns, but I wouldn't get the corresponding values 
for z (ie 1 2 NA)
 
Any suggestions about how to obtain the desired results efficiently (the actual 
dataset has millions of records and almost 50 columns, and I would apply the 
procedure on 12 of these columns)?
 
Sincerely,
 
Jose Luis 
 
Jose Luis Iparraguirre
Senior Research Economist 
Economic Research Institute of Northern Ireland
 
 

[[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 mixed-effects model with temporal pseudoreplication!

2009-04-01 Thread Ryan Hope
Sorry if this is the wrong ml for this question, I am new to R. I am
trying to use R to analyze the data from my thesis experiment and I am
having troubles accounting for the pseudoreplication properly from
having each participant repeat each treatment combination (combination
of fixed factors) 5 times. The design of the experiment is as
follows...

Responses:
CompletionTIme
VisitedTargets

Fixed-factors:
Targets (4-levels): 4, 9, 14, 19
Entropy (3-levels): Low, Medium, High

Random-factors:
Participants: 31 total participants
Replicates: 5 (this could also be viewed as a time factor I think)
BlockOrder: 1 though 60 (the order of the trials was random for each
participant, but I am not so concerned about this right now)

The fixed part of the model seems pretty intuitive:
fixed=log(CompletionTime)~(Targets*Entropy)

The random part of the model is where I get stuck on, I've tried many
combinations and all give me the wrong degrees of freedom. I really
don't know what to use.  Any help would be greatly appreciated

Here is the code I am using in R:

library(nlme)
datafile=http://people.rit.edu/rmh3093/mot.csv;
master1 = read.table(datafile,header=T)
Block=factor(master1$Block)
BlockOrder=factor(master1$Block_Order)
Replicate=factor(master1$Replicate)
Participant=factor(master1$Participant_ID)
Targets=factor(master1$Targets)
Entropy=factor(master1$Entropy)
CompletionTime=master1$Completion_Time
summary(lme(log(CompletionTime)~(Entropy*Targets),random=~1|Participant,method=ML))



Thanks in advance!
-Ryan

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


Re: [R] Calculating First Occurance by a factor

2009-04-01 Thread jwg20

I have another question regarding ddply. In my actual data.frame, I have many
other column variables corresponding to the type of the trial. I'm wondering
if I can have ddply include those in firstfixtime as well.

I tried messing with the line df$FixTime[which.min(df$FixInx)] changing it
to df[which.min(df$FixInx)] or adding new lines with the additional columns
that I want to include, but nothing seemed to work. I'll admit I only have a
mild understanding of what is going on with the function .fun. :-)




Mike Lawrence wrote:
 
 I discovered Hadley Wickham's plyr package last week and have found
 it very useful in circumstances like this:
 
 library(plyr)
 
 firstfixtime = ddply(
.data = data
, .variables = c('Sub','Tr','IA')
, .fun - function(df){
df$FixTime[which.min(df$FixInx)]
}
 )
 
 On Mon, Mar 30, 2009 at 3:40 PM, jwg20 jason.gulli...@gmail.com wrote:

 I'm having difficulty finding a solution to my problem that without
 using a
 for loop. For the amount of data I (will) have, the for loop will
 probably
 be too slow. I tried searching around before posting and couldn't find
 anything, hopefully it's not embarrassingly easy.

 Consider the data.frame, Data,  below

 Data
 Sub Tr  IA   FixInx  FixTime
 p1   t1  1    1        200
 p1   t1  2    2        350
 p1   t1  2    3        500
 p1   t1  3    4        600
 p1   t1  3    5        700
 p1   t1  4    6        850
 p1   t1  3    7        1200
 p1   t1  5    8        1350
 p1   t1  5    9        1500

 What I'm trying to do is for each unique IA get the first occurring
 FixTime.
 This will eventually need to be done by each Trial (Tr) and each Subject
 Number (Sub). FixInx is essentially the number of rows in a trial. The
 resulting data.frame is below.

 Sub Tr  IA  FirstFixTime
 p1   t1  1   200
 p1   t1  2   350
 p1   t1  3   600
 p1   t1  4   850
 p1   t1  5   1350

 Here is the solution I have now.

 agg = aggregate(data$FixInx, list(data$Sub, data$Tr, data$IA), min) #get
 the
 minimum fix index by Sub, Tr, and IA... I can use this min fix index to
 pull
 out the desired fixtime

 agg$firstfixtime = 0 # new column for results

 for (rown in 1:length(rownames(agg))){ #cycle through rows and get each
 data$firstfixtime from FixTime in matching rows
  agg$firstfixtime[rown] = as.character(data[data$Tr == agg$Group.2[rown]
 
 data$Sub == agg$Group.1[rown]  data$IA == agg$Group.3[rown] 
 data$FixInx
 == agg$x[rown], ]$FixTime)
 }
 --
 View this message in context:
 http://www.nabble.com/Calculating-First-Occurance-by-a-factor-tp22789964p22789964.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.

 
 
 
 -- 
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University
 
 Looking to arrange a meeting? Check my public calendar:
 http://tinyurl.com/mikes-public-calendar
 
 ~ Certainty is folly... I think. ~
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Calculating-First-Occurance-by-a-factor-tp22789964p22829525.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] Calculating First Occurance by a factor

2009-04-01 Thread hadley wickham
 I tried messing with the line df$FixTime[which.min(df$FixInx)] changing it
 to df[which.min(df$FixInx)] or adding new lines with the additional columns
 that I want to include, but nothing seemed to work. I'll admit I only have a
 mild understanding of what is going on with the function .fun. :-)

You probably want:

df[which.min(df$FixInx), ]

Hadley

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

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


Re: [R] Calculating First Occurance by a factor

2009-04-01 Thread hadley wickham
On Wed, Apr 1, 2009 at 11:00 AM, hadley wickham h.wick...@gmail.com wrote:
 I tried messing with the line df$FixTime[which.min(df$FixInx)] changing it
 to df[which.min(df$FixInx)] or adding new lines with the additional columns
 that I want to include, but nothing seemed to work. I'll admit I only have a
 mild understanding of what is going on with the function .fun. :-)

 You probably want:

 df[which.min(df$FixInx), ]

Or alternatively:

ddply(data, .(Sub, Tr, IA), subset, FixInx == min(FixInx))

which might be a bit easier to understand.

Hadley

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

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


[R] Latex symbols in R (\perp and \parallel)

2009-04-01 Thread Lorenzo Isella
Dear All,
I am sure this is a one-liner, but I cannot find the R command to
generate the LaTex symbols \perp and \parallel. Consider for instance
the figure
(one can use any kind of data for the plot)

pdf(friction_linear_chain_perpendicular.pdf)

par( mar = c(4.5,5, 2, 1) + 0.1)

plot(data[ ,1], data[
,4],col=blue,lwd=1.5,lty=1,pch=5,ylab=expression(*beta[n]^{perpendicular}/beta[1]*),
xlab=expression(*n*)
 ,cex.axis=1.4,cex.lab=1.6)
lines(x,beta_perp(as.list(coef(nls.out)), x), col=black, lwd=2)
dev.off()

Greek letters are understood on the spot, but this is not the case for
the perpendicular symbol in LaTex.
Does anyone know where I can find a list of LaTex symbols translated for R?
Many thanks

Lorenzo

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Deriving Samples from specific, not implemented PDF for a QQ-Plot

2009-04-01 Thread Arndt Zimmermann
David, thank you very much for the quick response:

The sample example helped and works fine for me. I'm sorry for not
providing an example. In order to explain my problem see following example:


test-rt(1000,df=5)

Repeat only the following code to see how the second and third plot
changes

par(mfrow=c(1,3))

qqnorm(test)

sample.from.normal-sample(seq(-3,3,by=0.0001), size=1000,
prob=dnorm(seq(-3,3,by=0.0001)), replace=TRUE)

qqplot(sample.from.normal,test, main = Q-Q Plot with sample from dnorm)

quanto-quantile(test,seq(0,1,by=0.0001))
quanta2-quantile(sample.from.normal,seq(0,1,by=0.0001))

plot(quanta2,quanto, main = Plot of Quantiles with sample from dnorm)



The first example shows the QQ-Plot against the normal (qqnorm), the second
shows the QQ-Plot against a sample of the normal, the third one is a
self-made QQ-Plot (not using the qqplot function). 


If you fix the data sample (test) and repeat only the plotting, the second
and third plot change a little bit every time. This is clearly because of
the sample drawing from the theoretical distribution (sample.from.normal).
Besides, this method seems to be circuitous and imprecisely.


Why does the qqnorm plot not change? I guess it is due to the precisely
calculated quantiles of the normal distribution.

How can I derive the quantiles directly from the pdf (i.e. from dnorm(x)
without sampling or how to get qnorm from dnorm without using qnorm)?
Remember, I've got only the pdf for use.



Best regards

Arndt Zimmermann





==
On Mar 31, 2009, at 11:53 AM, Arndt Zimmermann wrote:

 trimmed superfluous white-space
 this is my first post to the R-help, so please don't be too strict.

Reproducible examples should not be too much to expect, since that is  
requested in the posting guide and multiple other locations.

 My problem concerns a QQ-Plot:

 I want to show how well  empirical samples match with a theoretical
 distribution. The theoretical distribution has got several  
 parameters, but I
 made it to fit via ML.

 Anyway, the theoretical function gives me the density for a given  
 data point
 x. As far as I'm aware, the qqplot (generic) function in R does only  
 take
 data samples as Input.

 How can I derive samples from the pdf? Am I right in the way I see the
 problem?

Rather hard to tell, since you haven't described what I understand to  
be a problem, nor described how you see it.

 Or
 How can I modify the qqplot function, (or rebuild for myself) to get  
 it
 going?

It seems to be going fine for us. Did you break it?

 I'm sure, this is very likely just a misunderstanding problem from  
 myself,
 but anybody who can shed further light on this is very welcome.

Since you offer no examples, it is rather difficult to offer specific  
advice. You should be able to use the sample function on a pdf by  
assigning a vector of probabilities to the prob argument.

  mean(sample(seq(-2,2,by=0.2), size=100,  
prob=dnorm(seq(-2,2,by=0.2)), replace=TRUE))
[1] -0.08
  sd(sample(seq(-2,2,by=0.2), siez=100, prob=dnorm(seq(-2,2,by=0.2)),  
replace=TRUE))
[1] 0.911101


David Winsemius, MD
Heritage Laboratories
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] Fit unequal variance model in R

2009-04-01 Thread Dieter Menne


Feng, Jingyu wrote:
 
 I'am trying to develop some code if R, which would correspond to what I
 did in SAS.
 The data look like:
 
 TreatmentReplicategroup1  GSI
 
 ..
 The SAS code is:
 proc mixed data=data_name order=data method=ml; *scoring=10;
   classes group1;
   model GSI=group1/residual influence solution;
   repeated /group=group1;
 
 run;
 
 Basically, I need different variance for each treatment group. I want to
 do the similar thing in R.
 
 Here is what I get so far:
 lm1-lme(response~treatment,data=o,random=~1|as.factor(dummy),weights=varIdent(form=~1|treatment),method=ML)
 
 There should no random term in the model. However If I don't specify one,
 lme won't work, so I made a dummy variable, which equals to 1 for every
 observation.
 
 

The much underused (quote Frank Harrell) gls in package nlme should do that.
Quote PB (p250): It can be viewed as an lme function without the random
argument.

Dieter
-- 
View this message in context: 
http://www.nabble.com/Fit-unequal-variance-model-in-R-tp22829549p22830566.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] Definition of = vs. -

2009-04-01 Thread Duncan Murdoch

On 4/1/2009 11:39 AM, Stavros Macrakis wrote:

On Wed, Apr 1, 2009 at 10:55 AM, Duncan Murdoch murd...@stats.uwo.cawrote:


On 4/1/2009 10:38 AM, Stavros Macrakis wrote:


As far as I can tell from the documentation, assignment with = is
precisely
equivalent to assignment with -.  Yet they call different primitives:



The parser does treat them differently:

 if (x - 2) cat(assigned\n)
assigned
 if (x = 2) cat(assigned\n)
Error: unexpected '=' in if (x =



Interesting way of handling the classic C glitch (some of us would say
design flaw in C, but...)



The ?= man page explains this:

 The  operator '-' can be used anywhere,
whereas the operator '=' is only allowed at the top level (e.g.,
in the complete expression typed at the command prompt) or as one
of the subexpressions in a braced list of expressions. 

though the restriction on '=' seems to be described incorrectly:




 if ((x = 2)) cat(assigned\n)
assigned



The restriction is incorrect in many other cases as well, e.g. the following
are all assignments: function()a=3; if(...)a=3; while(...)a=3; a=b=3 (two
assignments), and even a*b=3 (parses as assignment, but `*-` happens not to
be defined in the default environment).

In fact, the only cases I have found where = does *not* mean assignment is
in functional or array argument position (f(a=2) and f[a=2]), the following
contexts with function-like syntax: function(XXX)..., if(XXX)..., and
while(XXX)...; and for (i in XXX)  Are there any others? Perhaps the
documentation could be updated?

As to the difference between the operations of the two primitives:  see

do_set in src/main/eval.c.  The facility is there to distinguish between
them, but it is not used.



So are you saying that it is planned to make = and - non-synonymous, unlike
a-b and b-a, which parse the same and are therefore guaranteed to be
synonymous?


No, I don't know of any plans like that.  That doesn't mean there aren't 
any, nor does the current implementation of - and - guarantee no 
changes there, but I wouldn't expect either to change.


Duncan Murdoch

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


Re: [R] Help with mixed-effects model with temporal pseudoreplication!

2009-04-01 Thread Dieter Menne



Bugzilla from rmh3...@gmail.com wrote:
 
 Responses:
 CompletionTIme
 VisitedTargets
 
 Fixed-factors:
 Targets (4-levels): 4, 9, 14, 19
 Entropy (3-levels): Low, Medium, High
 
 Random-factors:
 Participants: 31 total participants
 Replicates: 5 (this could also be viewed as a time factor I think)
 BlockOrder: 1 though 60 (the order of the trials was random for each
 participant, but I am not so concerned about this right now)
 
 The fixed part of the model seems pretty intuitive:
 fixed=log(CompletionTime)~(Targets*Entropy)
 
 The random part of the model is where I get stuck on, I've tried many
 combinations and all give me the wrong degrees of freedom. I really
 don't know what to use.  Any help would be greatly appreciated
 
 Here is the code I am using in R:
 
 library(nlme)
 datafile=http://people.rit.edu/rmh3093/mot.csv;
 master1 = read.table(datafile,header=T)
 Block=factor(master1$Block)
 BlockOrder=factor(master1$Block_Order)
 Replicate=factor(master1$Replicate)
 Participant=factor(master1$Participant_ID)
 Targets=factor(master1$Targets)
 Entropy=factor(master1$Entropy)
 CompletionTime=master1$Completion_Time
 summary(lme(log(CompletionTime)~(Entropy*Targets),random=~1|Participant,method=ML))
 

Looks perfectly fine to me. To paraphrase Kubrick: Stop worrying about
degrees of freedoms, and love your results. You might find a few flames and
insights when searching the list for degrees freedom bates lme lmer.

Using log(CompletionTime) is fine if that's what is usually done in your
field, but think of using the weights argument in lme to get results
directly in linear units. Most readers prefer time to log(time) in the final
result.

Dieter





-- 
View this message in context: 
http://www.nabble.com/Help-with-mixed-effects-model-with-temporal-pseudoreplication%21-tp22829729p22830759.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] Vector of Vectors

2009-04-01 Thread Shawn Garbett
I have a matrix of data. I need to scan the matrix and find every  
sequence from maxima to maxima across a row. I can write a loop to do  
this easily. Problem is, I can't figure out how to store the results.  
Each result is a vector of widely varying lengths. Ideally I'd like a  
vector of these, i.e. a vector of vectors, so I can quickly iterate  
through them and compute correlation coefficients.


Here's a transcript of my fuddling to date:

 x - c(1,2,3)
 y - c(4,5)
 v - list(1=x, 2=y)
 unlist(v[1])
11 12 13
 1  2  3
 unlist(v[1])[1]
11
 1
 unlist(v[1])[2]
12
 2
 unlist(v[1])[3]
13
 3
 unlist(v[2])[3]
NA
  NA
 unlist(v[2])[2]
22
 5
 v - c(x,y)
 v
[1] 1 2 3 4 5
 v - vector()
 v - merge(v, x)
 v
 [,1] [,2]
attr(,row.names)
integer(0)
 v[1]
[1] NA


As you can see, vectors aren't very cooperative and lists are  
downright baffling to me.


Shawn Garbett shawn.p.garb...@vanderbilt.edu
Vanderbilt Cancer Biology
220 Pierce Ave, PRB 715AA
Nashville, TN 37232
Office: 615.936.1975
Cell: 615.397.8737

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

2009-04-01 Thread Ted Harding
On 01-Apr-09 15:49:40, Jose Iparraguirre D'Elia wrote:
 Dear all,
 Say I have the following dataset:
  
 DF
 x y z
 [1]   1 1 1
 [2]   2 2 2
 [3]   3 3NA
 [4]   4   NA   4
 [5]  NA  5 5
  
 And I want to omit all the rows which have NA, but only in columns X
 and Y, so that I get:
  
  x  y  z
 1  1  1
 2  2  2
 3  3  NA

Roll up your sleeves, and spell out in detail the condition you need:

  DF-data.frame(x=c(1,2,3,4,NA),y=c(1,2,3,NA,5),z=c(1,2,NA,4,5))
  DF
#x  y  z
# 1  1  1  1
# 2  2  2  2
# 3  3  3 NA
# 4  4 NA  4
# 5 NA  5  5

  DF[!(is.na(rowSums(DF[,(1:2)]))),]
#   x y  z
# 1 1 1  1
# 2 2 2  2
# 3 3 3 NA

Hoping this helps,
Ted.

 If I use na.omit(DF), I would delete the row for which z=NA, obtaining
 thus
  
 x y z
 1 1 1
 2 2 2
  
 But this is not what I want, of course. 
 If I use na.omit(DF[,1:2]), then I obtain
  
 x y 
 1 1
 2 2
 3 3
  
 which is OK for x and y columns, but I wouldn't get the corresponding
 values for z (ie 1 2 NA)
  
 Any suggestions about how to obtain the desired results efficiently
 (the actual dataset has millions of records and almost 50 columns, and
 I would apply the procedure on 12 of these columns)?
  
 Sincerely,
  
 Jose Luis 
  
 Jose Luis Iparraguirre
 Senior Research Economist 
 Economic Research Institute of Northern Ireland
  
  
 
   [[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.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Apr-09   Time: 18:00:53
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Latex symbols in R (\perp and \parallel)

2009-04-01 Thread Dieter Menne


Lorenzo Isella wrote:
 
 I am sure this is a one-liner, but I cannot find the R command to
 generate the LaTex symbols \perp and \parallel.
 

As often, the most helpful how-to resource is by Prof. Brian Ripley

http://markmail.org/thread/kauzftprydrhqq5m

if you manage to get around the many lines telling me that I am an idiot.
What works depends on your system. Mine is Windows.

plot(1:5, type=n) 
#http://www.fileformat.info/info/unicode/char/27c2/index.htm
text(1,1, \u27C2) # does not work for me
#http://www.stat.auckland.ac.nz/~paul/R/CM/AdobeSym.html
text(2,2, \u22a5) # not for me
text(3,3, \x5e,font=5) # works for me

Please simplify your examples and make them self-running next time.


Dieter



-- 
View this message in context: 
http://www.nabble.com/Latex-symbols-in-R-%28%5Cperp-and-%5Cparallel%29-tp22829919p22831262.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 query about na.omit

2009-04-01 Thread Gabor Grothendieck
First input the data frame:

 Lines - x y z
+1 1 1
+2 2 2
+3 3NA
+4   NA   4
+   NA  5 5

 DF - read.table(textConnection(Lines), header = TRUE)

 # Now uses complete.cases to get required rows:


 DF[complete.cases(DF[1:2]),]
  x y  z
1 1 1  1
2 2 2  2
3 3 3 NA


On Wed, Apr 1, 2009 at 11:49 AM, Jose Iparraguirre D'Elia
j...@erini.ac.uk wrote:
 Dear all,

 Say I have the following dataset:

 DF
        x     y     z
 [1]   1     1     1
 [2]   2     2     2
 [3]   3     3    NA
 [4]   4   NA   4
 [5]  NA  5     5

 And I want to omit all the rows which have NA, but only in columns X and Y, 
 so that I get:

  x  y  z
 1  1  1
 2  2  2
 3  3  NA

 If I use na.omit(DF), I would delete the row for which z=NA, obtaining thus

 x y z
 1 1 1
 2 2 2

 But this is not what I want, of course.
 If I use na.omit(DF[,1:2]), then I obtain

 x y
 1 1
 2 2
 3 3

 which is OK for x and y columns, but I wouldn't get the corresponding values 
 for z (ie 1 2 NA)

 Any suggestions about how to obtain the desired results efficiently (the 
 actual dataset has millions of records and almost 50 columns, and I would 
 apply the procedure on 12 of these columns)?

 Sincerely,

 Jose Luis

 Jose Luis Iparraguirre
 Senior Research Economist
 Economic Research Institute of Northern Ireland



        [[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] Recommended packages for a statistician

2009-04-01 Thread Eamonn O'Brien
The company I work for require users to request what packages they want from
the IT department (user cannot download themselves). I intend to request
installation of the latest version of R plus the 23 Cran task views. As a
statistician what are the recommended packages or packages that
statisticians using R recommend to install. I have started a new position
and want to (greedily) get everything that I may or may not use as I want to
avoid multiple requests to our IT dept.
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] Noobie ANOVA intercept question

2009-04-01 Thread AllenL

Dear R list,
I've been attempting to interpret the results from a three-way ANOVA. I
think I understand contrasts and the R defaults for these (treatment
contrasts). My question is: what is the intercept in this test? As far as I
can tell, its NOT the expected value of a point that belongs to the first
level of all three explanatory factors (because there is only one point that
satisfies these requirements and their values differ). Its not the grand
mean, or any of the treatment means. What is this thing?

(Note: this dataset is from an example I'm working through in Grafen  Hails
2002 text)

Q2: Just noticed that in pasting I lose mono-spaced formatting. Is it
possible to post to the list such that format is maintained?

Thanks in advance!



Relevant output:


 anova(mod1)
Analysis of Variance Table

Response: SQBLOOMS
  Df Sum Sq Mean Sq F valuePr(F)
BED2 4.1323  2.0661  9.4570 0.0007277 ***
WATER  2 3.7153  1.8577  8.5029 0.0013016 ** 
SHADE  3 1.6465  0.5488  2.5120 0.0789451 .  
Residuals 28 6.1173  0.2185  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 summary(mod1)

Call:
lm(formula = SQBLOOMS ~ BED + WATER + SHADE)

Residuals:
 Min   1Q   Median   3Q  Max 
-1.23992 -0.18979 -0.01840  0.17471  0.74686 

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)   3.7765 0.2203  17.139 2.23e-16 ***
BED2  0.3185 0.1908   1.669 0.106242
BED3 -0.5044 0.1908  -2.643 0.013293 *  
WATER20.7842 0.1908   4.109 0.000313 ***
WATER30.4489 0.1908   2.353 0.025905 *  
SHADE20.1969 0.2203   0.894 0.379172
SHADE3   -0.2157 0.2203  -0.979 0.336068
SHADE4   -0.3673 0.2203  -1.667 0.106641
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.4674 on 28 degrees of freedom
  (51 observations deleted due to missingness)
Multiple R-squared: 0.6081, Adjusted R-squared: 0.5102 
F-statistic: 6.208 on 7 and 28 DF,  p-value: 0.0001911 

 model.frame(mod1)
   SQBLOOMS BED WATER SHADE
1 4.359   1 1 1
2 3.317   1 1 2
3 3.606   1 1 3
4 4.123   1 1 4
5 4.472   1 2 1
6 4.583   1 2 2
7 4.359   1 2 3
8 4.690   1 2 4
9 4.123   1 3 1
104.123   1 3 2
113.464   1 3 3
123.873   1 3 4
133.606   2 1 1
144.000   2 1 2
153.464   2 1 3
163.873   2 1 4
174.690   2 2 1
185.000   2 2 2
195.385   2 2 3
204.583   2 2 4
214.690   2 3 1
224.690   2 3 2
234.690   2 3 3
244.243   2 3 4
253.317   3 1 1
263.606   3 1 2
273.317   3 1 3
282.828   3 1 4
293.873   3 2 1
305.000   3 2 2
313.742   3 2 3
322.449   3 2 4
334.000   3 3 1
344.583   3 3 2
353.162   3 3 3
363.162   3 3 4


 model.tables(mod1,means,se=TRUE)
Tables of means
Grand mean
 
4.029028 

 BED 
BED
1 2 3 
4.091 4.409 3.587 

 WATER 
WATER
1 2 3 
3.618 4.402 4.067 

 SHADE 
SHADE
1 2 3 4 
4.126 4.322 3.910 3.758 

Standard errors for differences of means
   BED  WATER  SHADE
0.1908 0.1908 0.2203
replic. 12 12  9

 


Design matrix:
 model.matrix(mod1)
   (Intercept) BED2 BED3 WATER2 WATER3 SHADE2 SHADE3 SHADE4
1100  0  0  0  0  0
2100  0  0  1  0  0
3100  0  0  0  1  0
4100  0  0  0  0  1
5100  1  0  0  0  0
6100  1  0  1  0  0
7100  1  0  0  1  0
8100  1  0  0  0  1
9100  0  1  0  0  0
10   100  0  1  1  0  0
11   100  0  1  0  1  0
12   100  0  1  0  0  1
13   110  0  0  0  0  0
14   110  0  0  1  0  0
15   110  0  0  0  1  0
16   110  0  0  0  0  1
17   110  1  0  0  0  0
18   110  1  0  1  0  0
19   110  1  0  0  1  0
20   110  1  0  0  0  1
21   110  0  1  0  0  0
22   110  0  1  1  0  0
23   110  0  1

[R] Lattice plot with an extra strip showing group weights

2009-04-01 Thread Jesse Y Cai
Dear r-help,

How can I add a strip to show group weights using lattice package? For
example, in the following code, I'd like to using wt variable in a  trip
to demonstrate the relative size of groups.

(Following is just the simplest form to demonstrate the question. A
conditional variable will be added to the bwplot in real problems).

#
 library(lattice)

# generate data
x1 - cbind(rnorm(50,1,1),rnorm(50,10,1),1)
x2 - cbind(rnorm(50,2,1),rnorm(50,20,1),2)
x  - as.data.frame(rbind(x1,x2))
names(x) - c(x,wt,group)
# plot
bwplot(x ~ group, data=x,horizontal=FALSE)
##

Thanks in advance for this great R group!

Regards,
Marvel1812

[[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] SNOW: Error in socketSelect(socklist) : not a socket connection

2009-04-01 Thread Ubuntu Diego
I'm trying to use snow in my dual-core (hopefully later this is going to
run in a cluster). So, at this moment I create a cluster using SOCK
connection (MPI in the future). However when I try to use
clusterApplyLB I got Error in socketSelect(socklist) : not a socket
connection. Any ideas ? Do you know if that is going to be an isuue too
when I swith from SOCK to MPI ?

Sample code is attached.

Thanks.



# TODO: Add comment
# 
# Author: diego
###


rm(list=ls())
library(snow)
t1-Sys.time()



rates-c(0.5,0.5,0.7)
initialState-c(0,0,0,0,0)
AllEvents-c(1,1,1,1,2,2,2,3,1,2)
AllLocations-c(1,2,3,4,1,4,2,1,5,4)
AllTimes-1:10
AllConfigurations-rbind(
c(0,0,0,0,0),
c(1,0,0,0,0),
c(1,1,0,0,0),
c(1,1,1,0,0),
c(1,1,1,1,0),
c(2,1,1,1,0),
c(2,1,1,2,0),
c(2,2,1,2,0),
c(0,2,1,2,0),
c(0,2,1,2,1),
c(0,2,1,0,1)
)

nevents-length(AllEvents)

clusterSize-2
cl-makeCluster(clusterSize,type=SOCK)

arguments-vector(list,nevents)

completedTimes-c(0,AllTimes)
for(i in 1:nevents){
element-c(AllConfigurations[i,],
rates,
completedTimes[i],
AllEvents[i],
AllLocations[i],
AllTimes[i])
arguments[[i]]-element
}

source(GetLogLikelihood.R)
parallelOutputs-clusterApplyLB(cl,arguments,GetLogLikelihood)  # This give me 
error
#parallelOutputs-clusterApply(cl,arguments,GetLogLikelihood) # This Work OK

print(sum(unlist(parallelOutputs)))

stopCluster(cl)
t2-Sys.time()
print(t2-t1)
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Plotting multiple ablines

2009-04-01 Thread Thomas Levine
I really want to do this:

abline(
a=tan(-kT*pi/180),
b=kY-tan(-kT*pi/180)*kX
)

where kX,kY and kT are vectors of equal length. But I can't do that
with abline unless I use a loop, and I haven't figured out the least
unelegant way of writing the loop yet. So is there a way to do this
without a loop?

Or if I am to resort to the loop, what's the best way of doing it
considering that I have some missing data? Here's the mess that I
wrote.

converge - na.omit(data.frame(kX,kY,kT))
for (z in (length(converge$kT)))
{abline(
a=tan(converge$kT[z]*pi/180),
b=converge$kY[z]-tan(-converge$kT[z]*converge$kX[z]*pi/180)
)}

I think the missing data are causing the problem; this happens when I run:

Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
  'a' and 'b' must be finite

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

2009-04-01 Thread Mokhles Rekaby
How can I  performing Bootstrap Confidence Intervals for the estimates of
nonparametric regression y=f(x)  such as  loess and spline smoothing

Thanks in advance

 


[[alternative HTML version deleted]]

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


[R] feature selection problem,urgent help need

2009-04-01 Thread Azade Mohammadi
 Hello,
I have a problem in feature selection I would be thankful if you can help
me.
I have a dataset with limited samples (for example 100) and a lot of
features (for example 3000) and i have to do feature selection.
if i use cross validation (for example *10 fold*) i rank the features based
on 90 samples (using svmrfe method) i achieve ranked feature for example
 {f2,f4,f1,f3,...} (it means f2 is ranked first with svmrfe)  now, I want to
know how many features i should use? so i should compute the performance for
n feature selected from first of the ranked list and compute the performance
of it. for example train learner with f2, another time with f2,f4, another
time with f2,f4,f1 ... and see which is better , but my problem is:
1) first of all,for comparison should i use the performance of  9 fold that
has been used for ranking or the performance of learner on the fold which
has been left out?I mean in the *feature selection* *step (not in the final
evaluation)*,for example to see I should select only f2 or select {f2 , f4}
how should I compare?
2) in each stage of cross validation different feature subset will be
created . i can compute for each feature the number of times it has repeated
in each folding result, but after that how can i conclude the final feature
set?
can you please help me? I need your urgent help.
thanks in advance
Azadeh

[[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] Plotting a time series

2009-04-01 Thread Thomas Adams

I have data that I read in using:

data-read.table(RAVK2.obs.data,sep=\t)

'data' looks like this:

   V1V2
1  2009-03-25 06:00:00 12.86
2  2009-03-25 12:00:00 12.80
3  2009-03-25 18:00:00 12.76
4  2009-03-26 00:00:00 12.68
5  2009-03-26 06:00:00 12.66
6  2009-03-26 12:00:00 12.64
7  2009-03-26 18:00:00 12.83
8  2009-03-27 00:00:00 13.33
9  2009-03-27 06:00:00 13.84
10 2009-03-27 12:00:00 14.13
11 2009-03-27 18:00:00 14.29
12 2009-03-28 00:00:00 14.41
13 2009-03-28 06:00:00 14.48
14 2009-03-28 12:00:00 14.58
15 2009-03-28 18:00:00 14.75
16 2009-03-29 00:00:00 15.02
17 2009-03-29 06:00:00 15.40
18 2009-03-29 12:00:00 15.88
19 2009-03-29 18:00:00 16.50
20 2009-03-30 00:00:00 16.77
21 2009-03-30 06:00:00 16.73
22 2009-03-30 12:00:00 16.55
23 2009-03-30 18:00:00 16.31
24 2009-03-31 00:30:00 16.04
25 2009-03-31 06:00:00 15.80
26 2009-03-31 12:00:00 15.65
27 2009-03-31 18:00:00 15.53
28 2009-04-01 00:00:00 15.39
29 2009-04-01 06:00:00 15.20
30 2009-04-01 12:00:00 15.00

when I use plot(data) the plot looks fine except that the plot symbols 
are broken horizontal lines. How do I change the plot symbol? I have tried:


plot(data, type=p)

and I get the same result.

Thanks,
Tom

--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  thomas.ad...@noaa.gov

VOICE:  937-383-0528
FAX:937-383-0033

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

2009-04-01 Thread Aaron Barzilai
Hello,

Earlier I posted a question about memory usage, and the community's input was 
very helpful.  However, I'm now extending my dataset (which I use when running 
a regression using lm).  As a result, I am continuing to run into problems with 
memory usage, and I believe I need to shift to implementing the analysis on a 
different system..  

I know that R supports R servers through Rserve. Are there any public servers 
where I could upload my datasets (either as a text file, or through a 
connection to a SQL server), execute the analysis, then download the results?  
I identifed Wessa.net  
(http://www.wessa.net/mrc.wasp?outtype=Browser%20Blue%20-%20Charts%20White), 
but it's not clear it will meet my needs.  Can anyone suggest any other 
resources?

Thanks in advance,
Aaron Barzilai



  
[[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] list substring

2009-04-01 Thread Wacek Kusnierczyk
calpeda wrote:
 thank you,
 but I m importing data from a txt file and I have a matrix of n*1
 The function str seems to work only from 1*n

   

you see, it would help if you provided more details from the start.  you
may still need to do it;  it seems that both solutions you were given
(mine and the substr one) work for both n*1 and 1*n matrices:

# 5*1
(strings = matrix(as.character(sample(10^6, 5)), ncol=1))
   
substr(strings, 1, 4)
substr(t(strings), 1, 4)

with a fixed pattern of four digits from the beginning of the string,
the substr solution is better -- simpler and a few times faster.

vQ

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


Re: [R] Variable Wildcard Value

2009-04-01 Thread Rolf Turner


This whole thing is an April Fool's joke.  Isn't it?

***Please***!!!  (Let it be an April Fool's joke.)

cheers,

Rolf Turner

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


Re: [R] A query about na.omit

2009-04-01 Thread Bernardo Rangel Tura
On Wed, 2009-04-01 at 16:49 +0100, Jose Iparraguirre D'Elia wrote:
 Dear all,
  
 Say I have the following dataset:
  
  DF
 x y z
 [1]   1 1 1
 [2]   2 2 2
 [3]   3 3NA
 [4]   4   NA   4
 [5]  NA  5 5
  
 And I want to omit all the rows which have NA, but only in columns X and Y, 
 so that I get:
  
  x  y  z
 1  1  1
 2  2  2
 3  3  NA
  
 If I use na.omit(DF), I would delete the row for which z=NA, obtaining thus
  
 x y z
 1 1 1
 2 2 2
  
 But this is not what I want, of course. 
 If I use na.omit(DF[,1:2]), then I obtain
  
 x y 
 1 1
 2 2
 3 3
  
 which is OK for x and y columns, but I wouldn't get the corresponding values 
 for z (ie 1 2 NA)
  
 Any suggestions about how to obtain the desired results efficiently (the 
 actual dataset has millions of records and almost 50 columns, and I would 
 apply the procedure on 12 of these columns)?
  
 Sincerely,
  
 Jose Luis 
  
 Jose Luis Iparraguirre
 Senior Research Economist 
 Economic Research Institute of Northern Ireland
  

Hi Jose Luis,

I think this script is sufficient for your problem:

tab-matrix(c(1,1,1,2,2,2,3,3,NA,4,NA,4,NA,5,5),ncol=3,byrow=T)
tab[!is.na(tab[,1])!is.na(tab[,2]),]

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

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

2009-04-01 Thread John Fox
Dear Allen,

On Wed, 1 Apr 2009 10:44:33 -0700 (PDT)
 AllenL allen.laroc...@gmail.com wrote:
 
 Dear R list,
 I've been attempting to interpret the results from a three-way ANOVA.
 I
 think I understand contrasts and the R defaults for these (treatment
 contrasts). My question is: what is the intercept in this test? As
 far as I
 can tell, its NOT the expected value of a point that belongs to the
 first
 level of all three explanatory factors (because there is only one
 point that
 satisfies these requirements and their values differ). Its not the
 grand
 mean, or any of the treatment means. What is this thing?

Actually, the intercept IS the estimated expected value of an
observation that belongs to the first level of all three factors, but
conditional on the model that you've fit, which is an additive model.
Had you fit a model with all interactions, SQBLOOMS ~ BED*WATER*SHADE,
then the intercept would have been the mean (i.e., single observation)
in this cell.

BTW, more than half the data were deleted due to NAs.
 
 
 (Note: this dataset is from an example I'm working through in Grafen
  Hails
 2002 text)
 
 Q2: Just noticed that in pasting I lose mono-spaced formatting. Is it
 possible to post to the list such that format is maintained?

This is a function of your mail client, not R. The r-help list sends
out plain-text email, so the monospaced font was restored.

I hope this helps,
 John

 
 Thanks in advance!
 
 
 
 Relevant output:
 
 
  anova(mod1)
 Analysis of Variance Table
 
 Response: SQBLOOMS
   Df Sum Sq Mean Sq F valuePr(F)
 BED2 4.1323  2.0661  9.4570 0.0007277 ***
 WATER  2 3.7153  1.8577  8.5029 0.0013016 ** 
 SHADE  3 1.6465  0.5488  2.5120 0.0789451 .  
 Residuals 28 6.1173  0.2185  
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
  summary(mod1)
 
 Call:
 lm(formula = SQBLOOMS ~ BED + WATER + SHADE)
 
 Residuals:
  Min   1Q   Median   3Q  Max 
 -1.23992 -0.18979 -0.01840  0.17471  0.74686 
 
 Coefficients:
 Estimate Std. Error t value Pr(|t|)
 (Intercept)   3.7765 0.2203  17.139 2.23e-16 ***
 BED2  0.3185 0.1908   1.669 0.106242
 BED3 -0.5044 0.1908  -2.643 0.013293 *  
 WATER20.7842 0.1908   4.109 0.000313 ***
 WATER30.4489 0.1908   2.353 0.025905 *  
 SHADE20.1969 0.2203   0.894 0.379172
 SHADE3   -0.2157 0.2203  -0.979 0.336068
 SHADE4   -0.3673 0.2203  -1.667 0.106641
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 
 Residual standard error: 0.4674 on 28 degrees of freedom
   (51 observations deleted due to missingness)
 Multiple R-squared: 0.6081, Adjusted R-squared: 0.5102 
 F-statistic: 6.208 on 7 and 28 DF,  p-value: 0.0001911 
 
  model.frame(mod1)
SQBLOOMS BED WATER SHADE
 1 4.359   1 1 1
 2 3.317   1 1 2
 3 3.606   1 1 3
 4 4.123   1 1 4
 5 4.472   1 2 1
 6 4.583   1 2 2
 7 4.359   1 2 3
 8 4.690   1 2 4
 9 4.123   1 3 1
 104.123   1 3 2
 113.464   1 3 3
 123.873   1 3 4
 133.606   2 1 1
 144.000   2 1 2
 153.464   2 1 3
 163.873   2 1 4
 174.690   2 2 1
 185.000   2 2 2
 195.385   2 2 3
 204.583   2 2 4
 214.690   2 3 1
 224.690   2 3 2
 234.690   2 3 3
 244.243   2 3 4
 253.317   3 1 1
 263.606   3 1 2
 273.317   3 1 3
 282.828   3 1 4
 293.873   3 2 1
 305.000   3 2 2
 313.742   3 2 3
 322.449   3 2 4
 334.000   3 3 1
 344.583   3 3 2
 353.162   3 3 3
 363.162   3 3 4
 
 
  model.tables(mod1,means,se=TRUE)
 Tables of means
 Grand mean
  
 4.029028 
 
  BED 
 BED
 1 2 3 
 4.091 4.409 3.587 
 
  WATER 
 WATER
 1 2 3 
 3.618 4.402 4.067 
 
  SHADE 
 SHADE
 1 2 3 4 
 4.126 4.322 3.910 3.758 
 
 Standard errors for differences of means
BED  WATER  SHADE
 0.1908 0.1908 0.2203
 replic. 12 12  9
 
  
 
 
 Design matrix:
  model.matrix(mod1)
(Intercept) BED2 BED3 WATER2 WATER3 SHADE2 SHADE3 SHADE4
 1100  0  0  0  0  0
 2100  0  0  1  0  0
 3100  0  0  0  1  0
 4100  0  0  0  0  1
 5100  1  0  0  0  0
 6100  1  0  1  0  0
 7100  1  0  0  1  0
 8100  1  0  0  0  1
 9100  0  1  0  0  0
 10  

[R] something equivalent to switch condition

2009-04-01 Thread Jason Rupert

Is there any syntax in R that allows a switch-type condition to be used? 

switch(variable){  
   case CONSTANT_VALUE;  
   break;  

   default:   
   break;
}


Thanks, 
Jason

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] unicode only works with a second one

2009-04-01 Thread Greg Snow
One of the points of my.symbols is that you can define your own symbols to use 
with it (hence the my).

I downloaded a graphic of the aries symbol (your original attempt in unicode I 
belive) and used the following code to trace the left half of the symbol 
(starting bottom center), then used that to create a matrix for the aries 
symbol:

library(EBImage)
tmp - chooseImage()
image(tmp)

library(TeachingDemos)
tmp2 - par('usr')
updateusr(tmp2[1:2], tmp2[3:4], c(-1,1), c(-1,1))

out1 - locator(type='l', col='red', lwd=3)

out1$x - out1$x - out1$x[1]
ms.aries - rbind( cbind( out1$x, out1$y), NA, cbind( -out1$x, out1$y ) )

this resulted in the matrix:

ms.aries - 
structure(c(0, 0, -0.00361689814814814, -0.047019675925926, 
-0.0795717592592593, 
-0.1085069, -0.14105902778, -0.1953125, -0.242332175925926, 
-0.285734953703704, -0.332754629629630, -0.365306712962963, -0.390625, 
-0.419560185185185, -0.43041087962963, -0.437644675925926, -0.441261574074074, 
-0.44487847222, -0.452112268518518, -0.44849537037037, -0.44487847222, 
-0.441261574074074, -0.426793981481481, -0.408709490740741, -0.390625, 
-0.3689236, -0.339988425925926, -0.318287037037037, -0.285734953703704, 
-0.253182870370370, -0.220630787037037, NA, 0, 0, 0.00361689814814814, 
0.047019675925926, 0.0795717592592593, 0.1085069, 0.14105902778, 
0.1953125, 0.242332175925926, 0.285734953703704, 0.332754629629630, 
0.365306712962963, 0.390625, 0.419560185185185, 0.43041087962963, 
0.437644675925926, 0.441261574074074, 0.44487847222, 0.452112268518518, 
0.44849537037037, 0.44487847222, 0.441261574074074, 0.426793981481481, 
0.408709490740741, 0.390625, 0.3689236, 0.339988425925926, 
0.318287037037037, 0.285734953703704, 0.253182870370370, 0.220630787037037, 
-0.534428351808399, -0.453515656606522, 0.254470426409904, 0.307063678291124, 
0.35561129541225, 0.387976373493001, 0.40820454729347, 0.432478355854034, 
0.448660894894409, 0.436523990614127, 0.420341451573752, 0.404158912533376, 
0.375839469212719, 0.339428756371875, 0.298972408770936, 0.262561695930091, 
0.246379156889716, 0.214014078808965, 0.185694635488308, 0.157375192167651, 
0.120964479326806, 0.0885994012460556, 0.0602799579253985, 0.0238692450845536, 
-0.000404563476009408, -0.0246783720365727, -0.0449065458370419, 
-0.0570434501173234, -0.0732259891576988, -0.0772716239177927, 
-0.0772716239177927, NA, -0.534428351808399, -0.453515656606522, 
0.254470426409904, 0.307063678291124, 0.35561129541225, 0.387976373493001, 
0.40820454729347, 0.432478355854034, 0.448660894894409, 0.436523990614127, 
0.420341451573752, 0.404158912533376, 0.375839469212719, 0.339428756371875, 
0.298972408770936, 0.262561695930091, 0.246379156889716, 0.214014078808965, 
0.185694635488308, 0.157375192167651, 0.120964479326806, 0.0885994012460556, 
0.0602799579253985, 0.0238692450845536, -0.000404563476009408, 
-0.0246783720365727, -0.0449065458370419, -0.0570434501173234, 
-0.0732259891576988, -0.0772716239177927, -0.0772716239177927
), .Dim = c(63L, 2L))

Which can be used as:

my.symbols(1:10,1:10, ms.aries, add=FALSE, inches=0.3, lwd=2)

If aries is the only one that you need, just use the above matrix, if you need 
others, you can follow the above steps to trace out the other symbols (just 
remember to put in a row of NA everywhere you want a jump without connecting 
line).

Hope this helps,

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


 -Original Message-
 From: Thomas Steiner [mailto:finbref.2...@gmail.com]
 Sent: Tuesday, March 31, 2009 4:07 PM
 To: Jim Lemon; Greg Snow
 Cc: r-help@r-project.org
 Subject: Re: [R] unicode only works with a second one
 
 unfortunately in my.symbols there are no zodiac signs, so I have to
 choose unicode which does not work for me yet.
 Thomas
 
 
 2009/3/31 Thomas Steiner finbref.2...@gmail.com:
  Thanks for the feedback.
  I did now try Vista (2.8.1), XP (2.9.0alpha) and Win2000 (2.8.1) and
  non did work compeletely, only on Vista/2.8.1 I got some symbols if I
  add the other sign. I will try the my.symbols later today, when i am
  at home.
  Thomas
 

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


Re: [R] something equivalent to switch condition

2009-04-01 Thread Gábor Csárdi
How about reading ?switch ?

Best,
Gabor

On Wed, Apr 1, 2009 at 9:37 PM, Jason Rupert jasonkrup...@yahoo.com wrote:

 Is there any syntax in R that allows a switch-type condition to be used?

 switch(variable){
   case CONSTANT_VALUE;
   break;

   default:
   break;
 }


 Thanks,
 Jason

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




-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

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

2009-04-01 Thread Rolf Turner


On 2/04/2009, at 8:37 AM, Jason Rupert wrote:



Is there any syntax in R that allows a switch-type condition to  
be used?


switch(variable){
   case CONSTANT_VALUE;
   break;

   default:
   break;
}


?switch

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


Re: [R] Convert Character to Date

2009-04-01 Thread Greg Snow
Just to correct/expand/clarify the parenthetical below (how often is there a 
chance to correct or clarify something posted by Bill Venables?), the ides are 
the 15th of March, May, July, and October, but the 13th of the other months.  
So if you want to use the ides as the date to use, you will need a vector 
rather than the scalar 15, if you use 15, then it will only be the ides of some 
months.

I wonder if the roman calendar was created on kalends April, but no one got the 
joke. 

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of bill.venab...@csiro.au
 Sent: Tuesday, March 31, 2009 1:29 AM
 To: quagmire54...@yahoo.com; r-help@r-project.org
 Subject: Re: [R] Convert Character to Date
 
 If you want the vector to be a Date you need to specify a date at least
 down to the day.  Otherwise the date is not well defined and becomes
 NA as you noted.
 
 Perhaps the easiest thing is to give it a particular day of the month,
 e.g. the first, or the 15 (the ides), or ...
 
  x - as.Date(paste(1990-January, 1, sep=-), format = %Y-%B-%d)
  x
 [1] 1990-01-01
 
 Now if you want to display the date suppressing the dummy day, you can
 
  y - format(x, %Y-%B)
  y
 [1] 1990-January
 
 
 Bill Venables
 http://www.cmis.csiro.au/bill.venables/
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Bob Roberts
 Sent: Tuesday, 31 March 2009 5:14 PM
 To: r-help@r-project.org
 Subject: [R] Convert Character to Date
 
 Hello,
I have a date in the format Year-Month Name (e.g. 1990-January) and
 R classes it as a character. I want to convert this character into a
 date format, but when I try as.Date(1990-January, %Y-%B), I get back
 NA. The function strptime also gives me NA back. 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-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Calculating First Occurance by a factor

2009-04-01 Thread Glen Sargeant

pmatch() facilitates a very simple solution:

#Data
IA - factor(c(1,2,2,3,3,4,3,5,5))
FixTime - c(200,350,500,600,700,850,1200,1350,1500)

#First occurrence of each level
first. - pmatch(levels(IA),IA)

#Use first occurrence to subscript a vector or data frame
FixTime[first.]

A simple way to apply pmatch across unique combinations of levels of several
factors is to create a new composite factor with paste() and factor(), then
proceed as above.

-- 
View this message in context: 
http://www.nabble.com/Calculating-First-Occurance-by-a-factor-tp22789964p22834451.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] Definition of = vs. -

2009-04-01 Thread Wacek Kusnierczyk
Stavros Macrakis wrote:

 `-`
 
 Error: object - not found
   

that's weird!

vQ

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


Re: [R] Plotting multiple ablines

2009-04-01 Thread Rolf Turner


On 2/04/2009, at 7:04 AM, Thomas Levine wrote:


I really want to do this:

abline(
a=tan(-kT*pi/180),
b=kY-tan(-kT*pi/180)*kX
)

where kX,kY and kT are vectors of equal length. But I can't do that
with abline unless I use a loop, and I haven't figured out the least
unelegant way of writing the loop yet. So is there a way to do this
without a loop?

Or if I am to resort to the loop, what's the best way of doing it
considering that I have some missing data? Here's the mess that I
wrote.

converge - na.omit(data.frame(kX,kY,kT))
for (z in (length(converge$kT)))
{abline(
a=tan(converge$kT[z]*pi/180),
b=converge$kY[z]-tan(-converge$kT[z]*converge$kX[z]*pi/180)
)}

I think the missing data are causing the problem; this happens when  
I run:


Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
  'a' and 'b' must be finite


The help for abline explicitly states that a and b must be ``single  
values'';
so no vectorization appears to be possible, as abline is currently  
written.

Hence you are stuck with a for-loop.

There appears to be nothing wrong with the for-loop that you've written,
at first blush at least.

There won't be NAs in ``converge'' since you've very cleverly used  
na.omit.

So ``missing data'' are NOT the problem.

The problem is then (probably) that some of your data are yielding  
infinite

values of tan().

***Look*** at the values in converge.  ***Look*** at the values of a  
and b

produced in your loop and see where you're getting infinite values.

cheers,

Rolf Turner

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


  1   2   >