Re: [R] a rounding option for \Sexpr{}?

2010-11-19 Thread Dieter Menne


Yihui Xie-2 wrote:
 
 
 Currently Sweave does not format the (especially numeric) value in
 \Sexpr{}, and I often have to round() the numbers explicitly,
 otherwise I will get more than 10 digits, which is not necessary for
 me in most cases. Is there a way to specify the number of digits to be
 kept for values in \Sexpr{}? e.g. can we make \Sexpr{} respect
 getOption('digits')?
 
 

Currently, Sweave does an eval on Sexpr, and that can be anything other than
a number (is mostly is, though). And you cannot define a new version of
Sexpr in latex, because Sexpr only looks like latex, but is processed before
texing.

My solution is to always do the rounding and formating in the R chunk (e.g.
with latexSN of Hmisc) to unclutter the Sexpr.

Dieter




-- 
View this message in context: 
http://r.789695.n4.nabble.com/a-rounding-option-for-Sexpr-tp3049872p3050001.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] latex tables with quantreg

2010-11-19 Thread Dieter Menne


Frank Black-2 wrote:
 
 
 I'm using the quantreg package to run some regressions. I'm trying to save
 the output as latex tables using the helpful latex command, which works
 fine. However, I've been unable to modify its behavior in some ways I'm
 insterested in. For instance, I'd like a table in which I had the
 asterisks
 corresponding to the significance levels of each variable, but I have been
 unable to find how to do it.
 
 

For some other models (lm, glm, lme), I have made some customizations (using
well-formatted p-values, asterisks are a bit outdated and not loved by most
journals). You can download the source from 

http://www.menne-biomed.de/download/Dmisc_1.2.1.tar.gz

Check, for example, latex.lm.R

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/latex-tables-with-quantreg-tp3049844p3050027.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] conditional mean between two data frames with different levels

2010-11-19 Thread albechan

Thank you so much Josh, that's exactly what i needed!
Cheers
alb
-- 
View this message in context: 
http://r.789695.n4.nabble.com/conditional-mean-between-two-data-frames-with-different-levels-tp3049010p3049980.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 number of patients at risk below survival curve

2010-11-19 Thread Dieter Menne


Thorsten Raff wrote:
 
 
 does anyone know of a R-package that has implemented the increasingly
 popular
 inclusion of the number of patients at risk below Kaplan-Meier curves like
 in
 
 http://bloodjournal.hematologylibrary.org/content/vol116/issue19/images/large/zh89991058760001.jpeg
 

survplot in Frank Harrell's package Design (looks like the example was
created with it).

Dieter

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-number-of-patients-at-risk-below-survival-curve-tp3048900p3050032.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] profile in lme4 and lme4a/lme4b

2010-11-19 Thread Niccolò Bassani
Dear R-users,
from Douglas Bates lme4 book I'm trying to run profile() on a quite large
dataset, in order to have some confidence intervals on random effects
parameter in mixed models. When I run it in lme4 however I'm faced with the
following error:

Errore in UseMethod(profile) :
  no applicable method for 'profile' applied to an object of class mer

Surfing on R-help mailing lists I understood that this has to do with some
compatibility problems which are undergoing development for next version of
the lme4 package, right? Also, I found that this function is active in the
development packages lme4a and lme4b, available from R-forge...

I was trying to install these packages, at least to have profile() running.
I've tried different ways for doing this but I'm stuck in a blind
alley...I've tried the following (all suggestions from R users found on the
Internet):

- install.packages(lme4a, repos=http://R-Forge.R-project.org;)

returning  Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘lme4a’ is not available

- installing binary file directly in the .libpaths directory, but: lme4a
binary for MAC can not be retrieved on the web (page not found), and lme4b
gives similar problem.

Now only installing package from source files remain, but this does not seem
so easy...at least not for me!
I have a Macbook Pro (running Mac OS/X 10.6.4 with Leopard)...

Any help is appreciated, since previous talks on R mailing list kind of
confused me much!!

thanx in advance
niccolò

[[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: how do I build panel data/longitudinal data models with AR terms using the plm package or any other package

2010-11-19 Thread Millo Giovanni
Hello Jude.
Please find my remarks below, with '##'



Da: Jude Ryan [mailto:jr...@marketsharepartners.com] 
Inviato: giovedì 18 novembre 2010 23:52
A: R-help@r-project.org
Cc: yves.croiss...@univ-reunion.fr; Millo Giovanni
Oggetto: how do I build panel data/longitudinal data models with AR terms using 
the plm package or any other package



Hi All,



I am doing econometric modeling of panel data (fixed effects). We currently use 
Eviews to do this, but I have discovered a bug in Eviews 7 and am exploring the 
use of R to build panel data models / longitudinal data models. I looked at the 
plm package but do not see how I can incorporate AR terms in the model using 
the plm package.  



## Two possible meanings here: either you want autoregressive y or 
autoregressive errors

1) y = rho1*y(-1) + rho2*y(-2) + Xb + e 

 or

2) y = Xb + u, u = rho1*u(-1) + rho2*u(-2) 



1) is easy: just use lags, like 

 fm - y ~ lag(y) + lag(y,2) + x

but be aware of the Nickell bias: your estimator needs T-asymptotics.



 I have an Eviews model with two AR terms, AR(1) and AR(2),  



## ...then, chances are you want 2) ! all my other remarks below apply to this 
second case (while 1) would fail for lack of strict endogeneity)



 and I am trying to replicate that model using R (and SAS too, if possible) as 
the fitted values in Eviews for panel data (fixed effects) appear to be wrong. 
In Eviews I tried a second approach and explicitly coded the fixed effects as 
dummy variables but the standard errors I get are very different from using the 
panel data options in Eviews, and thus the final model selected could be very 
different based on these two approaches. 



Can I incorporate AR terms in a panel data model using the plm package, and if 
so, how?  



## As of now, no. We plan to add feasible AR(1) à la Baltagi, but it won't be 
tomorrow. This is also because ---



 Also, are there any other packages like nlme, lme4, .. that will let me build 
panel data models / longitudinal data models with AR terms?  



## Yes. You can try 'nlme' and its newer sibling 'lme4'. I'm sure it can do 
random effects + AR(1), and sure you can put in the FEs as dummies; there are 
probably more elegant solutions but I'm not that familiar with it myself. For 
an introduction from the econometrician's viewpoint, see here 
http://www.jstatsoft.org/v27/i02 Ch. 7



 Do any of these packages let you build panel data models / longitudinal data 
models specifying both AR and MA terms? Looking at the ACF and PCAF it seems 
that some of the error processes are best/more compactly represented by a 
combination of AR and MA terms, but unfortunately Eviews only lets you use AR 
terms for panel data and getting rid of the cross-sections in the panel data 
and building ARIMA models, which let you specify both AR and MA terms for the 
error process, will mean building separate models for each cross-section. 
Besides, we do not have that much data to build time series models and panel 
data methods let us circumvent the limited data issue.  



## The issue here is, of course, cross-sectional poolability. The ARMA process 
in the errors should be the same for each individual. I am confident that you 
may find something in 'nlme''s rich error covariance structures. If you do, 
another possibility to get rid of the FEs and use standard methods is using 
first-difference data (but of course this modifies the errors' covariance 
specification, and you should reparameterize it).



It is my understanding (but I could be wrong) that some of the SAS procs, like 
HPMIXED, let you specify only one AR term for panel data so I am hoping there 
is some R package that will let me replicate what I can do in Eviews, and 
possibly even go beyond what Eviews can do by specifying both AR and MA terms. 



## If you're comfortable with ML, you could as well try to  write down the 
likelihood and optimize it. There are facilities in package 'maxLik'.



Thanks in advance for your time,



Jude Ryan

MarketShare Partners

1270 Avenue of the Americas, Suite # 2702

New York, NY 10020

http://www.marketsharepartners.com

Work: (646)-745-9916 ext: 222

Cell: (973)-943-2029 



## No ready solutions, sorry. HTH,

Giovanni



Giovanni Millo
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Italy)
tel. +39 040 671184
fax  +39 040 671160 






[[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 tables with quantreg

2010-11-19 Thread Frank Black
Ok, thank you very much, I'll try it.

Kind regards,
Emili

2010/11/19 Dieter Menne dieter.me...@menne-biomed.de



 Frank Black-2 wrote:
 
 
  I'm using the quantreg package to run some regressions. I'm trying to
 save
  the output as latex tables using the helpful latex command, which works
  fine. However, I've been unable to modify its behavior in some ways I'm
  insterested in. For instance, I'd like a table in which I had the
  asterisks
  corresponding to the significance levels of each variable, but I have
 been
  unable to find how to do it.
 
 

 For some other models (lm, glm, lme), I have made some customizations
 (using
 well-formatted p-values, asterisks are a bit outdated and not loved by most
 journals). You can download the source from

 http://www.menne-biomed.de/download/Dmisc_1.2.1.tar.gz

 Check, for example, latex.lm.R

 Dieter


 --
 View this message in context:
 http://r.789695.n4.nabble.com/latex-tables-with-quantreg-tp3049844p3050027.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Question on overdispersion

2010-11-19 Thread ONKELINX, Thierry
Dear Nameless,

The quasi distribution can no longer be used in lme4 because a) the
results were not very reliable b) there is an alternative to model
overdispersion.

The alternative is to expand your dataset to bernoulli trials. Then add
a random effect with one level per observation. This random effect will
model additive overdisperion. The quasi distributions model
overdisperion multiplicative.

In the example below, the random effect of RowID has 0 variance. Hence
no overdispersion.

dataset - data.frame(
male_chick_no = c(2,4,1,0,3,5,2), 
female_chick_no=c(1,0,3,3,1,0,2), 
FemaleID=c(A,A,B,B,C,D,E))

longFormat - do.call(rbind, lapply(seq_len(nrow(dataset)), function(i){
with(dataset, data.frame(Sex = c(rep(M, male_chick_no[i]),
rep(F, female_chick_no[i])), FemaleID = FemaleID[i]))
}))
longFormat$FemaleID - factor(longFormat$FemaleID)
longFormat$RowID - factor(seq_len(nrow(longFormat)))
longFormat$Male - longFormat$Sex == M

library(lme4)
fit1 - glmer(Male ~ (1|FemaleID), data = longFormat, family = binomial)
fit2 - glmer(Male ~ (1|FemaleID) + (1|RowID), data = longFormat, family
= binomial)
anova(fit1, fit2)

Best regards,

Thierry

PS sig-mixed-models is a better mailinglist for this kind of questions.



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

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

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

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

The plural of anecdote is not data.
~ Roger Brinner

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

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] Namens cct663
 Verzonden: vrijdag 19 november 2010 5:39
 Aan: r-help@r-project.org
 Onderwerp: [R] Question on overdispersion
 
 
 I have a few questions relating to overdispersion in a sex 
 ratio data set that I am working with (note that I already 
 have an analysis with GLMMs for fixed effects, this is just 
 to estimate dispersion). The response variable is binomial 
 because nestlings can only be male or female. I have samples of
 1-5 nestlings from each nest (individuals within a nest are 
 not independent, so the response variable is the ratio of 
 sons to daughters) and some females have multiple nests in 
 the data set (so I need to include female identity as a 
 random effect). 
 
 Here is an example of what the three vectors used in the 
 model look like (the real data set is much bigger, just to 
 illustrate what I'm talking
 about):
 
 male_chick_no=c(2,4,1,0,3,5,2)
 female_chick_no=c(1,0,3,3,1,0,2)
 FemaleID=c(A,A,B,B,C,D,E)
 
 My first question relates to coding the test in R. I received 
 this suggested R syntax from a reviewer:
 
 SexRatio = cbind(male_chick_no, female_chick_no)
 
 Model - lmer(SexRatio ~ 1 +(1|FemaleID), family = quasibinomial)
 
 But when I try to use this in R I get the error: Error in 
 glmer(formula = ratio ~ 1 + (1 | femid), family = 
 quasibinomial) : quasi families cannot be used in glmer.
 
 I've tried playing around with some other mixed model 
 functions but can't seem to find one that will provide an 
 estimate of dispersion and allow me to include my random effect. 
 
 Is there some other function I should be using? Or is there a 
 different syntax that I should use for lmer?
 
 My second question is more general: I understand that with 
 binomial data overdispersion suggests that the observed data 
 have a greater variance than expected given binomial errors 
 (in my case this means that more nests would be all male/all 
 female than expected if sex is random). So with binomial 
 errors the expected estimate of dispersion is 1, if I find 
 that dispersion is  1 it suggests that my data are 
 overdispersed. My question is, how much greater than 1 should 
 that number be to conclude that the data are overdispersed? 
 Is there a rule of thumb or does it just depend on the dataset? 
 
 I was thinking of doing a randomization test with the same 
 structure (nest size and female id) as my real data set but 
 with sex ratio of each nest randomized with a 50:50 chance of 
 individuals being sons or daughters and comparing my observed 
 dispersion to the distribution of dispersions from the 
 randomization test. Would this be a valid way to ask whether 
 my data are overdispersed? Is it even necessary?
 
 Any help/advice that you can provide would be greatly 
 appreciated. I am relatively new to R so explicit 
 

[R] Calculating distance between longitude,latitude of 2 points

2010-11-19 Thread Lily_stats

Hi all, 

I would like to know a way of calculating the distance between 2 points when
I already have the longitude and latitude of the points.

For example :

Point 1 :  52° 9'54.00N  4°25'8.40E
Point 2 :  52°27'46.80N  4°33'18.00E

Distance between point 1 and point in km 

Is there any functions already available for this ?

Any help will be much appreciated! 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Calculating-distance-between-longitude-latitude-of-2-points-tp3050123p3050123.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] [R-sig-ME] Question on overdispersion

2010-11-19 Thread Jarrod Hadfield

Hi Thierry + nameless,

It is not necessary to expand the binomial into Bernoulli trials (nor  
advisable if n and/or the binomial size are large). You can just fit  
observation-level random effects:


dataset$resid-as.factor(1:dim(dataset)[1])

fit3 - glmer(cbind(male_chick_no, female_chick_no) ~ 1+(1|FemaleID)+  
(1|resid), data = dataset, family = binomial)


gives the same answer as fit2

Cheers,

Jarrod






Quoting ONKELINX, Thierry thierry.onkel...@inbo.be:


Dear Nameless,

The quasi distribution can no longer be used in lme4 because a) the
results were not very reliable b) there is an alternative to model
overdispersion.

The alternative is to expand your dataset to bernoulli trials. Then add
a random effect with one level per observation. This random effect will
model additive overdisperion. The quasi distributions model
overdisperion multiplicative.

In the example below, the random effect of RowID has 0 variance. Hence
no overdispersion.

dataset - data.frame(
male_chick_no = c(2,4,1,0,3,5,2),
female_chick_no=c(1,0,3,3,1,0,2),
FemaleID=c(A,A,B,B,C,D,E))

longFormat - do.call(rbind, lapply(seq_len(nrow(dataset)), function(i){
with(dataset, data.frame(Sex = c(rep(M, male_chick_no[i]),
rep(F, female_chick_no[i])), FemaleID = FemaleID[i]))
}))
longFormat$FemaleID - factor(longFormat$FemaleID)
longFormat$RowID - factor(seq_len(nrow(longFormat)))
longFormat$Male - longFormat$Sex == M

library(lme4)
fit1 - glmer(Male ~ (1|FemaleID), data = longFormat, family = binomial)
fit2 - glmer(Male ~ (1|FemaleID) + (1|RowID), data = longFormat, family
= binomial)
anova(fit1, fit2)

Best regards,

Thierry

PS sig-mixed-models is a better mailinglist for this kind of questions.



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

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

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

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

The plural of anecdote is not data.
~ Roger Brinner

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



-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] Namens cct663
Verzonden: vrijdag 19 november 2010 5:39
Aan: r-help@r-project.org
Onderwerp: [R] Question on overdispersion


I have a few questions relating to overdispersion in a sex
ratio data set that I am working with (note that I already
have an analysis with GLMMs for fixed effects, this is just
to estimate dispersion). The response variable is binomial
because nestlings can only be male or female. I have samples of
1-5 nestlings from each nest (individuals within a nest are
not independent, so the response variable is the ratio of
sons to daughters) and some females have multiple nests in
the data set (so I need to include female identity as a
random effect).

Here is an example of what the three vectors used in the
model look like (the real data set is much bigger, just to
illustrate what I'm talking
about):

