Re: [R] apply family functions

2010-08-06 Thread Steven Kang
ini <- as.Date("2010/1/1", "%Y/%m/%d")
# Generate arbitrary data frame consisting of date values
oc <- data.frame(Open = seq(ini, ini + 6, 1), Close = seq(ini + 365, ini +
365 + 6, 1), Open1 = seq(ini + 365*2, ini + 365*2 + 6, 1), Close1 = seq(ini
+ 365*3, ini + 365*3 + 6, 1), Open2 = seq(ini + 365*4, ini + 365*4 + 6, 1),
Close2 = seq(ini + 365*5, ini + 365*5 + 6, 1))
rownames(oc) <- c("AAA", "C", "AA", "A", "CC", "BB", "B")

> oc
  Open  Close  Open1Close1
Open2Close2
AAA  2010-01-01  2011-01-01  2012-01-01  2012-12-31  2013-12-31  2014-12-31
C  2010-01-02  2011-01-02  2012-01-02  2013-01-01  2014-01-01
2015-01-01
AA2010-01-03  2011-01-03  2012-01-03  2013-01-02  2014-01-02  2015-01-02
A  2010-01-04  2011-01-04  2012-01-04  2013-01-03  2014-01-03
2015-01-03
CC2010-01-05  2011-01-05  2012-01-05  2013-01-04  2014-01-04  2015-01-04
BB2010-01-06  2011-01-06  2012-01-06  2013-01-05  2014-01-05  2015-01-05
B 2010-01-07   2011-01-07  2012-01-07  2013-01-06  2014-01-06
2015-01-06

dat <- data.frame(Class = c("AAA", "C", "CC", "BB", "B", "A"), Close_date =
c(ini, ini, ini, ini+109, ini+39, ini+24), stringsAsFactors = FALSE)
ind <- sapply(dat$Class, function(x) match(x, rownames(oc)))

for (i in length(ind))  {
dat[["Flag"]] <- sapply(dat[["Close_date"]], function(x) ifelse((x >=
oc[ind[[i]], 1] & x < oc[ind[[i]], 2]) | (x >= oc[ind[[i]], 3] & x <
oc[ind[[i]], 4]) | (x >= oc[ind[[i]], 5] & x < oc[ind[[i]], 6]),
"Valid", "Invalid"))
}
> dat
 Class   Close_dateFlag
*1   AAA2010-01-01   Invalid*
2 C  2010-01-01   Invalid
3CC2010-01-01Invalid
4BB2010-04-20Valid
5 B 2010-02-09Valid
6 A 2010-01-25Valid
The first record (highlighted in yellow) is flagged as "Invalid" where it
should really be "Valid".

Any suggestions on resolving this would be great.

Many 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] R: Confidence Intervals for logistic regression

2010-08-06 Thread Guazzetti Stefano
a closer look to the help on predict.glm will reveal that the function 
accepts a 'type' argument.
In you case 'type = response' will give you the results in probabilities
(that it seems to be what you are looking for).
There also is an example on use of the 'type' argument at the end of the
page.

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di Troy S
Inviato: Friday, August 06, 2010 6:31 PM
A: Michael Bedward
Cc: r-help@r-project.org
Oggetto: Re: [R] Confidence Intervals for logistic regression


Michael,

Thanks for the reply.  I believe Aline was sgiving me CI's on coefficients
as well.

So c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
pred$se.fit) gives me the CI on the logits if I understand correctly?  Maybe
the help on predict.glm can be updated.

Thanks!

On 6 August 2010 01:46, Michael Bedward  wrote:

> Sorry about earlier reply - didn't read your email properly (obviously :)
>
> You're suggestion was right, so as well as method for Aline below,
> another way of doing the same thing is:
>
> pred <- predict(y.glm, newdata= something, se.fit=TRUE)
> ci <- matrix( c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
> pred$se.fit), ncol=2 )
>
> lines( something, plogis( ci[,1] ) )
> lines( something, plogis( ci[,2] ) )
>
>
>
> On 6 August 2010 18:39, aline uwimana  wrote:
> > Dear Troy,
> > use this commend, your will get IC95% and OR.
> >
> >  logistic.model <- glm(formula =y~ x1+x2, family = binomial)
> > summary(logistic.model)
> >
> > sum.coef<-summary(logistic.model)$coef
> >
> > est<-exp(sum.coef[,1])
> > upper.ci<-exp(sum.coef[,1]+1.96*sum.coef[,2])
> > lower.ci<-exp(sum.coef[,1]-1.96*sum.coef[,2])
> >
> > cbind(est,upper.ci,lower.ci)
> >
> > regards.
> >
> > 2010/8/6 Troy S 
> >
> >> Dear UseRs,
> >>
> >> I have fitted a logistic regression using glm and want a 95% confidence
> >> interval on a response probability.  Can I use
> >>
> >> predict(model, newdata, se.fit=T)
> >>
> >> Will fit +/- 1.96se give me a 95% of the logit?  And then
> >> exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities?
> >>
> >> Troy
> >>
> >>[[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

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

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


"Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03)".


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


Re: [R] 64-bit R on 64-bit Windows box... Still not enough memory?!

2010-08-06 Thread noclue_

sorry I opened a previous R version. 

Here is my 64-bit R session -

> .Machine$sizeof.pointer 
[1] 8


-- 
View this message in context: 
http://r.789695.n4.nabble.com/64-bit-R-on-64-bit-Windows-box-Still-not-enough-memory-tp2315742p2316970.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] R: Backward elimination in svyglm function in R

2010-08-06 Thread aline uwimana
stepwise backward elimination in R is possible if we use the syvglm funtion
in regression logistique?
thanx

-- Forwarded message --
From: aline uwimana 
Date: 2010/8/6
Subject: R:Backward elimination in svyglm function in R
To: r-help@r-project.org



Dear all,
someone knows  how to get the best fit model by using the svyglm function
with backward elimination method.
thanx

[[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] Odp: Pausing script to allow user input from keyboard.

2010-08-06 Thread Michael Bedward
I'm having problems with your method Petr.  I seem to get an additional prompt.

Example...
f <- function() {
  cat("\n", "Enter a string:", "\n")
  s <- scan(n=1)
  cat("\n", "You entered", s, "\n")
}

Running f() produces...

 Enter a string:
1: blah
1:
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  scan() expected 'a real', got 'blah'
>

Changing the code to
   scan(n=1, what="character")
Fixes the problem but your post implies that this is not necessary.

Could it be GUI specific ? I am running R 2.11.1 with the Mac OSX GUI
1.34 Leopard build 64-bit (5589)

Michael

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


[R] converting "if not os.path.exists(afile ): continue" to R

2010-08-06 Thread Hyunchul Kim
Hi, all
How to convert following simple python script to R ?
if not os.path.exists(targetfile):
 continue
Thanks in advance,
Hyunchul
 
 
 
 
 
 
 
 
 
 sundol313´ÔÀÇ ºí·Î±×
 ¾È³çÇϼ¼¿ä.
 
 
 
 

[[alternative HTML version deleted]]

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


Re: [R] R script doesn't load libraries when called from cron

2010-08-06 Thread zerdna

Actually, i think i figured it out. My bad, i am inexperienced with cron.
When it runs, it doesn't have the environment. Once i wrapped my R script
into shell script that sourced the .bashrc file, i was back in business.
Maybe there is more elegant solution, without additional shell script --
possibly someone will chime in. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-script-doesn-t-load-libraries-when-called-from-cron-tp2316594p2316832.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] converting "if not os.path.exists(afile): continue" to R

2010-08-06 Thread Henrique Dallazuanna
See

?file.exists
?file.info

On Fri, Aug 6, 2010 at 6:59 PM, Hyunchul Kim  wrote:

> Hi, all
>
> How to convert following simple python script to R ?
>
> if not os.path.exists(targetfile):
>continue
>
> Thanks in advance,
>
> Hyunchul
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

[[alternative HTML version deleted]]

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


Re: [R] Latex errors when checking package

2010-08-06 Thread Ben Bolker
Christian Hennig  stats.ucl.ac.uk> writes:
 
> LaTeX errors when creating PDF version.
> This typically indicates Rd problems.
> LaTeX errors found:
> ! Font T1/ptm/m/n/10=ptmr8t at 10.0pt not loadable: Metric (TFM) file not 
> found

  I'm guessing you're running Ubuntu.  If so,



suggests that you

sudo apt-get texlive-fonts-recommended

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

2010-08-06 Thread Stephen Liu
Hi folks,

On console - RGUI (64 bit)

-> Windows

I can't find;
R Graphic:Device 2 (ACTIVE)

Only "R Console" is there.

Please advise how to add it?  TIA

B.R.
SL




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


Re: [R] brew equivalent of "R CMD Sweave"

2010-08-06 Thread Duncan Murdoch

On 06/08/2010 7:10 PM, Liviu Andronic wrote:

Dear Duncan

On Fri, 06 Aug 2010 18:46:55 -0400
Duncan Murdoch  wrote:

You can run a single R command from the command line using the -e
option, so

R -e "brew::brew('featurefull.brew')"

(or some variation on that, depending on how your shell handles
quotes) will run that one command.  Use R --help to see other
options, e.g. to suppress the banner, etc.


Thank you for the suggestion. Just tried from the command line and it
seems to work. I'm slightly puzzled, however, that this option is not
documented in R --help or man R: 
li...@debian-liv:~$ R --help | grep -i "\-e"

  --encoding=ENCSpecify encoding to be used for stdin
  --no-environ  Don't read the site and user environment files
--no-init-file and --no-environ
  LINK  Front-end for creating executable programs

I'm running 2.10.1. Thanks again


I'm puzzled why you would report a problem with an obsolete version.

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] brew equivalent of "R CMD Sweave"

2010-08-06 Thread Liviu Andronic
Dear Duncan

On Fri, 06 Aug 2010 18:46:55 -0400
Duncan Murdoch  wrote:
> You can run a single R command from the command line using the -e
> option, so
> 
> R -e "brew::brew('featurefull.brew')"
> 
> (or some variation on that, depending on how your shell handles
> quotes) will run that one command.  Use R --help to see other
> options, e.g. to suppress the banner, etc.
> 
Thank you for the suggestion. Just tried from the command line and it
seems to work. I'm slightly puzzled, however, that this option is not
documented in R --help or man R: 
li...@debian-liv:~$ R --help | grep -i "\-e"
  --encoding=ENCSpecify encoding to be used for stdin
  --no-environ  Don't read the site and user environment files
--no-init-file and --no-environ
  LINK  Front-end for creating executable programs

I'm running 2.10.1. Thanks again
Liviu

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


Re: [R] brew equivalent of "R CMD Sweave"

2010-08-06 Thread Duncan Murdoch

On 06/08/2010 5:23 PM, Liviu Andronic wrote:

Dear all
Is there an equivalent of "R CMD Sweave" for brew [1] documents?
Something in the lines of "R CMD brew"? Can R be configured to parse
brew documents from the commandline, without opening an interactive R
session and issuing the following? 
require(brew)

brew("featurefull.brew")


You can run a single R command from the command line using the -e option, so

R -e "brew::brew('featurefull.brew')"

(or some variation on that, depending on how your shell handles quotes) 
will run that one command.  Use R --help to see other options, e.g. to 
suppress the banner, etc.


It shouldn't be too hard to work out how to construct that line from 
your favourite shell scripting language, so


brew featurefull.brew

would execute it.

Duncan Murdoch



I would like to set a LyX converter for brew documents, and for this
I'd need to call the brew parser from the cli. Please let me know of
any ideas. 


Regards
Liviu

[1] http://cran.r-project.org/web/packages/brew/index.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] converting "if not os.path.exists(afile): continue" to R

2010-08-06 Thread David Winsemius


On Aug 6, 2010, at 5:59 PM, Hyunchul Kim wrote:


Hi, all

How to convert following simple python script to R ?

if not os.path.exists(targetfile):
   continue

Thanks in advance,


> Sys.glob("/Users/davidwinsemius/Downloads/")
[1] "/Users/davidwinsemius/Downloads/"
> Sys.glob("/Users/davidwinsemius/Downlo/")
character(0)
> length(Sys.glob("/Users/davidwinsemius/Downlo/") ) == 0
[1] TRUE

I'm not at all familiar with python but wondered if this code in R  
will do what you want (Note that "continue is a not an R command so  
you need to substitute something valid.


if (length( Sys.glob("/Users/davidwinsemius/Downloads/")  == 0 )  
{}


--

David Winsemius, MD
West Hartford, CT

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


[R] converting "if not os.path.exists(afile): continue" to R

2010-08-06 Thread Hyunchul Kim
Hi, all

How to convert following simple python script to R ?

if not os.path.exists(targetfile):
continue

Thanks in advance,

Hyunchul

[[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] Running Sweave directly from Windows command line

2010-08-06 Thread Gabor Grothendieck
On Fri, Aug 6, 2010 at 3:39 PM,   wrote:
> Hello everybody out there using R,
> When I try to run the command "R CMD Sweave file.Rnw" (R Version 2.11.1) on 
> the command line of Windows 7, an error message tells me that the command 
> "sh" is not known.
> I suppose that R is trying to use a shell script, which can't be interpreted 
> using Windows. However, running Sweave from the R command prompt works fine.
> Anyway, under Linux the command "R CMD Sweave file.Rnw" works also perfectly.
> Is there any possibility to get it working in Windows?
> Thanks in advance!
>
> Wassertemperaturen in Deutschland
> Sommer, Sonne, Strand - wer braucht Abkühlung? Die aktuellen 
> Wassertemperaturen und Windgeschwindigkeiten für Deutschlands Badeseen gibt´s 
> auf arcor.de.
>

Google for Rtools, go to first hit, download and install it being sure
the Rtools bin directory is on your path.  Then try again.

There is also Sweave.bat in http://batchfiles.googlecode.com . If you
use Sweave.bat it will find Rtools in the registry so you don't need
to add the Rtools bin directory to your path.

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

2010-08-06 Thread Christian Hennig

Dear listers,

I just run R CMD check on an update of one of my packages.
All seems fine but after having gone through all the Rd-file and example 
checking and so on, I get the following kind of errors:


LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
! Font T1/ptm/m/n/10=ptmr8t at 10.0pt not loadable: Metric (TFM) file not 
found

.

   relax
l.7 \begin{document}
! Font T1/ptm/m/n/24.88=ptmr8t at 24.88pt not loadable: Metric (TFM) file 
not f

ound.


(and similar ones)

l.18 ...ian Hennig \email{chr...@stats.ucl.ac.uk}}
! \textfont 0 is undefined (character h).
\...@formatstring ...\...@string \UrlRight \...@th $

l.41 ...http://www.homepages.ucl.ac.uk/~ucakche/}}

! \textfont 0 is undefined (character t).
\...@formatstring ...\...@string \UrlRight \...@th $

l.41 ...http://www.homepages.ucl.ac.uk/~ucakche/}}

! \textfont 0 is undefined (character t).
\...@formatstring ...\...@string \UrlRight \...@th $

(...and lots of further ones that look preety much the same.)

I have no idea what went wrong and don't see anything suspicious in the 
Rd-files.


Any hint what this could be about?
Is something missing in my LATEX-installation?

Thanks and best regards,
Christian


*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] brew equivalent of "R CMD Sweave"

2010-08-06 Thread Liviu Andronic
Dear all
Is there an equivalent of "R CMD Sweave" for brew [1] documents?
Something in the lines of "R CMD brew"? Can R be configured to parse
brew documents from the commandline, without opening an interactive R
session and issuing the following? 
require(brew)
brew("featurefull.brew")

I would like to set a LyX converter for brew documents, and for this
I'd need to call the brew parser from the cli. Please let me know of
any ideas. 

Regards
Liviu

[1] http://cran.r-project.org/web/packages/brew/index.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] r sig for tcl/tk?

2010-08-06 Thread Liviu Andronic
On Fri, 6 Aug 2010 14:51:59 -0500
Erin Hodgess  wrote:

> Dear R People:
> 
> Is there an R sig for Tcl/Tk, please?
> 
There is r-sig-gui that should fit most tcltk questions. 
Liviu

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


Re: [R] Signals and Noise

2010-08-06 Thread David Winsemius


On Aug 6, 2010, at 3:56 PM, TGS wrote:

Is there a reference page indicating which packages or functions are  
available in R for the filed of electrical engineering?


Have you seen?:

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

(I was surprised that tuneR was not mentioned there.)




I'm not an EE but I've been doing some simulations regarding signals  
and noise and I found the 'tuneR' to be useful. Are there any others?

__

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] image plot but data not on grid.

2010-08-06 Thread Hadley Wickham
On Fri, Aug 6, 2010 at 9:24 AM, W Eryk Wolski  wrote:
> Hi,
>
> Would like to make an image
> however the values in z are not on an uniform grid.
>
> Have a dataset with
> length(x) == length(y) == length(z)
> x[1],y[1] gives the position of z[1]
>
> and would like to encode value of z by a color.
>
> looking for something like
> plot(x,y, col = z)
> where col for z is cleverly chosen from a colorscale.

library(ggplot2)
qplot(x, y, fill = z, data = df, geom = "tile")

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread Benjamin Caldwell
All right, thanks.


On Fri, Aug 6, 2010 at 1:13 PM, David Winsemius wrote:

>
> On Aug 6, 2010, at 4:03 PM, Benjamin Caldwell wrote:
>
>  Woops, that should read
>> e.g.
>> >> qqnorm.lme(modelincrF)
>> Error: could not find function "qqnorm.lme"
>>
>
> You said you were getting expected results with:
>
> qqnorm(modelincrF)
>
> I was pointing out that the R methods dispatching was actually applying the
> function "qqnorm.lme" function to that model object and that all of the
> parameter options should be available, in particular the line drawing
> options that can be specified for parameter abline. I was _not_ suggesting
> that you call the function in the manner that you did. I _was_ suggesting
> that you read the correct help page.  Try the examples in the help page for
> qqnorm.lme  and notice how the examples call it.
>
> ?methods
>
>
>
>
>>
>> On Fri, Aug 6, 2010 at 12:47 PM, Benjamin Caldwell <
>> btcaldw...@berkeley.edu> wrote:
>> Okay, yeah, so he're the deal - nlme is loaded, did the library(nlme)
>> thing no problem. When I run
>>  >??qqnorm.lme
>>
>
> It's:
> ?qqnorm.lme  # just one "?"
>
>
>  the file comes up fine. But, if I try to use the function, I get an error
>> like the package isn't loaded
>>  e.g.
>> >qqnorm.gls(modelincrF)
>> Error: could not find function "qqnorm.gls"
>>
>>
>> On Fri, Aug 6, 2010 at 11:24 AM, David Winsemius 
>> wrote:
>>
>> On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote:
>>
>> Hi all,
>>
>> I'm modeling using lme in the nlme package. qqnorm makes plots just find,
>> but when I try to add a line with qqline, I get the following error:
>> "Error in sort.list(x, partial = unique(c(lo, hi))) :
>>  'x' must be atomic for 'sort.list'
>> Have you called 'sort' on a list?"
>>
>> For example
>> modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|
>> site/transect/plot),na.action=na.omit)
>> summary(modelincr10)
>> qqnorm(modelincr10, main="qqnorm res10")
>> qqline(modelincr10)
>> Error in sort.list(x, partial = unique(c(lo, hi))) :
>>  'x' must be atomic for 'sort.list'
>> Have you called 'sort' on a list?
>>
>> There is no lme methof for qqline.
>>
>> Have you read the help page for the qqnorm.lme function?
>>
>> ?qqnorm.lme
>>
>> I am guessing that you did not realize it was a completely different
>> function that qqnorm.default.
>>
>> --
>> David Winsemius, MD
>> West Hartford, CT
>>
>>
>>
>>
> David Winsemius, MD
> West Hartford, CT
>
>

[[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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread David Winsemius


On Aug 6, 2010, at 4:03 PM, Benjamin Caldwell wrote:


Woops, that should read
e.g.
>> qqnorm.lme(modelincrF)
Error: could not find function "qqnorm.lme"


You said you were getting expected results with:

qqnorm(modelincrF)

I was pointing out that the R methods dispatching was actually  
applying the function "qqnorm.lme" function to that model object and  
that all of the parameter options should be available, in particular  
the line drawing options that can be specified for parameter abline. I  
was _not_ suggesting that you call the function in the manner that you  
did. I _was_ suggesting that you read the correct help page.  Try the  
examples in the help page for qqnorm.lme  and notice how the examples  
call it.


?methods





On Fri, Aug 6, 2010 at 12:47 PM, Benjamin Caldwell > wrote:
Okay, yeah, so he're the deal - nlme is loaded, did the  
library(nlme) thing no problem. When I run

 >??qqnorm.lme


It's:
?qqnorm.lme  # just one "?"

the file comes up fine. But, if I try to use the function, I get an  
error like the package isn't loaded

 e.g.
>qqnorm.gls(modelincrF)
Error: could not find function "qqnorm.gls"


On Fri, Aug 6, 2010 at 11:24 AM, David Winsemius > wrote:


On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote:

Hi all,

I'm modeling using lme in the nlme package. qqnorm makes plots just  
find,

but when I try to add a line with qqline, I get the following error:
"Error in sort.list(x, partial = unique(c(lo, hi))) :
 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?"

For example
modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|
site/transect/plot),na.action=na.omit)
summary(modelincr10)
qqnorm(modelincr10, main="qqnorm res10")
qqline(modelincr10)
Error in sort.list(x, partial = unique(c(lo, hi))) :
 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

There is no lme methof for qqline.

Have you read the help page for the qqnorm.lme function?

?qqnorm.lme

I am guessing that you did not realize it was a completely different  
function that qqnorm.default.


--
David Winsemius, MD
West Hartford, CT





David Winsemius, MD
West Hartford, CT

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


Re: [R] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread Benjamin Caldwell
Oh, and now I see the call is qqnorm, not qqnorm.lme. Guess I needed lunch.
Ben Caldwell

On Fri, Aug 6, 2010 at 1:03 PM, Benjamin Caldwell
wrote:

> Woops, that should read
> e.g.
> >> qqnorm.lme(modelincrF)
> Error: could not find function "qqnorm.lme"
>
>
> On Fri, Aug 6, 2010 at 12:47 PM, Benjamin Caldwell <
> btcaldw...@berkeley.edu> wrote:
>
>> Okay, yeah, so he're the deal - nlme is loaded, did the library(nlme)
>> thing no problem. When I run
>>  >??qqnorm.lme
>> the file comes up fine. But, if I try to use the function, I get an error
>> like the package isn't loaded
>>  e.g.
>> >qqnorm.gls(modelincrF)
>> Error: could not find function "qqnorm.gls"
>>
>>
>> On Fri, Aug 6, 2010 at 11:24 AM, David Winsemius 
>> wrote:
>>
>>>
>>> On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote:
>>>
>>>  Hi all,

 I'm modeling using lme in the nlme package. qqnorm makes plots just
 find,
 but when I try to add a line with qqline, I get the following error:
 "Error in sort.list(x, partial = unique(c(lo, hi))) :
  'x' must be atomic for 'sort.list'
 Have you called 'sort' on a list?"

 For example

> modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|
>
 site/transect/plot),na.action=na.omit)

> summary(modelincr10)
> qqnorm(modelincr10, main="qqnorm res10")
> qqline(modelincr10)
>
 Error in sort.list(x, partial = unique(c(lo, hi))) :
  'x' must be atomic for 'sort.list'
 Have you called 'sort' on a list?

  There is no lme methof for qqline.
>>>
>>> Have you read the help page for the qqnorm.lme function?
>>>
>>> ?qqnorm.lme
>>>
>>> I am guessing that you did not realize it was a completely different
>>> function that qqnorm.default.
>>>
>>> --
>>> David Winsemius, MD
>>> West Hartford, CT
>>>
>>>
>>
>

[[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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread Benjamin Caldwell
Woops, that should read
e.g.
>> qqnorm.lme(modelincrF)
Error: could not find function "qqnorm.lme"


On Fri, Aug 6, 2010 at 12:47 PM, Benjamin Caldwell
wrote:

> Okay, yeah, so he're the deal - nlme is loaded, did the library(nlme) thing
> no problem. When I run
>  >??qqnorm.lme
> the file comes up fine. But, if I try to use the function, I get an error
> like the package isn't loaded
>  e.g.
> >qqnorm.gls(modelincrF)
> Error: could not find function "qqnorm.gls"
>
>
> On Fri, Aug 6, 2010 at 11:24 AM, David Winsemius 
> wrote:
>
>>
>> On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote:
>>
>>  Hi all,
>>>
>>> I'm modeling using lme in the nlme package. qqnorm makes plots just find,
>>> but when I try to add a line with qqline, I get the following error:
>>> "Error in sort.list(x, partial = unique(c(lo, hi))) :
>>>  'x' must be atomic for 'sort.list'
>>> Have you called 'sort' on a list?"
>>>
>>> For example
>>>
 modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|

>>> site/transect/plot),na.action=na.omit)
>>>
 summary(modelincr10)
 qqnorm(modelincr10, main="qqnorm res10")
 qqline(modelincr10)

>>> Error in sort.list(x, partial = unique(c(lo, hi))) :
>>>  'x' must be atomic for 'sort.list'
>>> Have you called 'sort' on a list?
>>>
>>>  There is no lme methof for qqline.
>>
>> Have you read the help page for the qqnorm.lme function?
>>
>> ?qqnorm.lme
>>
>> I am guessing that you did not realize it was a completely different
>> function that qqnorm.default.
>>
>> --
>> David Winsemius, MD
>> West Hartford, CT
>>
>>
>

[[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] Signals and Noise

2010-08-06 Thread TGS
Is there a reference page indicating which packages or functions are available 
in R for the filed of electrical engineering?

I'm not an EE but I've been doing some simulations regarding signals and noise 
and I found the 'tuneR' to be useful. Are there any others?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 sig for tcl/tk?

2010-08-06 Thread Erin Hodgess
Dear R People:

Is there an R sig for Tcl/Tk, please?

I looked at the User Groups list on the main page and didn't see one.

However, I thought I'd double check.

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread Benjamin Caldwell
Okay, yeah, so he're the deal - nlme is loaded, did the library(nlme) thing
no problem. When I run
 >??qqnorm.lme
the file comes up fine. But, if I try to use the function, I get an error
like the package isn't loaded
 e.g.
>qqnorm.gls(modelincrF)
Error: could not find function "qqnorm.gls"


On Fri, Aug 6, 2010 at 11:24 AM, David Winsemius wrote:

>
> On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote:
>
>  Hi all,
>>
>> I'm modeling using lme in the nlme package. qqnorm makes plots just find,
>> but when I try to add a line with qqline, I get the following error:
>> "Error in sort.list(x, partial = unique(c(lo, hi))) :
>>  'x' must be atomic for 'sort.list'
>> Have you called 'sort' on a list?"
>>
>> For example
>>
>>> modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|
>>>
>> site/transect/plot),na.action=na.omit)
>>
>>> summary(modelincr10)
>>> qqnorm(modelincr10, main="qqnorm res10")
>>> qqline(modelincr10)
>>>
>> Error in sort.list(x, partial = unique(c(lo, hi))) :
>>  'x' must be atomic for 'sort.list'
>> Have you called 'sort' on a list?
>>
>>  There is no lme methof for qqline.
>
> Have you read the help page for the qqnorm.lme function?
>
> ?qqnorm.lme
>
> I am guessing that you did not realize it was a completely different
> function that qqnorm.default.
>
> --
> David Winsemius, MD
> West Hartford, CT
>
>

[[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] Running Sweave directly from Windows command line

2010-08-06 Thread julia . jacobson
Hello everybody out there using R,
When I try to run the command "R CMD Sweave file.Rnw" (R Version 2.11.1) on the 
command line of Windows 7, an error message tells me that the command "sh" is 
not known.
I suppose that R is trying to use a shell script, which can't be interpreted 
using Windows. However, running Sweave from the R command prompt works fine.
Anyway, under Linux the command "R CMD Sweave file.Rnw" works also perfectly.
Is there any possibility to get it working in Windows?
Thanks in advance!

Wassertemperaturen in Deutschland
Sommer, Sonne, Strand - wer braucht Abkühlung? Die aktuellen Wassertemperaturen 
und Windgeschwindigkeiten für Deutschlands Badeseen gibt´s auf arcor.de.

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


Re: [R] How to apply apply?!

2010-08-06 Thread Philipp Pagel

> How do I multiply only the close of every row using the 'apply' function?
> And once multiplied how do I obtain a new table that also contains the new
> 2*CLOSE column (without cbind?).

You don't use apply in this case - a simple multiplication and
variable assignment will do:

> require(tseries)
> foo <- get.hist.quote('^GDAXI')
> foo[1:10, ]
 Open   HighLow  Close
1991-01-02 1375.4 1375.4 1359.1 1366.1
1991-01-03 1371.7 1374.7 1365.2 1366.7
1991-01-04 1375.4 1398.0 1375.4 1396.1
1991-01-07 1373.6 1373.6 1352.5 1358.2
1991-01-08 1350.4 1357.1 1345.5 1354.0
1991-01-09 1358.6 1380.8 1358.0 1375.2
1991-01-10 1367.9 1383.7 1363.1 1383.4
1991-01-11 1401.3 1406.4 1376.9 1382.3
1991-01-14 1354.5 1354.5 1327.8 1327.8
1991-01-15 1327.0 1330.3 1312.4 1325.6
> foo$Close <- foo$Close * 2
> foo$Close <- foo$Close * 2
> foo[1:10, ]
 Open   HighLow  Close
1991-01-02 1375.4 1375.4 1359.1 2732.2
1991-01-03 1371.7 1374.7 1365.2 2733.4
1991-01-04 1375.4 1398.0 1375.4 2792.2
1991-01-07 1373.6 1373.6 1352.5 2716.4
1991-01-08 1350.4 1357.1 1345.5 2708.0
1991-01-09 1358.6 1380.8 1358.0 2750.4
1991-01-10 1367.9 1383.7 1363.1 2766.8
1991-01-11 1401.3 1406.4 1376.9 2764.6
1991-01-14 1354.5 1354.5 1327.8 2655.6
1991-01-15 1327.0 1330.3 1312.4 2651.2

> 2) Also, how do I run a generic function per row. Say for example I want to
> calculate the Implied Volatility for each row of this data frame ( using the
> RMterics package). How do I do that please using the apply function? I am
> focusing on apply because I like the vectorisation concept in R and I do not
> want to use a for loop etc.