male_chick_no=c(2,4,1,0,3,5,2)
female_chick_no=c(1,0,3,3,1,0,2)
FemaleID=c(A,A,B,B,C,D,E)

My first question relates to coding the test in R. I received
this suggested R syntax from a reviewer:

SexRatio = cbind(male_chick_no, female_chick_no)

Model - lmer(SexRatio ~ 1 +(1|FemaleID), family = quasibinomial)

But when I try to use this in R I get the error: Error in
glmer(formula = ratio ~ 1 + (1 | femid), family =
quasibinomial) : quasi families cannot be used in glmer.

I've tried playing around with some other mixed model
functions but can't seem to find one that will provide an
estimate of dispersion and allow me to include my random effect.

Is there some other function I should be using? Or is there a
different syntax that I should use for lmer?

My second question is more general: I understand that with
binomial data overdispersion suggests that the observed data
have a greater variance than expected given binomial errors
(in my case this means that more nests would be all male/all
female than expected if sex is random). So with binomial
errors the expected estimate of dispersion is 1, if I find
that dispersion is  1 it suggests that my data are
overdispersed. My question is, how much greater than 1 should
that number be to conclude that the data are overdispersed?
Is there a rule of thumb or does it just depend on the dataset?

I was thinking of doing a randomization test with the same
structure (nest size and female id) as my real data set but
with sex ratio of each nest randomized 

Re: [R] Playwith-problem with loading

2010-11-19 Thread Fencl, Martin
At the end it seems to be that the failure of R is not connected with instaling 
GTK+, because it occures after loading playwith library no matter if I confirm 
the GTK+ installation or not.  In fact it does not fail imediatelly you can 
even continue to input commands to the comand line but it fails after scolling 
left e.g. to see some longer expression.

The error message looks like this: R for Windowa GUI front-end has encountered 
a problem and needs to close

The details of error are specified like this: AppName: rgui.exe 
AppVer: 2.120.53317.0   ModName: msvcrt.dll  ModVer: 7.0.2600.5512  Offset: 
00037fd4

If I confirm the instalation of GTK+ after calling the library playwith it the 
instalation proceed (the GTK2-Runtime with banch of dll files occures on 
disk) but I cannot say if it is really completed  succesfuly.

After running the R again and calling the playwith library the same problem 
occurs no matter if there is GTK+ installed or not.

Thanks,
Martin





From: Michael Lawrence [lawrence.mich...@gene.com]
Sent: 18 November 2010 23:26
To: Fencl, Martin
Cc: r-help@r-project.org
Subject: Re: [R] Playwith-problem with loading

On Tue, Nov 16, 2010 at 10:59 AM, Fencl, Martin 
martin.fe...@eawag.chmailto:martin.fe...@eawag.ch wrote:
Helllo,
I am having trouble with running the library Playwith in the R-2.12.0. running 
under 32bit Windows XP. After calling the library the error message The 
procedure entry point gdk_cairo_reset_clip could not be located in the dynamic 
library libgdk-win32-2.0-0.dll. occurs and the R asks for instaling the GTK+ 
package. However the instalation of GTK+ thorugh the R fails. I have installed 
GTK+ by installing GIMP 2.0 version 2.6.10 and set the path of environment 
variables. But it still does not work. It seems to be that the problem is in 
gtk2 (which I also installed).
Thank you for any hints!


The GIMP binary of GTK+ has been known not to work well with R, and probably 
simply is not new enough in this case. What do you mean the GTK+ installer 
fails? Some details on that would be helpful.

Thanks,
Michael



 library(playwith)
Loading required package: lattice
Loading required package: cairoDevice
Loading required package: gWidgetsRGtk2
Loading required package: gWidgets
Error in inDL(x, as.logical(local), as.logical(now), ...) :
 unable to load shared object 
'C:/PROGRA~1/R/R-212~1.0/library/RGtk2/libs/i386/RGtk2.dll':
 LoadLibrary failure:  The specified procedure could not be found.


Failed to load RGtk2 dynamic library, attempting to install it.
trying URL 
'http://downloads.sourceforge.net/gtk-win/gtk2-runtime-2.22.0-2010-10-21-ash.exe?download'
Content type 'application/x-msdos-program' length 7820679 bytes (7.5 Mb)
opened URL
downloaded 7.5 Mb

Learn more about GTK+ at http://www.gtk.org
If the package still does not load, please ensure that GTK+ is installed and 
that it is on your PATH environment variable
IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN
Error : .onAttach failed in attachNamespace() for 'gWidgetsRGtk2', details:
 call: .Call(name, ..., PACKAGE = PACKAGE)
 error: C symbol name S_gtk_icon_factory_new not in DLL for package RGtk2
Error: package 'gWidgetsRGtk2' could not be loaded


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

2010-11-19 Thread Robert Ruser
Hello R Users,
I have vectors
x - c(a2,b7,c8)
y1 - c(1,2,3,2)
y2 - c(4,2,7,5,4,3,8)
y3 - c(1:10)
and I want to assign values form vector y1 to a new variable which
name comes from the 1st value of the vector x etc. How to do it using
only vector x.  As a result I should have:
a2 - y1
b7 - y2
c8 - y3

More general problem: I have 2 txt files.
First is a one column
C4
C6
F
D
D1
D2
D5
D6

Second is (non-define number of columns):
44, 60, 65, 139, 138
47
48
49, 46
.
is it possible to automatically assign:
C4 - c(44, 60, 65, 139, 138)
C6 - c(47)
...

I would appreciate for any help.

Robert

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


Re: [R] profile in lme4 and lme4a/lme4b

2010-11-19 Thread Dennis Murphy
Hi:

2010/11/19 Niccolò Bassani biostatist...@gmail.com

 Dear R-users,
 from Douglas Bates lme4 book I'm trying to run profile() on a quite large
 dataset, in order to have some confidence intervals on random effects
 parameter in mixed models. When I run it in lme4 however I'm faced with the
 following error:

 Errore in UseMethod(profile) :
  no applicable method for 'profile' applied to an object of class mer

 Surfing on R-help mailing lists I understood that this has to do with some
 compatibility problems which are undergoing development for next version of
 the lme4 package, right? Also, I found that this function is active in the
 development packages lme4a and lme4b, available from R-forge...


If you were surfing on R-mixed-models, you should have discovered somewhere
along the way that the release version of lme4 on CRAN does not have (m?)any
of the experimental functions in the first draft of Prof. Bates' book. The
code/functions corresponding to the book in progress reside in package lme4a
on R-forge and much, if not all, of it is in active development and subject
to change (both in the book and the code). lme4b is not intended for general
use, if I've read Prof. Bates' meaning from past posts correctly.

I don't know what you infer by 'compatibility problems', but my
understanding is that the eventual goal is to have an integrated
computational platform that provides a unified way of modeling [non]linear
[generalized] mixed effects problems. Considering that the theory itself is
in quite active development, this project is very ambitious in scope.
Because it's bleeding edge methodology, I understand why Prof. Bates is
loath to add new features to the release version lme4 until they meet his
performance standards on the computational side and whatever issues exist on
the methodological side are more or less resolved, since his name is on it.
I trust his judgment in these matters.

Moreover, Prof. Bates does his development work in Linux, so binaries for
Windows and Macs are not always completely up to date. He has also mentioned
several times this term that his teaching schedule gives him little
opportunity to make substantial progress re development and maintenance of
lme4(a). Such is life on the bleeding edge.

The operative word here is patience. I'm certain that when he has the time
to do so, the binaries for non-Linux platforms will be updated and reported
here and/or R-mixed-models.

With thanks to Prof. Bates for all the great work he's done on this project
and many others,

Dennis


 I was trying to install these packages, at least to have profile() running.
 I've tried different ways for doing this but I'm stuck in a blind
 alley...I've tried the following (all suggestions from R users found on the
 Internet):

 - install.packages(lme4a, repos=http://R-Forge.R-project.org;)

 returning  Warning message:
 In getDependencies(pkgs, dependencies, available, lib) :
  package ‘lme4a’ is not available

 - installing binary file directly in the .libpaths directory, but: lme4a
 binary for MAC can not be retrieved on the web (page not found), and lme4b
 gives similar problem.

 Now only installing package from source files remain, but this does not
 seem
 so easy...at least not for me!
 I have a Macbook Pro (running Mac OS/X 10.6.4 with Leopard)...

 Any help is appreciated, since previous talks on R mailing list kind of
 confused me much!!

 thanx in advance
 niccolò

[[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] Plotting number of patients at risk below survival curve

2010-11-19 Thread t . raff
Dear Dieter,

thanks a lot, that was exactly what I was looking for.

Best regards

Thorsten

 From: Dieter Menne dieter.menne_at_menne-biomed.de
 Date: Fri, 19 Nov 2010 00:36:58 -0800 (PST)

 Thorsten Raff wrote:


 does anyone know of a R-package that has implemented the increasingly
 popular
 inclusion of the number of patients at risk below Kaplan-Meier curves
 like in

 http://bloodjournal.hematologylibrary.org/content/vol116/issue19/images/large/zh89991058760001.jpeg


 survplot in Frank Harrell's package Design (looks like the example was
 created with it).

 Dieter


-- 
Thorsten Raff
2nd Medical Department,
University Hospital Schleswig-Holstein, Campus Kiel
Chemnitzstraße 33
24116 Kiel
GERMANY

phone: +49 431 1697-5234
fax:   +49 431 1697-1264

email: t.raffatmed2.uni-kiel.de
web:   www.uk-sh.de




-- 
Thorsten Raff
2nd Medical Department,
University Hospital Schleswig-Holstein, Campus Kiel
Chemnitzstraße 33
24116 Kiel
GERMANY

phone: +49 431 1697-5234
fax:   +49 431 1697-1264

email: t.raffatmed2.uni-kiel.de
web:   www.uk-sh.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] assigment

2010-11-19 Thread Joshua Wiley
Hi Robert,

What about a named list?  This will generalize to your two text files
one with data, the other with names.

x - c(a2,b7,c8)
y1 - c(1,2,3,2)
y2 - c(4,2,7,5,4,3,8)
y3 - c(1:10)


dat - list(c(1,2,3,2), c(4,2,7,5,4,3,8), c(1:10))
names(dat) - c(a2,b7,c8)
dat
# example
dat$a2
dat[[a2]]


## or using your variables
dat2 - list(y1, y2, y3)
names(dat2) - x

Cheers,

Josh


On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser robert.ru...@gmail.com wrote:
 Hello R Users,
 I have vectors
 x - c(a2,b7,c8)
 y1 - c(1,2,3,2)
 y2 - c(4,2,7,5,4,3,8)
 y3 - c(1:10)
 and I want to assign values form vector y1 to a new variable which
 name comes from the 1st value of the vector x etc. How to do it using
 only vector x.  As a result I should have:
 a2 - y1
 b7 - y2
 c8 - y3

 More general problem: I have 2 txt files.
 First is a one column
 C4
 C6
 F
 D
 D1
 D2
 D5
 D6
 
 Second is (non-define number of columns):
 44, 60, 65, 139, 138
 47
 48
 49, 46
 .
 is it possible to automatically assign:
 C4 - c(44, 60, 65, 139, 138)
 C6 - c(47)
 ...

 I would appreciate for any help.

 Robert

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

2010-11-19 Thread Adam Streline
Hi, I've looked through the posts but couldn't find a solution to this. I'd be 
really grateful if someone could help,

I'd like to convert a data file of mutual information that is formatted as 
a matrix:

            TF1    TF2    TF3    TF200...
Gene1    0.0    0.2    0.2
Gene2    1.4    0.0    2.8
Gene3    0.3    0.6    1.7
Gene6000

To a list:

Gene1    TF1    0.0
Gene1    TF2    0.2    
Gene1    TF3    0.2
Gene2    TF1    1.4
Gene2    TF2    0.0
Gene2    TF3    2.8
Gene3    TF1    0.3
Gene3    TF2    0.6
Gene3    TF3    1.7
Gene6000...TF200...etc

The matrix is ~6000X200 in size,

Adam


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

2010-11-19 Thread Robert Ruser
Thank you, but unfortunately it's not  resolve my problem. After
writing in R console e.g.  a2 a should get the values.
Do you know how to read file 2 into R?

2010/11/19 Joshua Wiley jwiley.ps...@gmail.com:
 Hi Robert,

 What about a named list?  This will generalize to your two text files
 one with data, the other with names.

 x - c(a2,b7,c8)
 y1 - c(1,2,3,2)
 y2 - c(4,2,7,5,4,3,8)
 y3 - c(1:10)


 dat - list(c(1,2,3,2), c(4,2,7,5,4,3,8), c(1:10))
 names(dat) - c(a2,b7,c8)
 dat
 # example
 dat$a2
 dat[[a2]]


 ## or using your variables
 dat2 - list(y1, y2, y3)
 names(dat2) - x

 Cheers,

 Josh


 On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser robert.ru...@gmail.com wrote:
 Hello R Users,
 I have vectors
 x - c(a2,b7,c8)
 y1 - c(1,2,3,2)
 y2 - c(4,2,7,5,4,3,8)
 y3 - c(1:10)
 and I want to assign values form vector y1 to a new variable which
 name comes from the 1st value of the vector x etc. How to do it using
 only vector x.  As a result I should have:
 a2 - y1
 b7 - y2
 c8 - y3

 More general problem: I have 2 txt files.
 First is a one column
 C4
 C6
 F
 D
 D1
 D2
 D5
 D6
 
 Second is (non-define number of columns):
 44, 60, 65, 139, 138
 47
 48
 49, 46
 .
 is it possible to automatically assign:
 C4 - c(44, 60, 65, 139, 138)
 C6 - c(47)
 ...

 I would appreciate for any help.

 Robert

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

2010-11-19 Thread Dennis Murphy
Hi:



On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser robert.ru...@gmail.comwrote:

 Hello R Users,
 I have vectors
 x - c(a2,b7,c8)
 y1 - c(1,2,3,2)
 y2 - c(4,2,7,5,4,3,8)
 y3 - c(1:10)
 and I want to assign values form vector y1 to a new variable which
 name comes from the 1st value of the vector x etc. How to do it using
 only vector x.  As a result I should have:
 a2 - y1
 b7 - y2
 c8 - y3


l - list(y1, y2, y3)
for(i in seq_along(x)) assign(x[i],  l[[i]])


 More general problem: I have 2 txt files.
 First is a one column
 C4
 C6
 F
 D
 D1
 D2
 D5
 D6
 
 Second is (non-define number of columns):
 44, 60, 65, 139, 138
 47
 48
 49, 46
 .
 is it possible to automatically assign:
 C4 - c(44, 60, 65, 139, 138)
 C6 - c(47)
 ...

 Same concept as above.

HTH,
Dennis


 I would appreciate for any help.

 Robert

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

2010-11-19 Thread Alex Bird
Hello there,

  Could anybody please help on how to correctly use ggplot when