You can get the manual page of any R-command by either preceding it
by a question mark or giving the command as an argument to the help
function - specificly:

?apply
help(apply)

Especially the example section is useful for a jumpstart.
Here is an example of computing row means:

apply(foo, 1, mean)

Instead of 'mean' you can insert whatever function you'd like to apply.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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

2010-08-06 Thread Erik Iverson



Raghuraman Ramachandran wrote:

guRus

I have say a dataframe, d and I wish to do the following:

1) For each row, I want to take one particular value of the row and multiply
it by 2. How do I do it. Say the data frame is as below:
   OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5
0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0
653.25 0 0 0 348 0 0 0 801 866.55 866.55 866.55 866.55 783.1 783.1 742.25
742.25 575 575 575 575 0 0 0 493 470 470 420 425 355 360 343 360 312.05
312.05 274 280.85 257.35 257.35 197 198.75 182 185.95 137 150.75 120.25 129
90.7 101.25 91.85 91.85 57 66.6


Much easier to give us the ?dput output so we can construct this!



How do I multiply only the close of every row using the 'apply' function?
And once multiplied how do I obtain a new table that also contains the new
2*CLOSE column (without cbind?).


Guessing here... but why do you want to use apply? Isn't

df$new.col <- df$CLOSE * 2

what you want?



2) Also, how do I run a generic function per row. Say for example I want to
calculate the Implied Volatility for each row of this data frame ( using the
RMterics package). How do I do that please using the apply function? I am
focusing on apply because I like the vectorisation concept in R and I do not
want to use a for loop etc.


Simply read ?apply to see examples.  Apply works on matrices, not 
data.frames, so if you give it a data.frame, it will be coerced into a 
matrix.


apply(your.data, 1, your.function)

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

2010-08-06 Thread Abhijit Dasgupta, PhD

For 1, an easy way is

dat <- transform(dat, CLOSE2=2*CLOSE)

For 2:

apply(dat,1,fun)

On 08/06/2010 03:06 PM, Raghuraman Ramachandran wrote:

guRus

I have say a dataframe, d and I wish to do the following:

1) For each row, I want to take one particular value of the row and multiply
it by 2. How do I do it. Say the data frame is as below:
OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5
0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0
653.25 0 0 0 348 0 0 0 801 866.55 866.55 866.55 866.55 783.1 783.1 742.25
742.25 575 575 575 575 0 0 0 493 470 470 420 425 355 360 343 360 312.05
312.05 274 280.85 257.35 257.35 197 198.75 182 185.95 137 150.75 120.25 129
90.7 101.25 91.85 91.85 57 66.6

How do I multiply only the close of every row using the 'apply' function?
And once multiplied how do I obtain a new table that also contains the new
2*CLOSE column (without cbind?).

2) Also, how do I run a generic function per row. Say for example I want to
calculate the Implied Volatility for each row of this data frame ( using the
RMterics package). How do I do that please using the apply function? I am
focusing on apply because I like the vectorisation concept in R and I do not
want to use a for loop etc.

Many thanks for the enlightment,
Raghu

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



--

Abhijit Dasgupta, PhD
Director and Principal Statistician
ARAASTAT
Ph: 301.385.3067
E: adasgu...@araastat.com
W: http://www.araastat.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] 64-bit R on 64-bit Windows box... Still not enough memory?!

2010-08-06 Thread Philipp Pagel
On Fri, Aug 06, 2010 at 09:03:09AM -0700, noclue_ wrote:
> 
> > .Machine$sizeof.pointer 
> [1] 4

So it appears you are not on 64bit. Experpt form the help page:

[...]
sizeof.pointer: the number of bytes in a C ‘SEXP’ type.  Will be ‘4’ on
  32-bit builds and ‘8’ on 64-bit builds of R.
[...]

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


Re: [R] pdf indifferent to lwd after some small number< 1 (e.g. 0.18)

2010-08-06 Thread Ben Bolker
Chuen Tan  yahoo.com> writes:

> 
> Hi,
> 
> To plot a figure, I used lwd=0.18 in the function lines() to plot
> very fine lines. However, using png() or
> pdf() to save the figure, it appears that lwd has no effect on
>  pdf() beyond some small number (e.g. 0.18) and
> the lines looks much thicker than png(). Setting lwd<0.18 
> does not make the lines any finer in pdf(). I also
> tried specifying the argument lwd in par() instead and still faced 
> the same problem. 

  This bug has been fixed in the development version of R: see
 and search for "lwd"

  For a Mac, you can get the development version from
http://r.research.att.com/ .

  Your PNG issue may (?) be that you don't have X11 available on
your machine -- see the MacOS R FAQ.

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


Re: [R] Creating timeSeries

2010-08-06 Thread Raghuraman Ramachandran
?xts

xts will do what you want. as.xts or xts() are straightforward ways.

On Fri, Aug 6, 2010 at 5:11 PM, Serdar Akin  wrote:

> Hi
>
> I want to create a TimeSeries object with already defined dates (in the
> first vector) so that all the data are coerced as a time series object with
> the dates as they are.
>
> Is there anyone that have an idea what to do?
>
> 2010-07-07 3.900833 3.176667 2.754167 2.045833 1.820833
> 2010-04-21 4.256667 3.356667 2.70 1.82 1.576667
> 2010-02-17 4.322500 3.45 2.67 1.792500 1.492500
> 2009-12-23 4.306667 3.426667 2.68 1.851667 1.481667
> 2009-10-28 4.34 3.425000 2.677500 2.17 1.522500
> 2009-09-09 4.472500 3.41 2.64 2.17 1.645000
>
> Serdar (MA)
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] How to apply apply?!

2010-08-06 Thread Raghuraman Ramachandran
guRus

I have say a dataframe, d and I wish to do the following:

1) For each row, I want to take one particular value of the row and multiply
it by 2. How do I do it. Say the data frame is as below:
   OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5
0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0
653.25 0 0 0 348 0 0 0 801 866.55 866.55 866.55 866.55 783.1 783.1 742.25
742.25 575 575 575 575 0 0 0 493 470 470 420 425 355 360 343 360 312.05
312.05 274 280.85 257.35 257.35 197 198.75 182 185.95 137 150.75 120.25 129
90.7 101.25 91.85 91.85 57 66.6

How do I multiply only the close of every row using the 'apply' function?
And once multiplied how do I obtain a new table that also contains the new
2*CLOSE column (without cbind?).

2) Also, how do I run a generic function per row. Say for example I want to
calculate the Implied Volatility for each row of this data frame ( using the
RMterics package). How do I do that please using the apply function? I am
focusing on apply because I like the vectorisation concept in R and I do not
want to use a for loop etc.

Many thanks for the enlightment,
Raghu

[[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] stats::reshape question

2010-08-06 Thread Krishna Tateneni
Thanks for the reply, I realize that having x and y in that order in
"varying" and "v.names" will work.  The question is why reversing the order
(i.e., y followed by x) does not work; it seems unintuitive, so I'm
wondering if I've just misread the documentation.

On Fri, Aug 6, 2010 at 1:45 PM, Dennis Murphy  wrote:

> Hi:
>
> Is this what you were aiming for?
>
> reshape(d,varying=list(c("x1","x2"),
> c("y1","y2")),v.names=c("x","y"),dir="long")
> time x y id
> 1.11 1 5  1
> 2.11 2 6  2
> 1.22 3 7  1
> 2.22 4 8  2
>
> HTH,
> Dennis
>
> On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni wrote:
>
>> Hello,
>>
>> A quick question for my edification.  When I run the following (R 2.8.1 on
>> Microsoft Windows):
>>
>> > d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
>> > reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long")
>>
>> I found myself surprised by the results--the column labeled "y" is
>> actually
>> the data from "x1" and "x2", and the column labeled "x" is actually the
>> data
>> from "y1" and "y2".
>>
>> Is this behaviour of reshape as intended?  That is, have I missed
>> something
>> in the documentation?
>>
>> Many thanks for any comments.
>>
>> --Krishna
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

[[alternative HTML version deleted]]

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


Re: [R] gsub

2010-08-06 Thread Marc Schwartz
On Aug 6, 2010, at 10:14 AM, Alfredo Alessandrini wrote:

> 
> Hi,
> 
> I'm using gsub, but I've a problem.
> 
>> print(i)
> [1] "piante_venere.csv"
>> gsub("\\.csv$", "", i)
> [1] "piante_venere"
>> gsub("^piante_", "", i)
> [1] "venere.csv"
> 
> 
> Can I combine the two expressions? 
> 
> Like this:
> 
>> gsub(.)
> [1] "venere"
> 
> Thanks,
> 
> Alfredo


The easiest way is to use a back reference to return the part of the vector 
that you want:

> gsub("^.*_(.*)\\.csv$", "\\1", "piante_venere.csv")
[1] "venere"


In this case, the "\\1" returns the part of the regex defined within the parens.

HTH,

Marc Schwartz

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


Re: [R] Error on random forest variable importance estimates

2010-08-06 Thread Liaw, Andy
From: Pierre Dubath
> 
> Hello,
> 
> I am using the R randomForest package to classify variable 
> stars. I have 
> a training set of 1755 stars described by (too) many 
> variables. Some of 
> these variables are highly correlated.
> 
> I believe that I understand how randomForest works and how 
> the variable 
> importance are evaluated (through variable permutations). Here are my 
> questions.
> 
> 1) variable importance error? Is there any ways to estimate 
> the error on 
> the "MeanDecreaseAccuracy"? In other words, I would like to know how 
> significant are "MeanDecreaseAccuracy" differences (and display 
> horizontal error bars in the VarImpPlot output).

If you really want to do it, one possibility is to do permutation test:
Permute your response, say, 1000 or 2000 times, run RF on each of these
permuted response, and use the importance measures as samples from the
null distribution.
 
> I have notice that even with relatively large number of trees, I have 
> variation in the importance values from one run to the next. 
> Could this 
> serve as a measure of the errors/uncertainties?

Yes.
 
> 2) how to deal with variable correlation? so far, I am iterating, 
> selecting the most important variable first, removing all 
> other variable 
> that have a high correlation (say higher than 80%), taking the second 
> most important variable left, removing variables with 
> high-correlation 
> with any of the first two variables, and so on... (also using some 
> astronomical insight as to which variables are the most important!)
> 
> Is there a better way to deal with correlation in randomForest? (I 
> suppose that using many correlated variables should not be a 
> problem for 
> randomForest, but it is for my understanding of the data and 
> for other 
> algorithms).

That depends a lot on what you're trying to do.  RF can tolerate
problematic data, but that doesn't mean it will magically give you good
answers.  Trying to draw conclusions about effects when there are highly
correlated (and worse, important) variables is a tricky business.
 
> 3) How many variables should eventually be used? I have made 
> successive 
> runs, adding one variable at a time from the most to the 
> least important 
> (not-too-correlated) variables. I then plot the error rate 
> (err.rate) as 
> a function of the number of variable used. As this number 
> increase, the 
> error first sharply decrease, but relatively soon it reaches 
> a plateau .
> I assume that the point of inflexion can be use to derive the minimum 
> number of variable to be used. Is that a sensible approach? 
> Is there any 
> other suggestion? A measure of the error on "err.rate" would 
> also here 
> really help. Is there any idea how to estimate this? From the 
> variation 
> between runs or with the help of "importanceSD" somehow?

One approach is described in the following paper (in the Proceedings of
MCS 2004):
http://www.springerlink.com/content/9n61mquugf9tungl/

Best,
Andy
 
> Thanks very much in advance for any help.
> 
> Pierre Dubath
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 script doesn't load libraries when called from cron

2010-08-06 Thread zerdna

I have R script that i need to run in cron. Either R libraries or some .so
libraries that they depend on don't get loaded correctly. Here is an
example. I have a file, call it tmp.R


tmp.R
=
R --slave --args $0 $* < tryCatchList -> tryCatchOne ->

Execution halted


seemingly it has problems with loading library, but i cannot figure out why.
I tried running it using Rscript program, R CMD BATCH, calling R directly
and i always run into the same problem when called from cron. 
I am running 64 bit R v10 on 64 Red Hat Lunix. 






-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-script-doesn-t-load-libraries-when-called-from-cron-tp2316594p2316594.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] Grouping clusters from dendrograms

2010-08-06 Thread Julia M

Hi,

I have produced a dendrogram of categorical data in R using the hclust
function, although the input was a dissimilarity matrix produced in SAS, as
I have defined my own distances. 

The dendrogram is fine and I can view and use this. However, I was wondering
if there is a method by which I can find out the optimal place to place
groups, rather than relying on my visual analysis? I don't have multiple
trees to compare and therefore would be relying on the data in the one tree. 

I have tried using dynamic tree cut, but this seems to be producing odd
results whereby it is grouping data that overlap branches. However, I'm not
sure if this is because of the script I am using to visualise the data which
may be incorrect. 

The script I tried was:

> dendro<-hclust(as.dist(combo2),method="average")
> cut2<-cutreeDynamicTree(dendro,maxTreeHeight=1,deepSplit=TRUE,minModuleSize=1)

I then used the following to visualise the data:

> cut2colour<-labels2colors(cut2)
> plotDendroAndColors(dendro,cut2colour,"Dynamic Tree Cut",
> dendroLabels=FALSE,hang=0.03,addGuide=TRUE,guideHang=0.05)

Any advice or ideas would be much appreciated!

Thanks,

Julia
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Grouping-clusters-from-dendrograms-tp2316521p2316521.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] 64-bit R on 64-bit Windows box... Still not enough memory?!

2010-08-06 Thread David Winsemius

You are running 32 bit R. Read the RW FAQ.

On Aug 6, 2010, at 12:03 PM, noclue_ wrote:




.Machine$sizeof.pointer

[1] 4
--



David Winsemius, MD
West Hartford, CT

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


Re: [R] stats::reshape question

2010-08-06 Thread Dennis Murphy
Hi:

Is this what you were aiming for?

reshape(d,varying=list(c("x1","x2"),
c("y1","y2")),v.names=c("x","y"),dir="long")
time x y id
1.11 1 5  1
2.11 2 6  2
1.22 3 7  1
2.22 4 8  2

HTH,
Dennis

On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni wrote:

> Hello,
>
> A quick question for my edification.  When I run the following (R 2.8.1 on
> Microsoft Windows):
>
> > d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
> > reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long")
>
> I found myself surprised by the results--the column labeled "y" is actually
> the data from "x1" and "x2", and the column labeled "x" is actually the
> data
> from "y1" and "y2".
>
> Is this behaviour of reshape as intended?  That is, have I missed something
> in the documentation?
>
> Many thanks for any comments.
>
> --Krishna
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Confidence Intervals for logistic regression

2010-08-06 Thread Troy S
Michael,

Thanks for the reply.  I believe Aline was sgiving me CI's on coefficients
as well.

So c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
pred$se.fit) gives me the CI on the logits if I understand correctly?  Maybe
the help on predict.glm can be updated.

Thanks!

On 6 August 2010 01:46, Michael Bedward  wrote:

> Sorry about earlier reply - didn't read your email properly (obviously :)
>
> You're suggestion was right, so as well as method for Aline below,
> another way of doing the same thing is:
>
> pred <- predict(y.glm, newdata= something, se.fit=TRUE)
> ci <- matrix( c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
> pred$se.fit), ncol=2 )
>
> lines( something, plogis( ci[,1] ) )
> lines( something, plogis( ci[,2] ) )
>
>
>
> On 6 August 2010 18:39, aline uwimana  wrote:
> > Dear Troy,
> > use this commend, your will get IC95% and OR.
> >
> >  logistic.model <- glm(formula =y~ x1+x2, family = binomial)
> > summary(logistic.model)
> >
> > sum.coef<-summary(logistic.model)$coef
> >
> > est<-exp(sum.coef[,1])
> > upper.ci<-exp(sum.coef[,1]+1.96*sum.coef[,2])
> > lower.ci<-exp(sum.coef[,1]-1.96*sum.coef[,2])
> >
> > cbind(est,upper.ci,lower.ci)
> >
> > regards.
> >
> > 2010/8/6 Troy S 
> >
> >> Dear UseRs,
> >>
> >> I have fitted a logistic regression using glm and want a 95% confidence
> >> interval on a response probability.  Can I use
> >>
> >> predict(model, newdata, se.fit=T)
> >>
> >> Will fit +/- 1.96se give me a 95% of the logit?  And then
> >> exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities?
> >>
> >> Troy
> >>
> >>[[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

[[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] pdf indifferent to lwd after some small number<1 (e.g. 0.18)

2010-08-06 Thread Chuen Tan
Hi,

To plot a figure, I used lwd=0.18 in the function lines() to plot very fine 
lines. However, using png() or pdf() to save the figure, it appears that lwd 
has no effect on pdf() beyond some small number (e.g. 0.18) and the lines looks 
much thicker than png(). Setting lwd<0.18 does not make the lines any finer in 
pdf(). I also tried specifying the argument lwd in par() instead and still 
faced the same problem. 

My understanding is pdf() allows lwd<1 but it seems that there is a lower 
bound. I hope to use pdf() instead of png() because the computer server gives 
the following error message when png is used: 
> png(file="tmp.png")
Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,  : 
  unable to start device PNG
In addition: Warning message:
In png(file = "tmp.png") : unable to open connection to X11 display ''
> 

Thanks for the help and advice in advance regarding the problem I am facing.

Best regards,
stan

My mac machine:
> version
   _
platform   x86_64-apple-darwin9.8.0 
arch   x86_64   
os darwin9.8.0  
system x86_64, darwin9.8.0  
status  
major  2
minor  11.1 
year   2010 
month  05   
day31   
svn rev52157
language   R
version.string R version 2.11.1 (2010-05-31)
> 

The computer sever:
> version
   _   
platform   x86_64-unknown-linux-gnu
arch   x86_64  
os linux-gnu   
system x86_64, linux-gnu   
status 
major  2   
minor  9.0 
year   2009
month  04  
day17  
svn rev48333   
language   R   
version.string R version 2.9.0 (2009-04-17)
>

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


Re: [R] 64-bit R on 64-bit Windows box... Still not enough memory?!

2010-08-06 Thread noclue_

> .Machine$sizeof.pointer 
[1] 4
-- 
View this message in context: 
http://r.789695.n4.nabble.com/64-bit-R-on-64-bit-Windows-box-Still-not-enough-memory-tp2315742p2316493.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] Creating timeSeries

2010-08-06 Thread Serdar Akin
Hi

I want to create a TimeSeries object with already defined dates (in the
first vector) so that all the data are coerced as a time series object with
the dates as they are.

Is there anyone that have an idea what to do?

2010-07-07 3.900833 3.176667 2.754167 2.045833 1.820833
2010-04-21 4.256667 3.356667 2.70 1.82 1.576667
2010-02-17 4.322500 3.45 2.67 1.792500 1.492500
2009-12-23 4.306667 3.426667 2.68 1.851667 1.481667
2009-10-28 4.34 3.425000 2.677500 2.17 1.522500
2009-09-09 4.472500 3.41 2.64 2.17 1.645000

Serdar (MA)

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

2010-08-06 Thread Alfredo Alessandrini

Hi,

I'm using gsub, but I've a problem.

> print(i)
[1] "piante_venere.csv"
> gsub("\\.csv$", "", i)
[1] "piante_venere"
> gsub("^piante_", "", i)
[1] "venere.csv"


Can I combine the two expressions? 

Like this:

> gsub(.)
[1] "venere"

Thanks,

Alfredo
-- 
View this message in context: 
http://r.789695.n4.nabble.com/gsub-tp2316443p2316443.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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread David Winsemius


On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote:


Hi all,

I'm modeling using lme in the nlme package. qqnorm makes plots just  
find,

but when I try to add a line with qqline, I get the following error:
"Error in sort.list(x, partial = unique(c(lo, hi))) :
 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?"

For example

modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|

site/transect/plot),na.action=na.omit)

summary(modelincr10)
qqnorm(modelincr10, main="qqnorm res10")
qqline(modelincr10)

Error in sort.list(x, partial = unique(c(lo, hi))) :
 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?


There is no lme methof for qqline.

Have you read the help page for the qqnorm.lme function?

?qqnorm.lme

I am guessing that you did not realize it was a completely different  
function that qqnorm.default.


--
David Winsemius, MD
West Hartford, CT

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


Re: [R] memory use without running gc()

2010-08-06 Thread Johann Hibschman
jim holtman  writes:

> ?memory.size

Only works on Windows.  I guess I should have specified; this is on Linux.

Thanks,
Johann

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


Re: [R] Computation Duration Time

2010-08-06 Thread Erik Iverson

?Rprof

or

?system.time

TGS wrote:

Is there a way to find out what the computation duration time was to complete 
executing a code chunk?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] m-estimators

2010-08-06 Thread Dennis Murphy
Hi:

Try (install package sos first if necessary):

library(sos)
findFn('M-estimator')

This produced 34 hits on my machine (not quite as productive as Petr's
search :), but it identifies a few packages that contain functions for
robust estimation. It's also a good way to get familiar with a very useful
search mechanism to find R functions in the maze of available packages.
Typing

RSiteSearch('M-estimator')

at the R prompt is another way to search within R.

HTH,
Dennis

On Fri, Aug 6, 2010 at 12:10 AM, Iasonas Lamprianou wrote:

>
> Dear colleagues
>
> can somebody help me by showing how we can compute m-estimators in R?
>
> thanks
>
> Dr. Iasonas Lamprianou
>
>
> Assistant Professor (Educational Research and Evaluation)
> Department of Education Sciences
> European University-Cyprus
> P.O. Box 22006
> 1516 Nicosia
> Cyprus
> Tel.: +357-22-713178
> Fax: +357-22-590539
>
>
> Honorary Research Fellow
> Department of Education
> The University of Manchester
> Oxford Road, Manchester M13 9PL, UK
> Tel. 0044  161 275 3485
> iasonas.lampria...@manchester.ac.uk
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Computation Duration Time

2010-08-06 Thread TGS
Is there a way to find out what the computation duration time was to complete 
executing a code chunk?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] memory use without running gc()

2010-08-06 Thread jim holtman
?memory.size

On Fri, Aug 6, 2010 at 1:00 PM, Johann Hibschman  wrote:
> Is there any way to get the current memory used by R without running
> gc()?
>
> I'd like to include the memory usage in logging output, but calling gc()
> to get that information takes long enough to be noticeable (~ 6 s with ~
> 20 GB of ram in use), which goes against the point of logging.
>
> Thanks,
> Johann
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] Plotting range of values in barplot()

2010-08-06 Thread Dennis Murphy
Hi:

As far as I recall, no one has provided a horizontal barchart as a solution,
so here's one using lattice:

library(lattice)
smw.dat<-factor(rep(c("Somewhat Disagree", "Neutral",  "Somewhat Agree",
 "Strongly Agree"),c(1,2,7,12)),  levels=c("Strongly Disagree",
 "Somewhat Disagree", "Neutral", "Somewhat Agree","Strongly Agree"),
 ordered=TRUE)
smw.f <- table(smw.dat)
barchart( ~ smw.f, horizontal = TRUE, xlim = c(0, 14),scales = list(axs =
'i'),
col=rainbow(5), main="Survey answers", xlab="Responses" )

Given the lengths of the labels, it might be preferable to view them from
this perspective instead. dotchart() [dotplot() in lattice] would be a
viable alternative for displaying this discrete distribution, but its colors
aren't as pretty :)

HTH,
Dennis

On Fri, Aug 6, 2010 at 3:57 AM, Jim Lemon  wrote:

> On 08/06/2010 04:22 AM, yankeetilidie wrote:
>
>>
>> Hello,
>>
>> I am attempting to create a bar plot that contains a range of possible
>> response values on the x-axis of 1 to 5 and contains barplots for the
>> number
>> of responses even in the event that there are 0 responses. For example, I
>> have a data set that contains values of 2, 3, 4, and 5 but I would also
>> like
>> my graph to show that there are no 1's.
>>
>> I have attached the resulting graph. The appropriate values should be 0 -
>> Strongly Disagree, 1 - Somewhat Disagree, 2 - Neutral, 7 - Somewhat Agree,
>> and 12 - Strongly Agree.
>>
>
> Hi Steve,
> Given your labels, I would suggest the following:
>
>
> smw.dat<-factor(rep(c("Somewhat Disagree","Neutral",
>  "Somewhat Agree","Strongly Agree"),c(1,2,7,12)),
>  levels=c("Strongly Disagree","Somewhat Disagree","Neutral",
>  "Somewhat Agree","Strongly Agree"),ordered=TRUE)
> library(prettyR)
> smw.freq<-freq(smw.dat,display.na=FALSE)
> library(plotrix)
> barp(smw.freq,names.arg=levels(smw.dat),staxx=TRUE,
>  col=rainbow(5),main="Survey answers",xlab="Responses")
>
> 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.
>

[[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] stats::reshape question

2010-08-06 Thread Wu Gong

It seems that we can't change the order of varying argument or v.names.

"Notice that the order of variables in varying is like x.1,y.1,x.2,y.2. "

Code can only be:
reshape(d,varying=c("x1","y1","x2","y2"),v.names=c("x","y"),dir="long")

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/stats-reshape-question-tp2316583p2316606.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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

2010-08-06 Thread Benjamin Caldwell
Hi all,

I'm modeling using lme in the nlme package. qqnorm makes plots just find,
but when I try to add a line with qqline, I get the following error:
"Error in sort.list(x, partial = unique(c(lo, hi))) :
  'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?"

For example
> modelincr10<-lme(lruin~can.pos.num, data=rwushi30, random=(~1|
site/transect/plot),na.action=na.omit)
> summary(modelincr10)
> qqnorm(modelincr10, main="qqnorm res10")
> qqline(modelincr10)
Error in sort.list(x, partial = unique(c(lo, hi))) :
  'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

Any help much appreciated.

Ben

[[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] Multiply each depth level of an array with another vector element

2010-08-06 Thread Wu Gong

It's interesting that sweep is the slowest one comparing to replicate and rep
:)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Multiply-each-depth-level-of-an-array-with-another-vector-element-tp2315537p2316586.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] stats::reshape question

2010-08-06 Thread Krishna Tateneni
Hello,

A quick question for my edification.  When I run the following (R 2.8.1 on
Microsoft Windows):

> d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
> reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long")

I found myself surprised by the results--the column labeled "y" is actually
the data from "x1" and "x2", and the column labeled "x" is actually the data
from "y1" and "y2".

Is this behaviour of reshape as intended?  That is, have I missed something
in the documentation?

Many thanks for any comments.

--Krishna