printing irregural time series, by irregural here I mean for example
the absence of some dates in the whole timespan of a dataset. To be
more precise in the following example I generated some random data
which spans the whole November up to now and dropped weekend days but
for some reasons ggplot continues to plot the days I just dropped. The
ggplot generated outputs for comparison purposes can be found here
(http://img269.imageshack.us/img269/121/ggplotweekends.png) where the
upper image is for the regular timeseries and the bottom one is for
the irregular one. Datasets for both the charts are
(http://img521.imageshack.us/img521/6729/regularts.png) and
(http://img517.imageshack.us/img517/8651/irregularts.png)
correspondingly.  The R code used to generate them is

dates-seq(ISOdate(2010,11,1), by = day, length.out = 19)
rets-xts(rlnorm(19),order.by=dates)
# the following line drops weekends from the timeseries
rets-rets[!weekdays(index(rets))%in%c('Saturday','Sunday'),]

rets.m-data.frame(index(rets),rets,check.names=F)
colnames(rets.m)-c('Date','Rets')
rets.m-melt(rets.m,id.vars=c('Date','Rets'))
ggplot(data=rets.m,aes(Date,Rets))+geom_bar(stat=identity)+scale_x_datetime(major
= freqprint, format='%m/%d')

Thanks in advance for your help/patience and my bad English.

Kind regards,
Alex

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

2010-11-19 Thread Ivan Calandra

Hi,

Not sure how since I never use it, but I think melt() and then cast() 
from the reshape (or reshape2?) package are designed for this kind of 
transformations


Ivan

Le 11/19/2010 12:08, Adam Streline a écrit :

Hi, I've looked through the posts but couldn't find a solution to this. I'd be
really grateful if someone could help,

I'd like to convert a data file of mutual information that is formatted as
a matrix:

 TF1TF2TF3TF200...
Gene10.00.20.2
Gene21.40.02.8
Gene30.30.61.7
Gene6000

To a list:

Gene1TF10.0
Gene1TF20.2   
Gene1TF30.2

Gene2TF11.4
Gene2TF20.0
Gene2TF32.8
Gene3TF10.3
Gene3TF20.6
Gene3TF31.7
Gene6000...TF200...etc

The matrix is ~6000X200 in size,

Adam



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


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

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

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


Re: [R] Converting matrix data to a list

2010-11-19 Thread Dennis Murphy
Hi:

Look into melt() from package reshape2. Assuming m is your matrix,

library(reshape2)
meltm - melt(m, id = rownames(m))
str(meltm)
head(meltm)

## Toy example:
m - matrix(1:30, nrow = 3)
rownames(m) - paste('Gene', 1:nrow(m), sep = '')
colnames(m) - paste('T', 1:ncol(m), sep = '')


m
  T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
Gene1  1  4  7 10 13 16 19 22 25  28
Gene2  2  5  8 11 14 17 20 23 26  29
Gene3  3  6  9 12 15 18 21 24 27  30

mm - melt(m, id = rownames(m))
 mm
  X1  X2 value
1  Gene1  T1 1
2  Gene2  T1 2
3  Gene3  T1 3
4  Gene1  T2 4
5  Gene2  T2 5
6  Gene3  T2 6
...
 str(mm)
'data.frame':   30 obs. of  3 variables:
 $ X1   : Factor w/ 3 levels Gene1,Gene2,..: 1 2 3 1 2 3 1 2 3 1 ...
 $ X2   : Factor w/ 10 levels T1,T10,T2,..: 1 1 1 3 3 3 4 4 4 5 ...
 $ value: int  1 2 3 4 5 6 7 8 9 10 ...

HTH,
Dennis

On Fri, Nov 19, 2010 at 3:08 AM, Adam Streline astrel...@yahoo.com wrote:

 Hi, I've looked through the posts but couldn't find a solution to this. I'd
 be
 really grateful if someone could help,

 I'd like to convert a data file of mutual information that is formatted as
 a matrix:

TF1TF2TF3TF200...
 Gene10.00.20.2
 Gene21.40.0 2.8
 Gene30.30.61.7
 Gene6000

 To a list:

 Gene1TF10.0
 Gene1TF20.2
 Gene1TF30.2
 Gene2TF11.4
 Gene2TF20.0
 Gene2TF32.8
 Gene3TF10.3
 Gene3TF20.6
 Gene3TF31.7
 Gene6000...TF200...etc

 The matrix is ~6000X200 in size,

 Adam



[[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] Converting matrix data to a list

2010-11-19 Thread Henrique Dallazuanna
Try this:

 x
  TF1 TF2 TF3
Gene1 0.0 0.2 0.2
Gene2 1.4 0.0 2.8
Gene3 0.3 0.6 1.7

as.data.frame.table(as.matrix(x))





On Fri, Nov 19, 2010 at 9:08 AM, Adam Streline astrel...@yahoo.com wrote:

 Hi, I've looked through the posts but couldn't find a solution to this. I'd
 be
 really grateful if someone could help,

 I'd like to convert a data file of mutual information that is formatted as
 a matrix:

 TF1TF2TF3TF200...
 Gene10.00.20.2
 Gene21.40.02.8
 Gene30.30.61.7
 Gene6000

 To a list:

 Gene1TF10.0
 Gene1TF20.2
 Gene1TF30.2
 Gene2TF11.4
 Gene2TF20.0
 Gene2TF32.8
 Gene3TF10.3
 Gene3TF20.6
 Gene3TF31.7
 Gene6000...TF200...etc

 The matrix is ~6000X200 in size,

 Adam



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

2010-11-19 Thread Joshua Wiley
On Fri, Nov 19, 2010 at 3:20 AM, Robert Ruser robert.ru...@gmail.com wrote:
 a2 a should get the values.

Lists are a nice way to allow variable data (e.g., vectors, data
frames, matrices, etc. all of different sizes) but still group related
things (such as data from a single file) together, kind of like
putting all your vegetables on one shelf of your fridge and all your
drinks on another.  If you really just want everything tossed in the
fridge (as it were), Dennis provided an option.

 Do you know how to read file 2 into R?

Hmm, it is difficult to say precisely without the actual file, but it
sounds like you should look at:

?readLines

You may need to do some additional processing if you get the data in
with readLines   (I think it pulls everything in as character data, so
you might need to split each row and convert to numeric or integer.
See ?strsplit for one way to split data, ?as.numeric, ?as.integer for
potential conversions).  Usually for reading in data I try (in this
order because read.table() is generally much easier to use than
readLines or scan):

read.table(), readLines(), and if all else fails, scan()

HTH,

Josh

[snip]



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

2010-11-19 Thread Henrique Dallazuanna
Try this:

mapply(assign, x, list(y1, y2, y3), MoreArgs = list(envir = globalenv()))


On Fri, Nov 19, 2010 at 8:57 AM, Robert Ruser robert.ru...@gmail.comwrote:

 Hello R Users,
 I have vectors
 x - c(a2,b7,c8)
 y1 - c(1,2,3,2)
 y2 - c(4,2,7,5,4,3,8)
 y3 - c(1:10)
 and I want to assign values form vector y1 to a new variable which
 name comes from the 1st value of the vector x etc. How to do it using
 only vector x.  As a result I should have:
 a2 - y1
 b7 - y2
 c8 - y3

 More general problem: I have 2 txt files.
 First is a one column
 C4
 C6
 F
 D
 D1
 D2
 D5
 D6
 
 Second is (non-define number of columns):
 44, 60, 65, 139, 138
 47
 48
 49, 46
 .
 is it possible to automatically assign:
 C4 - c(44, 60, 65, 139, 138)
 C6 - c(47)
 ...

 I would appreciate for any help.

 Robert

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




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

[[alternative HTML version deleted]]

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


[R] expand comma separated field vertically in data.frame

2010-11-19 Thread Daniel Brewer
Hello,

I have a data.frame like this:
a   1,2,3,4 b1
b   6,7 b3

And I would like to transform it to this:
a   1   b1
a   2   b1
a   3   b1
a   4   b1
b   6   b3
b   7   b3

I have been looking at ddply but can't seem to work it out.  ANy help
would be gratefully received.

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

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

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

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


Re: [R] expand comma separated field vertically in data.frame

2010-11-19 Thread Henrique Dallazuanna
Try this:

transform(x[rep(seq(nrow(x)), sapply(v.s - strsplit(as.character(x$V2),
,), length)),], V2 = unlist(v.s))


On Fri, Nov 19, 2010 at 10:04 AM, Daniel Brewer daniel.bre...@icr.ac.ukwrote:

 Hello,

 I have a data.frame like this:
 a   1,2,3,4 b1
 b   6,7 b3

 And I would like to transform it to this:
 a   1   b1
 a   2   b1
 a   3   b1
 a   4   b1
 b   6   b3
 b   7   b3

 I have been looking at ddply but can't seem to work it out.  ANy help
 would be gratefully received.

 Dan

 --
 **
 Daniel Brewer, Ph.D.

 Institute of Cancer Research
 Molecular Carcinogenesis
 Email: daniel.bre...@icr.ac.uk
 **

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

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

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


Re: [R] negative axis values in image() and scalebar in cor.plot() {psych}

2010-11-19 Thread Łukasz Ręcławowicz
2010/11/19 Lara Poplarski larapoplar...@gmail.com


  In order to make the output more readable



You can just copy the style of the cor.plot.

mat-matrix(rnorm(256e4),16e2,16e2)
image(cor(mat),axes=F,col= grey((dim(mat)[1]:0)/dim(mat)[1]),main=Like
this)

-- 
Mi³ego dnia

[[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] Question on overdispersion

2010-11-19 Thread Ben Bolker
cct663 cct663 at gmail.com writes:

 I have a few questions relating to overdispersion in a sex ratio data set
 that I am working with (note that I already have an analysis with GLMMs for
 fixed effects, this is just to estimate dispersion). The response variable
 is binomial because nestlings can only be male or female. I have samples of
 1-5 nestlings from each nest (individuals within a nest are not independent,
 so the response variable is the ratio of sons to daughters) and some females
 have multiple nests in the data set (so I need to include female identity as
 a random effect). 
 
 Here is an example of what the three vectors used in the model look like
 (the real data set is much bigger, just to illustrate what I’m talking
 about):
 
 male_chick_no=c(2,4,1,0,3,5,2)
 female_chick_no=c(1,0,3,3,1,0,2)
 FemaleID=c(A,A,B,B,C,D,E)
 
 My first question relates to coding the test in R. I received this suggested
 R syntax from a reviewer:
 
 SexRatio = cbind(male_chick_no, female_chick_no)
 
 Model - lmer(SexRatio ~ 1 +(1|FemaleID), family = quasibinomial)
 
 But when I try to use this in R I get the error: “Error in glmer(formula =
 ratio ~ 1 + (1 | femid), family = quasibinomial) : quasi families cannot
 be used in glmer”.

   After many discussions of the unreliability of quasi-likelihood
estimation in lme4, Doug Bates added this error/warning in a fairly
recent version.  The recommended approach now is to use individual-level
random effects: to continue your example above,

 indiv - 1:length(FemaleID)
 Model - lmer(SexRatio ~ 1 + (1|indiv) + (1|FemaleID), family=binomial)

  By the way, it is generally better practice to put all of your data
into a dataframe and use the data= argument to lmer.

 My second question is more general: I understand that with binomial data
 overdispersion suggests that the observed data have a greater variance than
 expected given binomial errors (in my case this means that more nests would
 be all male/all female than expected if sex is random). So with binomial
 errors the expected estimate of dispersion is 1, if I find that dispersion
 is  1 it suggests that my data are overdispersed. My question is, how much
 greater than 1 should that number be to conclude that the data are
 overdispersed? Is there a rule of thumb or does it just depend on the
 dataset? 

   Very generally/crudely, the (squared) Pearson residuals are expected to be
chi-square distributed.  Specifically, if you know the residual
degrees of freedom (which can be a bit tricky/poorly defined for mixed
models, but is approximately (# data points)-(# estimated parameters),
then sum(residuals^2) should be chi-squared distributed with df equal
to the residual degrees of freedom.  Venables and Ripley have a useful
discussion.
 
 I was thinking of doing a randomization test with the same structure (nest
 size and female id) as my real data set but with sex ratio of each nest
 randomized with a 50:50 chance of individuals being sons or daughters and
 comparing my observed dispersion to the distribution of dispersions from the
 randomization test. Would this be a valid way to ask whether my data are
 overdispersed? Is it even necessary?

  It seems reasonable.  You could go even farther and simulate data
from your estimated model with binomial errors (i.e. use the estimated
sex ratios rather than assuming a 50/50 sex ratio).

  Followups should probably be sent to the r-sig-mixed-models list.

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


Re: [R] Calculating distance between longitude, latitude of 2 points

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 4:50 AM, Lily_stats wrote:



Hi all,

I would like to know a way of calculating the distance between 2  
points when

I already have the longitude and latitude of the points.

For example :

Point 1 :  52° 9'54.00N 4°25'8.40E
Point 2 :  52°27'46.80N 4°33'18.00E

Distance between point 1 and point in km 

Is there any functions already available for this ?


Searching on:  distance points longitude latitude

gdist {Imap} Geodesic distance (great circle distance) between points
Ellipsoidal.Distance {GEOmap} Ellipsoidal Distance
deg.dist {fossil} Haversine Distance Formula
distaz {RSEIS} Distance and Azimuth from two points
distaz {GEOmap} Distance and Azimuth from two points (# one probably  
borrowed from the other)

AlongGreat {RFOC} Get Points Along Great Circle
distAB {clim.pact} Distance between two points on Earth


Any help will be much appreciated!


Suggest you learn to search.

--

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] Plotting number of patients at risk below survival curve

2010-11-19 Thread Frank Harrell

Use the rms package, a replacement for of Design

Frank


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-number-of-patients-at-risk-below-survival-curve-tp3048900p3050315.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] Error: could not find function.

2010-11-19 Thread Lei Zhou
Dear all,

I use TinnR to write commands for R.

Why sometimes I can't call some basic functions, such as anova, var ?

Following is my command and reponse.

 anova(addative,saturated,test='Chisq')
Error: could not find function anova


Thanks:)


Regards,
Lei

[[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 save object created by assign()

2010-11-19 Thread Jinsong Zhao

Hi there,

When I run the following code, I could get correct objects (with correct 
values):


for(i in 1:6) { #-- Create objects  'r.1', 'r.2', ... 'r.6' --
  nam - paste(r,i, sep=.)
  assign(nam, 1:i)
# save(nam, file = paste(nam, RData, sep = .))
 }

I hope to save the object 'r.1', 'r.2', ..., 'r.6' using the above 
commented line, however, I just got 'r.1.RData' with a object 'nam' in 
it, which had the value, e.g., 'r.6', not the value of 'r.6', i.e., 1:6.


Any suggestions? Thanks in advance.

Jinsong

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


[R] Still confused with lapply

2010-11-19 Thread PtitBleu

Hello,

I would like to replace a for loop with lapply in order to speed up the
treatment of my data (I've read lapply can help to do it).

At the end of the message, you will find a simple example (function is more
complex and data frames is more than 1 million of rows) of what I would like
to do, that is applying the same calculation to all the rows of the data
frame (knowing that I cannot change the structure of the function).

I hope you understand my french explainations ...
Thanks in advance for your help,
Have a nice week-end,
Ptit Bleu.
  

df1-data.frame(c(1,2,3,4), c(9,6,5,8), c(5,4,8,6))
names(df1)-c(C1, C2, C3)

fcttest-function(a1,a2,a3) {
  v-a1*a2
  w-a2+a3
return(c(v,w))
}

# The following for loop works
result-data.frame()
for (i in 1:length(df1[,1])) {
result-rbind(result,fcttest(df1[i,1],df1[i,2],df1[i,3]))
}

# But the command 
lapply(df1, fcttest)
# gives (in french, sorry)
# Erreur dans FUN(X[[1L]], ...) : l'élément 2 est vide ;
# la partie de la liste d'arguments de '*' en cours d'évaluation était :
#  (a1, a2)



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Still-confused-with-lapply-tp3050414p3050414.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] assigment

2010-11-19 Thread Robert Ruser
Joshua, Dennis ans Henrique I'm immensely indebted to you.  Thanks to
you I resolved my problem - a code works perfectly. I put the code,
maybe someone finds it's helpful.

f1 - readLines(file(file1.txt))
f2 - readLines(file(file2.txt))

for ( i in seq_along(f1)){
assign(f1[i],as.numeric(unlist(strsplit(f2[i],,)) ))
}

file 1 (names of the variables; just copy and paste to see how it works)
A
A2
A3
A4
A7
B
B4
B5
B7
C
C1
C3
C4
C6
F
D

file 2 (values of the variables; just copy and paste to see how it
works as well)
1
3, 6, 7
4, 13, 9
5, 2
8,10, 11,12,15
17
21, 29, 18, 32, 145
22, 34, 19, 27, 20
24, 23, 33, 28, 25, 26
35
36, 40
38, 37
39
41
92
42


Robert

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


Re: [R] Still confused with lapply

2010-11-19 Thread Ken Knoblauch
PtitBleu ptit_bleu at yahoo.fr writes:

 
 
 Hello,
 
 I would like to replace a for loop with lapply in order to speed up the
 treatment of my data (I've read lapply can help to do it).
 
 At the end of the message, you will find a simple example (function is more
 complex and data frames is more than 1 million of rows) of what I would like
 to do, that is applying the same calculation to all the rows of the data
 frame (knowing that I cannot change the structure of the function).
 
 I hope you understand my french explainations ...
 Thanks in advance for your help,
 Have a nice week-end,
 Ptit Bleu.
 
 df1-data.frame(c(1,2,3,4), c(9,6,5,8), c(5,4,8,6))
 names(df1)-c(C1, C2, C3)
 
 fcttest-function(a1,a2,a3) {
   v-a1*a2
   w-a2+a3
 return(c(v,w))
 }
 
 # The following for loop works
 result-data.frame()
 for (i in 1:length(df1[,1])) {
 result-rbind(result,fcttest(df1[i,1],df1[i,2],df1[i,3]))



why bother with lapply when you can just do this

with(df1, cbind(df1[[1]] * df1[[2]], df1[[2]] + df1[[3]]))

HTH

Ken

-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.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] Option to Print with numbers formatted

2010-11-19 Thread Santosh Srinivas
Hello group,

I have a data frame called test.df  with a bunch of columns. 

When I do a print(test.df), I want the numbers to appear a pre-defined
setting.

I believe this can be achieved by sprintf but this needs to be done
individually for the data.

However, is there an option that I can set so that all numerical values
default to comma separated, 2 decimal places when they appear?

Thanks,
S

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


Re: [R] Still confused with lapply

2010-11-19 Thread PtitBleu

Thanks for your answer but do you have a solution using the function ?
I need to you use the data frame with a function (not the one given).

Thanks in advance again.
Ptit Bleu.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Still-confused-with-lapply-tp3050414p3050455.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] RGoogleDocs stopped working

2010-11-19 Thread Harlan Harris
Any new thoughts on this? I really want to get this working again! Is there
someone else that can help or somewhere else I should be asking?

Thanks!

 -Harlan


On Wed, Nov 17, 2010 at 10:16 AM, Harlan Harris har...@harris.name wrote:

 Following up again. I found on the forums for the Google Apps API this
 thread that seems to be about a similar issue:
 http://www.google.com/support/forum/p/apps-apis/thread?tid=1c22cb44eb5cbba6hl=ensearch_impression_id=ab161b010ecf8803%3A12c5a65ce83search_source=related_question

 It's using Java and is rather over my head, but it seems to suggest that
 something related to the content type might be wrong? Does this offer any
 suggestions on how to fix my use of RGoogleDocs?

 Thanks,

  -Harlan


 On Mon, Nov 15, 2010 at 12:16 PM, Harlan Harris har...@harris.namewrote:

 Thanks, Duncan. Finally getting a chance to follow up on this...

 I tried again, changing and resetting my password, and trying to specify
 my login and password manually in the getGoogleDocsConnection argument list.
 I also tried removing either or both of the service and error options. No
 luck in any case. I also tried a different Google account, also with no
 luck.

 I've also tried tweaking the URL being generated by the code, and in all
 cases, I get a 403: Forbidden error with content Error=BadAuthentication.

 I don't really know enough about how authentication is supposed to work to
 get much farther. Can you help? Should I try the Google API forum instead?

  -Harlan



 From: Duncan Temple Lang dun...@wald.ucdavis.edu
 To: r-help@r-project.org
 Date: Wed, 10 Nov 2010 10:33:47 -0800
 Subject: Re: [R] RGoogleDocs stopped working

 Hi Harlan

  I just tried to connect to Google Docs and I had ostensibly the same
 problem.
 However, the password was actually different from what I had specified.
 After resetting it with GoogleDocs, the getGoogleDocsConnection() worked
 fine. So I don't doubt that the login and password are correct, but
 you might just try it again to ensure there are no typos.
 The other thing to look at is the values for Email and Passwd
 sent in the URL, i.e. the string in url in your debugging
 below. (Thanks for that by the way). If either has special characters,
 e.g. , it is imperative that they are escaped correctly, i.e. converted
 to %24.  This should happen and nothing should have changed, but it is
 worth verifying.

  So things still seem to work for me. It is a data point, but not one
 that gives you much of a clue as to what is wrong on your machine.

  D.


 On Wed, Nov 10, 2010 at 10:36 AM, Harlan Harris har...@harris.namewrote:

 Hello,

 Some code using RGoogleDocs, which had been working smoothly since the
 summer, just stopped working. I know that it worked on November 3rd, but it
 doesn't work today. I've confirmed that the login and password still work
 when I log in manually. I've confirmed that the URL gives the same error
 when I paste it into Firefox. I don't know enough about this web service to
 figure out the problem myself, alas...

 Here's the error and other info (login/password omitted):

  ss.con - getGoogleDocsConnection(login=gd.login, password=gd.password,
 service='wise', error=FALSE)
 Error: Forbidden

 Enter a frame number, or 0 to exit

 1: getGoogleDocsConnection(login = gd.login, password = gd.password,
 service = wise, error = FALSE)
 2: getGoogleAuth(..., error = error)
 3: getForm(https://www.google.com/accounts/ClientLogin;, accountType =
 HOSTED_OR_GOOGLE, Email = login, Passw
 4: getURLContent(uri, .opts = .opts, .encoding = .encoding, binary =
 binary, curl = curl)
 5: stop.if.HTTP.error(http.header)

 Selection: 4
 Called from: eval(expr, envir, enclos)
 Browse[1] http.header
Content-Type
 Cache-control  Pragma
text/plainno-cache,
 no-store  no-cache
 ExpiresDate
 X-Content-Type-Options
 Mon, 01-Jan-1990 00:00:00 GMT Wed, 10 Nov 2010 15:24:39
 GMT   nosniff
X-XSS-Protection
 Content-Length  Server
 1; mode=block
 24   GSE
  status   statusMessage
   403 Forbidden\r\n
 Browse[1] url
 [1] 
 https://www.google.com/accounts/ClientLogin?accountType=HOSTED%5FOR%5FGOOGLEEmail=***Passwd=***service=wisesource=R%2DGoogleDocs%2D0%2E1
 
 Browse[1] .opts
 $ssl.verifypeer
 [1] FALSE


  R.Version()
 $platform
 [1] i386-apple-darwin9.8.0

 $arch
 [1] i386

 $os
 [1] darwin9.8.0

 $system
 [1] i386, darwin9.8.0

 $status
 [1] 

 $major
 [1] 2

 $minor
 [1] 10.1

 $year
 [1] 2009

 $month
 [1] 12

 $day
 [1] 14

 $`svn rev`
 [1] 50720

 $language
 [1] R

 $version.string
 [1] R version 2.10.1 (2009-12-14)


  installed.packages()[c('RCurl', 'RGoogleDocs'), ]
 Package
 LibPath  

[R] Job scheduling in R

2010-11-19 Thread amit jain
Hi All,

Can anyone point to any package/resouce to schedule a job in R which runs a .R 
file at a specified time ?

I couldn't find anything useful in R Reference manual or RSiteSearch. I am sure 
its there but i am unable to locate.

Thanks for your help.
Puneet

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 rounding option for \Sexpr{}?

2010-11-19 Thread Yihui Xie
Maybe this should go to R-devel as a wishlist:

Can we change as.character() to format() in this line in
src/library/utils/R/Sweave.R?

val - as.character(eval(parse(text=cmd), envir=.GlobalEnv))

i.e.

val - format(eval(parse(text=cmd), envir=.GlobalEnv))

I guess this would not affect Sweave users, unless they really want 12
digits in the output (e.g. the standard error is 0.123456789012).
Since format() can respect getOption('digits'), it will be much easier
to control the number of digits globally.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Fri, Nov 19, 2010 at 2:02 AM, Dieter Menne
dieter.me...@menne-biomed.de wrote:


 Yihui Xie-2 wrote:


 Currently Sweave does not format the (especially numeric) value in
 \Sexpr{}, and I often have to round() the numbers explicitly,
 otherwise I will get more than 10 digits, which is not necessary for
 me in most cases. Is there a way to specify the number of digits to be
 kept for values in \Sexpr{}? e.g. can we make \Sexpr{} respect
 getOption('digits')?



 Currently, Sweave does an eval on Sexpr, and that can be anything other than
 a number (is mostly is, though). And you cannot define a new version of
 Sexpr in latex, because Sexpr only looks like latex, but is processed before
 texing.

 My solution is to always do the rounding and formating in the R chunk (e.g.
 with latexSN of Hmisc) to unclutter the Sexpr.

 Dieter



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


Re: [R] Option to Print with numbers formatted

2010-11-19 Thread Duncan Murdoch

On 19/11/2010 9:59 AM, Santosh Srinivas wrote:

Hello group,

I have a data frame called test.df  with a bunch of columns.

When I do a print(test.df), I want the numbers to appear a pre-defined
setting.

I believe this can be achieved by sprintf but this needs to be done
individually for the data.

However, is there an option that I can set so that all numerical values
default to comma separated, 2 decimal places when they appear?



No, there's no global option with that level of flexibility.  You can 
set options(digits), but you won't get the commas.


You should probably write your own function to do this.  For example,

myformat - function(x, big.mark=,, scientific = FALSE, nsmall=2, ...) {
   format.data.frame(x, big.mark=big.mark, scientific=scientific, 
nsmall=2, ...)

}

and then print(myformat(df)) should give what you want.  It is possible 
to replace the print.data.frame and format.data.frame functions with new 
ones, but that's probably not advisable.


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.


[R] Function call on every prompt

2010-11-19 Thread Barry Rowlingson
Someone on stackoverflow.com was wondering how to display the current
time in the R prompt. I could have swore there was a mechanism for
hooking a function into R such that it is was called before the 
prompt was given, but no amount of searching in R's docs, R's source,
or RSiteSearch can find it.

 I've searched for 'hook', 'event', 'signal', and various combinations
of those with 'console', 'prompt', 'after' and 'before' with no joy.
I'm sure other people have asked this on R-help before, but I can't
find those messages either.

 Have I been hallucinating or is my search-fu week this Friday?

Barry

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


Re: [R] Still confused with lapply

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 10:00 AM, PtitBleu wrote:



Thanks for your answer but do you have a solution using the function ?
I need to you use the data frame with a function (not the one given).


I do not think lapply is the *apply you want. since it will  
individually access the columns and you appear to want row operations.  
See if apply(..., 1, fctest) works better. (Since you Nabble users  
often don't include context, I can't check spelling in this post, but  
ISTR your function's name is something like that.)




Thanks in advance again.
Ptit Bleu.
--
View this message in context: 
http://r.789695.n4.nabble.com/Still-confused-with-lapply-tp3050414p3050455.html



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] library(datasets)

2010-11-19 Thread lgpeco

## i have one question anouth this package..
library(datasets)
eurodist
## if i type this i get max distance between european cities
 max(eurodist)
[1] 4532
## but i would like get something like this: 4532 Gilbratar - Anthens
## and another one..  
## if a live in barcelona and i would like travel in all cities
## how can i get sum of all distance to other cities... i try
sapply(eurodist[Barcelona], sum)
## and rowSums(eurodist[Barcelona,]) and it doesn't working.. tnx for
helping ;)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/library-datasets-tp3050497p3050497.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] a rounding option for \Sexpr{}?

2010-11-19 Thread Duncan Murdoch

On 19/11/2010 10:12 AM, Yihui Xie wrote:

Maybe this should go to R-devel as a wishlist:

Can we change as.character() to format() in this line in
src/library/utils/R/Sweave.R?

 val- as.character(eval(parse(text=cmd), envir=.GlobalEnv))

i.e.

 val- format(eval(parse(text=cmd), envir=.GlobalEnv))

I guess this would not affect Sweave users, unless they really want 12
digits in the output (e.g. the standard error is 0.123456789012).
Since format() can respect getOption('digits'), it will be much easier
to control the number of digits globally.


I don't like the current behaviour, but that change could break a lot of 
existing documents.  Since you can easily wrap your Sexpr arguments in a 
call to whatever formatting function you want, why force all of those 
users to change their documents?


Duncan Murdoch


Regards,
Yihui
--
Yihui Xiexieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Fri, Nov 19, 2010 at 2:02 AM, Dieter Menne
dieter.me...@menne-biomed.de  wrote:


  Yihui Xie-2 wrote:


  Currently Sweave does not format the (especially numeric) value in
  \Sexpr{}, and I often have to round() the numbers explicitly,
  otherwise I will get more than 10 digits, which is not necessary for
  me in most cases. Is there a way to specify the number of digits to be
  kept for values in \Sexpr{}? e.g. can we make \Sexpr{} respect
  getOption('digits')?



  Currently, Sweave does an eval on Sexpr, and that can be anything other than
  a number (is mostly is, though). And you cannot define a new version of
  Sexpr in latex, because Sexpr only looks like latex, but is processed before
  texing.

  My solution is to always do the rounding and formating in the R chunk (e.g.
  with latexSN of Hmisc) to unclutter the Sexpr.

  Dieter



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


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


Re: [R] Function call on every prompt

2010-11-19 Thread Marc Schwartz
On Nov 19, 2010, at 9:23 AM, Barry Rowlingson wrote:

 Someone on stackoverflow.com was wondering how to display the current
 time in the R prompt. I could have swore there was a mechanism for
 hooking a function into R such that it is was called before the 
 prompt was given, but no amount of searching in R's docs, R's source,
 or RSiteSearch can find it.
 
 I've searched for 'hook', 'event', 'signal', and various combinations
 of those with 'console', 'prompt', 'after' and 'before' with no joy.
 I'm sure other people have asked this on R-help before, but I can't
 find those messages either.
 
 Have I been hallucinating or is my search-fu week this Friday?
 
 Barry


Baz,

What's wrong with:

 options(prompt = paste(format(Sys.time(), %a %b %d %X %Y %Z), ))
Fri Nov 19 09:30:53 2010 CST 
Fri Nov 19 09:30:53 2010 CST 
Fri Nov 19 09:30:53 2010 CST 

?

HTH,

Marc Schwartz

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


[R] how to improve this inefficient R code for imputing missing values

2010-11-19 Thread Coen van Hasselt
Hello all,

I have a big data.frame multiple studies, subjects and timepoints per
subject, i.e.

STUDY[,1] SUBJECT[,2] .. WT[,16] HT[,17] TEMP[,18] BSA[,19]
1   150  170   37
 1.90
1   1NA   NA  NA
NA
1   152  170   38
 1.94


In this dataset, three types of missing (demographic) values exist:

1) first value for a subject is missing:
ie. study 1, subject 1: mis X1 X2 X3.
Here I want to carry the first non-missing value backwards to the missing value.

2) last values for a subject is missing:
ie. study 1, subject 1: X1 X2 X3 mis.
Here I want to carry the last non-missing value forwards to the missing value

3) some intermediate value for a subject is missing (like example
data.frame above)
i.e. study 1, subject 1: X1 mis X2 X3.
Here I want to impute the missing value with the mean value between X1 and X2

The missing value is actually a subset of columns in the data frame,
ie. always the columns WT HT TEMP BSA (m[,16:19]) are missing
altogether.

I have written some R code that tries to do this, but it is incredibly
slow due to the many for-loops and the big dataset I have (and might
not even be completely correct yet).

QUESTION:
I would greatly appreciate it if somebody can be give me some
guidance/hints on what direction I should roughly think for coding the
above a little more efficient then the horribly inefficient code
pasted below.

Thank you in advance and best regards,

Coen


for(s in unique(m$Study)){ # for each study
 for(i in unique(m$Subject[m$Study==s  is.na(m$Wt)])){  # for each
subject with a missing value (if $Wt is missing, all 4 columns 16:19
are missing)
   vals-which(m$Study==s  m$Subject==i  !is.na(m$Wt))  # values
with NO missing values
   for(w in which(m$Study==s  m$Subject==i  is.na(m$Wt))){  # for
each value that is missing for subject i and study s
 if(w  min(vals) ){  # FIRST VALUES MISSING ?   #
carry the backwards
   m[w,][16:19]-m[min(vals),][16:19]
 } else if(w  max(vals) ) {  # LAST VALUES MISSING#
carry forwards
   m[w,][16:19]-m[max(vals),][16:19]
 } else { # INTERMEDIATE VALUES MISSING  #
impute missing with mean
   maxV-min(vals[valsw])
   minV-max(vals[valsw])
   m[w,][16:19]- mean(m[c(maxV,minV),][16:19],na.rm=T)
 }
   }
 }
}

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


[R] problems with rJava

2010-11-19 Thread R Heberto Ghezzo, Dr

Hello, using r-2.12.0 on a Toshiba laptop with Win7
I am trying to install JGR, iut installs OK but when loading, complains about 
rJava
so I did:
 install.packages(rJava)
Installing package(s) into ‘I:\R\cran’
(as ‘lib’ is unspecified)
trying URL 
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.12/rJava_0.8-8.zip'
Content type 'application/zip' length 636680 bytes (621 Kb)
opened URL
downloaded 621 Kb

The downloaded packages are in
C:\Users\Heberto\AppData\Local\Temp\Rtmpyd0JHa\downloaded_packages
 library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'I:/R/cran/rJava/libs/i386/rJava.dll':
  LoadLibrary failure:  The device is not ready.

Error: package/namespace load failed for 'rJava'
 
rJava.dll is in that place. Is it a problem witm Win7? 
Thanks

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


Re: [R] Function call on every prompt

2010-11-19 Thread Duncan Murdoch

On 19/11/2010 10:31 AM, Marc Schwartz wrote:

On Nov 19, 2010, at 9:23 AM, Barry Rowlingson wrote:

  Someone on stackoverflow.com was wondering how to display the current
  time in the R prompt. I could have swore there was a mechanism for
  hooking a function into R such that it is was called before the 
  prompt was given, but no amount of searching in R's docs, R's source,
  or RSiteSearch can find it.

  I've searched for 'hook', 'event', 'signal', and various combinations
  of those with 'console', 'prompt', 'after' and 'before' with no joy.
  I'm sure other people have asked this on R-help before, but I can't
  find those messages either.

  Have I been hallucinating or is my search-fu week this Friday?


Barry was probably remembering SweaveHook.



  Barry


Baz,

What's wrong with:

  options(prompt = paste(format(Sys.time(), %a %b %d %X %Y %Z), ))
Fri Nov 19 09:30:53 2010 CST
Fri Nov 19 09:30:53 2010 CST
Fri Nov 19 09:30:53 2010 CST


That one doesn't get updated with every prompt.

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] Function call on every prompt

2010-11-19 Thread Marc Schwartz

On Nov 19, 2010, at 9:36 AM, Duncan Murdoch wrote:

 On 19/11/2010 10:31 AM, Marc Schwartz wrote:
 On Nov 19, 2010, at 9:23 AM, Barry Rowlingson wrote:
 
   Someone on stackoverflow.com was wondering how to display the current
   time in the R prompt. I could have swore there was a mechanism for
   hooking a function into R such that it is was called before the 
   prompt was given, but no amount of searching in R's docs, R's source,
   or RSiteSearch can find it.
 
   I've searched for 'hook', 'event', 'signal', and various combinations
   of those with 'console', 'prompt', 'after' and 'before' with no joy.
   I'm sure other people have asked this on R-help before, but I can't
   find those messages either.
 
   Have I been hallucinating or is my search-fu week this Friday?
 
 Barry was probably remembering SweaveHook.
 
 
   Barry
 
 
 Baz,
 
 What's wrong with:
 
   options(prompt = paste(format(Sys.time(), %a %b %d %X %Y %Z), ))
 Fri Nov 19 09:30:53 2010 CST
 Fri Nov 19 09:30:53 2010 CST
 Fri Nov 19 09:30:53 2010 CST
 
 That one doesn't get updated with every prompt.
 
 Duncan Murdoch

D'ohyou are right.  Thanks Duncan

Time for more coffee...

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 rounding option for \Sexpr{}?

2010-11-19 Thread Dieter Menne


Duncan Murdoch-2 wrote:
 
 On 19/11/2010 10:12 AM, Yihui Xie wrote:
 Maybe this should go to R-devel as a wishlist:
  val- format(eval(parse(text=cmd), envir=.GlobalEnv))

 I don't like the current behaviour, but that change could break a lot of 
 existing documents.  
 

Not necessarily. Add an Sweave option useFormat=FALSE to keep the old
behavior.

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/a-rounding-option-for-Sexpr-tp3049872p3050529.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] Function call on every prompt

2010-11-19 Thread Barry Rowlingson
On Fri, Nov 19, 2010 at 3:36 PM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:

 Barry was probably remembering SweaveHook.

 The key is the  taskCallbackManager. Does exactly what it says on
the tin.  Doesn't come up with any of my search strings!

 Hopefully now this is in R-help it'll come up when people search for
do something before every prompt.

Barry

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


[R] Odp: Still confused with lapply

2010-11-19 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 19.11.2010 15:41:08:

 
 Hello,
 
 I would like to replace a for loop with lapply in order to speed up the
 treatment of my data (I've read lapply can help to do it).

Not exactly. For loop if correctly written can be as quick as lapply. See 
P.Burns' R inferno.

 
 At the end of the message, you will find a simple example (function is 
more
 complex and data frames is more than 1 million of rows) of what I would 
like
 to do, that is applying the same calculation to all the rows of the data
 frame (knowing that I cannot change the structure of the function).

Why? You do not have access to the code of a function?

 
 I hope you understand my french explainations ...
 Thanks in advance for your help,
 Have a nice week-end,
 Ptit Bleu.
 
 
 df1-data.frame(c(1,2,3,4), c(9,6,5,8), c(5,4,8,6))
 names(df1)-c(C1, C2, C3)
 
 fcttest-function(a1,a2,a3) {
   v-a1*a2
   w-a2+a3
 return(c(v,w))
 }
 
 # The following for loop works
 result-data.frame()
 for (i in 1:length(df1[,1])) {
 result-rbind(result,fcttest(df1[i,1],df1[i,2],df1[i,3]))
 }

Let assume you want to use some function for first two columns and some 
for the columns 2 and 3. Than why not just do it?

 matrix(fcttest(df1[,1],df1[,2],df1[,3]),ncol=2)
 [,1] [,2]
[1,]9   14
[2,]   12   10
[3,]   15   13
[4,]   32   14

Regards
Petr



 
 # But the command 
 lapply(df1, fcttest)
 # gives (in french, sorry)
 # Erreur dans FUN(X[[1L]], ...) : l'élément 2 est vide ;
 # la partie de la liste d'arguments de '*' en cours d'évaluation était :
 #  (a1, a2)
 
 
 
 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Still-confused-
 with-lapply-tp3050414p3050414.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Function call on every prompt

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 10:23 AM, Barry Rowlingson wrote:


Someone on stackoverflow.com was wondering how to display the current
time in the R prompt. I could have swore there was a mechanism for
hooking a function into R such that it is was called before the 
prompt was given, but no amount of searching in R's docs, R's source,
or RSiteSearch can find it.

I've searched for 'hook', 'event', 'signal', and various combinations
of those with 'console', 'prompt', 'after' and 'before' with no joy.
I'm sure other people have asked this on R-help before, but I can't
find those messages either.

Have I been hallucinating or is my search-fu week this Friday?


The question on SO as I understood it was how to get the time on the  
prompt to keep changing without hitting the enter key. The questioner  
had already figured out how to use:


options(prompt=paste(format(Sys.time(), %H:%M:%S), ))

--

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] printCoefmat() for a data.frame with factors