[[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] eval-parse and lme in a loop

2010-08-06 Thread Greg Snow
> fortune(106)

If the answer is parse() you should usually rethink the question.
   -- Thomas Lumley
  R-help (February 2005)

Here is one approach that seems to be working:

for (meanCol in paste("Mean_", 1:3, sep="")) {

cat('\n##',meanCol,'\n\n')

f <- formula( paste( meanCol, '~ Group + c1 + c2 + c3' ) )

means.lmeWithCovariate <- lme(f, data=df, random = ~ 1 | Subject)
print(summary(means.lmeWithCovariate))
print(anova(means.lmeWithCovariate))
}



-- 
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 Connolly, Colm
> Sent: Thursday, August 05, 2010 3:18 PM
> To: r-help@r-project.org
> Subject: [R] eval-parse and lme in a loop
> 
> Hi everybody,
> 
> I'm having trouble getting an eval-parse combination to work with lme
> in a for loop.
> 
> Consider the code below. The call to lme outside the loop works. The
> call to aov inside the loop works, but the call to to lme inside the
> loop does not.
> The latter fails with
> 
> Error in model.frame.default(formula = ~meanCol + Group + c1 + c3 +
> Subject,  :
>   variable lengths differ (found for 'Group')
> 
> and I don't know why the eval-parse portion of the code is node being
> replaced as it is in the call to aov. Anybody got any idea what's
> wrong?
> 
> rm(list=ls())
> 
> library('nlme')
> 
> df=data.frame(
>   Group=rep(c("ctrl", "short", "long"), each=9, times=1),
>   Subject=paste("S", 1:27, sep=""),
>   Mean_1=c(-2.335482,  8.269832,  6.704734, -2.355664,  0.724432,
> 11.212987,  5.966652, 10.741065,  3.567522,  5.359832,  4.899951,
> 4.084452,  5.976326, 8.634508,  5.750942,  7.455622,  6.823843,
> 0.903801, 13.198157,  5.238985,  5.171453, 10.273715, 5.184785,
> 6.225874,  8.889997, 12.096968, 9.843028),
>   Mean_2=c(16.24, -1.486571,  1.817303,  3.814328, -0.343775,
> 19.323227, -0.390764,  7.149855,  4.517766, -0.967120, 11.219844,
> 0.561103,  5.188478, -4.819444,  6.253271,  7.062638,  4.502291, -
> 0.469567, 12.739646,  5.832679,  9.193511,  7.664636, 6.083930,
> 9.493136,  7.478424,  7.642287, 7.205822),
>   Mean_3=c(7.213662,  2.147219, -1.345795, -0.495567,  3.733844,
> 3.544084,  0.949573,  4.318238,  2.914248,  3.913391,  9.240128,
> 8.315122, 12.323612, 14.622557, 11.169847, 10.857631, 14.637243,
> 7.203096,  7.777472, -1.457673,  2.766380,  9.675148, -5.047292,
> 1.982447,  3.865502,  5.045913, 10.660579),
>   c1=rnorm(9, mean=0.1, sd=0.4),
>   c2=rnorm(9, mean=0.5, sd=0.7),
>   c3=rnorm(9, mean=0.9, sd=1)
>   );
> 
> 
> ## this works
> means.lmeNoCovariate=lme(Mean_1 ~ Group, data=df, random = ~ 1 |
> Subject)
> print(summary(means.lmeNoCovariate))
> print(anova(means.lmeNoCovariate))
> 
> 
> for (meanCol in paste("Mean_", 1:3, sep="")) {
>   ## LMEs go here
> 
> 
> cat("##
> ##\n")
>   cat("### AOV\n")
> 
> cat("##
> ##\n")
>   ## this works
>   means.aov<-aov(eval(parse(text=meanCol)) ~ Group, data=df);
>   means.aov.summary=summary(means.aov)
>   print(means.aov.summary)
> 
> 
> cat("##
> ##\n")
>   cat("### LME\n")
> 
> cat("##
> ##\n")
> 
>   ## this doe not work
>   means.lmeWithCovariate=lme(eval(parse(text=meanCol)) ~ Group + c1 +
> c1 + c3, data=df, random = ~ 1 | Subject)
>   print(summary(means.lmeWithCovariate))
>   print(anova(means.lmeWithCovariate))
> 
> }
> 
> Regards,
> --
> Colm G. Connolly, Ph. D.
> Dept of Psychiatry
> University of California, San Diego
> 9500 Gilman Dr. #0738
> La Jolla, CA 92093-0738
> Tel: +1-858-246-0684
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] memory use without running gc()

2010-08-06 Thread Johann Hibschman
Is there any way to get the current memory used by R without running
gc()?

I'd like to include the memory usage in logging output, but calling gc()
to get that information takes long enough to be noticeable (~ 6 s with ~
20 GB of ram in use), which goes against the point of logging.

Thanks,
Johann

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

2010-08-06 Thread Joshua Wiley
On Fri, Aug 6, 2010 at 9:29 AM, Raghuraman Ramachandran
 wrote:
> Hi
>
> I wish to read a file from my local directory from inside a function. I am
> passing the filename as the argument but this does not work.
> Say for example
> function(dat)
> {
> dat1=read.csv("D:\\dat.csv",header=TRUE)

this does not work because in the quoted string, 'dat' is not
evaluated.  You have several options, one as shown by Wu Gong, simply
pass the entire file path as the argument to your function.
Alternately, suppose your data files are always located at D:\\ and
always end in .csv you could do this which paste()s D:\\ and .csv to
the front and end, respectively, of 'dat'.

myfun <- function(dat) {
  filename <- paste("D:\\", dat, ".csv", sep = "")
  read.csv(file = filename, header = TRUE)
}

myfun("datafilename") #or whatever the filename is

HTH,

Josh

> }
> If I call funtion(dat) I get the following error. 'Intuitively' i understand
> this is a mistake but how do I overcome this and how can I read a file name
> passed as an argument please?
>
>
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>  cannot open file 'D:\dat.csv': No such file or directory
>
> Many thanks
> Raghu
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Multiply each depth level of an array with another vector element

2010-08-06 Thread Greg Snow
?sweep

-- 
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 Maurits Aben
> Sent: Thursday, August 05, 2010 2:00 PM
> To: r-help@r-project.org
> Subject: [R] Multiply each depth level of an array with another vector
> element
> 
> Suppose
> 
> x <- array(c(1,1,1,1,2,2,2,2), dim = c(2,2,2))
> 
> y <- c(5, 10)
> 
> 
> 
> Now I would like to multiply x[, , 1] with y[1] and x[, , 2] with y[2].
> 
> 
> 
> Possible solution is a for-loop:
> 
> for (i in 1:2) {
> 
> x[, , i] * y[i]
> 
> }
> 
> 
> 
> Another possible solution is this construction:
> 
> as.vector(t(replicate(nrow(x) * ncol(x), y))) * x
> 
> 
> 
> I find that these two solutions have a relatively large computation
> time (on
> larger arrays) and I suspect there should be solution with less
> computation
> time. Is there a faster method to perform this calculation (thus to
> multiply
> the depth of an array with respective vector elements)?
> 
> 
> 
> Best regards,
> 
> Maurits Aben
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] gsub

2010-08-06 Thread Wu Gong

i <- "piante_venere.csv" 
gsub("^.*_(.*)\\.csv$", "\\1", i)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/gsub-tp2316443p2316550.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] plotting lines and colors

2010-08-06 Thread Joshua Wiley
On Fri, Aug 6, 2010 at 9:42 AM, Erin Hodgess  wrote:
> Dear R People:
>
> Suppose I plot the following
>
> plot(1:50)
>
> Is there a way to plot, say, [1:25] in red and [26:50] in blue, please?

One simple way is with the col argument, there are certainly fancier
solutions too.

plot(1:50, col = rep(c("red","blue"), each = 25))

Cheers,

Josh

>
> (or should I just plot 2 separate lines, please?)
>
> I'm about 99% sure that there is no way without 2 lines.
>
> thanks for any help,
> Sincerely,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] plotting lines and colors

2010-08-06 Thread Erin Hodgess
Dear R People:

Suppose I plot the following

plot(1:50)

Is there a way to plot, say, [1:25] in red and [26:50] in blue, please?

(or should I just plot 2 separate lines, please?)

I'm about 99% sure that there is no way without 2 lines.

thanks for any help,
Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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


Re: [R] How to read a file inside a function?

2010-08-06 Thread Wu Gong

ff <- function(filename)
{
dat1 <- read.csv(file=filename,header=TRUE)
} 

filename <- "D:\dat.csv"

ff(filename)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-read-a-file-inside-a-function-tp2316516p2316528.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] Stopping precision using 'optim'

2010-08-06 Thread Ravi Varadhan
Read the help file for optim().

?optim

It clearly says the following with regards to L-BFGS-B:

factr
controls the convergence of the "L-BFGS-B" method. Convergence occurs when
the reduction in the objective is within this factor of the machine
tolerance. Default is 1e7, that is a tolerance of about 1e-8. 

pgtol
helps control the convergence of the "L-BFGS-B" method. It is a tolerance on
the projected gradient in the current search direction. This defaults to
zero, when the check is suppressed.

So, all you need to do is to change these two (I am not sure if you really
want to change pgtol) if you want better (or different) answers.  

You should not *minimize* the log-likelihood.  You may have meant that you
are minimizing its negative.  You can do this by setting control$fnscale =
-1.

Hope this helps,
Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Jeremy Beaulieu
Sent: Thursday, August 05, 2010 8:45 PM
To: r-help@r-project.org
Subject: [R] Stopping precision using 'optim'

Hi all~

I am wondering if it is possible to alter the stopping precision for
parameters estimated using the 'optim'?

If it helps, I am minimizing the log-likelihood of a function using
constraints (i.e. L-BFG-S). 

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

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


[R] How to read a file inside a function?

2010-08-06 Thread Raghuraman Ramachandran
Hi

I wish to read a file from my local directory from inside a function. I am
passing the filename as the argument but this does not work.
Say for example
function(dat)
{
dat1=read.csv("D:\\dat.csv",header=TRUE)
}
If I call funtion(dat) I get the following error. 'Intuitively' i understand
this is a mistake but how do I overcome this and how can I read a file name
passed as an argument please?


Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'D:\dat.csv': No such file or directory

Many thanks
Raghu

[[alternative HTML version deleted]]

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


Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread Tom Quarendon
packages that include functions implemented in C (and hence are 
>> provided in native libraries linked to R.dll) and distribute them under 
>> licenses not compatible with GPL. This was achieved by making the relevant 
>> header files available under the LGPL. This was an explicit change that was 
>> made in February 2001, and the intention was to allow for DLLs that require 
>> the API header files for compilation and are linked against R.dll to not be 
>> "infected" with the GPL.
>>
>> However the Rembedded.h header file isn't included in the list in the 
>> doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header 
>> file lists the GPL and not the LGPL as the relevant license.  So it doesn't 
>> look like it was the intention to allow that I be able to use the R 
>> invocation API to launch R and embed it in a product (such as a new GUI, or 
>> other such integration) and ship that product under a license not compatible 
>> with GPL. Is this correct? Or is it the intention that I be able to write a 
>> commercial front-end of some kind for R?
>>
>>
>>
>> My understanding of LGPL is that ALL of the source files that go into R.dll 
>> (and indeed all libraries that R.dll itself linked to, apart from those 
>> covered by the GPL system library exception) would need to be released under 
>> LGPL in order to allow me to link to R.dll and not have my program subject 
>> to GPL. If that weren't the situation then I could take a library covered by 
>> GPL, write a different interface to it, put LGPL on those headers compile up 
>> a new DLL and I've then got LGPL access to a library previously released 
>> under GPL, which can't be the intention, otherwise LGPL would drive a coach 
>> and horses through GPL. This would apply to native libraries (dlls) 
>> providing functions in addon packages too, and so hence I'm not sure I 
>> necessarily understand how simply putting LGPL on the header files is 
>> sufficient to achieve the intention.
>>
>>
>>
>> There is provision in the GPL license (it's mentioned in the FAQ) for 
>> providing for linking to a GPL library through one specific interface by 
>> providing specific exception text in the copyright header in all of the 
>> files that make up the library. That would only be possible if the copyright 
>> holders of all relevant GPL code agreed to that, as that would be an extra 
>> grant to the license. So if R linked to any third party GPL code, this 
>> wouldn't be possible I don't think.
>>
>> So I guess the question here is what the intention is of the R foundation 
>> with respect to the limitations or freedoms that they are intending to 
>> allow. After all, as the copyright owners they aren't going to sue if a use 
>> falls within their intention, even if on a strict interpretation of the 
>> license such use wouldn't be allowed.
>>
>>
>>
>> So it seems to be the intention that I can write a DLL to provide R 
>> functions in an add on package, which requires linkage to R.dll. Not 
>> convinced that the license it set up right to cover that, but that appears 
>> to be the intention. Question is whether at the other end, at the invocation 
>> API end, whether it is the intention to be able to use the invocation API 
>> and link to R.dll without my program being subjected to GPL.
>>
>>
>>
>> Note that I'm not talking here about anything to do with code written in the 
>> language of R. This is purely concerned with treating R as a library with an 
>> interface and wanting to link to that interface and whether the intention or 
>> the actuality of the license allow that.
>>
>>
>>
>> Thanks!
>>




__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5347 (20100806) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5347 (20100806) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.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] Tukey post hoc test for testing interaction between two or more predictors

2010-08-06 Thread Nicola Spotorno

Hi everyone,

I woudl like to apply a Tukey post hoc after a repeated measure ANOVA. I 
followed the suggestions  that I found in this  help -list  especially 
this one:


/[R] Tukey HSD (or other post hoc tests) following repeated measures ANOVA

You want to use lme() in package nlme, then glht() in the multcomp package.
This will give you multiplicity adjusted p-values and confidence intervals.

## Example
require(MASS) ## for oats data set
require(nlme) ## for lme()
require(multcomp)  ## for multiple comparison stuff

Aov.mod <- aov(Y ~ N + V + Error(B/V), data = oats)
Lme.mod <- lme(Y ~ N + V, random = ~1 | B/V, data = oats)

summary(Aov.mod)
anova(Lme.mod)

summary(Lme.mod)
summary(glht(Lme.mod, linfct=mcp(V="Tukey")))

HTH, Mark.

/My problem is that in my study I want to test the interactions among 
different levels of two predictors. Considering oats dataset in MASS 
package how can I test the contrast between one level of the variable V 
(for example, Victory) and one level of the variable N(for example 0.0cwt)?


Thank you very much for your help.

Nicola

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


Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread Tom Quarendon
OK. Can I say once more. I'm not after legal advice! That I can get elsewhere! 
We understand the need for legal advice and so far our legal advice has been 
sound on other matters.

I was simply trying to understand the apparent contradiction between the GPL 
and the attempt to allow commercial add-on packages.

TomQ.

-Original Message-
From: David Smith [mailto:da...@revolutionanalytics.com]
Sent: 06 August 2010 16:56
To: Tom Quarendon
Cc: Marc Schwartz; r-help@r-project.org
Subject: Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?

Tom,

I would strongly echo the advice of Duncan and Marc and others already
on this thread to seek expert legal advice on this issue. At
Revolution we rely on the expertise of Mark Radcliffe, the General
Legal Counsel of the Open Source Initiative. (Additional information
here: http://www.revolutionanalytics.com/downloads/gpl-sources.php .)
Because GPL issues draw on aspects of copyright law, contract law, and
other legal domains (that can also vary by jurisdiction), legal advice
with expertise in all the relevant areas is essential.

Hope this helps,
# David Smith

--
David M Smith 
VP of Marketing, Revolution Analytics  http://blog.revolutionanalytics.com
Tel: +1 (650) 330-0553 x205 (Palo Alto, CA, USA)



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5347 (20100806) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5347 (20100806) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.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] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread Tom Quarendon
can't speak for the R Foundation, but I can say that its intentions
> aren't all you have to consider.  R has many copyright owners.  You need
> to get permission from all of them if you want a special license, so the
> easiest thing is to stay with a GPL v2 compatible license.  If you don't
> want to do that, then you could go ahead with some other license and see
> what happens, but it might not be until your project becomes popular
> that someone decides to take action.  So in the latter case I'd get a
> legal opinion, not a mailing list opinion, before I invested a lot of
> time or money.
>
> Duncan Murdoch
>
>> I've looked at various threads on the r-devel archive and it looks like this 
>> may have been discussed before, but as far as could tell, not to any great 
>> resolution, and not, it seems, specifically covering this angle.
>>
>>
>>
>> In the doc\COPYRIGHTS file it is made clear that the intention is that you 
>> can write R packages that include functions implemented in C (and hence are 
>> provided in native libraries linked to R.dll) and distribute them under 
>> licenses not compatible with GPL. This was achieved by making the relevant 
>> header files available under the LGPL. This was an explicit change that was 
>> made in February 2001, and the intention was to allow for DLLs that require 
>> the API header files for compilation and are linked against R.dll to not be 
>> "infected" with the GPL.
>>
>> However the Rembedded.h header file isn't included in the list in the 
>> doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header 
>> file lists the GPL and not the LGPL as the relevant license.  So it doesn't 
>> look like it was the intention to allow that I be able to use the R 
>> invocation API to launch R and embed it in a product (such as a new GUI, or 
>> other such integration) and ship that product under a license not compatible 
>> with GPL. Is this correct? Or is it the intention that I be able to write a 
>> commercial front-end of some kind for R?
>>
>>
>>
>> My understanding of LGPL is that ALL of the source files that go into R.dll 
>> (and indeed all libraries that R.dll itself linked to, apart from those 
>> covered by the GPL system library exception) would need to be released under 
>> LGPL in order to allow me to link to R.dll and not have my program subject 
>> to GPL. If that weren't the situation then I could take a library covered by 
>> GPL, write a different interface to it, put LGPL on those headers compile up 
>> a new DLL and I've then got LGPL access to a library previously released 
>> under GPL, which can't be the intention, otherwise LGPL would drive a coach 
>> and horses through GPL. This would apply to native libraries (dlls) 
>> providing functions in addon packages too, and so hence I'm not sure I 
>> necessarily understand how simply putting LGPL on the header files is 
>> sufficient to achieve the intention.
>>
>>
>>
>> There is provision in the GPL license (it's mentioned in the FAQ) for 
>> providing for linking to a GPL library through one specific interface by 
>> providing specific exception text in the copyright header in all of the 
>> files that make up the library. That would only be possible if the copyright 
>> holders of all relevant GPL code agreed to that, as that would be an extra 
>> grant to the license. So if R linked to any third party GPL code, this 
>> wouldn't be possible I don't think.
>>
>> So I guess the question here is what the intention is of the R foundation 
>> with respect to the limitations or freedoms that they are intending to 
>> allow. After all, as the copyright owners they aren't going to sue if a use 
>> falls within their intention, even if on a strict interpretation of the 
>> license such use wouldn't be allowed.
>>
>>
>>
>> So it seems to be the intention that I can write a DLL to provide R 
>> functions in an add on package, which requires linkage to R.dll. Not 
>> convinced that the license it set up right to cover that, but that appears 
>> to be the intention. Question is whether at the other end, at the invocation 
>> API end, whether it is the intention to be able to use the invocation API 
>> and link to R.dll without my program being subjected to GPL.
>>
>>
>>
>> Note that I'm not talking here about anything to do with code written in the 
>> language of R. This is purely concerned with treating R as a library with an 
>> interface and wanting to link to that interface and whether the intention or 
>> the actuality of the license allow that.
>>
>>
>>
>> Thanks!
>>




__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5347 (20100806) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5347 (20100806) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.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] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread David Smith
Tom,

I would strongly echo the advice of Duncan and Marc and others already
on this thread to seek expert legal advice on this issue. At
Revolution we rely on the expertise of Mark Radcliffe, the General
Legal Counsel of the Open Source Initiative. (Additional information
here: http://www.revolutionanalytics.com/downloads/gpl-sources.php .)
Because GPL issues draw on aspects of copyright law, contract law, and
other legal domains (that can also vary by jurisdiction), legal advice
with expertise in all the relevant areas is essential.

Hope this helps,
# David Smith

--
David M Smith 
VP of Marketing, Revolution Analytics  http://blog.revolutionanalytics.com
Tel: +1 (650) 330-0553 x205 (Palo Alto, CA, USA)

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

2010-08-06 Thread Stephen Liu
Hi folks,

I have R x64 2.11.1 installed on Win 7 64 bit which is running as VM (guest) on 
Oracle VirtualBox.  Is there any difference between it and R on Linux?  I can 
install another R on Debian 5.04, also running as VM.  TIA

B.R.
Stephen L




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Colours on conditional levelplots in package "lattice"

2010-08-06 Thread gordon . morrison

I am having difficulty in getting the colours on a conditional levelplot in
the package lattice to work as I want them to - I wonder if someone could
help me.

The colours do not completely agree with the colour key.

Here is a specimen example.

require(lattice)

col1 <- c
(1.37,2.35,0.20,1.85,0.274,1.56,-0.76,-0.03,-1.39,-0.95,-0.50,0.91,1.58,0.17,-0.34,-0.48,1.50,-0.68,1.05)
col2 <- c
("A","B","C","F","G","H","B","C","E","G","H","A","B","C","D","E","F","G","H")
col3 <- c
("X","Y","X","Y","X","Y","Y","X","X","X","Y","X","Y","X","Y","X","Y","X","Y")
col4 <- c
("1","1","1","1","1","1","2","2","2","2","2","3","3","3","3","3","3","3","3")
dat1 <- data.frame(X1=col1, var1=col2, var2=col3, var3=col4)

maxAbsValue <- max(abs(as.vector(dat1[, "X1"])))
colorkeyAt <- pretty(c(-maxAbsValue, maxAbsValue), n = 10)
boxColours <- c("#8B", "#A83500", "#C46B00", "#E2A100", "#FFD700",
"#ADD8E6", "#81A2CF", "#566CB8", "#2B36A1", "#8B")

levelplot(X1 ~ var1 * var2 | var3, data = dat1,
  col.regions = boxColours,
  colorkey = list(at = colorkeyAt,
  labels = list(labels = colorkeyAt, at = colorkeyAt, cex =
0.6)),
  panel = function(x, y, z, ...) {
panel.fill(col = "darkgrey")
at =  pretty(c(-maxAbsValue, maxAbsValue), n = 10)
panel.levelplot(x, y, z, ...)
  })

I am hoping that all the "blue" shades appear in panel 1, the reds in panel
2 and a mixture only in panel 3. Can anyone help explain why this is not
happening?

I am using

> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] RColorBrewer_1.0-2 lattice_0.18-8 rcom_2.2-3 rscproxy_1.3-1
svSocket_0.9-48
[6] TinnR_1.0.3R2HTML_2.1 Hmisc_3.8-2
survival_2.35-8

loaded via a namespace (and not attached):
[1] cluster_1.12.3 svMisc_0.9-57  tools_2.11.1

Windows XP Professional

Regards

Gordon Morrison



HSBC Bank plc may be solicited in the course of its placement efforts for a
new issue, by investment clients of the firm for whom the Bank as a firm
already provides other services. It may equally decide to allocate to its
own proprietary book or with an associate of HSBC Group. This represents a
potential conflict of interest. HSBC Bank plc has internal arrangements
designed to ensure that the firm would give unbiased and full advice to the
corporate finance client about the valuation and pricing of the offering as
well as internal systems, controls and procedures to identify and manage
conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised and regulated by the Financial Services Authority.


-
SAVE PAPER - THINK BEFORE YOU PRINT!

This transmission has been issued by a member of the HSBC Group
"HSBC" for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.

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


Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread Marc Schwartz
Tom,

FWIW, since you appear to be representing World Programming in your queries (at 
least that is my inference given your e-mail domain), it would be prudent to 
get formal legal advice here and not place your company at legal and financial 
risk by basing decisions on comments (well intentioned though they may be) on 
an e-mail list. 

You don't want to make key business decisions on "beliefs".  

There are other commercial companies doing what you are proposing to do. 
However, the devil is in the details.

To an extent, the intentions of the various R related copyright holders do not 
matter. The copyright holders, who are not themselves software licensing 
lawyers, may not be fully cognizant of all of the legal implications of the 
licenses they used and how those licenses apply to specific situations. Their 
intentions, explicit and implicit, must be legally consistent with the licenses 
under which their code and R are released. The R Foundation cannot make a 
proactive decision to let you do something that is in violation of the GPL as 
the R Foundation would put itself at legal risk.

One of the key points in the GPL licensing scheme, is that one need not get the 
permission or the opinion of every copyright holder involved in the code that 
is desired to be used. Once the copyright holders have made the decision to 
release their code under the GPL, the only consideration is whether or not the 
subsequent use of that code by others is legally consistent with the GPL. I 
can't stop you from doing something with my GPL code, as long as you honor the 
GPL, even if I might disagree with the application of my code to a particular 
task (eg. http://www.gnu.org/licenses/gpl-faq.html#NoMilitary).

It is when you make the decision to build and distribute (at no cost or 
otherwise) closed source software on top of open source software that things 
get dicey.

Thus, what will matter in the end, at some point down the road when you have a 
closed source commercial R product, with revenues at risk, is whether or not 
the the R Foundation and/or the FSF, will contact you due to a violation of the 
GPL because of the **specific** way in which your closed source GUI interacts 
with R. The FSF will have an interest here, because R is a GNU project, not to 
mention, ensuring that the GPL is properly enforced.

The FSF has already shown that it will independently undertake such 
communications on behalf of GNU projects and enforcing the GPL license. That 
recently happened, for example, with GNU Go for iOS via the Apple App Store, 
resulting in the removal of that product. In addition (timing is everything), 
the Software Freedom Conservancy just won a judgement against Westinghouse due 
to a GPL violation:

  http://www.linuxplanet.com/linuxplanet/reports/7145/1/

While the details of these situations are not directly applicable to your 
query, it is a demonstration that GPL enforcement is moving forward in the 
courts and legal precedents are being established. In the end, all of that is 
good, because it will be helpful to others to better understand the legal 
boundaries and interpretations of the GPL as they apply to specific situations.

So there is a real risk to your company, dependent upon fairly low level 
programming and operational details, which can impact whether or not you can 
sell a closed source GUI that runs on top of R. 

At the end of the day, you have a fiduciary responsibility to your company to 
seek formal legal advice. That is part of the cost of doing business and making 
informed decisions.

HTH,

Marc Schwartz


On Aug 6, 2010, at 8:42 AM, Tom Quarendon wrote:

> It wasn't the intention of the GPL I was really interested in, I believe I 
> understand that (or at least I believe I understand the FSF view on things), 
> it was the intention of the authors of R. I believe that the FSF view linking 
> to a DLL creating a derived work and hence you are "infected" by the GPL. "If 
> you want to use GPL code you can, as long as you're willing to be GPL 
> yourself". This doesn't appear to square with the intention of the R authors 
> to allow non-GPL add-on projects with native code.
> 
> 
> 
> Tom Q.
> 
> 
> 
> From: Tal Galili [mailto:tal.gal...@gmail.com]
> Sent: 06 August 2010 12:28
> To: Tom Quarendon
> Cc: Duncan Murdoch; r-help@r-project.org
> Subject: Re: [R] Is R GPL or LGPL (or can I write a commercial front end to 
> R)?
> 
> 
> 
> From what I've seen on other OSS project, GPL can be a bit viral, making it 
> (purposefully) difficult for someone to close the source code for free reuse.
> 
> 
> 
> My tip for you would be to try and see what REvolution computing has been 
> doing with their product (which is a repackaging of R with more code which is 
> proprietary).
> 
> 
> 
> Also, Richard Stallman (the author of GPL, and other one or two meaningful 
> pieces of code, if to understate) gave a talk on "free software" and GPL 
> during his talk on useR2010.  I don't think he'll say 

Re: [R] image plot but data not on grid.

2010-08-06 Thread David Winsemius


On Aug 6, 2010, at 10:24 AM, W Eryk Wolski wrote:


Hi,

Would like to make an image
however the values in z are not on an uniform grid.

Have a dataset with
length(x) == length(y) == length(z)
x[1],y[1] gives the position of z[1]

and would like to encode value of z by a color.

looking for something like
plot(x,y, col = z)
where col for z is cleverly chosen from a colorscale.


?palette
??palette  # for other coloring options
?colorRamp

# random integer index from default palette for coloring of random x,y  
points:


plot(rnorm(20), rnorm(20), col=palette()[ runif(20, 1,10) ])

# The cleverness is left to you.
--

David Winsemius, MD
West Hartford, CT

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


Re: [R] data.frame: return all rows where at least one...

2010-08-06 Thread werner w

Thanks for the answers! The any function was basically exactly what I was
looking for. 
(previously I used something with rowSums() which is probably not the most
efficient way.)

Thanks so much,
  Werner
-- 
View this message in context: 
http://r.789695.n4.nabble.com/data-frame-return-all-rows-where-at-least-one-tp2316292p2316407.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] image plot but data not on grid.

2010-08-06 Thread Martyn Byng
Hi,

Not really sure what you are after, but the following plots a series of
points of varying colour

plot(x,y,type='n')
apply(cbind(x,y,z),1,function(a) {points(a[1],a[2],col=a[3],pch=".")})

but its going to be really slow for a large number of points

Martyn

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of W Eryk Wolski
Sent: 06 August 2010 15:25
To: r-help@r-project.org
Subject: [R] image plot but data not on grid.

Hi,

Would like to make an image
however the values in z are not on an uniform grid.

Have a dataset with
length(x) == length(y) == length(z)
x[1],y[1] gives the position of z[1]

and would like to encode value of z by a color.

looking for something like
plot(x,y, col = z)
where col for z is cleverly chosen from a colorscale.

Hope I made clear what I am looking for.

Thanks
Eryk

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

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


[R] Error on random forest variable importance estimates

2010-08-06 Thread Pierre Dubath

Hello,

I am using the R randomForest package to classify variable stars. I have 
a training set of 1755 stars described by (too) many variables. Some of 
these variables are highly correlated.


I believe that I understand how randomForest works and how the variable 
importance are evaluated (through variable permutations). Here are my 
questions.


1) variable importance error? Is there any ways to estimate the error on 
the "MeanDecreaseAccuracy"? In other words, I would like to know how 
significant are "MeanDecreaseAccuracy" differences (and display 
horizontal error bars in the VarImpPlot output).


I have notice that even with relatively large number of trees, I have 
variation in the importance values from one run to the next. Could this 
serve as a measure of the errors/uncertainties?


2) how to deal with variable correlation? so far, I am iterating, 
selecting the most important variable first, removing all other variable 
that have a high correlation (say higher than 80%), taking the second 
most important variable left, removing variables with high-correlation 
with any of the first two variables, and so on... (also using some 
astronomical insight as to which variables are the most important!)