2010-11-19 Thread Michael Friendly
I want to use something like printCoefmat() in a print.summary method to 
print a more nicely formatted version
of the result from a summary method, but where the estimates may be 
cross-classified by one or more factors.


However, printCoefmat() assumes that the labels for the parameters are 
the rownames of the object, and
prints factors as integers. With one factor, I could just assign that as 
the rownames, but with 1,
I would be forced to paste() them together, giving a less readable 
display. Perhaps printCoefmat()
needs another argument for this case (factor.ind= indices of column 
numbers which are factors, or

stringsAsFactors=TRUE), or maybe there is some other method I could use.

Here is an example:

 summary(lor.Emp)
EmploymentLength LayoffCause Log Odds Ratio Std. Error z value Pr(|z|)
1 1Mo:1-3Mo Closure -0.04082199 0.5143769 -0.07936203 0.468372334
2 1-3Mo:3-12Mo Closure 0.02353050 0.2782868 0.08455486 0.466307643
3 3-12Mo:1-2Yr Closure 0.04904020 0.2327390 0.21070895 0.416557193
4 1-2Yr:2-5Yr Closure -0.07555132 0.2468528 -0.30605823 0.379780157
5 2-5Yr:5Yr Closure -0.26157903 0.2943756 -0.88858949 0.187111872
6 1Mo:1-3Mo Replaced -0.19415601 0.3173846 -0.61173729 0.270355791
7 1-3Mo:3-12Mo Replaced -0.77994333 0.2546200 -3.06316597 0.001095043
8 3-12Mo:1-2Yr Replaced -0.18513757 0.3192303 -0.57994984 0.280974223
9 1-2Yr:2-5Yr Replaced 0.19521478 0.3422052 0.57046111 0.284182498
10 2-5Yr:5Yr Replaced -0.24791884 0.3971645 -0.62422200 0.266240900

 str(summary(lor.Emp))
'data.frame': 10 obs. of 6 variables:
$ EmploymentLength: Factor w/ 5 levels 1Mo:1-3Mo,1-3Mo:3-12Mo,..: 1 
2 3 4 5 1 2 3 4 5

$ LayoffCause : Factor w/ 2 levels Closure,Replaced: 1 1 1 1 1 2 2 2 2 2
$ Log Odds Ratio : num -0.0408 0.0235 0.049 -0.0756 -0.2616 ...
$ Std. Error : num 0.514 0.278 0.233 0.247 0.294 ...
$ z value : num -0.0794 0.0846 0.2107 -0.3061 -0.8886 ...
$ Pr(|z|) : num 0.468 0.466 0.417 0.38 0.187 ...

Result from printCoefmat() is considerably worse:

 printCoefmat(summary(lor.Emp))
EmploymentLength LayoffCause Log Odds Ratio Std. Error z value Pr(|z|)
[1,] 1.00 1.00 -0.040822 0.514377 -0.0794 0.468372
[2,] 2.00 1.00 0.023530 0.278287 0.0846 0.466308
[3,] 3.00 1.00 0.049040 0.232739 0.2107 0.416557
[4,] 4.00 1.00 -0.075551 0.246853 -0.3061 0.379780
[5,] 5.00 1.00 -0.261579 0.294376 -0.8886 0.187112
[6,] 1.00 2.00 -0.194156 0.317385 -0.6117 0.270356
[7,] 2.00 2.00 -0.779943 0.254620 -3.0632 0.001095 **
[8,] 3.00 2.00 -0.185138 0.319230 -0.5799 0.280974
[9,] 4.00 2.00 0.195215 0.342205 0.5705 0.284182
[10,] 5.00 2.00 -0.247919 0.397165 -0.6242 0.266241
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 rounding option for \Sexpr{}?

2010-11-19 Thread Duncan Murdoch

On 19/11/2010 10:38 AM, Dieter Menne wrote:


Duncan Murdoch-2 wrote:

  On 19/11/2010 10:12 AM, Yihui Xie wrote:
  Maybe this should go to R-devel as a wishlist:
   val- format(eval(parse(text=cmd), envir=.GlobalEnv))

  I don't like the current behaviour, but that change could break a lot of
  existing documents.


Not necessarily. Add an Sweave option useFormat=FALSE to keep the old
behavior.


I think the default would have to be FALSE, so that old documents didn't 
suddenly change.   But is it really so hard to define your own formatting?


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] Odp: Still confused with lapply

2010-11-19 Thread PtitBleu

Hello Petr,

Your solution works well with my example.
But with the function I want to use (which calls another functions), I still
have errors.
I have to work on it again (but only on monday).

Again thank you,
Ptit Bleu.

PS : I have access to all the functions but I don't want to modify all of
them because I just need to correct an error I discovered in already-treated
data (not sure I'm clear ...).
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Still-confused-with-lapply-tp3050414p3050573.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] Function call on every prompt

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 10:38 AM, Marc Schwartz wrote:


What's wrong with:

options(prompt = paste(format(Sys.time(), %a %b %d %X %Y %Z),  
))

Fri Nov 19 09:30:53 2010 CST
Fri Nov 19 09:30:53 2010 CST
Fri Nov 19 09:30:53 2010 CST


That one doesn't get updated with every prompt.

Duncan Murdoch


D'ohyou are right.  Thanks Duncan

Time for more coffee...


Me too, but I think there is a descending limb on the coffee x  
efficiency curve and I may have already reached it.


--

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] all extended ASCII characters exist for R console output?

2010-11-19 Thread Mark Heckmann
Hi,

can the R console print all extended ASCII characters?
I am especially interested in characters 176-178 from 
http://www.asciitable.com/ 
  bottom table.
As far as I know the character mapping in R is somewhat different  
(octal).
So  as I am not familiar with these things I am not sure if it exists.

TIA
Mark
–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Straße 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]

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


Re: [R] Job scheduling in R

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 10:09 AM, amit jain wrote:


Hi All,

Can anyone point to any package/resouce to schedule a job in R which  
runs a .R file at a specified time ?


That wouldn't be an R function but rather a system function, wouldn't  
it?




I couldn't find anything useful in R Reference manual or  
RSiteSearch. I am sure its there but i am unable to locate.


Search with:  R CMD BATCH
(that pulled up about twenty R documents including the fullrefman just  
looking on my harddrive)


RSiteSearch
 terms = BATCH chron

 terms = batch scheduling

 terms = schedule batch

(all of them worked to varying extents)



Thanks for your help.
Puneet

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Odp: how to improve this inefficient R code for imputing missing values

2010-11-19 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 19.11.2010 16:34:04:

Without going too deeply to your code, try to check na.locf function from 
zoo package.

I would split your data to list according to study and subject, use 
na.locf with respect to your miising value types

 x-c(NA, 1:5)
 y-rev(x)
 x
[1] NA  1  2  3  4  5
 y
[1]  5  4  3  2  1 NA
 z-c(y,x)
 z
 [1]  5  4  3  2  1 NA NA  1  2  3  4  5
 lll-list(x,y,z)
 lll
[[1]]
[1] NA  1  2  3  4  5

[[2]]
[1]  5  4  3  2  1 NA

[[3]]
 [1]  5  4  3  2  1 NA NA  1  2  3  4  5


library(zoo)
lapply(lll[unlist(lapply(lll, function(x) all(which(is.na(x))==1)))], 
na.locf, fromLast=TRUE)
lapply(lll[unlist(lapply(lll, function(x) 
all(which(is.na(x))==length(x], na.locf)

The third you shall probably do without na.locf, but I do not have clear 
idea how exactly.

After that you will get three lists and you can put them together again. 
However I am not sure if it is the best way how to do what you want.

Regards
Peetr



 [R] how to improve this inefficient R code for imputing missing values
 
 Hello all,
 
 I have a big data.frame multiple studies, subjects and timepoints per
 subject, i.e.
 
 STUDY[,1] SUBJECT[,2] .. WT[,16] HT[,17] TEMP[,18] BSA[,19]
 1   150  170   37
  1.90
 1   1NA   NA  NA
 NA
 1   152  170   38
  1.94
 
 
 In this dataset, three types of missing (demographic) values exist:
 
 1) first value for a subject is missing:
 ie. study 1, subject 1: mis X1 X2 X3.
 Here I want to carry the first non-missing value backwards to the 
missing value.
 
 2) last values for a subject is missing:
 ie. study 1, subject 1: X1 X2 X3 mis.
 Here I want to carry the last non-missing value forwards to the missing 
value
 
 3) some intermediate value for a subject is missing (like example
 data.frame above)
 i.e. study 1, subject 1: X1 mis X2 X3.
 Here I want to impute the missing value with the mean value between X1 
and X2
 
 The missing value is actually a subset of columns in the data frame,
 ie. always the columns WT HT TEMP BSA (m[,16:19]) are missing
 altogether.
 
 I have written some R code that tries to do this, but it is incredibly
 slow due to the many for-loops and the big dataset I have (and might
 not even be completely correct yet).
 
 QUESTION:
 I would greatly appreciate it if somebody can be give me some
 guidance/hints on what direction I should roughly think for coding the
 above a little more efficient then the horribly inefficient code
 pasted below.
 
 Thank you in advance and best regards,
 
 Coen
 
 
 for(s in unique(m$Study)){ # for each study
  for(i in unique(m$Subject[m$Study==s  is.na(m$Wt)])){  # for each
 subject with a missing value (if $Wt is missing, all 4 columns 16:19
 are missing)
vals-which(m$Study==s  m$Subject==i  !is.na(m$Wt))  # values
 with NO missing values
for(w in which(m$Study==s  m$Subject==i  is.na(m$Wt))){  # for
 each value that is missing for subject i and study s
  if(w  min(vals) ){  # FIRST VALUES MISSING ?   #
 carry the backwards
m[w,][16:19]-m[min(vals),][16:19]
  } else if(w  max(vals) ) {  # LAST VALUES MISSING#
 carry forwards
m[w,][16:19]-m[max(vals),][16:19]
  } else { # INTERMEDIATE VALUES MISSING  #
 impute missing with mean
maxV-min(vals[valsw])
minV-max(vals[valsw])
m[w,][16:19]- mean(m[c(maxV,minV),][16:19],na.rm=T)
  }
}
  }
 }
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Odp: Still confused with lapply

2010-11-19 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 19.11.2010 16:58:01:

 PtitBleu ptit_b...@yahoo.fr 
 
 Hello Petr,
 
 Your solution works well with my example.
 But with the function I want to use (which calls another functions), I 
still
 have errors.
 I have to work on it again (but only on monday).
 
 Again thank you,
 Ptit Bleu.
 
 PS : I have access to all the functions but I don't want to modify all 
of
 them because I just need to correct an error I discovered in 
already-treated
 data (not sure I'm clear ...).

In that case probably only person who can help you are yourself.

Regards
Petr


 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Still-confused-
 with-lapply-tp3050414p3050573.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] all extended ASCII characters exist for R console output?

2010-11-19 Thread Henrique Dallazuanna
In the plot window:

plot(1, main = \u2591\u2592\u2593)


On Fri, Nov 19, 2010 at 2:02 PM, Mark Heckmann mark.heckm...@gmx.de wrote:

 Hi,

 can the R console print all extended ASCII characters?
 I am especially interested in characters 176-178 from
 http://www.asciitable.com/
  bottom table.
 As far as I know the character mapping in R is somewhat different
 (octal).
 So  as I am not familiar with these things I am not sure if it exists.

 TIA
 Mark
 –––
 Mark Heckmann
 Dipl. Wirt.-Ing. cand. Psych.
 Celler Straße 27
 28205 Bremen
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]


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