Is there a better way to deal with correlation in randomForest? (I 
suppose that using many correlated variables should not be a problem for 
randomForest, but it is for my understanding of the data and for other 
algorithms).


3) How many variables should eventually be used? I have made successive 
runs, adding one variable at a time from the most to the least important 
(not-too-correlated) variables. I then plot the error rate (err.rate) as 
a function of the number of variable used. As this number increase, the 
error first sharply decrease, but relatively soon it reaches a plateau .
I assume that the point of inflexion can be use to derive the minimum 
number of variable to be used. Is that a sensible approach? Is there any 
other suggestion? A measure of the error on "err.rate" would also here 
really help. Is there any idea how to estimate this? From the variation 
between runs or with the help of "importanceSD" somehow?


Thanks very much in advance for any help.

Pierre Dubath

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


Re: [R] Partial Function Application

2010-08-06 Thread Mog
Thank you! That's exactly what I wanted.

--Mog

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] image plot but data not on grid.

2010-08-06 Thread W Eryk Wolski
Hi,

Would like to make an image
however the values in z are not on an uniform grid.

Have a dataset with
length(x) == length(y) == length(z)
x[1],y[1] gives the position of z[1]

and would like to encode value of z by a color.

looking for something like
plot(x,y, col = z)
where col for z is cleverly chosen from a colorscale.

Hope I made clear what I am looking for.

Thanks
Eryk

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


Re: [R] Partial Function Application

2010-08-06 Thread baptiste Auguié
Hi,

I think you mean Currying, there's a function in roxygen that looks like,

Curry
function (f, ..., .left = TRUE) 
{
.orig = list(...)
function(...) {
if (.left) {
args <- c(.orig, list(...))
}
else {
args <- c(list(...), .orig)
}
do.call(f, args)
}
}

HTH,

baptiste

On Aug 6, 2010, at 3:56 PM, Mog wrote:

> Hi. I would like to partially apply a function to a list of arguments,
> and I don't know how to do this in R, without perhaps writing default
> values to the formals() of my function, or writing to the environment
> object of a function. For context, my definition of partially apply
> is: "fix some of the arguments, leaving the others as variables,
> return a new function that takes the un-fixed arguments from the
> original function as arguments"
> 
> The issue is that I would like several different sets of arguments for
> the "partially applied" phase, and I think that would involve copying
> the function to several different places with the above methods.
> 
> Alternately, I could hard-code the partial applications using a
> function() form, but I would prefer not to do this, as there will be a
> sizable number of these closures needed and I'd prefer to automate the
> process.
> 
> Thanks!
> 
> --Mog
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Partial Function Application

2010-08-06 Thread David Winsemius


On Aug 6, 2010, at 9:56 AM, Mog wrote:


Hi. I would like to partially apply a function to a list of arguments,
and I don't know how to do this in R, without perhaps writing default
values to the formals() of my function, or writing to the environment
object of a function. For context, my definition of partially apply
is: "fix some of the arguments, leaving the others as variables,
return a new function that takes the un-fixed arguments from the
original function as arguments"


I don't understand the difficulties:

> f1 <- function(a,b,c,d) a+b+c+d
> f1(1,2,3,4)
[1] 10

> f2 <- function(a , b) f1(a,b, 3,4)
> f2(1,2)
[1] 10

> f1(1,2)
Error in a + b + c : 'c' is missing

> floop <- function(a,b){ for( cc in 2:4) { for (dd in 5:7)  
{ print( f1(a, b, cc, dd) )}} }

> floop(1,2)
[1] 10
[1] 11
[1] 12
[1] 11
[1] 12
[1] 13
[1] 12
[1] 13
[1] 14


The issue is that I would like several different sets of arguments for
the "partially applied" phase, and I think that would involve copying
the function to several different places with the above methods.

Alternately, I could hard-code the partial applications using a
function() form, but I would prefer not to do this, as there will be a
sizable number of these closures needed and I'd prefer to automate the
process.

Thanks!

--Mog

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


David Winsemius, MD
West Hartford, CT

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


[R] [OT] R on Atlas library

2010-08-06 Thread Matthias Gondan
Dear List,

I am aware this is slightly off-topic, but I am sure there are people who 
already had the problem and who perhaps solved it.

I am running long-lasting model fits using constrOptim command. At work
there is a linux computer (Quad Core, debian) on which I already have
compiled R and Atlas, in the hope that things will go faster on that
machine.

Atlas offers the possibility to be compiled for multiple cores, I used
that option, but without success. Performance meter ("top") for Linux
shows 25% CPU usage, and there is no loss of performance if I run
4 instances of R doing heavy matrix multiplications. Performance drops
when a 5th instance of R is doing the same job, so I assume my attempt
was not successful.

I am sure I did something wrong. Is there anybody who sucessfully
runs R with Atlas and all processors? A short description of the
necessary steps would be helpful.

Searching around the internet was not very encourageing. Some people
wrote that it is not so simple to have Atlas fully exploit a multicore
computer.

I hope this is not too unspecific.

Best wishes,

Matthias

-- 
Dr. rer. nat. Matthias Gondan
Institut für Psychologie
Universität Regensburg
D-93050 Regensburg
Tel. 0941-943-3856
Fax 0941-943-3233
Email: matthias.gon...@psychologie.uni-regensburg.de
http://www.psychologie.uni-r.de/Greenlee/team/gondan/gondan.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] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread peter dalgaard
 by the GPL system library exception) would need to be released 
>>> under LGPL in order to allow me to link to R.dll and not have my program 
>>> subject to GPL. If that weren't the situation then I could take a library 
>>> covered by GPL, write a different interface to it, put LGPL on those 
>>> headers compile up a new DLL and I've then got LGPL access to a library 
>>> previously released under GPL, which can't be the intention, otherwise LGPL 
>>> would drive a coach and horses through GPL. This would apply to native 
>>> libraries (dlls) providing functions in addon packages too, and so hence 
>>> I'm not sure I necessarily understand how simply putting LGPL on the header 
>>> files is sufficient to achieve the intention.
>>> 
>>> 
>>> 
>>> There is provision in the GPL license (it's mentioned in the FAQ) for 
>>> providing for linking to a GPL library through one specific interface by 
>>> providing specific exception text in the copyright header in all of the 
>>> files that make up the library. That would only be possible if the 
>>> copyright holders of all relevant GPL code agreed to that, as that would be 
>>> an extra grant to the license. So if R linked to any third party GPL code, 
>>> this wouldn't be possible I don't think.
>>> 
>>> So I guess the question here is what the intention is of the R foundation 
>>> with respect to the limitations or freedoms that they are intending to 
>>> allow. After all, as the copyright owners they aren't going to sue if a use 
>>> falls within their intention, even if on a strict interpretation of the 
>>> license such use wouldn't be allowed.
>>> 
>>> 
>>> 
>>> So it seems to be the intention that I can write a DLL to provide R 
>>> functions in an add on package, which requires linkage to R.dll. Not 
>>> convinced that the license it set up right to cover that, but that appears 
>>> to be the intention. Question is whether at the other end, at the 
>>> invocation API end, whether it is the intention to be able to use the 
>>> invocation API and link to R.dll without my program being subjected to GPL.
>>> 
>>> 
>>> 
>>> Note that I'm not talking here about anything to do with code written in 
>>> the language of R. This is purely concerned with treating R as a library 
>>> with an interface and wanting to link to that interface and whether the 
>>> intention or the actuality of the license allow that.
>>> 
>>> 
>>> 
>>> 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.
>>> 
>>> 
>> 
>> 
>> 
>> 
>> __ Information from ESET NOD32 Antivirus, version of virus signature 
>> database 5346 (20100806) __
>> 
>> The message was checked by ESET NOD32 Antivirus.
>> 
>> http://www.eset.com
>> 
>> 
>> 
>> __ Information from ESET NOD32 Antivirus, version of virus signature 
>> database 5346 (20100806) __
>> 
>> The message was checked by ESET NOD32 Antivirus.
>> 
>> http://www.eset.com
>> 
>> 
> 
> 
> 
> 
> __ Information from ESET NOD32 Antivirus, version of virus signature 
> database 5346 (20100806) __
> 
> The message was checked by ESET NOD32 Antivirus.
> 
> http://www.eset.com
> 
> 
> 
> __ Information from ESET NOD32 Antivirus, version of virus signature 
> database 5346 (20100806) __
> 
> The message was checked by ESET NOD32 Antivirus.
> 
> http://www.eset.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] try-error within for loop

2010-08-06 Thread Olga Lyashevska

Wu Gong wrote:
> So, try() inside loop should work. Like 
> 
> for () { 
> if (class(try(...,silent=T))=="try-error") result[[i]] <- NA 
> ... 
> } 

Thanks a lot, it worked for me!

Cheers
Olga

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: Pausing script to allow user input from keyboard.

2010-08-06 Thread Petr PIKAL
Hi

Some time ago somebody advised me to use

cat("\n","Enter filename","\n") # prompt
x=scan(n=1) # read 1 line from console

than use x in further code

Regards
Petr


r-help-boun...@r-project.org napsal dne 06.08.2010 15:52:17:

> Hi all,
> 
> I have written a simple R script to help me analyze a large data set. 
> I would like to have the script pause to allow the user to input a 
> character string that is subsequently used as a filename when saving 
> tables.  I have tried to use the "readline" command - this seems to 
> work fine when entering commands one by one, but when I copy and paste 
> the entire script into R, it does not pause for input and just charges 
> ahead writes the files.  Any help is appreciated, I've copied and 
> pasted the script below.  Any help is appreciated - I am really new to 
> R so if you can be as detailed as possible in your responses it would 
> be greatly appreciated.
> 
> Thanks,
> 
> JT
> 
> R version: R 2.11.1 GUI 1.34
> OS: OS 10.5.8
> 
> Here's the script:
> 
> #readfiles, "a" is nuclear measurements, "b" is cytoplasmic measurements
> a <- read.table(file.choose(), header=TRUE, sep=",")
> b <- read.table(file.choose(), header=TRUE, sep=",")
> 
> #make a new data frame named "new" with important columns
> new <- data.frame(a$ImageNumber, a$AreaShape_Area, a 
> $Intensity_IntegratedIntensity_OrigRFP, a 
> $Intensity_IntegratedIntensity_OrigGFP, b 
> $Intensity_MeanIntensity_OrigGFP)
> 
> #make three new columns, "EstCytoIntensity" estimates Cytoplasmic 
> intensity based on the mean measured intensity and an estimate of the 
> nuclear volume to the cytoplasmic volume, "TotalIntensity" is the sum 
> of the integrated nuclear intensity and estimated cytoplasmic 
> intensity, "NucToCytoRatio" is the ratio of nuclear intensity divided 
> by cytoplasmic intensity
> new$EstCytoIntensity <- b$Intensity_MeanIntensity_OrigGFP * (a 
> $AreaShape_Area/0.3)
> new$TotalIntensity <- new$a.Intensity_IntegratedIntensity_OrigGFP + new 
> $EstCytoIntensity
> new$NucToCytoRatio <- new$a.Intensity_IntegratedIntensity_OrigGFP / new 
> $TotalIntensity
> 
> #creates a table that determines the means for the measurements of all 
> objects within an image
> library(plyr)
> newmean <- ddply(new, c("a.ImageNumber"), summarize, 
> NuclearMean=mean(a.Intensity_IntegratedIntensity_OrigGFP, trim=0.01), 
> CytoMean=mean(EstCytoIntensity, trim=0.01), 
> IntensityMean=mean(TotalIntensity, trim=0.01), 
> RatioMean=mean(NucToCytoRatio, trim=0.01))
> 
> # input file name
> name <- readline(prompt="give filename ")
> 
> #writes tables based on name given, both 'raw' containing all 
> information and 'mean' containing the image means
> 
> write.table(new, file=paste(name,"raw.csv", sep=""), row.names=FALSE, 
> sep=",")
> write.table (newmean, file=paste(name, "mean.csv", sep=""), 
> row.names=FALSE, sep=",")
> 
> #end
> 
> 
> 
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Pausing script to allow user input from keyboard.

2010-08-06 Thread jim holtman
Don't cut/paste; 'source' in the script.  readLines is trying to read
from stdin which is where the commands are being read from.  Using
'source' avoids that problem.  You can also look at some examples I
have seen using tk/tcl where you can bring up a window for user input.

On Fri, Aug 6, 2010 at 9:52 AM, Johnny Tkach  wrote:
> Hi all,
>
> I have written a simple R script to help me analyze a large data set.
> I would like to have the script pause to allow the user to input a
> character string that is subsequently used as a filename when saving
> tables.  I have tried to use the "readline" command - this seems to
> work fine when entering commands one by one, but when I copy and paste
> the entire script into R, it does not pause for input and just charges
> ahead writes the files.  Any help is appreciated, I've copied and
> pasted the script below.  Any help is appreciated - I am really new to
> R so if you can be as detailed as possible in your responses it would
> be greatly appreciated.
>
> Thanks,
>
> JT
>
> R version: R 2.11.1 GUI 1.34
> OS: OS 10.5.8
>
> Here's the script:
>
> #readfiles, "a" is nuclear measurements, "b" is cytoplasmic measurements
> a <- read.table(file.choose(), header=TRUE, sep=",")
> b <- read.table(file.choose(), header=TRUE, sep=",")
>
> #make a new data frame named "new" with important columns
> new <- data.frame(a$ImageNumber, a$AreaShape_Area, a
> $Intensity_IntegratedIntensity_OrigRFP, a
> $Intensity_IntegratedIntensity_OrigGFP, b
> $Intensity_MeanIntensity_OrigGFP)
>
> #make three new columns, "EstCytoIntensity" estimates Cytoplasmic
> intensity based on the mean measured intensity and an estimate of the
> nuclear volume to the cytoplasmic volume, "TotalIntensity" is the sum
> of the integrated nuclear intensity and estimated cytoplasmic
> intensity, "NucToCytoRatio" is the ratio of nuclear intensity divided
> by cytoplasmic intensity
> new$EstCytoIntensity <- b$Intensity_MeanIntensity_OrigGFP * (a
> $AreaShape_Area/0.3)
> new$TotalIntensity <- new$a.Intensity_IntegratedIntensity_OrigGFP + new
> $EstCytoIntensity
> new$NucToCytoRatio <- new$a.Intensity_IntegratedIntensity_OrigGFP / new
> $TotalIntensity
>
> #creates a table that determines the means for the measurements of all
> objects within an image
> library(plyr)
> newmean <- ddply(new, c("a.ImageNumber"), summarize,
> NuclearMean=mean(a.Intensity_IntegratedIntensity_OrigGFP, trim=0.01),
> CytoMean=mean(EstCytoIntensity, trim=0.01),
> IntensityMean=mean(TotalIntensity, trim=0.01),
> RatioMean=mean(NucToCytoRatio, trim=0.01))
>
> # input file name
> name <- readline(prompt="give filename ")
>
> #writes tables based on name given, both 'raw' containing all
> information and 'mean' containing the image means
>
> write.table(new, file=paste(name,"raw.csv", sep=""), row.names=FALSE,
> sep=",")
> write.table (newmean, file=paste(name, "mean.csv", sep=""),
> row.names=FALSE, sep=",")
>
> #end
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


[R] Partial Function Application

2010-08-06 Thread Mog
Hi. I would like to partially apply a function to a list of arguments,
and I don't know how to do this in R, without perhaps writing default
values to the formals() of my function, or writing to the environment
object of a function. For context, my definition of partially apply
is: "fix some of the arguments, leaving the others as variables,
return a new function that takes the un-fixed arguments from the
original function as arguments"

The issue is that I would like several different sets of arguments for
the "partially applied" phase, and I think that would involve copying
the function to several different places with the above methods.

Alternately, I could hard-code the partial applications using a
function() form, but I would prefer not to do this, as there will be a
sizable number of these closures needed and I'd prefer to automate the
process.

Thanks!

--Mog

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Pausing script to allow user input from keyboard.

2010-08-06 Thread Johnny Tkach
Hi all,

I have written a simple R script to help me analyze a large data set.   
I would like to have the script pause to allow the user to input a  
character string that is subsequently used as a filename when saving  
tables.  I have tried to use the "readline" command - this seems to  
work fine when entering commands one by one, but when I copy and paste  
the entire script into R, it does not pause for input and just charges  
ahead writes the files.  Any help is appreciated, I've copied and  
pasted the script below.  Any help is appreciated - I am really new to  
R so if you can be as detailed as possible in your responses it would  
be greatly appreciated.

Thanks,

JT

R version: R 2.11.1 GUI 1.34
OS: OS 10.5.8

Here's the script:

#readfiles, "a" is nuclear measurements, "b" is cytoplasmic measurements
a <- read.table(file.choose(), header=TRUE, sep=",")
b <- read.table(file.choose(), header=TRUE, sep=",")

#make a new data frame named "new" with important columns
new <- data.frame(a$ImageNumber, a$AreaShape_Area, a 
$Intensity_IntegratedIntensity_OrigRFP, a 
$Intensity_IntegratedIntensity_OrigGFP, b 
$Intensity_MeanIntensity_OrigGFP)

#make three new columns, "EstCytoIntensity" estimates Cytoplasmic  
intensity based on the mean measured intensity and an estimate of the  
nuclear volume to the cytoplasmic volume, "TotalIntensity" is the sum  
of the integrated nuclear intensity and estimated cytoplasmic  
intensity, "NucToCytoRatio" is the ratio of nuclear intensity divided  
by cytoplasmic intensity
new$EstCytoIntensity <- b$Intensity_MeanIntensity_OrigGFP * (a 
$AreaShape_Area/0.3)
new$TotalIntensity <- new$a.Intensity_IntegratedIntensity_OrigGFP + new 
$EstCytoIntensity
new$NucToCytoRatio <- new$a.Intensity_IntegratedIntensity_OrigGFP / new 
$TotalIntensity

#creates a table that determines the means for the measurements of all  
objects within an image
library(plyr)
newmean <- ddply(new, c("a.ImageNumber"), summarize,  
NuclearMean=mean(a.Intensity_IntegratedIntensity_OrigGFP, trim=0.01),  
CytoMean=mean(EstCytoIntensity, trim=0.01),  
IntensityMean=mean(TotalIntensity, trim=0.01),  
RatioMean=mean(NucToCytoRatio, trim=0.01))

# input file name
name <- readline(prompt="give filename ")

#writes tables based on name given, both 'raw' containing all  
information and 'mean' containing the image means

write.table(new, file=paste(name,"raw.csv", sep=""), row.names=FALSE,  
sep=",")
write.table (newmean, file=paste(name, "mean.csv", sep=""),  
row.names=FALSE, sep=",")

#end





[[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] Exporting nlme summary

2010-08-06 Thread Ronald Wendt
Thanks for all the help.  A nice and easy fix.

On Thu, Aug 5, 2010 at 6:36 PM, David Winsemius wrote:

>
> On Aug 5, 2010, at 6:22 PM, Jun Shen wrote:
>
> I believe this has been discussed many times in the archives. Here is
>> one way to do it.
>>
>
> Yes, you are so right.
>
>
>> Use function "sink" to direct the output to a file you specify
>>
>> sink( file='your file.txt')
>>>
>> after you execute this command, all the output will be saved to your
>> file and you won't see it on the screen. Say
>>
>>> summary(horton.nlme)
>>>
>>
>> give the output back to console
>>
>>> sink()
>>>
>>
> And one line that is equivalent to those three lines:
>
> capture.output( summary(horton.nlme) , file='your file.txt')
>
> -- David.
>
>
>> Hope this helps.
>>
>> Jun Shen
>> Senior Pharmacokineticist
>> Seventh Wave Labs
>>
>> On Thu, Aug 5, 2010 at 2:30 PM, Ronald Wendt  wrote:
>>
>>> I'm trying to export the results of my summary data for the object
>>> horton.nlme, but failing miserably.  Running summary(horton.nlme) works
>>> fine, but both write.table and write.csv return the error "cannot coerce
>>> class 'c("summary.lme", "nlme", "lme")' into a data.frame".
>>>
>>> I know I can copy and paste the output from the summary function, but
>>> it's
>>> ugly because the spacing between numbers and fields is minimal.
>>>
>>> Thanks for any help!
>>>
>>
>
> David Winsemius, MD
> West Hartford, CT
>
>


-- 
Ronald Wendt
Columbia University
Master of International Affairs Candidate, 2011
Economic and Political Development

[[alternative HTML version deleted]]

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


Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?

2010-08-06 Thread Tom Quarendon
a special license, so the
easiest thing is to stay with a GPL v2 compatible license.  If you don't
want to do that, then you could go ahead with some other license and see
what happens, but it might not be until your project becomes popular
that someone decides to take action.  So in the latter case I'd get a
legal opinion, not a mailing list opinion, before I invested a lot of
time or money.

Duncan Murdoch

> I've looked at various threads on the r-devel archive and it looks like this 
> may have been discussed before, but as far as could tell, not to any great 
> resolution, and not, it seems, specifically covering this angle.
>
>
>
> In the doc\COPYRIGHTS file it is made clear that the intention is that you 
> can write R packages that include functions implemented in C (and hence are 
> provided in native libraries linked to R.dll) and distribute them under 
> licenses not compatible with GPL. This was achieved by making the relevant 
> header files available under the LGPL. This was an explicit change that was 
> made in February 2001, and the intention was to allow for DLLs that require 
> the API header files for compilation and are linked against R.dll to not be 
> "infected" with the GPL.
>
> However the Rembedded.h header file isn't included in the list in the 
> doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header 
> file lists the GPL and not the LGPL as the relevant license.  So it doesn't 
> look like it was the intention to allow that I be able to use the R 
> invocation API to launch R and embed it in a product (such as a new GUI, or 
> other such integration) and ship that product under a license not compatible 
> with GPL. Is this correct? Or is it the intention that I be able to write a 
> commercial front-end of some kind for R?
>
>
>
> My understanding of LGPL is that ALL of the source files that go into R.dll 
> (and indeed all libraries that R.dll itself linked to, apart from those 
> covered by the GPL system library exception) would need to be released under 
> LGPL in order to allow me to link to R.dll and not have my program subject to 
> GPL. If that weren't the situation then I could take a library covered by 
> GPL, write a different interface to it, put LGPL on those headers compile up 
> a new DLL and I've then got LGPL access to a library previously released 
> under GPL, which can't be the intention, otherwise LGPL would drive a coach 
> and horses through GPL. This would apply to native libraries (dlls) providing 
> functions in addon packages too, and so hence I'm not sure I necessarily 
> understand how simply putting LGPL on the header files is sufficient to 
> achieve the intention.
>
>
>
> There is provision in the GPL license (it's mentioned in the FAQ) for 
> providing for linking to a GPL library through one specific interface by 
> providing specific exception text in the copyright header in all of the files 
> that make up the library. That would only be possible if the copyright 
> holders of all relevant GPL code agreed to that, as that would be an extra 
> grant to the license. So if R linked to any third party GPL code, this 
> wouldn't be possible I don't think.
>
> So I guess the question here is what the intention is of the R foundation 
> with respect to the limitations or freedoms that they are intending to allow. 
> After all, as the copyright owners they aren't going to sue if a use falls 
> within their intention, even if on a strict interpretation of the license 
> such use wouldn't be allowed.
>
>
>
> So it seems to be the intention that I can write a DLL to provide R functions 
> in an add on package, which requires linkage to R.dll. Not convinced that the 
> license it set up right to cover that, but that appears to be the intention. 
> Question is whether at the other end, at the invocation API end, whether it 
> is the intention to be able to use the invocation API and link to R.dll 
> without my program being subjected to GPL.
>
>
>
> Note that I'm not talking here about anything to do with code written in the 
> language of R. This is purely concerned with treating R as a library with an 
> interface and wanting to link to that interface and whether the intention or 
> the actuality of the license allow that.
>
>
>
> Thanks!
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org<mailto:R-help@r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> 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 %nin% operator?

2010-08-06 Thread Kevin Wright
There's many additional operators defined in the mvbutils package, including
%!in%.

Kevin


On Thu, Aug 5, 2010 at 10:25 AM, David Huffer wrote:

> See Harrell's Hmisc package
>
> --
>  David Huffer, Ph.D.
>  Deputy Director
>  CSOSA/ORE
>  Washington, DC
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Ken Williams
> Sent: Thursday, August 05, 2010 11:20 AM
> To: r-help@r-project.org
> Subject: [R] A %nin% operator?
>
> Sometimes I write code like this:
>
> > qf.a <- subset(qf, pubid %in% c(104, 106, 107, 108)) qf.b <-
> > subset(qf, !pubid %in% c(104, 106, 107, 108))
>
> and I get a little worried that maybe I've remembered the precedence
> rules wrong, so I change it to
>
> > qf.a <- subset(qf, pubid %in% c(104, 106, 107, 108)) qf.b <-
> > subset(qf, !(pubid %in% c(104, 106, 107, 108)))
>
> and pretty soon my code looks like fingernail clippings (or Lisp) and
> I'm thinking about precedence rather than my original task.  So I write
> a %nin% operator which I define as:
>
> > `%nin%` <- function (x, table) match(x, table, nomatch = 0L) == 0L
>
> and then I'm happy again.
>
> I wonder, would something like this find a home in core R?  Or is that
> too much syntactic sugar for your taste?
>
> --
> Ken Williams
> Sr. Research Scientist
> Thomson Reuters
> Phone: 651-848-7712
> ken.willi...@thomsonreuters.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.
>



-- 
Kevin Wright

[[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] Tobit Modelling

2010-08-06 Thread Cristian Montes
Hi Patrick

Here is some code that might help you implement your tobit regression, if you 
don´t mind
using maximum likelihood.

#first declare a likelihood function with a censored model
#assume your x2 is censored for values below -1, and using a simple
#linear model in this case.  Our censoring threshold will be z.


YOURX1 = c(1,2,3,4,6,7,8,9,10,11)
YOURX2 = c(-1,-1,-1,-1,2.2,3.1,6.4,7, 7.2,8)

loglik <- function(param, x1, x2, z)
{
b0<- param[1]
b1<- param[2]
sigma <- param[3]

result <-  ifelse(x2 >z, dnorm(x2, b0 + b1 * x1, sigma, log = 
T),
  pnorm((z-b0+b1*x1)/sigma, log = T))
return(sum(result))
}


regression <- optim( par= c(-3,1,1),
   fn  = loglik,
   method  = "L-BFGS-B",
   lower   = c(-Inf, -Inf, 1e-10),  #bound solution for 
b0 and b1 to be any, but sigma >0
   x1  = YOURX1,
   x2  = YOURX2,
   z   = -1,
control = list(fnscale = -1))  #maximize likelihood 
   
   
plot(YOURX2 ~ YOURX1)
abline(a=regression$par[1], b= regression$par[2])
abline(lm (YOURX2~YOURX1), lty= 2)


The key here is that you are analyzing the likelihood for your x2 with 
different probabilities.
The code above was implemented for nonlinear regression, so you can put any 
model you want with
minor changes and it will work identically.  

Cheers,

Cristian.

-
Cristian Montes
Site Productivity Division Head
Bioforest S.A.

-Mensaje original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En 
nombre de Patrick Sessford
Enviado el: Jueves, 05 de Agosto de 2010 08:42 p.m.
Para: r-help@r-project.org
Asunto: [R] Tobit Modelling



Dear R-users,

I would like to model data where the response variable consists of many minus 
ones and many different positive values that seem to follow an apparently 
separate distribution (ie. -1, -1, 0.5, -1, 3, 3.5, 1.2, -1, -1, 0.4, etc); no 
values of the response can be less than minus one or between minus and zero 
(exclusive).

I am aware of tobit regression but unaware of exactly how to implement it in R. 
If anyone is able to help me on this issue I'd be extremely grateful; for 
example, if my (continuous) explanatory variables were x1 and x2, how should I 
define the model?

Thank you for your time.

Pat

  
[[alternative HTML version deleted]]

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

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


Re: [R] data.frame: return all rows where at least one...

2010-08-06 Thread Tal Galili
One solution -

let's say our data.frame is "xx"
Then:

xx <- matrix(rnorm(9), 3,3)
apply(xx < 0, 1, any)





Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Aug 6, 2010 at 4:03 PM, Werner W.  wrote:

> Hi,
>
> I know ways to do this but they all seem awkward and I somehow believe that
> there is a convenient shortcut.
>
> If I have a data.frame with many columns, how can I request all rows for
> which
> at least one column satisfy an expression?
>
> For instance, all rows where at least one column is negative.
>
> Many thanks,
>  Werner
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Problems using external BLAS

2010-08-06 Thread Bjørn-Helge Mevik
I have problems building R 2.11.1 with an external BLAS.  I've tried
several with several libraries:

# ACML:
export LD_LIBRARY_PATH=/site/VERSIONS/acml-3.6.0/gfortran64_int64/lib
BLAS=--with-blas="-L/site/VERSIONS/acml-3.6.0/gfortran64_int64/lib -lacml"
LAPACK=--with-lapack

# MKL 11:
BLAS=--with-blas="-L/site/VERSIONS/intel-11.1/mkl/lib/em64t -lmkl_gf_lp64 
-lmkl_sequential -lmkl_lapack -lmkl_core"
LAPACK=--with-lapack

# MKL 8.1, trad. way:
BLAS=--with-blas="-L/site/intel/cmkl/8.1/lib/em64t -lmkl -lvml -lguide 
-lpthread"
LAPACK=--with-lapack

I configure R like this:

export CFLAGS="-O3 -mtune=opteron"
export FFLAGS="-O3 -mtune=opteron"
export CXXFLAGS="-O3 -mtune=opteron"
export FCFLAGS="-O3 -mtune=opteron"

./configure --prefix="/site/VERSIONS/R-2.11.1" \
  "$BLAS" "$LAPACK" \
  --enable-R-shlib

In all cases, I get

configure:29120: checking whether double complex BLAS can be used
configure:29206: result: no

The conftestf.f and conftest.c seem to compile fine, but exit status
from conftest in line 29181 of configure is nonzero.

This is on a Quad-Core AMD Opteron node running CentOS 5.2, with gcc and
gfortran version 4.1.2 20071124 (Red Hat 4.1.2-42)

(I have also tried without the *FLAGS variables, and without
--with-lapack.  The result is the same.)

(We have successfully built older versions of R with MKL 8.1 earlier, but
with intel compilers v. 10.1, using
./configure --prefix="/site/VERSIONS/R-$version" \
  --with-blas="-L/site/intel/cmkl/8.1/lib/em64t -lmkl -lvml -lguide -lpthread" \
  --with-lapack="-L/site/intel/cmkl/8.1/lib/em64t -lmkl_lapack64 -lmkl" \
  --enable-R-shlib
but we wanted to switch to gcc because not all R packages compile with icc.)

Does anyone have any idea about what could be wrong?


-- 
Regards,
Bjørn-Helge Mevik

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


Re: [R] data.frame: return all rows where at least one...

2010-08-06 Thread Erik Iverson

On 08/06/2010 08:03 AM, Werner W. wrote:

Hi,

I know ways to do this but they all seem awkward and I somehow believe that
there is a convenient shortcut.



Since you don't show us what you tried, I don't know what you consider 
'awkward'.



If I have a data.frame with many columns, how can I request all rows for which
at least one column satisfy an expression?

For instance, all rows where at least one column is negative.


A small, reproducible example in R is far better to work from than English 
descriptions.


Does your data.frame consist entirely of numeric variables?  It sounds like it,
in which case, you can use apply, which will coerce your data.frame to a matrix.

df1 <- data.frame(...)

df1[apply(df1, 1, function(x) any(x) < 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] data.frame: return all rows where at least one...

2010-08-06 Thread Werner W.
Hi,

I know ways to do this but they all seem awkward and I somehow believe that 
there is a convenient shortcut.

If I have a data.frame with many columns, how can I request all rows for which 
at least one column satisfy an expression? 

For instance, all rows where at least one column is negative.

Many thanks,
  Werner




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