-- 
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] Job scheduling in R

2010-11-19 Thread Whit Armstrong
http://hudson-ci.org/

give hudson a try.  It's incredibly easy to set up, and handles job
dependencies and notifications for job failures.

Its suggested use case is for automated software builds, but it fits
the role of scheduled jobs (and interjob dependencies) very well.

-Whit


On Fri, Nov 19, 2010 at 10:09 AM, amit jain budd...@indiatimes.com wrote:
 Hi All,

 Can anyone point to any package/resouce to schedule a job in R which runs a 
 .R file at a specified time ?

 I couldn't find anything useful in R Reference manual or RSiteSearch. I am 
 sure its there but i am unable to locate.

 Thanks for your help.
 Puneet

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

2010-11-19 Thread Immanuel Seeger
Hello all,

using package tcltk this is my problem:

 

I want to set a colour of a tclVar().

I have a tklabel (fixed in position) which should display two variables
occasionally. 

If a constraint is fulfilled, the tklabel should display
correct-tclVar('correct') in green, otherwise it should display
wrong-tclVar('wrong') in red!

 

To display the variables is no problem, but getting colour into them.

Up to now for me it was only possible to set the colour of the whole label. 

 

Any advice?

 

Thanks!

 

Immanuel Seeger

 

 

 


[[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] all extended ASCII characters exist for R console output?

2010-11-19 Thread Mark Heckmann
is it also possible on the console?
that is what i am actually interested in?

Thanks in advance!
Mark

Am 19.11.2010 um 17:24 schrieb Henrique Dallazuanna:

 In the plot window:

 plot(1, main = \u2591\u2592\u2593)


 On Fri, Nov 19, 2010 at 2:02 PM, Mark Heckmann  
 mark.heckm...@gmx.de wrote:
 Hi,

 can the R console print all extended ASCII characters?
 I am especially interested in characters 176-178 from 
 http://www.asciitable.com/
  bottom table.
 As far as I know the character mapping in R is somewhat different
 (octal).
 So  as I am not familiar with these things I am not sure if it exists.

 TIA
 Mark
 –––
 Mark Heckmann
 Dipl. Wirt.-Ing. cand. Psych.
 Celler Straße 27
 28205 Bremen
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]


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




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

–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Straße 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]

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


Re: [R] all extended ASCII characters exist for R console output?

2010-11-19 Thread Mark Heckmann
just found it out.
to get an overview:

for (i in 2590:3000)
cat(eval(parse(text=paste(\\\u, i, \, sep=

Thanks,
Mark

Am 19.11.2010 um 17:24 schrieb Henrique Dallazuanna:

 In the plot window:

 plot(1, main = \u2591\u2592\u2593)


 On Fri, Nov 19, 2010 at 2:02 PM, Mark Heckmann  
 mark.heckm...@gmx.de wrote:
 Hi,

 can the R console print all extended ASCII characters?
 I am especially interested in characters 176-178 from 
 http://www.asciitable.com/
  bottom table.
 As far as I know the character mapping in R is somewhat different
 (octal).
 So  as I am not familiar with these things I am not sure if it exists.

 TIA
 Mark
 –––
 Mark Heckmann
 Dipl. Wirt.-Ing. cand. Psych.
 Celler Straße 27
 28205 Bremen
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]


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




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

–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Straße 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]

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


Re: [R] all extended ASCII characters exist for R console output?

2010-11-19 Thread Jeff Newmiller
The glyphs displayed depend on the terminal you are using, which may be 
operating-system dependent. Beware of assuming that other people will see the 
same things you do in their consoles.

Mark Heckmann mark.heckm...@gmx.de wrote:

just found it out.
to get an overview:

for (i in 2590:3000)
   cat(eval(parse(text=paste(\\\u, i, \, sep=

Thanks,
Mark

Am 19.11.2010 um 17:24 schrieb Henrique Dallazuanna:

 In the plot window:

 plot(1, main = \u2591\u2592\u2593)


 On Fri, Nov 19, 2010 at 2:02 PM, Mark Heckmann  
 mark.heckm...@gmx.de wrote:
 Hi,

 can the R console print all extended ASCII characters?
 I am especially interested in characters 176-178 from
http://www.asciitable.com/
  bottom table.
 As far as I know the character mapping in R is somewhat different
 (octal).
 So  as I am not familiar with these things I am not sure if it
exists.

 TIA
 Mark
 ���
 Mark Heckmann
 Dipl. Wirt.-Ing. cand. Psych.
 Celler Stra�e 27
 28205 Bremen
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]


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




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

���
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Stra�e 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




   [[alternative HTML version deleted]]

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

---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.

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


Re: [R] predict() an rpart() model: how to ignore missing levels in a factor

2010-11-19 Thread jamessc

many thanks - that's perfect, excluding records on a rep-by-rep basis is what
I was just hoping for but I probably didn't explain myself that well!

James
-- 
View this message in context: 
http://r.789695.n4.nabble.com/predict-an-rpart-model-how-to-ignore-missing-levels-in-a-factor-tp3049218p3050670.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] all extended ASCII characters exist for R console output?

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 11:45 AM, Jeff Newmiller wrote:

The glyphs displayed depend on the terminal you are using, which  
may be operating-system dependent. Beware of assuming that other  
people will see the same things you do in their consoles.




On a Mac this:

 cat(\u2591,\u2592,\u2593)
░ ▒ ▓

Prints three rectangles of varying size and density. This appears  
somewhat similar to what I see im my browser except for the noticeable  
variation in size.


--
David


Mark Heckmann mark.heckm...@gmx.de wrote:


just found it out.
to get an overview:

for (i in 2590:3000)
cat(eval(parse(text=paste(\\\u, i, \, sep=

Thanks,
Mark

Am 19.11.2010 um 17:24 schrieb Henrique Dallazuanna:


In the plot window:

plot(1, main = \u2591\u2592\u2593)


On Fri, Nov 19, 2010 at 2:02 PM, Mark Heckmann
mark.heckm...@gmx.de wrote:
Hi,

can the R console print all extended ASCII characters?
I am especially interested in characters 176-178 from

http://www.asciitable.com/

bottom table.
As far as I know the character mapping in R is somewhat different
(octal).
So  as I am not familiar with these things I am not sure if it

exists.


TIA
Mark
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
��

Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Stra�e 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




  [[alternative HTML version deleted]]


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

http://www.R-project.org/posting-guide.html

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




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


� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
� 
���

Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Stra�e 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




[[alternative HTML version deleted]]

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


---
Jeff NewmillerThe .   .  Go  
Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.   
Live Go...
 Live:   OO#.. Dead: OO#..   
Playing

Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.   
rocks...1k

---
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] calculating martingale residual on new data using predict.coxph

2010-11-19 Thread Shi, Tao
Hi list,

I was trying to use predict.coxph to calculate martingale residuals on a test 
data, however, as pointed out before

http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html

predict(mycox1, newdata, type=expected) is not implemented yet.  Dieter 
suggested to use 'cph' and 'predict.Design', but from my reading so far, I'm 
not 
sure they can do that.

Do you other ways to calculate martingale residuals on a new data?

Thank you very much!

...Tao

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 do I build panel data/longitudinal data models with AR terms using the plm package or any other package

2010-11-19 Thread Jude Ryan
Hi Giovanni,

Thanks a lot for your input. I will explore using 'nlme' and 'lme4'. I had read 
your paper early on and was hoping, for reasons outlined in your paper 
regarding the differences in approaches and jargon between statisticians and 
econometricians ..., I could do what I needed with the 'plm' package. When you 
do get around to adding this capability to your package, let me know if there 
is any way I can help, such as testing the functionality out with data I work 
with, QA'ing, ...

Regards,

Jude Ryan
MarketShare Partners
1270 Avenue of the Americas, Suite # 2702
New York, NY 10020
http://www.marketsharepartners.com
Work: (646)-745-9916 ext: 222
Cell: (973)-943-2029

From: Millo Giovanni [mailto:giovanni_mi...@generali.com]
Sent: Friday, November 19, 2010 1:22 AM
To: Jude Ryan; R-help@r-project.org
Cc: yves.croiss...@univ-reunion.fr
Subject: R: how do I build panel data/longitudinal data models with AR terms 
using the plm package or any other package

Hello Jude.
Please find my remarks below, with '##'


Da: Jude Ryan [mailto:jr...@marketsharepartners.com]
Inviato: giovedì 18 novembre 2010 23:52
A: R-help@r-project.org
Cc: yves.croiss...@univ-reunion.fr; Millo Giovanni
Oggetto: how do I build panel data/longitudinal data models with AR terms using 
the plm package or any other package
Hi All,

I am doing econometric modeling of panel data (fixed effects). We currently use 
Eviews to do this, but I have discovered a bug in Eviews 7 and am exploring the 
use of R to build panel data models / longitudinal data models. I looked at the 
plm package but do not see how I can incorporate AR terms in the model using 
the plm package.

## Two possible meanings here: either you want autoregressive y or 
autoregressive errors
1) y = rho1*y(-1) + rho2*y(-2) + Xb + e
 or
2) y = Xb + u, u = rho1*u(-1) + rho2*u(-2)

1) is easy: just use lags, like
 fm - y ~ lag(y) + lag(y,2) + x
but be aware of the Nickell bias: your estimator needs T-asymptotics.

 I have an Eviews model with two AR terms, AR(1) and AR(2),

## ...then, chances are you want 2) ! all my other remarks below apply to this 
second case (while 1) would fail for lack of strict endogeneity)

 and I am trying to replicate that model using R (and SAS too, if possible) as 
the fitted values in Eviews for panel data (fixed effects) appear to be wrong. 
In Eviews I tried a second approach and explicitly coded the fixed effects as 
dummy variables but the standard errors I get are very different from using the 
panel data options in Eviews, and thus the final model selected could be very 
different based on these two approaches.

Can I incorporate AR terms in a panel data model using the plm package, and if 
so, how?

## As of now, no. We plan to add feasible AR(1) à la Baltagi, but it won't be 
tomorrow. This is also because ---

 Also, are there any other packages like nlme, lme4, .. that will let me build 
panel data models / longitudinal data models with AR terms?

## Yes. You can try 'nlme' and its newer sibling 'lme4'. I'm sure it can do 
random effects + AR(1), and sure you can put in the FEs as dummies; there are 
probably more elegant solutions but I'm not that familiar with it myself. For 
an introduction from the econometrician's viewpoint, see here 
http://www.jstatsoft.org/v27/i02 Ch. 7

 Do any of these packages let you build panel data models / longitudinal data 
models specifying both AR and MA terms? Looking at the ACF and PCAF it seems 
that some of the error processes are best/more compactly represented by a 
combination of AR and MA terms, but unfortunately Eviews only lets you use AR 
terms for panel data and getting rid of the cross-sections in the panel data 
and building ARIMA models, which let you specify both AR and MA terms for the 
error process, will mean building separate models for each cross-section. 
Besides, we do not have that much data to build time series models and panel 
data methods let us circumvent the limited data issue.

## The issue here is, of course, cross-sectional poolability. The ARMA process 
in the errors should be the same for each individual. I am confident that you 
may find something in 'nlme''s rich error covariance structures. If you do, 
another possibility to get rid of the FEs and use standard methods is using 
first-difference data (but of course this modifies the errors' covariance 
specification, and you should reparameterize it).

It is my understanding (but I could be wrong) that some of the SAS procs, like 
HPMIXED, let you specify only one AR term for panel data so I am hoping there 
is some R package that will let me replicate what I can do in Eviews, and 
possibly even go beyond what Eviews can do by specifying both AR and MA terms.

## If you're comfortable with ML, you could as well try to  write down the 
likelihood and optimize it. There are facilities in package 'maxLik'.

Thanks in advance for your time,

Jude Ryan
MarketShare Partners
1270 

Re: [R] calculating martingale residual on new data using predict.coxph

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 12:32 PM, Shi, Tao wrote:


Hi list,

I was trying to use predict.coxph to calculate martingale  
residuals on a test

data, however, as pointed out before


What about resid(fit) ?  It's my reading of Therneau  Gramsch [and of  
help(coxph.object) ] that they consider those martingale residuals.




http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html

predict(mycox1, newdata, type=expected) is not implemented yet.   
Dieter
suggested to use 'cph' and 'predict.Design', but from my reading so  
far, I'm not

sure they can do that.

Do you other ways to calculate martingale residuals on a new data?

Thank you very much!

...Tao



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] all extended ASCII characters exist for R console output?

2010-11-19 Thread Henrik Bengtsson
Just to get the message through that some already tried, e.g. on
Windows 7 with R (Rterm) you get:

 cat(\u2591,\u2592,\u2593)
¦ ¦ ¦


See it didn't even cut'n'paste the same visual symbols as I see in
Rterm but I guess you cannot see that.  Make sense?  No?   Point is,
expect issues if you're running this outside your own system/on
different setup.  (This has nothing to do with R).

/H

On Fri, Nov 19, 2010 at 9:16 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Nov 19, 2010, at 11:45 AM, Jeff Newmiller wrote:

 The glyphs displayed depend on the terminal you are using, which may be
 operating-system dependent. Beware of assuming that other people will see
 the same things you do in their consoles.


 On a Mac this:

 cat(\u2591,\u2592,\u2593)
 ░ ▒ ▓

 Prints three rectangles of varying size and density. This appears somewhat
 similar to what I see im my browser except for the noticeable variation in
 size.

 --
 David

 Mark Heckmann mark.heckm...@gmx.de wrote:

 just found it out.
 to get an overview:

 for (i in 2590:3000)
        cat(eval(parse(text=paste(\\\u, i, \, sep=

 Thanks,
 Mark

 Am 19.11.2010 um 17:24 schrieb Henrique Dallazuanna:

 In the plot window:

 plot(1, main = \u2591\u2592\u2593)


 On Fri, Nov 19, 2010 at 2:02 PM, Mark Heckmann
 mark.heckm...@gmx.de wrote:
 Hi,

 can the R console print all extended ASCII characters?
 I am especially interested in characters 176-178 from

 http://www.asciitable.com/

 bottom table.
 As far as I know the character mapping in R is somewhat different
 (octal).
 So  as I am not familiar with these things I am not sure if it

 exists.

 TIA
 Mark
 ���
 Mark Heckmann
 Dipl. Wirt.-Ing. cand. Psych.
 Celler Stra�e 27
 28205 Bremen
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com




      [[alternative HTML version deleted]]


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

 http://www.R-project.org/posting-guide.html

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




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

 ���
 Mark Heckmann
 Dipl. Wirt.-Ing. cand. Psych.
 Celler Stra�e 27
 28205 Bremen
 Blog: www.markheckmann.de
 R-Blog: http://ryouready.wordpress.com




        [[alternative HTML version deleted]]

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


 ---
 Jeff Newmiller                        The     .       .  Go
 Live...
 DCN:jdnew...@dcn.davis.ca.us        Basics: ##.#.       ##.#.  Live
 Go...
                                     Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
 /Software/Embedded Controllers)               .OO#.       .OO#.
  rocks...1k

 ---
 Sent from my phone. Please excuse my brevity.

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


Re: [R] Set colour in tcl variable

2010-11-19 Thread Phil Spector

Immanuel -
   I don't believe you can associate a color with a TclVar,
but you can use tkconfigure to change the color of a label.
Does this little program help?

library(tcltk)
base = tktoplevel()
lab = tklabel(base,text='correct',foreground='green')
tkpack(lab)
red = function(...)tkconfigure(lab,foreground='red',text='wrong')
green = function(...)tkconfigure(lab,foreground='green',text='correct')
tkpack(tkbutton(base,text='Red',command=red))
tkpack(tkbutton(base,text='Green',command=green))


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


On Fri, 19 Nov 2010, Immanuel Seeger wrote:


Hello all,

using package tcltk this is my problem:



I want to set a colour of a tclVar().

I have a tklabel (fixed in position) which should display two variables
occasionally.

If a constraint is fulfilled, the tklabel should display
correct-tclVar('correct') in green, otherwise it should display
wrong-tclVar('wrong') in red!



To display the variables is no problem, but getting colour into them.

Up to now for me it was only possible to set the colour of the whole label.



Any advice?



Thanks!



Immanuel Seeger








[[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] a rounding option for \Sexpr{}?

2010-11-19 Thread Claudia Beleites

Dear all,


I don't like the current behaviour, but that change could break a lot of
existing documents. Since you can easily wrap your Sexpr arguments in a call to
whatever formatting function you want, why force all of those users to change
their documents?
I'm someone who would change a whole lot of \Sexpr{}s: I could get rid of all 
those round() and format()s...


Currently almost don't use \Sexpr as I find the advantage of just having a tiny 
little R expression in the text is lost if half a line of formatting code is 
required. Particularly, as one has to be careful not to have a line break in the 
\Sexpr{} as Sweave doesn't recognize those.
At the moment, I tend to use chunks with result=latex instead – which is not the 
nicest thing to read in the source as it breaks the flow of a sentence quite 
badly. But currently, it is much faster to type for me. On the other hand, maybe 
it's just about time to write a template/snippet for \Sexpr{format (, digits = 
3)}...


An alternative of course would be introducing a new kind of those commands. If 
that's going to happen, I'd vote for something really short like the brew 
syntax. But maybe I just didn't understand the advantage of \Sexpr{} and 
\VignetteXXX{} looking like Latex commands although they aren't (particularly as 
Latex source code highlighting without taking into account Sweave syntax is 
anyways messed up by $ in the \Sexpr{}.
Also, very subjectively, I'd find a syntax with angle brackets more consistent 
as the code chunks start with angle brackets anyways.


My 2 ct,

Claudia


--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

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


Re: [R] RGoogleDocs stopped working

2010-11-19 Thread Tal Galili
I second Harlan's call.


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, Nov 19, 2010 at 5:00 PM, Harlan Harris har...@harris.name wrote:

 Any new thoughts on this? I really want to get this working again! Is there
 someone else that can help or somewhere else I should be asking?

 Thanks!

  -Harlan


 On Wed, Nov 17, 2010 at 10:16 AM, Harlan Harris har...@harris.name
 wrote:

  Following up again. I found on the forums for the Google Apps API this
  thread that seems to be about a similar issue:
 
 http://www.google.com/support/forum/p/apps-apis/thread?tid=1c22cb44eb5cbba6hl=ensearch_impression_id=ab161b010ecf8803%3A12c5a65ce83search_source=related_question
 
  It's using Java and is rather over my head, but it seems to suggest that
  something related to the content type might be wrong? Does this offer any
  suggestions on how to fix my use of RGoogleDocs?
 
  Thanks,
 
   -Harlan
 
 
  On Mon, Nov 15, 2010 at 12:16 PM, Harlan Harris har...@harris.name
 wrote:
 
  Thanks, Duncan. Finally getting a chance to follow up on this...
 
  I tried again, changing and resetting my password, and trying to specify
  my login and password manually in the getGoogleDocsConnection argument
 list.
  I also tried removing either or both of the service and error options.
 No
  luck in any case. I also tried a different Google account, also with no
  luck.
 
  I've also tried tweaking the URL being generated by the code, and in all
  cases, I get a 403: Forbidden error with content
 Error=BadAuthentication.
 
  I don't really know enough about how authentication is supposed to work
 to
  get much farther. Can you help? Should I try the Google API forum
 instead?
 
   -Harlan
 
 
 
  From: Duncan Temple Lang dun...@wald.ucdavis.edu
  To: r-help@r-project.org
  Date: Wed, 10 Nov 2010 10:33:47 -0800
  Subject: Re: [R] RGoogleDocs stopped working
 
  Hi Harlan
 
   I just tried to connect to Google Docs and I had ostensibly the same
  problem.
  However, the password was actually different from what I had specified.
  After resetting it with GoogleDocs, the getGoogleDocsConnection()
 worked
  fine. So I don't doubt that the login and password are correct, but
  you might just try it again to ensure there are no typos.
  The other thing to look at is the values for Email and Passwd
  sent in the URL, i.e. the string in url in your debugging
  below. (Thanks for that by the way). If either has special characters,
  e.g. , it is imperative that they are escaped correctly, i.e.
 converted
  to %24.  This should happen and nothing should have changed, but it is
  worth verifying.
 
   So things still seem to work for me. It is a data point, but not one
  that gives you much of a clue as to what is wrong on your machine.
 
   D.
 
 
  On Wed, Nov 10, 2010 at 10:36 AM, Harlan Harris har...@harris.name
 wrote:
 
  Hello,
 
  Some code using RGoogleDocs, which had been working smoothly since the
  summer, just stopped working. I know that it worked on November 3rd,
 but it
  doesn't work today. I've confirmed that the login and password still
 work
  when I log in manually. I've confirmed that the URL gives the same
 error
  when I paste it into Firefox. I don't know enough about this web
 service to
  figure out the problem myself, alas...
 
  Here's the error and other info (login/password omitted):
 
   ss.con - getGoogleDocsConnection(login=gd.login,
 password=gd.password,
  service='wise', error=FALSE)
  Error: Forbidden
 
  Enter a frame number, or 0 to exit
 
  1: getGoogleDocsConnection(login = gd.login, password = gd.password,
  service = wise, error = FALSE)
  2: getGoogleAuth(..., error = error)
  3: getForm(https://www.google.com/accounts/ClientLogin;, accountType
 =
  HOSTED_OR_GOOGLE, Email = login, Passw
  4: getURLContent(uri, .opts = .opts, .encoding = .encoding, binary =
  binary, curl = curl)
  5: stop.if.HTTP.error(http.header)
 
  Selection: 4
  Called from: eval(expr, envir, enclos)
  Browse[1] http.header
 Content-Type
  Cache-control  Pragma
 text/plainno-cache,
  no-store  no-cache
  ExpiresDate
  X-Content-Type-Options
  Mon, 01-Jan-1990 00:00:00 GMT Wed, 10 Nov 2010 15:24:39
  GMT   nosniff
 X-XSS-Protection
  Content-Length  Server
  1; mode=block
  24   GSE
   status   statusMessage
403 Forbidden\r\n
  Browse[1] url
  [1] 
 
 

Re: [R] calculating martingale residual on new data using predict.coxph

2010-11-19 Thread Shi, Tao
Hi David,

Thank you for the quick reply!   

resid(fit) only gives the residuals on the training data not on test data.

...Tao




- Original Message 
 From: David Winsemius dwinsem...@comcast.net
 To: Shi, Tao shida...@yahoo.com
 Cc: r-help@r-project.org; dieter.me...@menne-biomed.de; r_ting...@hotmail.com
 Sent: Fri, November 19, 2010 9:50:06 AM
 Subject: Re: [R] calculating martingale residual on new data using 
predict.coxph
 
 
 On Nov 19, 2010, at 12:32 PM, Shi, Tao wrote:
 
  Hi list,
  
  I was trying to use predict.coxph to calculate martingale residuals  on a 
test
  data, however, as pointed out before
 
 What about  resid(fit) ?  It's my reading of Therneau  Gramsch [and of  
help(coxph.object) ] that they consider those martingale residuals.
 
  
  http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html
  
  predict(mycox1, newdata, type=expected) is not implemented yet.   Dieter
  suggested to use 'cph' and 'predict.Design', but from my reading  so far, 
  I'm 
not
  sure they can do that.
  
  Do you other  ways to calculate martingale residuals on a new data?
  
  Thank you  very much!
  
  ...Tao
 
 
 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] calculating martingale residual on new data using predict.coxph

2010-11-19 Thread David Winsemius


On Nov 19, 2010, at 12:50 PM, David Winsemius wrote:



On Nov 19, 2010, at 12:32 PM, Shi, Tao wrote:


Hi list,

I was trying to use predict.coxph to calculate martingale  
residuals on a test

data, however, as pointed out before


What about resid(fit) ?  It's my reading of Therneau  Gramsch [and  
of help(coxph.object) ] that they consider those martingale residuals.


The manner in which I _thought_ this would work was to insert some  
dummy cases into the original data and then to get residuals by  
weighting the cases appropriately. That doesn't seem to be as  
successful as I imagined:


 test1 - list(time=c(4,3,1,1,2,2,3,3), weights=c(rep(1,7), 0),
+   status=c(1,1,1,0,1,1,0,1),
+   x=c(0,2,1,1,1,0,0,1),
+   sex=c(0,0,0,0,1,1,1,1))
 coxph(Surv(time, status) ~ x , test1, weights=weights)$weights
Error in fitter(X, Y, strats, offset, init, control, weights =  
weights,  :

  Invalid weights, must be 0
# OK then make it a small number
 test1 - list(time=c(4,3,1,1,2,2,3,3), weights=c(rep(1,7), 0.01),
+   status=c(1,1,1,0,1,1,0,1),
+   x=c(0,2,1,1,1,0,0,1),
+   sex=c(0,0,0,0,1,1,1,1))
 print(resid( coxph(Surv(time, status) ~ x ,  
test1,weights=weights) ) ,digits=3)

  1   2   3   4   5   6   7   8
-0.6410 -0.5889  0.8456 -0.1544  0.4862  0.6931 -0.6410  0.0509
Now take out constructed case and weights

 test1 - list(time=c(4,3,1,1,2,2,3),
+   status=c(1,1,1,0,1,1,0),
+   x=c(0,2,1,1,1,0,0),
+   sex=c(0,0,0,0,1,1,1))
 print(resid( coxph(Surv(time, status) ~ x , test1) ) ,digits=3)
 1  2  3  4  5  6  7
-0.632 -0.589  0.846 -0.154  0.486  0.676 -0.632

Expecting approximately the same residuals for first 7 cases but not  
really getting it. There must be something about weights in coxph that  
I don't understand, unless a one-hundreth of a case gets up indexed  
inside the machinery of coxph?


Still think that inserting a single constructed case into a real  
dataset of sufficient size ought to be able to yield some sort of  
estimate, and only be a minor perturbation,  although I must admit I'm  
having trouble figuring out ... why are we attempting such a maneuver?  
The notion of residuals around constructed cases makes me  
statistically suspicious, although I suppose that is just some sort of  
cumulative excess/deficit death fraction.



http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html

predict(mycox1, newdata, type=expected) is not implemented yet.   
Dieter
suggested to use 'cph' and 'predict.Design', but from my reading so  
far, I'm not

sure they can do that.

Do you other ways to calculate martingale residuals on a new data?

Thank you very much!

...Tao


--
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] Calculating distance between longitude, latitude of 2 points

2010-11-19 Thread MacQueen, Don
Also
  spDists
  spDistsN1  Euclidean or Great Circle distance between points
In the sp package.

(and in my personal opinion, the  sp package would be a good place to start, 
since it’s part of a group of packages I view as R’s core packages for working 
with spatial data)
-Don

On 11/19/10 5:17 AM, David Winsemius dwinsem...@comcast.net wrote:


On Nov 19, 2010, at 4:50 AM, Lily_stats wrote:


 Hi all,

 I would like to know a way of calculating the distance between 2
 points when
 I already have the longitude and latitude of the points.

 For example :

 Point 1 :  52° 9'54.00N   4°25'8.40E
 Point 2 :  52°27'46.80N   4°33'18.00E

 Distance between point 1 and point in km 

 Is there any functions already available for this ?

Searching on:  distance points longitude latitude

gdist {Imap} Geodesic distance (great circle distance) between points
Ellipsoidal.Distance {GEOmap} Ellipsoidal Distance
deg.dist {fossil} Haversine Distance Formula
distaz {RSEIS} Distance and Azimuth from two points
distaz {GEOmap} Distance and Azimuth from two points (# one probably
borrowed from the other)
AlongGreat {RFOC} Get Points Along Great Circle
distAB {clim.pact} Distance between two points on Earth

 Any help will be much appreciated!

Suggest you learn to search.

--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
925 423-1062

[[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] Color Alaska in USA map

2010-11-19 Thread Xin Sun
Hello:

I have a problem when I tried to color the USA map with different colors. 
The following is my data (I only used the second column of data):

alaska,1, 2
Hawaii, 0, 0
USA,5, 5

And here is my code:

library(latticeExtra)
library(mapproj)
state-read.table(C:\\usaclass.txt,sep=,)
state
range-with(state,range(state[1:3,3]))
range
nbreaks=6
breaks-do.breaks(range,nbreaks)
StateName-state[1:3,1]
StateName
mapplot(StateName~state[1:3,3],data=state,breaks=breaks,
map=map(world, c(USA, Hawaii), fill=TRUE) ,scales=list(draw=FALSE),
colramp = colorRampPalette(c(white, black)),xlab=NULL)

After I run this code, the continental USA could be colored, but  alaska is not 
colored. I have tried to write alaska as Alaska and USA:alaska. However, it 
does not work. Do you have any suggestion? Thanks!


Sun

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


[R] simple loop problemo (Geo brownian motion)

2010-11-19 Thread newbster

I would like to plot multiple random walks onto the same graph.  My p
variable dictates how may random walks there will be.


par(mfrow=c(1,1))
p - 100
N - 1000
S0 - 10
mu - 0.03
sigma - 0.2
nu - mu-sigma^2/2
x - matrix(rep(0,(N+1)*p),nrow=(N+1)) 
y - matrix(rep(0,(N+1)*p),nrow=(N+1)) 
t- (c(0:N))/N
for (j in 1:p)
{
z - rnorm(N,0,1)
x[1,j] - 0
y[1,j] - S0
for (i in 1:N)
{
x[i+1,j] - (1/sqrt(N))*sum(z[1:i])
y[i+1,j] - y[1,j]*exp(nu*t[i+1]+sigma*x[i+1,j])
}

plot(t,y,type=l,xlab=time, ylab=Geometric Brownian motion)

}


Any help would be appreciated, thanks.


-- 
View this message in context: 
http://r.789695.n4.nabble.com/simple-loop-problemo-Geo-brownian-motion-tp3050762p3050762.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to apply sample function to each row of a data frame?

2010-11-19 Thread wangwallace

this is a simple question, but I wasn't able to figure it out myself. 

here is the data frame:

M P Q
1 2 3
4 5 6
7 8 9

M, P, Q each represent a variable

I want to draw 2 random sample from each row separately to create a new data
frame. how can I do it?

thanks!!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050787p3050787.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] simple loop problemo (Geo brownian motion)

2010-11-19 Thread Duncan Murdoch

On 19/11/2010 1:09 PM, newbster wrote:

I would like to plot multiple random walks onto the same graph.  My p
variable dictates how may random walks there will be.


par(mfrow=c(1,1))
p- 100
N- 1000
S0- 10
mu- 0.03
sigma- 0.2
nu- mu-sigma^2/2
x- matrix(rep(0,(N+1)*p),nrow=(N+1))
y- matrix(rep(0,(N+1)*p),nrow=(N+1))
t- (c(0:N))/N
for (j in 1:p)
{
z- rnorm(N,0,1)
x[1,j]- 0
y[1,j]- S0
for (i in 1:N)
{
x[i+1,j]- (1/sqrt(N))*sum(z[1:i])
y[i+1,j]- y[1,j]*exp(nu*t[i+1]+sigma*x[i+1,j])
}

plot(t,y,type=l,xlab=time, ylab=Geometric Brownian motion)

}


Any help would be appreciated, thanks.



You can use the matplot function to plot multiple columns of a matrix at 
once.  So with your code as above, leave out the call to plot(), then  
matplot(t, y) would give you approximately what you're looking for 
(though the colour and symbol choices need some work).


You can get rid of the inner loop by using cumsum() and vectorized 
calculations; then it will be reasonably fast.


Another way to do this is to create the plot before the loop, then use 
lines() to add lines to it within the loop.  Then you need to guess the 
scale ahead of time, or do a little experimentation.


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.


[R] question about constraint minimization

2010-11-19 Thread dhacade...@gmail.com

Hi, 

I am a beginner of R. There is a question about constraint minimization. A
function, y=f(x1,x2,x3x12), needs to be minimized. There are 3
requirements for the minimization: 

(1) x2+x3+...+x12=1.5 (x1 is excluded);
(2) x1=x3=x4;
(3) x1, x3 and x5 are in the range of -1~0, respectively. The rest variables
(x2, x4, x6, x7, , x12) are in the range of 0~1, respectively.

The optim function is used. And part of my input is as follow, where
xx1r represents the x12:

xx1r=1.5-x[2]-x[1]-x[1]-x[3]-x[4]-x[5]-x[6]-x[7]-x[8]-x[9]
start=rnorm(9)
up=1:9/1:9*1
lo=1:9/1:9*-1
out=optim(start,f,lower=lo,upper=up,method=L-BFGS-B,hessian=TRUE,
control=list(trace=6,maxit=1000))

There are two problems in this input. the up and lo only define a range
of -1~1 for x1 to x11, which can not meet the requirement (3). In addition,
there is not any constraint imposed on x12. I have no idea how to specify a
matrix that can impose different constraints on individual variables in a
function. Any suggestion is highly appreciated.

Best,
Hao


-- 
View this message in context: 
http://r.789695.n4.nabble.com/question-about-constraint-minimization-tp3050880p3050880.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] question about constraint minimization

2010-11-19 Thread Jonathan P Daily
Does ?constrOptim look as though it will handle your needs?
--
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it.
 - Jubal Early, Firefly

r-help-boun...@r-project.org wrote on 11/19/2010 02:51:46 PM:

 [image removed] 
 
 [R] question about constraint minimization
 
 dhacade...@gmail.com 
 
 to:
 
 r-help
 
 11/19/2010 03:15 PM
 
 Sent by:
 
 r-help-boun...@r-project.org
 
 
 Hi, 
 
 I am a beginner of R. There is a question about constraint minimization. 
A
 function, y=f(x1,x2,x3x12), needs to be minimized. There are 3
 requirements for the minimization: 
 
 (1) x2+x3+...+x12=1.5 (x1 is excluded);
 (2) x1=x3=x4;
 (3) x1, x3 and x5 are in the range of -1~0, respectively. The rest 
variables
 (x2, x4, x6, x7, , x12) are in the range of 0~1, respectively.
 
 The optim function is used. And part of my input is as follow, where
 xx1r represents the x12:
 
 xx1r=1.5-x[2]-x[1]-x[1]-x[3]-x[4]-x[5]-x[6]-x[7]-x[8]-x[9]
 start=rnorm(9)
 up=1:9/1:9*1
 lo=1:9/1:9*-1
 out=optim(start,f,lower=lo,upper=up,method=L-BFGS-B,hessian=TRUE,
 control=list(trace=6,maxit=1000))
 
 There are two problems in this input. the up and lo only define a 
range
 of -1~1 for x1 to x11, which can not meet the requirement (3). In 
addition,
 there is not any constraint imposed on x12. I have no idea how to 
specify a
 matrix that can impose different constraints on individual variables in 
a
 function. Any suggestion is highly appreciated.
 
 Best,
 Hao
 
 
 -- 
 View this message in context: http://r.789695.n4.nabble.com/
 question-about-constraint-minimization-tp3050880p3050880.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] how to apply sample function to each row of a data frame?

2010-11-19 Thread Jorge Ivan Velez
Hi wangwallace,

Here are two ways of doing it. Could you please be more specific?

# data set
X - matrix(1:9, ncol = 3, byrow = TRUE)
colnames(X) - c('M', 'P', 'Q')
X

# option 1  -- two samples per row
replicate(2, {
 out - t(apply(X, 1, sample))
 colnames(out) - colnames(X)
 list(out)
 })

# option 2  -- two samples of the whole data
replicate(2,{
X - X[sample(3),]
 list(X)
 })



HTH,
Jorge


On Fri, Nov 19, 2010 at 1:34 PM, wangwallace  wrote:


 this is a simple question, but I wasn't able to figure it out myself.

 here is the data frame:

 M P Q
 1 2 3
 4 5 6
 7 8 9

 M, P, Q each represent a variable

 I want to draw 2 random sample from each row separately to create a new
 data
 frame. how can I do it?

 thanks!!
 --
 View this message in context:
 http://r.789695.n4.nabble.com/how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050787p3050787.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


[R] RGoogleDocs stopped working

2010-11-19 Thread Farrel Buchinsky
Harlan and Tal have had problems. I had lots too. I spent hours getting it
to work. Terrible process to go through but RGoogleDocs is so useful that
the time was worth it - I think!

My problems were overcome when

   1. I used the latest zip file by Duncan Temple Lang see below
   2. I inserted an options line that loosened the ssl security - do not
   know if that was a good thing or not but it got it to work

Duncan said:
I have put an updated version of the source of the package with
these changes. It is available from
http://www.omegahat.org/RGoogleDocs/RGoogleDocs_0.4-1.tar.gz
There is a binary for Windows  in
http://www.omegahat.org/RGoogleDocs/RGoogleDocs_0.4-1.zip

Here is my script that works. Does yours look like this?

library(RGoogleDocs)
packageDescription(RGoogleDocs)
ps -readline(prompt=get the password in )
options(RCurlOptions = list(capath = system.file(CurlSSL, cacert.pem,
package = RCurl), ssl.verifypeer = FALSE))
sheets.con = getGoogleDocsConnection(getGoogleAuth(fjb...@gmail.com, ps,
service =wise))
ts2=getWorksheets(OnCall,sheets.con) #OnCall is just the name of a
spreadsheet
names(ts2)
y2005-sheetAsMatrix(ts2$y2005,header=TRUE, as.data.frame=TRUE, trim=TRUE)

Finally, I am willing to offer you a TeamViewer session where we can take
control of one another's computers and see if the problem is code or the
installation. I warn you that I am neither a programmer nor a developer,
just a very enthusiastic RGoogleDocs user who probably perseveres more than
is good for him.

Farrel Buchinsky

[[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] Integrating functions / vector arithmetic

2010-11-19 Thread Erich Neuwirth
Some remarks:
Why are you using assignments to indicate the return values of functions?
This is R idiom:
 f-function(u){
  f-0
  for (j in 1:4){
f-f+coeff[j]*(zeta(j)(u))
  }
  f
 }
 

If you only want the inner product of 2 vector, outer probably is an overkill.

g - function(u){
 sum(coeff * zeta(1:4)(u))
}

should be enough.

And plot(g) does not work because g is not vectorized.

plot(Vectorize(g))

will work

On Nov 16, 2010, at 1:18 AM, Eduardo de Oliveira Horta wrote:

 Hello,
 
 I was trying to build some functions which I would like to integrate over an
 interval using the function 'integrate' from the 'stats' package. As an
 example, please consider the function
 
 h(u)=sin(pi*u) + sqrt(2)*sin(pi*2*u) + sqrt(3)*sin(pi*3*u) + 2*sin(pi*4*u)
 
 Two alternative ways to 'build' this function are as in f and g below:
 
 coeff-sqrt(1:4)
 
 zeta-function(i) {force(i); function(u){
  zeta-sqrt(2)+sin(pi*i*u)
 }}
 
 f-function(u){
  f-0
  for (j in 1:4){
f-f+coeff[j]*(zeta(j)(u))
  }
  f-f
 }
 
 g-function(u){
  g-crossprod(coeff,zeta(1:4)(u))
 }
 
 Obviously, f and g are equivalent, but in the actual code I am writing, g is
 much faster. However, I can't seem to integrate (neither to plot) g. In
 fact, these are the error messages I get:
 
 print(f(.1))
 [1] 4.443642
 print(g(.1))
 [,1]
 [1,] 4.443642
 
 Everything ok until here... but...
 
 When using plot(), I get this:
 
 plot(f) #plots, as expected.
 plot(g)
 Error in crossprod(coeff,zeta(1:4)(u)) : arguments not compatible
 Besides that: Warning message:
 In pi * i * u :
  longer object length is not a multiple of shorter object length
 
 When using integrate(), I get this:
 
 integrate(f,0,1)
 1.004172 with absolute error  2.5e-13
 integrate(g,0,1)
 Error in crossprod(coeff,zeta(1:4)(u)) : arguments not compatible
 Besides that: Warning message:
 In pi * i * u :
  longer object length is not a multiple of shorter object length
 
 
 I have already tried some simple 'solutions', for example to set
 g-function(u){
  vec1-drop(coeff)
  vec2-drop(zeta(1:4)(u))
  g-drop(crossprod(coeff,zeta(1:4)(u)))
 }
 
 as well as using the %*% operation, but these won't solve my problem.
 
 Any suggestions would be welcome. Thanks in advance,
 
 Eduardo Horta
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Center for Computer Science Didactics and Learning Research 
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39902 Fax: +43-1-4277-39459

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


[R] ?summaryRprof running at 100% cpu for one hour ...

2010-11-19 Thread Kjetil Halvorsen
This is very strange. (Debian squeeze, R 2.12.0 compiled from source)

I did some moderately large computation (including svd of a 560x50 matrix),
running a few minutes, and R memory increasing to about 900MB on this
2 GB ram laptop. I had done Rprof(memory.profiling=TRUE) first.
Then doing summaryRprof().
Then doing
?summaryRprof
and then the computer running with one of two cores at 100% for more
than an hour!

Whats happening?
(running R from within emacs-ess)
Kjetil

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

2010-11-19 Thread Patrick Leyshock
I'm trying to configure Version 2.12.0 or R to do memory profiling.

I've reconfigured the code:

% ./compile --enable-memory-profiling=YES

and verified that it's configured correctly by examining the output.  I then
rebuild R:

% make

Then I fire up R and run a script, using Rprof with the memory-profiling
switch set to TRUE:

Rprof(output, memory.profiling=TRUE);
# a bunch of R code
Rprof(NULL);

When I examine the output, however, using either R CMD Rprof from the shell,
or summaryRprof from within R, the output I see is identical to the output I
got when I ran R BEFORE I recompiled with memory profiling enabled.

Anyone see something that I'm missing?

Thanks, Patrick

[[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] a rounding option for \Sexpr{}?

2010-11-19 Thread Yihui Xie
I will appreciate a lot if you do not mind add a new option like
'useFormat'. I suggested format() because I'm allergic to too many
options.

I must say it is not hard to define the formatting, but it is just
tedious to do it for every single number because by default we have
too many digits especially for decimals.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Fri, Nov 19, 2010 at 9:55 AM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:
 On 19/11/2010 10:38 AM, Dieter Menne wrote:

 Duncan Murdoch-2 wrote:
 
   On 19/11/2010 10:12 AM, Yihui Xie wrote:
   Maybe this should go to R-devel as a wishlist:
val- format(eval(parse(text=cmd), envir=.GlobalEnv))
 
   I don't like the current behaviour, but that change could break a lot
  of
   existing documents.
 

 Not necessarily. Add an Sweave option useFormat=FALSE to keep the old
 behavior.

 I think the default would have to be FALSE, so that old documents didn't
 suddenly change.   But is it really so hard to define your own formatting?

 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.


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

2010-11-19 Thread Soyeon Kim
Dear All,

I want to print out graph1.png  graph2.png graph3.png  ... How
can I print it out?

Thank you,

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 sample function to each row of a data frame?

2010-11-19 Thread Petr Savicky
On Fri, Nov 19, 2010 at 10:34:26AM -0800, wangwallace wrote:
 
 this is a simple question, but I wasn't able to figure it out myself. 
 
 here is the data frame:
 
 M P Q
 1 2 3
 4 5 6
 7 8 9
 
 M, P, Q each represent a variable
 
 I want to draw 2 random sample from each row separately to create a new data
 frame. how can I do it?

I am not sure, what you exactly mean. Can you provide an example of
the expected output?

If you consider each row as a sample of size 3 and want to use the
function sample() or sample(, replace=TRUE) to create a new sample
of the same size as a row of a new table, then in addition to the
already posted solutions you can use

  X - matrix(1:9, ncol = 3, byrow = TRUE)

  j - rep(seq(nrow(X)), each=2)
  Y - matrix(, ncol=ncol(X), nrow=length(j))
  for (i in seq(nrow(Y))) {
  Y[i, ] - sample(X[j[i], ]) # or add replace=TRUE
  }

  colnames(Y) - c(M, P, Q)
  data.frame(Y)

M P Q
  1 2 3 1
  2 1 3 2
  3 5 4 6
  4 6 4 5
  5 7 9 8
  6 8 9 7

PS.

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

2010-11-19 Thread sahin

hello,

I try to model traffic accidents with the following model:

glm.nb(y~j+w+m+sf+b+ft,data=fr[]). the problem is that there exist  
autocorrelation  in the data. one possibility is to model traffic  
accidents with inar(1)-models. has anyone an idea how to change this  
model in order to abtain an integer valued time series model?


thanks
nazli

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

2010-11-19 Thread Jorge Ivan Velez
Perhaps this?

 paste('graph', 1:10, '.png', sep = )

Please give us more context/details on what you are trying to do. I
will undoubtedly help us to help you. In this case, the posting guide is
your friend.

HTH,
Jorge


On Fri, Nov 19, 2010 at 3:57 PM, Soyeon Kim  wrote:

 Dear All,

 I want to print out graph1.png  graph2.png graph3.png  ... How
 can I print it out?

 Thank you,

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


[[alternative HTML version deleted]]

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


Re: [R] How to print graph1.png graph2.png graph3.png ... ?

2010-11-19 Thread Soyeon Kim
Yes. This is what I want to do. Thanks!
I've tried to paste function but I didn't know how to use
appropriately in this case.

Have a nice weekend.

On Fri, Nov 19, 2010 at 3:05 PM, Jorge Ivan Velez
jorgeivanve...@gmail.com wrote:
 Perhaps this?
  paste('graph', 1:10, '.png', sep = )
 Please give us more context/details on what you are trying to do. I
 will undoubtedly help us to help you. In this case, the posting guide is
 your friend.

 HTH,
 Jorge


 On Fri, Nov 19, 2010 at 3:57 PM, Soyeon Kim  wrote:

 Dear All,

 I want to print out graph1.png  graph2.png graph3.png  ... How
 can I print it out?

 Thank you,

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

2010-11-19 Thread Kjetil Halvorsen
see
http://onlinelibrary.wiley.com/doi/10./j.1467-9892.2010.00684.x/abstract

kjetil

On Fri, Nov 19, 2010 at 6:02 PM,  sa...@hsu-hh.de wrote:
 hello,

 I try to model traffic accidents with the following model:

 glm.nb(y~j+w+m+sf+b+ft,data=fr[]). the problem is that there exist
 autocorrelation  in the data. one possibility is to model traffic accidents
 with inar(1)-models. has anyone an idea how to change this model in order to
 abtain an integer valued time series model?

 thanks
 nazli

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

2010-11-19 Thread Steven Ranney
All -

I think I'm being dense, but for the life of me, I can't figure out
why I get error message with the code below.

I have data that looks like

param level perc.surv asin.tran
DO 3 0.6864407 0.9764544
DO 3 0.125 0.3613671
DO 3 0.8738739 1.2077299
DO 4 0.4615385 0.7468986
DO 4 0.5691057 0.8547258
DO 4 0.8504673 1.1737517
DO 6 0.5494505 0.8349297
DO 6 0.4938272 0.7792252
DO 6 0.1230769 0.3584500
DO 6 0.7209302 1.0142339
DO 6 0.2297297 0.4998584
DO 6 0.930 1.3030330
DO 6 0.4482759 0.7335813
DO 6 0.000 0.000
DO 6 0.6018519 0.8879679


and code

aov.DO - aov(asin.tran~level)
summary(aov.DO)
TukeyHSD(aov.DO)

When I run the final line, I get the following error message

Error in TukeyHSD.aov(aov.DO) : no factors in the fitted model
In addition: Warning message:
In replications(paste(~, xx), data = mf) : non-factors ignored: level

What am I missing?

Thanks for your help -

Steven Ranney
steven.ran...@montana.edu

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


Re: [R] TukeyHSD error

2010-11-19 Thread Steven Ranney
Rescinded.  Problem solved.  I discovered that TukeyHSD doesn't like
numeric factors; changing the level to a factor solved my problem.

SR
Steven H. Ranney
steven.ran...@montana.edu

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