Re: [R] rename and color a list of list of list of values

2015-06-05 Thread Karim Mezhoud
Thanks Sven,

I started with the first function.
The values are not in a list but in df. it is more easy for me

the output is a df:
 Genesbrca_tcga  gbm_tcga   color_brca  color_gbm
name1 v1v2col1 col2
name2 v3v4col3 col4
name3v5 v6col5 col6



attriColorGene <- function(df,colname, color=c(x,y,z)){
Max <- max(df, na.rm=TRUE)
Min <- min(df, na.rm=TRUE)
#"white","yellow", "darkgoldenrod3"
my.colors <- colorRampPalette(c(x,y,z )) #creates a function my.colors
which interpolates n colors between blue, white and red
color.df <- data.frame(colname=seq(Min,Max,1), paste("col_", colname,
sep="")=my.colors(Max- Min)) #generates 2001 colors from the color ramp
df.with.color <- merge(df, color.df, by=colname)
return(df.with.color)
}

for(i in 2:length(colnames(df)) ){
  colname <- colnames[i]
  attriColorGene(df,colname, color=c(x,y,z))
}


could you describe me the structure of the output of
magic_colour, list_child , list_parent?

Thanks
Karim



On Fri, Jun 5, 2015 at 6:12 PM, Sven E. Templer 
wrote:

> Hi Karim,
>
> you should learn ?Map to iterate along the list and supply mutliple list
> arguments (there is also parallel:::mcMap for multicore).
> The magic of the color code generation you figure out yourself, I guess...
>
>
> Here 'i' intends to be the value, 'n' the name, e.g.
>
> # returns color by character/numeric value:
> magic_colour <- function (x) { ... }
>
> # returns child
> list_child <- function (i, n) { list(name=n, colour=magic_colour(i)) }
>
> # returns parent
> list_parent <- function (i, n) { list(name=n, children=Map(list_child, i,
> names(i)), colour=magic_colour(n)) }
>
> # get grandparent
> grandparent <- Map(list_parent, expBefore, names(expBefore))
>
>
> Hope this helps!
>
> Best, S.
>
>
> On 5 June 2015 at 18:31, Karim Mezhoud  wrote:
>
>> Hi all,
>> I have a list like this
>>
>> expBefore <-
>>
>> list(HM450=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),
>>
>>
>> gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
>> ),
>>
>>
>> HM27=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),
>>
>>
>> gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
>>  )
>>  )
>>
>>
>> and I would convert it to
>>
>> expAfter <-list(
>>   list(
>> name="HM450",
>> children=list(
>>   list(name="brca_tcga",
>>children=list(
>>  list(name="ATM", colour="11"),
>>  list(name="ATR", colour="33"),
>>  list(name="BRCA1", colour="55"),
>>  list(name="BRCA2", colour="77"),
>>  list(name="CHEK1", colour="99"),
>>  list(name="CHEK2", colour="bb")
>>
>>), colour="aa" # brca_tcga
>>),
>> list(name="gbm_tcga",
>> children=list(
>>   list(name="ATM", colour="001100"),
>>   list(name="ATR", colour="003300"),
>>   list(name="BRCA1", colour="005500"),
>>   list(name="BRCA2", colour="007700"),
>>   list(name="CHEK1", colour="009900"),
>>   list(name="CHEK2", colour="00bb00")
>> ), colour="345345" # gbm_tcga
>> )
>>
>>), colour="ffa500" # HM450
>>   ),
>>   list(
>> name="HM27",
>> children=list(
>>   list(name="brca_tcga",
>>children=list(
>>  list(name="ATM", colour="11"),
>>  list(name="ATR", colour="33"),
>>  list(name="BRCA1", colour="55"),
>>  list(name="BRCA2", colour="77"),
>>  list(name="CHEK1", colour="99"),
>>  list(name="CHEK2", colour="bb")
>>
>>), colour="aa" ##brca_tcga
>>),
>>   list(name="gbm_tcga",
>>children=list(
>>  list(name="ATM", colour="001100"),
>>  list(name="ATR", colour="003300"),
>>  list(name="BRCA1", colour="005500"),
>>  list(name="BRCA2", colour="007700"),
>>  list(name="CHEK1", colour="009900"),
>>  list(name="CHEK2", colour="00bb00")
>>), colour="345345") #gbm_tcga
>>
>> ), colour="ff00ff"  #HM27
>>   )
>>
>> );
>> any suggestion?
>> Thanks
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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.

[R] "Updating Loaded Package" behavior

2015-06-05 Thread Drew Marticorena
Hello, I am trying to handle more gracefully the issue that occurs when one 
attempts to install a new version of a package whose library is currently 
loaded.  When one does this the functions in the package work but when one 
tries to view the documentation a warning pop is given and the following 
messages are in the terminal.


Error in fetch(key) : lazy-load database '' is corrupt
Warning message: In fetch(key) : internal error -3 in R_decompress1


When testing this behavior with other packages but installing old versions, 
loading the libraries, and then trying to update I sometimes get a popup 
message from Rstudio that begins


Updating Loaded Package

One or more of the packages that will be updated by this installation are 
currently loaded. Restarting R prior to updating these packages is strongly 
recommended. RStudio can restart R and then automatically continue the 
installation after restarting (all work and data will be preserved during the 
restart). Do you want to restart R prior to installing?


The popup asks if I want to restart the R session prior to installing.  This 
has never occurred with my own package, only ones I have gotten from CRAN.   I 
however can not reliably replicate this popup appearing.  For my purpose all of 
the work with the package will occur within RStudio.  Is there a way to force 
RStudio to show this popup when one tries to update an already loaded 
package/library in order to avoid having the user have to figure out why the 
documentation has all of a sudden stopped working?  Alternatively could the 
same thing be done at the command line forcing the user to acknowledge the 
issue and either progress with the install or first restart?


Thank you for any help or insights into this problem


drew marticorena



[[alternative HTML version deleted]]

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


Re: [R] [FORGED] Re: Dunnett Test in 'multicomp' package

2015-06-05 Thread James Henson
Thanks. A useful tip for a long-time SAS user.
James F. Henson

On Fri, Jun 5, 2015 at 3:47 AM, Gerrit Eichner <
gerrit.eich...@math.uni-giessen.de> wrote:

> Hello, everyone,
>
> aside from Rolf's hint (and Richard's warning!) you could also consider
> relevel():
>
> viagraData$dose <- relevel( viagraData$dose, ref = "placebo")
>
>  Hth  --  Gerrit
>
>
> On Fri, 5 Jun 2015, Rolf Turner wrote:
>
>  On 05/06/15 11:08, Jim Lemon wrote:
>>
>>> Hi James,
>>> You can change the order of levels like this:
>>>
>>> levels(viagraData$dose)<-c("placebo","low dose","high dose")
>>>
>>
>> 
>>
>> As Richard Heiberger has pointed out, this is wrong.
>>
>> What *does* work is:
>>
>> viagraData$dose)<-factor(viagraData$dose,
>>levels=c("placebo","low dose","high dose")
>>
>> This is a trap into which many a Young Player (including my very good
>> self) has fallen.
>>
>> cheers,
>>
>> Rolf Turner
>>
>>
>>
>> --
>> Technical Editor ANZJS
>> Department of Statistics
>> University of Auckland
>> Phone: +64-9-373-7599 ext. 88276
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error in eigen(nhatend)

2015-06-05 Thread Olu Ola via R-help
Hello,
I am estimating a nonlinear GMM and I got the following error message. I have 
searched online in other to understand what is going on but could not find help

> ngmm = optimx(par=b0, fn=object,gr=gred, method = c("BFGS","nlminb","nlm"), 
> itnmax=1, control=list(follow.on = TRUE,starttests=TRUE, 
> save.failures=TRUE, trace=0))
Error in eigen(nhatend) : infinite or missing values in 'x'
In addition: Warning messages:
1: In optimx.run(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower,  :
  Hessian is reported non-symmetric with asymmetry ratio NaN
2: Hessian forced symmetric 
Error in ans.ret[meth, ] <- c(ans$par, ans$value, ans$fevals, ans$gevals,  : 
  number of items to replace is not a multiple of replacement length
In addition: Warning message:
In optimx.run(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower,  :
  Eigenvalue failure after method BFGS

A way forward will be highly appreciated.

Thank you

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Confidence interval for the mean in the random intercept and random slople model

2015-06-05 Thread li li
Hi all,
  I am fitting a random slope and random intercept model usign lme
fucntion as shown below. Type is factor with two levels. I would like
to to find a confidence interval for mean of this model. Note that the
variance we use in finding the confidence interval should include the
variariance component from random effect.  Any suggestions?


## using lme function
> mod_lme <- lme(ti  ~ type*months, random=~ 1+months|lot, na.action=na.omit,
+ data=one, control = lmeControl(opt = "optim"))
> summary(mod_lme)
Linear mixed-effects model fit by REML
 Data: one
AIC   BIC   logLik
  -82.60042 -70.15763 49.30021

Random effects:
 Formula: ~1 + months | lot
 Structure: General positive-definite, Log-Cholesky parametrization
StdDev   Corr
(Intercept) 8.907584e-03 (Intr)
months  6.039781e-05 -0.096
Residual4.471243e-02

Fixed effects: ti ~ type * months
 Value   Std.Error DF   t-value p-value
(Intercept) 0.25831245 0.016891587 31 15.292373  0.
type0.13502089 0.026676101  4  5.061493  0.0072
months  0.00804790 0.001218941 31  6.602368  0.
type:months -0.00693679 0.002981859 31 -2.326329  0.0267
 Correlation:
   (Intr) typPPQ months
type   -0.633
months -0.785  0.497
type:months  0.321 -0.762 -0.409

Standardized Within-Group Residuals:
  MinQ1   MedQ3   Max
-2.162856e+00 -1.962972e-01 -2.771184e-05  3.749035e-01  2.088392e+00

Number of Observations: 39
Number of Groups: 6

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


Re: [R] S4 / operator "[" : Compatibility issue between lme4 and kml

2015-06-05 Thread Martin Maechler
> Christophe Genolini 
> on Fri, 5 Jun 2015 00:36:42 -0700 writes:

> Hi all,
> There is a compatibility issue between the package 'lme4' and my package
> 'kml'. I define the "[" operator. It works just fine in my package (1). 
If I
> try to use the lme4 package, then it does no longer work (2). Moreover, it
> has some kind of strange behavior (3). Do you know what is wrong? Any idea
> of how I can correct that?

> Here is a reproductible example, and the same code with the result 
follows.

> Thanks for your help
> Christophe

  [ ... I'm providing slightly different code below  ]

> --- 8< - Execution of the previous code ---

> > library(kml)
> Le chargement a nécessité le package : clv
> Le chargement a nécessité le package : cluster
> Le chargement a nécessité le package : class
> Le chargement a nécessité le package : longitudinalData
> Le chargement a nécessité le package : rgl
> Le chargement a nécessité le package : misc3d
> > dn <- gald(1)

>  ###
> ### (1) the "[" operator works just fine

> > dn["traj"]
>   t0   t1t2t3t4   t5   t6t7t8t9   t10
> i1 -3.11 4.32  2.17  1.82  4.90 7.34 0.83 -2.70  5.36  4.96  3.16
> i2 -7.11 1.40 -2.40 -2.96  4.31 0.50 1.25  0.52 -0.04  7.55  5.50
> i3  2.80 6.23  6.08  2.87  2.58 2.88 6.58 -2.38  2.30 -1.74 -3.23
> i4  2.24 0.91  6.50 10.92 11.32 7.79 7.78 10.69  9.15  1.07 -0.51

>  ###
> ### (2) using 'lme4', it does no longer work

> > library(lme4)
> Le chargement a nécessité le package : Matrix
> Le chargement a nécessité le package : Rcpp
> > dn["traj"]
> Error in x[i, j] :
>   erreur d'évaluation de l'argument 'j' lors de la sélection d'une méthode
> pour la fonction '[' : Erreur : l'argument "j" est manquant, avec aucune
> valeur par défaut

>  ###
> ### (3) If I define again the "[", it does not work the first time I call
> it, but it work the second time!
> > setMethod("[",
> +   signature=signature(x="ClusterLongData", i="character", 
> j="ANY",drop="ANY"),
> +   definition=function (x, i, j="missing", ..., drop = TRUE){
> +   x <- as(x, "LongData")
> +   return(x[i, j])
> + }
> + )
> [1] "["

> ### No working the first time I use it
> > dn["traj"]
> Error in dn["traj"] :
>   l'argument "j" est manquant, avec aucune valeur par défaut

> ### But working the second time
> > dn["traj"]
>   t0   t1t2t3t4   t5   t6t7t8t9   t10
> i1 -3.11 4.32  2.17  1.82  4.90 7.34 0.83 -2.70  5.36  4.96  3.16
> i2 -7.11 1.40 -2.40 -2.96  4.31 0.50 1.25  0.52 -0.04  7.55  5.50
> i3  2.80 6.23  6.08  2.87  2.58 2.88 6.58 -2.38  2.30 -1.74 -3.23
> i4  2.24 0.91  6.50 10.92 11.32 7.79 7.78 10.69  9.15  1.07 -0.51 

I have made some investigations, but have to stop for now, and
leave this hopefully to others knowledgable about S4 method
dispatch, etc :

1) I am confident to say that you have uncovered an "unfelicity if
  not a bug" in R.

2) I am also pretty confident that the "[" methods that you
  define in 'kml' and in the package '

3) Diagnosing is not easy: As you have shown yourself above,
  in some situations the bug "bites" and if you repeat the *same*
  code, things work.

  This is related to the fact that S4 methods are __cached__
  (so next time they are found more quickly) under some
  circumstances, and the cache is cleared under other such circumstances.

3b) Actually, I am sure that we have seen +/- the same problem many
months ago, in other contexts but did not get "down to it";
and at the moment, I cannot quickly find where to look for
the problem there...


##--- 8< Commented (incl output) reproducible code--
library(kml)

### Creating some data
dn <- gald(1)
(dnt <- dn["traj"])

showMethods("[")
## Function: [ (package base)
## x="ClusterLongData", i="character"
## x="ListPartition", i="ANY"
## x="LongData", i="ANY"
## x="LongData", i="character"
## (inherited from: x="LongData", i="ANY")
## x="LongData3d", i="ANY"
## x="nonStructure", i="ANY"
## x="ParChoice", i="ANY"
## x="ParKml", i="ANY"
## x="ParLongData", i="ANY"
## x="Partition", i="ANY"
## x="ParWindows", i="ANY"

### using Matrix  (or lme4, which 'Depends' on Matrix; hence same effect)
library(Matrix)
dn["traj"]
## Error in x[i, j] :
##   error in evaluating the argument 'j' in selecting a method for function 
'[': Error: argument "j" is missing, with no default
traceback()
## 3: x[i, j]
## 2: dn["traj"]
## 1: dn["traj"]
(ms <- methods(`[`)) ## 81 methods

## MM: debugging :
trace("[", browser, signature=c("ClusterLongData", "character", "missing",   
"missing"))
trace("[", browser, signature=c("LongData","character", "character", 
"missing"))
dn["traj"]
## -> you get into the browser, just press   "c"   twice (once for each "trace")
## ==> it works !!

## Remove the tracing :
untrace("[", signature=c("ClusterLongData", "character", "missing",   
"missing"))
untrace("[", signa

Re: [R] rename and color a list of list of list of values

2015-06-05 Thread Sven E. Templer
Hi Karim,

you should learn ?Map to iterate along the list and supply mutliple list
arguments (there is also parallel:::mcMap for multicore).
The magic of the color code generation you figure out yourself, I guess...


Here 'i' intends to be the value, 'n' the name, e.g.

# returns color by character/numeric value:
magic_colour <- function (x) { ... }

# returns child
list_child <- function (i, n) { list(name=n, colour=magic_colour(i)) }

# returns parent
list_parent <- function (i, n) { list(name=n, children=Map(list_child, i,
names(i)), colour=magic_colour(n)) }

# get grandparent
grandparent <- Map(list_parent, expBefore, names(expBefore))


Hope this helps!

Best, S.


On 5 June 2015 at 18:31, Karim Mezhoud  wrote:

> Hi all,
> I have a list like this
>
> expBefore <-
>
> list(HM450=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),
>
>
> gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
> ),
>
>
> HM27=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),
>
>
> gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
>  )
>  )
>
>
> and I would convert it to
>
> expAfter <-list(
>   list(
> name="HM450",
> children=list(
>   list(name="brca_tcga",
>children=list(
>  list(name="ATM", colour="11"),
>  list(name="ATR", colour="33"),
>  list(name="BRCA1", colour="55"),
>  list(name="BRCA2", colour="77"),
>  list(name="CHEK1", colour="99"),
>  list(name="CHEK2", colour="bb")
>
>), colour="aa" # brca_tcga
>),
> list(name="gbm_tcga",
> children=list(
>   list(name="ATM", colour="001100"),
>   list(name="ATR", colour="003300"),
>   list(name="BRCA1", colour="005500"),
>   list(name="BRCA2", colour="007700"),
>   list(name="CHEK1", colour="009900"),
>   list(name="CHEK2", colour="00bb00")
> ), colour="345345" # gbm_tcga
> )
>
>), colour="ffa500" # HM450
>   ),
>   list(
> name="HM27",
> children=list(
>   list(name="brca_tcga",
>children=list(
>  list(name="ATM", colour="11"),
>  list(name="ATR", colour="33"),
>  list(name="BRCA1", colour="55"),
>  list(name="BRCA2", colour="77"),
>  list(name="CHEK1", colour="99"),
>  list(name="CHEK2", colour="bb")
>
>), colour="aa" ##brca_tcga
>),
>   list(name="gbm_tcga",
>children=list(
>  list(name="ATM", colour="001100"),
>  list(name="ATR", colour="003300"),
>  list(name="BRCA1", colour="005500"),
>  list(name="BRCA2", colour="007700"),
>  list(name="CHEK1", colour="009900"),
>  list(name="CHEK2", colour="00bb00")
>), colour="345345") #gbm_tcga
>
> ), colour="ff00ff"  #HM27
>   )
>
> );
> any suggestion?
> Thanks
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] rename and color a list of list of list of values

2015-06-05 Thread Karim Mezhoud
Hi all,
I have a list like this

expBefore <-
list(HM450=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),

gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
),

HM27=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),

gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
 )
 )


and I would convert it to

expAfter <-list(
  list(
name="HM450",
children=list(
  list(name="brca_tcga",
   children=list(
 list(name="ATM", colour="11"),
 list(name="ATR", colour="33"),
 list(name="BRCA1", colour="55"),
 list(name="BRCA2", colour="77"),
 list(name="CHEK1", colour="99"),
 list(name="CHEK2", colour="bb")

   ), colour="aa" # brca_tcga
   ),
list(name="gbm_tcga",
children=list(
  list(name="ATM", colour="001100"),
  list(name="ATR", colour="003300"),
  list(name="BRCA1", colour="005500"),
  list(name="BRCA2", colour="007700"),
  list(name="CHEK1", colour="009900"),
  list(name="CHEK2", colour="00bb00")
), colour="345345" # gbm_tcga
)

   ), colour="ffa500" # HM450
  ),
  list(
name="HM27",
children=list(
  list(name="brca_tcga",
   children=list(
 list(name="ATM", colour="11"),
 list(name="ATR", colour="33"),
 list(name="BRCA1", colour="55"),
 list(name="BRCA2", colour="77"),
 list(name="CHEK1", colour="99"),
 list(name="CHEK2", colour="bb")

   ), colour="aa" ##brca_tcga
   ),
  list(name="gbm_tcga",
   children=list(
 list(name="ATM", colour="001100"),
 list(name="ATR", colour="003300"),
 list(name="BRCA1", colour="005500"),
 list(name="BRCA2", colour="007700"),
 list(name="CHEK1", colour="009900"),
 list(name="CHEK2", colour="00bb00")
   ), colour="345345") #gbm_tcga

), colour="ff00ff"  #HM27
  )

);
any suggestion?
Thanks

[[alternative HTML version deleted]]

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


Re: [R] [FORGED] Re: Dunnett Test in 'multicomp' package

2015-06-05 Thread Richard M. Heiberger
One more note.  There is actually a valid reason to use `levels<-`, and that is
to change the spelling of the levels while maintaining the existing order.

> tmp <- factor(c("mm", "cm", "dm", "m", "km"))
> tmp
[1] mm cm dm m  km
Levels: cm dm km m mm
> levels(tmp) <- c("centimeter","decimeter","kilometer","meter","millimeter")
> tmp
[1] millimeter centimeter decimeter  meter  kilometer
5 Levels: centimeter decimeter kilometer ... millimeter
> levels(tmp)
[1] "centimeter" "decimeter"  "kilometer"  "meter"
[5] "millimeter"
>

Rich

On Fri, Jun 5, 2015 at 4:47 AM, Gerrit Eichner
 wrote:
> Hello, everyone,
>
> aside from Rolf's hint (and Richard's warning!) you could also consider
> relevel():
>
> viagraData$dose <- relevel( viagraData$dose, ref = "placebo")
>
>  Hth  --  Gerrit
>
>
> On Fri, 5 Jun 2015, Rolf Turner wrote:
>
>> On 05/06/15 11:08, Jim Lemon wrote:
>>>
>>> Hi James,
>>> You can change the order of levels like this:
>>>
>>> levels(viagraData$dose)<-c("placebo","low dose","high dose")
>>
>>
>> 
>>
>> As Richard Heiberger has pointed out, this is wrong.
>>
>> What *does* work is:
>>
>> viagraData$dose)<-factor(viagraData$dose,
>>levels=c("placebo","low dose","high dose")
>>
>> This is a trap into which many a Young Player (including my very good
>> self) has fallen.
>>
>> cheers,
>>
>> Rolf Turner
>>
>>
>>
>> --
>> Technical Editor ANZJS
>> Department of Statistics
>> University of Auckland
>> Phone: +64-9-373-7599 ext. 88276
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] building a list in a loop

2015-06-05 Thread William Dunlap
Does the following do what you want?
> d <- list() # empty list
> for(i in 1:8) if (i %% 2 == 0) {
 newElement <- structure(list(i), names=LETTERS[i])
 d <- c(d, newElement)
  }
> str(d)
List of 4
 $ B: int 2
 $ D: int 4
 $ F: int 6
 $ H: int 8




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jun 5, 2015 at 1:40 AM, carol white via R-help  wrote:

> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note that
> the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name below?
> d = list(d,c(1,2,3)
> Thanks
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] building a list in a loop

2015-06-05 Thread Jeff Newmiller
Your explanation of the problem is unclear and your use of HTML formatting 
corrupts your code examples.

One issue is your reference to a loop while showing no loop nor input nor 
output. There is more than one construct for iterating in R. One problem you 
may be encountering is that you cannot change the vector over which you iterate 
in a for loop while you are in that loop. If that is your problem then you 
probably need to use something like a while loop. However your example is too 
abstract (and scrambled by HTML) for me to fix it.

To make your problem clearer [1], you could give us a dput of a sample input 
data object with a few elements (rows, columns, whatever) and build each 
element of your output without resorting to a loop. We could then suggest ways 
to use a loop to accomplish the same thing.

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  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.

On June 5, 2015 1:40:04 AM PDT, carol white via R-help  
wrote:
>It might be an easy question but how to construct correctly a list in a
>loop? 
>
>The following doesn't work
>before starting the loopd = NULL#in the loop, 1st iteration
>d = list(d,c(1,2,3)d[[1]]
>NULL
>
>[[2]]
>[1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
>[[1]]
>[[1]][[1]]
>NULL
>
>[[1]][[2]]
>[1] 1 2 3
>
>
>[[2]]
>[1] 4 5 6
>the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
>list components are not known out of the loop.
>d[[1]]
>[1] 1 2 3
>
>[[2]]
>[1] 4 5 6
>Moreover, how to name the components of the list in the loop while
>constructing as the names are not known out of the loop, either? note
>that the name of the component is stored in a variable in the loop
>
>d = NULL#name1 contains the name for c(1,2,3), how to give the name
>below?
>d = list(d,c(1,2,3)
>Thanks
> 
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] is.na for S4 object

2015-06-05 Thread Martin Maechler
> Martin Morgan 
> on Thu, 4 Jun 2015 10:33:37 -0700 writes:

> On 06/04/2015 10:08 AM, cgenolin wrote:
>> Hi the list,
>> 
>> I have a variable y that is either NA or some S4 object. I would like to
>> know in which case I am, but it seems taht is.na does not work with S4
>> object, I get a warnings:
>> 
>> --- 8< 
>> setClass("myClass",slots=c(x="numeric"))
>> if(runif(1)>0.5){a <- new("myClass")}else{a <- NA}
>> is.na(a)
>> --- 8< 
>> 
>> Any solution?

> getGeneric("is.na")

> shows that it's an S4 generic, so implement a method

> setMethod("is.na", "myClass", function(x) FALSE)

> Martin

For the present special case though,  a more efficient solution would be
to use  isS4(.)  instead of  !is.na(.)

another Martin 


>> Thanks
>> Christophe

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


Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread Sergio Fonda
Thank you very much!
Il 05/giu/2015 15:58, "David L Carlson"  ha scritto:

> You can select elements of a matrix using a 2 dimensional matrix that
> specifies the row/column number of the cells you want to extract:
>
> > c2 <- cbind(seq_len(nrow(c0)), c1)
> > c2
>c1
> [1,] 1  2
> [2,] 2  2
> [3,] 3  1
> [4,] 4  2
> [5,] 5  1
> [6,] 6  1
> > d1 <- c0[c2]
> > d1
> [1]  -1  -3  12   2 -23  17
>
> See the help page for [
>
> ?'['
>
> -
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sergio
> Fonda
> Sent: Friday, June 5, 2015 8:47 AM
> To: John Kane
> Cc: R-help
> Subject: Re: [R] Matrix of indexes to extract sparse data in dataframe
>
> Thank you, of course but I can't use that form as I told. My question is
> about the possibility to enter in a dataframe with a matrix of indices and
> get the corresponding values
> Thanks again
>  Il 05/giu/2015 15:39, "John Kane"  ha scritto:
>
> > d1  <-  apply(c0, 1, min)  I think does it.
> >
> > John Kane
> > Kingston ON Canada
> >
> >
> > > -Original Message-
> > > From: sergio.fond...@gmail.com
> > > Sent: Fri, 5 Jun 2015 15:06:34 +0200
> > > To: r-help@r-project.org
> > > Subject: [R] Matrix of indexes to extract sparse data in dataframe
> > >
> > > I would like to avoid a "for loop" to get a vector of data taken from
> > > rows of a data frame for specific columns.
> > > An example is the following (I can't apply min to every row of df, this
> > > is
> > > just an example):
> > >
> > > c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19))
> > > c1=apply(c0,1,which.min)
> > >> c1
> > > [1] 2 2 1 2 1 1
> > >
> > > I would like to get a result like the following call, but without
> > > employing a "for loop":
> > >
> > > d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]],
> > > c0[6,c1[6]])
> > >> d1
> > > [1]  -1  -3  12   2 -23  17
> > >
> > > Thanks a lot for any help!
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > 
> > Can't remember your password? Do you need a strong and secure password?
> > Use Password manager! It stores your passwords & protects your account.
> > Check it out at http://mysecurelogon.com/password-manager
> >
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread David L Carlson
You can select elements of a matrix using a 2 dimensional matrix that specifies 
the row/column number of the cells you want to extract:

> c2 <- cbind(seq_len(nrow(c0)), c1)
> c2
   c1
[1,] 1  2
[2,] 2  2
[3,] 3  1
[4,] 4  2
[5,] 5  1
[6,] 6  1
> d1 <- c0[c2]
> d1
[1]  -1  -3  12   2 -23  17

See the help page for [

?'['

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sergio Fonda
Sent: Friday, June 5, 2015 8:47 AM
To: John Kane
Cc: R-help
Subject: Re: [R] Matrix of indexes to extract sparse data in dataframe

Thank you, of course but I can't use that form as I told. My question is
about the possibility to enter in a dataframe with a matrix of indices and
get the corresponding values
Thanks again
 Il 05/giu/2015 15:39, "John Kane"  ha scritto:

> d1  <-  apply(c0, 1, min)  I think does it.
>
> John Kane
> Kingston ON Canada
>
>
> > -Original Message-
> > From: sergio.fond...@gmail.com
> > Sent: Fri, 5 Jun 2015 15:06:34 +0200
> > To: r-help@r-project.org
> > Subject: [R] Matrix of indexes to extract sparse data in dataframe
> >
> > I would like to avoid a "for loop" to get a vector of data taken from
> > rows of a data frame for specific columns.
> > An example is the following (I can't apply min to every row of df, this
> > is
> > just an example):
> >
> > c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19))
> > c1=apply(c0,1,which.min)
> >> c1
> > [1] 2 2 1 2 1 1
> >
> > I would like to get a result like the following call, but without
> > employing a "for loop":
> >
> > d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]],
> > c0[6,c1[6]])
> >> d1
> > [1]  -1  -3  12   2 -23  17
> >
> > Thanks a lot for any help!
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> 
> Can't remember your password? Do you need a strong and secure password?
> Use Password manager! It stores your passwords & protects your account.
> Check it out at http://mysecurelogon.com/password-manager
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread Sergio Fonda
Thank you, of course but I can't use that form as I told. My question is
about the possibility to enter in a dataframe with a matrix of indices and
get the corresponding values
Thanks again
 Il 05/giu/2015 15:39, "John Kane"  ha scritto:

> d1  <-  apply(c0, 1, min)  I think does it.
>
> John Kane
> Kingston ON Canada
>
>
> > -Original Message-
> > From: sergio.fond...@gmail.com
> > Sent: Fri, 5 Jun 2015 15:06:34 +0200
> > To: r-help@r-project.org
> > Subject: [R] Matrix of indexes to extract sparse data in dataframe
> >
> > I would like to avoid a "for loop" to get a vector of data taken from
> > rows of a data frame for specific columns.
> > An example is the following (I can't apply min to every row of df, this
> > is
> > just an example):
> >
> > c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19))
> > c1=apply(c0,1,which.min)
> >> c1
> > [1] 2 2 1 2 1 1
> >
> > I would like to get a result like the following call, but without
> > employing a "for loop":
> >
> > d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]],
> > c0[6,c1[6]])
> >> d1
> > [1]  -1  -3  12   2 -23  17
> >
> > Thanks a lot for any help!
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> 
> Can't remember your password? Do you need a strong and secure password?
> Use Password manager! It stores your passwords & protects your account.
> Check it out at http://mysecurelogon.com/password-manager
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] if else statement for rain data to define zero for dry and one to wet

2015-06-05 Thread John Kane
Please do not post in HTML. It made your posting unreadable.  R-help is a plain 
text list and when it removes all the HTML tags often the result is gibberish

Have a look at 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 and http://adv-r.had.co.nz/Reproducibility.html for some suggestions on how to 
post to R-help.


John Kane
Kingston ON Canada


> -Original Message-
> From: roslina...@gmail.com
> Sent: Fri, 5 Jun 2015 16:49:08 +0800
> To: r-help@r-project.org
> Subject: [R] if else statement for rain data to define zero for dry and
> one to wet
> 
> Dear r-users,
> 
> I have a set of rain data:
> 
> X1950 X1951 X1952 X1953 X1954 X1955 X1956 X1957 X1958 X1959 X1960 X1961
> X1962
> 
> 1   0.0   0.0  14.3   0.0  13.5  13.2   4.0 0   3.3 0 0   0.0
> 
> 
> 2   0.0   0.0  21.9   0.0  10.9   6.6   2.1 0   0.0 0 0   0.0
> 
> 
> 3  25.3   6.7  18.6   0.8   2.3   0.0   8.0 0   0.0 0 0  11.0
> 
> 
> 4  12.7   3.4  37.2   0.9   8.4   0.0   5.8 0   0.0 0 0   5.5
> 
> 
> 5   0.0   0.0  58.3   3.6  21.1   4.2   3.0 0   0.0 0 0  15.9
> 
> 
> I would like to go through each column and define each cell with value
> greater than 0.1 mm will be 1 and else zero. Hence I would like to attach
> the rain data and the category side by side:
> 
> 
> 1950   state
> 
> 1 0.00
> 
> 2 0.00
> 
> 3 25.3   1
> 
> 4 12.7   1
> 
> 5 0.00
> 
> 
> ...
> 
> 
> This is my code:
> 
> 
> wet_dry  <- function(dt)
> 
> { cl   <- length(dt)
> 
>   tresh  <- 0.1
> 
> 
>   for (i in 1:cl)
> 
>   {  xi <- dt[,i]
> 
>  if (xi < tresh ) 0 else 1
> 
>   }
> 
> dd <- cbind(dt,xi)
> 
> dd
> 
> }
> 
> 
> wet_dry(dt)
> 
> 
> Results:
> 
>> wet_dry(dt)
> 
>X1950 X1951 X1952 X1953 X1954 X1955 X1956 X1957 X1958 X1959 X1960
> X1961
> X1962 X1963 X1964 X1965 X1966 X1967 X1968 X1969 X1970 X1971 X1972 X1973
> X1974 X1975 X1976 X1977
> 
> 10.0   0.0  14.3   0.0  13.5  13.2   4.0   0.0   3.3   0.0   0.0
> 0.0
>   4.2   0.0   2.2   0.0   4.4   5.1 0   7.2   0.0   0.0   0.0   5.1
> 0   0.0 0   0.3
> 
> 20.0   0.0  21.9   0.0  10.9   6.6   2.1   0.0   0.0   0.0   0.0
> 0.0
>   8.4   0.0   4.0   0.0   4.9   0.7 0   0.0   0.0   0.0   0.0   5.4
> 0   3.3 0   0.3
> 
> 3   25.3   6.7  18.6   0.8   2.3   0.0   8.0   0.0   0.0   0.0   0.0
> 11.0
>   4.2   0.0   2.0   0.0  14.2  17.1 0   0.0   0.0   0.0   0.0   2.1
> 0   1.7 0   4.4
> 
> 4   12.7   3.4  37.2   0.9   8.4   0.0   5.8   0.0   0.0   0.0   0.0
> 5.5
>   0.0   0.0   5.4   0.0   6.4  14.9 0  10.1   2.9 143.4   0.0   6.1
> 0   0.0 0  33.5
> 
> 
> It does not work and give me the original data.  Why is that?
> 
> 
> Thank you so much for your help.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.

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


Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread John Kane
d1  <-  apply(c0, 1, min)  I think does it.

John Kane
Kingston ON Canada


> -Original Message-
> From: sergio.fond...@gmail.com
> Sent: Fri, 5 Jun 2015 15:06:34 +0200
> To: r-help@r-project.org
> Subject: [R] Matrix of indexes to extract sparse data in dataframe
> 
> I would like to avoid a "for loop" to get a vector of data taken from
> rows of a data frame for specific columns.
> An example is the following (I can't apply min to every row of df, this
> is
> just an example):
> 
> c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19))
> c1=apply(c0,1,which.min)
>> c1
> [1] 2 2 1 2 1 1
> 
> I would like to get a result like the following call, but without
> employing a "for loop":
> 
> d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]],
> c0[6,c1[6]])
>> d1
> [1]  -1  -3  12   2 -23  17
> 
> Thanks a lot for any help!
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread Sergio Fonda
I would like to avoid a "for loop" to get a vector of data taken from
rows of a data frame for specific columns.
An example is the following (I can't apply min to every row of df, this is
just an example):

c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19))
c1=apply(c0,1,which.min)
> c1
[1] 2 2 1 2 1 1

I would like to get a result like the following call, but without
employing a "for loop":

d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]],
c0[6,c1[6]])
> d1
[1]  -1  -3  12   2 -23  17

Thanks a lot for any help!

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


Re: [R] if else statement for rain data to define zero for dry and one to wet

2015-06-05 Thread PIKAL Petr
Hi

I will not inspect your function as it is corrupted by HTML posting.

If your data frame is named rain

newrain <- (rain>.1)*1

gives you new data frame with reqired coding.

However I am not sure, what do you want to do next. Do you want to merge those 
2 data frames so as coded column is beside original column? Why? What do you 
want to do with such merged data? It seems to me without sense.

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> roslinazairimah zakaria
> Sent: Friday, June 05, 2015 10:49 AM
> To: r-help@r-project.org
> Subject: [R] if else statement for rain data to define zero for dry and
> one to wet
>
> Dear r-users,
>
> I have a set of rain data:
>
> X1950 X1951 X1952 X1953 X1954 X1955 X1956 X1957 X1958 X1959 X1960 X1961
> X1962
>
> 1   0.0   0.0  14.3   0.0  13.5  13.2   4.0 0   3.3 0 0
> 0.0
>
>
> 2   0.0   0.0  21.9   0.0  10.9   6.6   2.1 0   0.0 0 0
> 0.0
>
>
> 3  25.3   6.7  18.6   0.8   2.3   0.0   8.0 0   0.0 0 0
> 11.0
>
>
> 4  12.7   3.4  37.2   0.9   8.4   0.0   5.8 0   0.0 0 0
> 5.5
>
>
> 5   0.0   0.0  58.3   3.6  21.1   4.2   3.0 0   0.0 0 0
> 15.9
>
>
> I would like to go through each column and define each cell with value
> greater than 0.1 mm will be 1 and else zero. Hence I would like to
> attach the rain data and the category side by side:
>
>
> 1950   state
>
> 1 0.00
>
> 2 0.00
>
> 3 25.3   1
>
> 4 12.7   1
>
> 5 0.00
>
>
> ...
>
>
> This is my code:
>
>
> wet_dry  <- function(dt)
>
> { cl   <- length(dt)
>
>   tresh  <- 0.1
>
>
>   for (i in 1:cl)
>
>   {  xi <- dt[,i]
>
>  if (xi < tresh ) 0 else 1
>
>   }
>
> dd <- cbind(dt,xi)
>
> dd
>
> }
>
>
> wet_dry(dt)
>
>
> Results:
>
> > wet_dry(dt)
>
>X1950 X1951 X1952 X1953 X1954 X1955 X1956 X1957 X1958 X1959 X1960
> X1961
> X1962 X1963 X1964 X1965 X1966 X1967 X1968 X1969 X1970 X1971 X1972 X1973
> X1974 X1975 X1976 X1977
>
> 10.0   0.0  14.3   0.0  13.5  13.2   4.0   0.0   3.3   0.0   0.0
> 0.0
>   4.2   0.0   2.2   0.0   4.4   5.1 0   7.2   0.0   0.0   0.0   5.1
> 0   0.0 0   0.3
>
> 20.0   0.0  21.9   0.0  10.9   6.6   2.1   0.0   0.0   0.0   0.0
> 0.0
>   8.4   0.0   4.0   0.0   4.9   0.7 0   0.0   0.0   0.0   0.0   5.4
> 0   3.3 0   0.3
>
> 3   25.3   6.7  18.6   0.8   2.3   0.0   8.0   0.0   0.0   0.0   0.0
> 11.0
>   4.2   0.0   2.0   0.0  14.2  17.1 0   0.0   0.0   0.0   0.0   2.1
> 0   1.7 0   4.4
>
> 4   12.7   3.4  37.2   0.9   8.4   0.0   5.8   0.0   0.0   0.0   0.0
> 5.5
>   0.0   0.0   5.4   0.0   6.4  14.9 0  10.1   2.9 143.4   0.0   6.1
> 0   0.0 0  33.5
>
>
> It does not work and give me the original data.  Why is that?
>
>
> Thank you so much for your help.
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall

[R] Changing colours for heatmap plot

2015-06-05 Thread John Wasige
​Dear community,

Could somebody help on how I can change the colour for this plot in the
heatmap plot script below to something like c("green", "green", "black",
"green", "green", "black", "black", "green", "green", "black"):

##
library(gplots)
library(lattice)

### loading data
data <- read.csv('D:/Londa/MyData.csv')
rowcolNames <- list(as.character(1980:2009), month.abb)
air_data <- matrix(data ,
   ncol = 12,
   byrow = TRUE,
   dimnames = rowcolNames)

print(levelplot(air_data,
col.regions=heat.colors,
xlab = "year",
ylab = "month",
main = "New #1"))​

##

Thanks for your help

John

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] if else statement for rain data to define zero for dry and one to wet

2015-06-05 Thread roslinazairimah zakaria
Dear r-users,

I have a set of rain data:

X1950 X1951 X1952 X1953 X1954 X1955 X1956 X1957 X1958 X1959 X1960 X1961
X1962

1   0.0   0.0  14.3   0.0  13.5  13.2   4.0 0   3.3 0 0   0.0


2   0.0   0.0  21.9   0.0  10.9   6.6   2.1 0   0.0 0 0   0.0


3  25.3   6.7  18.6   0.8   2.3   0.0   8.0 0   0.0 0 0  11.0


4  12.7   3.4  37.2   0.9   8.4   0.0   5.8 0   0.0 0 0   5.5


5   0.0   0.0  58.3   3.6  21.1   4.2   3.0 0   0.0 0 0  15.9


I would like to go through each column and define each cell with value
greater than 0.1 mm will be 1 and else zero. Hence I would like to attach
the rain data and the category side by side:


1950   state

1 0.00

2 0.00

3 25.3   1

4 12.7   1

5 0.00


...


This is my code:


wet_dry  <- function(dt)

{ cl   <- length(dt)

  tresh  <- 0.1


  for (i in 1:cl)

  {  xi <- dt[,i]

 if (xi < tresh ) 0 else 1

  }

dd <- cbind(dt,xi)

dd

}


wet_dry(dt)


Results:

> wet_dry(dt)

   X1950 X1951 X1952 X1953 X1954 X1955 X1956 X1957 X1958 X1959 X1960 X1961
X1962 X1963 X1964 X1965 X1966 X1967 X1968 X1969 X1970 X1971 X1972 X1973
X1974 X1975 X1976 X1977

10.0   0.0  14.3   0.0  13.5  13.2   4.0   0.0   3.3   0.0   0.0   0.0
  4.2   0.0   2.2   0.0   4.4   5.1 0   7.2   0.0   0.0   0.0   5.1
0   0.0 0   0.3

20.0   0.0  21.9   0.0  10.9   6.6   2.1   0.0   0.0   0.0   0.0   0.0
  8.4   0.0   4.0   0.0   4.9   0.7 0   0.0   0.0   0.0   0.0   5.4
0   3.3 0   0.3

3   25.3   6.7  18.6   0.8   2.3   0.0   8.0   0.0   0.0   0.0   0.0  11.0
  4.2   0.0   2.0   0.0  14.2  17.1 0   0.0   0.0   0.0   0.0   2.1
0   1.7 0   4.4

4   12.7   3.4  37.2   0.9   8.4   0.0   5.8   0.0   0.0   0.0   0.0   5.5
  0.0   0.0   5.4   0.0   6.4  14.9 0  10.1   2.9 143.4   0.0   6.1
0   0.0 0  33.5


It does not work and give me the original data.  Why is that?


Thank you so much for your help.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 to HTML problem

2015-06-05 Thread Pijush Das
Hi r-help,


I am trying to develop a program in R where I want to display the
out put result in a HTML page. But I unable to put two tables side by side
which is required to me. Another problem is that I unable to put the title
in the center of the
page. The code is given below.


Please help me.

library(R2HTML)
filepath<-"C:/Users/Desktop/Selection"
target <- HTMLInitFile(filepath,filename="sample",
BackGroundColor="#FF")
HTML.title("Output of Class Prediction",file=target, HR=3)
HTML("",file=target)
HTML("The output result is given below:",file=target)
HTML(iris[1:10,1:4], file=target,align = "left",Border = 1, innerBorder = 1)
HTML(iris[1:10,1:4], file=target,align = "left",Border = 1, innerBorder = 1)
HTMLEndFile()


Thank you.

Regards
Pijush

[[alternative HTML version deleted]]

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


Re: [R] building a list in a loop

2015-06-05 Thread PIKAL Petr
Hi

I do not understand. „i“ is variable and list elements are called by this 
variable

#constructing list
> d<-as.list(sample(letters[1:5], 5, replace=F))
> names(d) <- letters[1:5]
> d
$a
[1] "c"
$b
[1] "a"
$c
[1] "e"
$d
[1] "b"
$e
[1] "d"

#variable el
> el<-"a"

#result
> d[[el]]<-"whatever I want to put under name a"
> d
$a
[1] "whatever I want to put under name a"
$b
[1] "a"
$c
[1] "e"
$d
[1] "b"
$e
[1] "d"

Cheers
Petr


From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 1:31 PM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: Re: [R] building a list in a loop

in this example can elements of the list be accessed by their name if their 
name is the value of a variable?
el = "a"
can the first element d[[1]] be accessed by el instead of the list index like 
d$a but via el?

Thanks


On Friday, June 5, 2015 12:04 PM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

This I do not consider as a loop without index.  AFAIK i is index and the loop 
is executed twice. First with i equal to „a“ and second time with i equal to 
„b“.

In that case you need to have some objects which are named “a” or “b”  and you 
can use it for selection or computing

d<-list(a=NULL, b=NULL)
for (i in c("a","b")) {
d[[i]]<-1:3
}

Cheers
Petr

From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:51 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop

for (i in c("a","b"))

best,



On Friday, June 5, 2015 11:36 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

Can you please specify how loop without index shall be constructed? It is 
rather new topic for me.

Petr

From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:21 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop

also consider a loop without index (not like for (i ...) where index could be 
used for the list construction)

Cheers,


On Friday, June 5, 2015 11:13 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

It is not clear what exactly do you want.

d<-list()
vec<-1:3
for (i in 1:2) {
vec<-vec+3*(i-1)
d[[i]]<-vec
#names(d)[i] <- paste("name",i)
}

You can add names in second loop or you can use names command in first loop.

Cheers
Petr

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of carol
> white via R-help
> Sent: Friday, June 05, 2015 10:40 AM
> To: R-help Help
> Subject: [R] building a list in a loop
>
> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note
> that the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name
> below?
> d = list(d,c(1,2,3)
> Thanks

>
>  [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc 

[R] Are melt and dcast with ffdf possible?

2015-06-05 Thread Ken Nussear
Having trouble getting melt and dcast to work with ffdf

 I'm trying to cast 3 columns to a square matrix

With a regular data.frame.

comb <- expand.grid((1:10),(1:10))
dim(comb)
comb$Dist <- (1:100)
c.melt <- melt(comb, id.vars=c("Var1","Var2"))
dcast(c.melt,Var2~Var1)

goes from
> comb
Var1 Var2 Dist
1  111
2  212
3  313
4  414
5  515
6  616
.
to

> c.melt
Var1 Var2 variable value
1  11 Dist 1
2  21 Dist 2
3  31 Dist 3
4  41 Dist 4
5  51 Dist 5
6  61 Dist 6
.
to
> dcast(c.melt,Var1~Var2)
   Var1  1  2  3  4  5  6  7  8  9  10
1 1  1 11 21 31 41 51 61 71 81  91
2 2  2 12 22 32 42 52 62 72 82  92
3 3  3 13 23 33 43 53 63 73 83  93
4 4  4 14 24 34 44 54 64 74 84  94
5 5  5 15 25 35 45 55 65 75 85  95
6 6  6 16 26 36 46 56 66 76 86  96
7 7  7 17 27 37 47 57 67 77 87  97
8 8  8 18 28 38 48 58 68 78 88  98
9 9  9 19 29 39 49 59 69 79 89  99
10   10 10 20 30 40 50 60 70 80 90 100

no trouble.

With ffdf it breaks on the melt step
comb.ff <- expand.ffgrid(ff(1:10),ff(1:10))
dim(comb.ff)
comb.ff$Dist <- ff(1:100)


> comb.ff
ffdf (all open) dim=c(100,3), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
 PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix
PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol
PhysicalIsOpen
Var1 Var1  integer   integer FALSE  
FALSEFALSE 11  
1   TRUE
Var2 Var2  integer   integer FALSE  
FALSEFALSE 21  
1   TRUE
Dist Dist  integer   integer FALSE  
FALSEFALSE 31  
1   TRUE
ffdf data
Var1 Var2 Dist
1  111
2  212
3  313
4  414
5  515
6  616

c.melt.ff <- melt(comb.ff, id.vars=c("Var1","Var2"))
> c.melt.ff
value NA  NA
1   1  1   1
2   2  1   2
3   3  1   3
4   4  1   4
5   5  1   5
6   6  1   6
7   7  1   7
.

Is it possible to use this method with ffdf?

I appreciate any help

Ken

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


Re: [R] building a list in a loop

2015-06-05 Thread carol white via R-help
Here is the best solution that I found as the list is built in the embedded 
functions withtout using loop index, list elements' names etc
d = list()d[[length(d)+1]] = 1:3d[[length(d)+1]] = 4:6
Many thanks for your help
 


 On Friday, June 5, 2015 12:04 PM, PIKAL Petr  
wrote:
   

 #yiv1728143486 #yiv1728143486 _filtered #yiv1728143486 
{font-family:Helvetica;} _filtered #yiv1728143486 {font-family:Helvetica;} 
_filtered #yiv1728143486 {font-family:Calibri;} _filtered #yiv1728143486 
{font-family:Tahoma;}#yiv1728143486 p.yiv1728143486MsoNormal, #yiv1728143486 
li.yiv1728143486MsoNormal, #yiv1728143486 div.yiv1728143486MsoNormal 
{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv1728143486 a:link, 
#yiv1728143486 span.yiv1728143486MsoHyperlink 
{color:blue;text-decoration:underline;}#yiv1728143486 a:visited, #yiv1728143486 
span.yiv1728143486MsoHyperlinkFollowed 
{color:purple;text-decoration:underline;}#yiv1728143486 
p.yiv1728143486MsoAcetate, #yiv1728143486 li.yiv1728143486MsoAcetate, 
#yiv1728143486 div.yiv1728143486MsoAcetate 
{margin:0cm;margin-bottom:.0001pt;font-size:8.0pt;}#yiv1728143486 
p.yiv1728143486msonormal, #yiv1728143486 li.yiv1728143486msonormal, 
#yiv1728143486 div.yiv1728143486msonormal 
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv1728143486 
p.yiv1728143486msochpdefault, #yiv1728143486 li.yiv1728143486msochpdefault, 
#yiv1728143486 div.yiv1728143486msochpdefault 
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv1728143486 
span.yiv1728143486msohyperlink {}#yiv1728143486 
span.yiv1728143486msohyperlinkfollowed {}#yiv1728143486 
span.yiv1728143486style-mailovzprvy17 {}#yiv1728143486 
p.yiv1728143486msonormal1, #yiv1728143486 li.yiv1728143486msonormal1, 
#yiv1728143486 div.yiv1728143486msonormal1 
{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv1728143486 
span.yiv1728143486msohyperlink1 
{color:blue;text-decoration:underline;}#yiv1728143486 
span.yiv1728143486msohyperlinkfollowed1 
{color:purple;text-decoration:underline;}#yiv1728143486 
span.yiv1728143486style-mailovzprvy171 {color:#1F497D;}#yiv1728143486 
p.yiv1728143486msochpdefault1, #yiv1728143486 li.yiv1728143486msochpdefault1, 
#yiv1728143486 div.yiv1728143486msochpdefault1 
{margin-right:0cm;margin-left:0cm;font-size:10.0pt;}#yiv1728143486 
span.yiv1728143486TextbublinyChar {}#yiv1728143486 
span.yiv1728143486StylE-mailovZprvy29 {color:#1F497D;}#yiv1728143486 
.yiv1728143486MsoChpDefault {font-size:10.0pt;} _filtered #yiv1728143486 
{margin:70.85pt 70.85pt 70.85pt 70.85pt;}#yiv1728143486 
div.yiv1728143486WordSection1 {}#yiv1728143486 Hi This I do not consider as a 
loop without index.  AFAIK i is index and the loop is executed twice. First 
with i equal to „a“ and second time with i equal to „b“.  In that case you need 
to have some objects which are named“a” or “b”  and you can use it for 
selection or computing d<-list(a=NULL, b=NULL)for (i in c("a","b")) 
{d[[i]]<-1:3} CheersPetr From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:51 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop for (i in c("a","b")) best,   On 
Friday, June 5, 2015 11:36 AM, PIKAL Petr  wrote: Hi 
Can you please specify how loop without index shall be constructed? It is 
rather new topic for me. Petr From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:21 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop also consider a loop without index 
(not like for (i ...) where index could be used for the list construction) 
Cheers,  On Friday, June 5, 2015 11:13 AM, PIKAL Petr  
wrote: Hi

It is not clear what exactly do you want.

d<-list()
vec<-1:3
for (i in 1:2) {
vec<-vec+3*(i-1)
d[[i]]<-vec
#names(d)[i] <- paste("name",i)
}

You can add names in second loop or you can use names command in first loop.

Cheers
Petr
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of carol
> white via R-help
> Sent: Friday, June 05, 2015 10:40 AM
> To: R-help Help
> Subject: [R] building a list in a loop
>
> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note
> that the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name
> below?
> d = list(d,c(1,2,3)
> Thanks
>
>      [[alternative HTML version deleted]]
>
> __
> R

Re: [R] building a list in a loop

2015-06-05 Thread carol white via R-help
in this example can elements of the list be accessed by their name if their 
name is the value of a variable?el = "a"can the first element d[[1]] be 
accessed by el instead of the list index like d$a but via el?
Thanks
 


 On Friday, June 5, 2015 12:04 PM, PIKAL Petr  
wrote:
   

 #yiv1728143486 #yiv1728143486 _filtered #yiv1728143486 
{font-family:Helvetica;} _filtered #yiv1728143486 {font-family:Helvetica;} 
_filtered #yiv1728143486 {font-family:Calibri;} _filtered #yiv1728143486 
{font-family:Tahoma;}#yiv1728143486 p.yiv1728143486MsoNormal, #yiv1728143486 
li.yiv1728143486MsoNormal, #yiv1728143486 div.yiv1728143486MsoNormal 
{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv1728143486 a:link, 
#yiv1728143486 span.yiv1728143486MsoHyperlink 
{color:blue;text-decoration:underline;}#yiv1728143486 a:visited, #yiv1728143486 
span.yiv1728143486MsoHyperlinkFollowed 
{color:purple;text-decoration:underline;}#yiv1728143486 
p.yiv1728143486MsoAcetate, #yiv1728143486 li.yiv1728143486MsoAcetate, 
#yiv1728143486 div.yiv1728143486MsoAcetate 
{margin:0cm;margin-bottom:.0001pt;font-size:8.0pt;}#yiv1728143486 
p.yiv1728143486msonormal, #yiv1728143486 li.yiv1728143486msonormal, 
#yiv1728143486 div.yiv1728143486msonormal 
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv1728143486 
p.yiv1728143486msochpdefault, #yiv1728143486 li.yiv1728143486msochpdefault, 
#yiv1728143486 div.yiv1728143486msochpdefault 
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv1728143486 
span.yiv1728143486msohyperlink {}#yiv1728143486 
span.yiv1728143486msohyperlinkfollowed {}#yiv1728143486 
span.yiv1728143486style-mailovzprvy17 {}#yiv1728143486 
p.yiv1728143486msonormal1, #yiv1728143486 li.yiv1728143486msonormal1, 
#yiv1728143486 div.yiv1728143486msonormal1 
{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv1728143486 
span.yiv1728143486msohyperlink1 
{color:blue;text-decoration:underline;}#yiv1728143486 
span.yiv1728143486msohyperlinkfollowed1 
{color:purple;text-decoration:underline;}#yiv1728143486 
span.yiv1728143486style-mailovzprvy171 {color:#1F497D;}#yiv1728143486 
p.yiv1728143486msochpdefault1, #yiv1728143486 li.yiv1728143486msochpdefault1, 
#yiv1728143486 div.yiv1728143486msochpdefault1 
{margin-right:0cm;margin-left:0cm;font-size:10.0pt;}#yiv1728143486 
span.yiv1728143486TextbublinyChar {}#yiv1728143486 
span.yiv1728143486StylE-mailovZprvy29 {color:#1F497D;}#yiv1728143486 
.yiv1728143486MsoChpDefault {font-size:10.0pt;} _filtered #yiv1728143486 
{margin:70.85pt 70.85pt 70.85pt 70.85pt;}#yiv1728143486 
div.yiv1728143486WordSection1 {}#yiv1728143486 Hi This I do not consider as a 
loop without index.  AFAIK i is index and the loop is executed twice. First 
with i equal to „a“ and second time with i equal to „b“.  In that case you need 
to have some objects which are named“a” or “b”  and you can use it for 
selection or computing d<-list(a=NULL, b=NULL)for (i in c("a","b")) 
{d[[i]]<-1:3} CheersPetr From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:51 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop for (i in c("a","b")) best,   On 
Friday, June 5, 2015 11:36 AM, PIKAL Petr  wrote: Hi 
Can you please specify how loop without index shall be constructed? It is 
rather new topic for me. Petr From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:21 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop also consider a loop without index 
(not like for (i ...) where index could be used for the list construction) 
Cheers,  On Friday, June 5, 2015 11:13 AM, PIKAL Petr  
wrote: Hi

It is not clear what exactly do you want.

d<-list()
vec<-1:3
for (i in 1:2) {
vec<-vec+3*(i-1)
d[[i]]<-vec
#names(d)[i] <- paste("name",i)
}

You can add names in second loop or you can use names command in first loop.

Cheers
Petr
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of carol
> white via R-help
> Sent: Friday, June 05, 2015 10:40 AM
> To: R-help Help
> Subject: [R] building a list in a loop
>
> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note
> that the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name
> below?
> d = list(d,c(1,2,3)
> Thanks
>
>      [[alternative HTML version deleted]]
>
> __
> R-

Re: [R] S4 / operator "[" : Compatibility issue between lme4 and kml

2015-06-05 Thread Martin Maechler
> Martin Maechler 
> on Fri, 5 Jun 2015 11:33:46 +0200 writes:

> Christophe Genolini 
> on Fri, 5 Jun 2015 00:36:42 -0700 writes:

>> Hi all,
>> There is a compatibility issue between the package 'lme4' and my package
>> 'kml'. I define the "[" operator. It works just fine in my package (1). 
If I
>> try to use the lme4 package, then it does no longer work (2). Moreover, 
it
>> has some kind of strange behavior (3). Do you know what is wrong? Any 
idea
>> of how I can correct that?

>> Here is a reproductible example, and the same code with the result 
follows.

> Dear Christophe,
> can you please specify the exact sessionInfo() ?
> (after loading both kml and lme4).

> 'Matrix' has been updated on CRAN very recently, and 
> 'lme4' is about to be update very soon,
> so this *is* a somewhat interesting and important problem,
> but the exact versions of the packages *do* matter.

As a matter of fact,  

1) the package versions don't seem to matter much.

2) lme4 is *not* involved directly:
   Much worse, it is the 'Matrix' package.

If you replace 'lme4' by 'Matrix' in your code, you get the same
symptoms.

... I'm investigating ..

Martin

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


Re: [R] building a list in a loop

2015-06-05 Thread PIKAL Petr
Hi

This I do not consider as a loop without index.  AFAIK i is index and the loop 
is executed twice. First with i equal to „a“ and second time with i equal to 
„b“.

In that case you need to have some objects which are named “a” or “b”  and you 
can use it for selection or computing

d<-list(a=NULL, b=NULL)
for (i in c("a","b")) {
d[[i]]<-1:3
}

Cheers
Petr

From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:51 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop

for (i in c("a","b"))

best,



On Friday, June 5, 2015 11:36 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

Can you please specify how loop without index shall be constructed? It is 
rather new topic for me.

Petr

From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:21 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop

also consider a loop without index (not like for (i ...) where index could be 
used for the list construction)

Cheers,


On Friday, June 5, 2015 11:13 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

It is not clear what exactly do you want.

d<-list()
vec<-1:3
for (i in 1:2) {
vec<-vec+3*(i-1)
d[[i]]<-vec
#names(d)[i] <- paste("name",i)
}

You can add names in second loop or you can use names command in first loop.

Cheers
Petr

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of carol
> white via R-help
> Sent: Friday, June 05, 2015 10:40 AM
> To: R-help Help
> Subject: [R] building a list in a loop
>
> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note
> that the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name
> below?
> d = list(d,c(1,2,3)
> Thanks

>
>  [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and w

Re: [R] building a list in a loop

2015-06-05 Thread PIKAL Petr
Hi

Can you please specify how loop without index shall be constructed? It is 
rather new topic for me.

Petr

From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:21 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop

also consider a loop without index (not like for (i ...) where index could be 
used for the list construction)

Cheers,


On Friday, June 5, 2015 11:13 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

It is not clear what exactly do you want.

d<-list()
vec<-1:3
for (i in 1:2) {
vec<-vec+3*(i-1)
d[[i]]<-vec
#names(d)[i] <- paste("name",i)
}

You can add names in second loop or you can use names command in first loop.

Cheers
Petr

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of carol
> white via R-help
> Sent: Friday, June 05, 2015 10:40 AM
> To: R-help Help
> Subject: [R] building a list in a loop
>
> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note
> that the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name
> below?
> d = list(d,c(1,2,3)
> Thanks

>
>  [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power 

Re: [R] building a list in a loop

2015-06-05 Thread PIKAL Petr
Hi

I do not understand. My mind reading ambilities are limited.

Where do you get your vectors from?

Instead of
vec<-vec+3*(i-1)

you can use any computation to create any object.

d<-list()
n=2
for (i in 1:n) {
s<-sample(1:26, 10, replace=FALSE)
rn<-rnorm(10)
y<-rn*s*rnorm(1)+rnorm(1)
fit<-lm(y~s)
d[[i]]<-fit
names(d)[i] <- paste(letters[round(mean(s))],i, sep="")
}

So my opinion is that the code for populating list is pretty general.

Petr

From: carol white [mailto:wht_...@yahoo.com]
Sent: Friday, June 05, 2015 11:18 AM
To: PIKAL Petr
Subject: Re: [R] building a list in a loop

vectors c(1,2,3) etc were an example. the general case should be considered if 
it is a character vector with the unknown elements out of the loop. the same as 
the name. your code can't be generalized.


On Friday, June 5, 2015 11:13 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:

Hi

It is not clear what exactly do you want.

d<-list()
vec<-1:3
for (i in 1:2) {
vec<-vec+3*(i-1)
d[[i]]<-vec
#names(d)[i] <- paste("name",i)
}

You can add names in second loop or you can use names command in first loop.

Cheers
Petr

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of carol
> white via R-help
> Sent: Friday, June 05, 2015 10:40 AM
> To: R-help Help
> Subject: [R] building a list in a loop
>
> It might be an easy question but how to construct correctly a list in a
> loop?
>
> The following doesn't work
> before starting the loopd = NULL#in the loop, 1st iteration
> d = list(d,c(1,2,3)d[[1]]
> NULL
>
> [[2]]
> [1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
> [[1]]
> [[1]][[1]]
> NULL
>
> [[1]][[2]]
> [1] 1 2 3
>
>
> [[2]]
> [1] 4 5 6
> the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the
> list components are not known out of the loop.
> d[[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 4 5 6
> Moreover, how to name the components of the list in the loop while
> constructing as the names are not known out of the loop, either? note
> that the name of the component is stored in a variable in the loop
>
> d = NULL#name1 contains the name for c(1,2,3), how to give the name
> below?
> d = list(d,c(1,2,3)
> Thanks

>
>  [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on

Re: [R] S4 / operator "[" : Compatibility issue between lme4 and kml

2015-06-05 Thread Martin Maechler
> Christophe Genolini 
> on Fri, 5 Jun 2015 00:36:42 -0700 writes:

> Hi all,
> There is a compatibility issue between the package 'lme4' and my package
> 'kml'. I define the "[" operator. It works just fine in my package (1). 
If I
> try to use the lme4 package, then it does no longer work (2). Moreover, it
> has some kind of strange behavior (3). Do you know what is wrong? Any idea
> of how I can correct that?

> Here is a reproductible example, and the same code with the result 
follows.

Dear Christophe,
can you please specify the exact sessionInfo() ?
(after loading both kml and lme4).

'Matrix' has been updated on CRAN very recently, and 
'lme4' is about to be update very soon,
so this *is* a somewhat interesting and important problem,
but the exact versions of the packages *do* matter.

Bonnes salutations!

Martin Maechler
ETH Zurich


   []

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


Re: [R] [FORGED] Re: Dunnett Test in 'multicomp' package

2015-06-05 Thread Gerrit Eichner

Hello, everyone,

aside from Rolf's hint (and Richard's warning!) you could also consider 
relevel():


viagraData$dose <- relevel( viagraData$dose, ref = "placebo")

 Hth  --  Gerrit

On Fri, 5 Jun 2015, Rolf Turner wrote:


On 05/06/15 11:08, Jim Lemon wrote:

Hi James,
You can change the order of levels like this:

levels(viagraData$dose)<-c("placebo","low dose","high dose")




As Richard Heiberger has pointed out, this is wrong.

What *does* work is:

viagraData$dose)<-factor(viagraData$dose,
   levels=c("placebo","low dose","high dose")

This is a trap into which many a Young Player (including my very good self) 
has fallen.


cheers,

Rolf Turner



--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] building a list in a loop

2015-06-05 Thread carol white via R-help
It might be an easy question but how to construct correctly a list in a loop? 

The following doesn't work
before starting the loopd = NULL#in the loop, 1st iteration
d = list(d,c(1,2,3)d[[1]]
NULL

[[2]]
[1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
[[1]]
[[1]][[1]]
NULL

[[1]][[2]]
[1] 1 2 3


[[2]]
[1] 4 5 6
the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the list 
components are not known out of the loop.
d[[1]]
[1] 1 2 3

[[2]]
[1] 4 5 6
Moreover, how to name the components of the list in the loop while constructing 
as the names are not known out of the loop, either? note that the name of the 
component is stored in a variable in the loop

d = NULL#name1 contains the name for c(1,2,3), how to give the name below?
d = list(d,c(1,2,3)
Thanks
 
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] S4 / operator "[" : Compatibility issue between lme4 and kml

2015-06-05 Thread cgenolin
Hi all,

There is a compatibility issue between the package 'lme4' and my package
'kml'. I define the "[" operator. It works just fine in my package (1). If I
try to use the lme4 package, then it does no longer work (2). Moreover, it
has some kind of strange behavior (3). Do you know what is wrong? Any idea
of how I can correct that?

Here is a reproductible example, and the same code with the result follows.

Thanks for your help
Christophe

--- 8< - Code for reproductible example ---
library(kml)

### Creating some data
dn <- gald(1)
dn["traj"]

### using lme4
library(lme4)
dn["traj"]

### Re-defining the "["
setMethod(   ### Simplified version ###
  "[",
  signature=signature(x="ClusterLongData", i="character",
j="ANY",drop="ANY"),
  definition=function (x, i, j="missing", ..., drop = TRUE){
  x <- as(x, "LongData")
  return(x[i, j])
}
)

dn["traj"]
dn["traj"]

--- 8< - Execution of the previous code ---

> library(kml)
Le chargement a nécessité le package : clv
Le chargement a nécessité le package : cluster
Le chargement a nécessité le package : class
Le chargement a nécessité le package : longitudinalData
Le chargement a nécessité le package : rgl
Le chargement a nécessité le package : misc3d
> dn <- gald(1)

 ###
### (1) the "[" operator works just fine

> dn["traj"]
  t0   t1t2t3t4   t5   t6t7t8t9   t10
i1 -3.11 4.32  2.17  1.82  4.90 7.34 0.83 -2.70  5.36  4.96  3.16
i2 -7.11 1.40 -2.40 -2.96  4.31 0.50 1.25  0.52 -0.04  7.55  5.50
i3  2.80 6.23  6.08  2.87  2.58 2.88 6.58 -2.38  2.30 -1.74 -3.23
i4  2.24 0.91  6.50 10.92 11.32 7.79 7.78 10.69  9.15  1.07 -0.51

 ###
### (2) using 'lme4', it does no longer work

> library(lme4)
Le chargement a nécessité le package : Matrix
Le chargement a nécessité le package : Rcpp
> dn["traj"]
Error in x[i, j] :
  erreur d'évaluation de l'argument 'j' lors de la sélection d'une méthode
pour la fonction '[' : Erreur : l'argument "j" est manquant, avec aucune
valeur par défaut

 ###
### (3) If I define again the "[", it does not work the first time I call
it, but it work the second time!
> setMethod(
+   "[",
+   signature=signature(x="ClusterLongData", i="character",
j="ANY",drop="ANY"),
+   definition=function (x, i, j="missing", ..., drop = TRUE){
+   x <- as(x, "LongData")
+   return(x[i, j])
+ }
+ )
[1] "["

### No working the first time I use it
> dn["traj"]
Error in dn["traj"] :
  l'argument "j" est manquant, avec aucune valeur par défaut

### But working the second time
> dn["traj"]
  t0   t1t2t3t4   t5   t6t7t8t9   t10
i1 -3.11 4.32  2.17  1.82  4.90 7.34 0.83 -2.70  5.36  4.96  3.16
i2 -7.11 1.40 -2.40 -2.96  4.31 0.50 1.25  0.52 -0.04  7.55  5.50
i3  2.80 6.23  6.08  2.87  2.58 2.88 6.58 -2.38  2.30 -1.74 -3.23
i4  2.24 0.91  6.50 10.92 11.32 7.79 7.78 10.69  9.15  1.07 -0.51 



--
View this message in context: 
http://r.789695.n4.nabble.com/S4-operator-Compatibility-issue-between-lme4-and-kml-tp4708236.html
Sent from the R help mailing list archive at Nabble.com.

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

Re: [R] is.na for S4 object

2015-06-05 Thread cgenolin
So easy!

Thanks a lot.



--
View this message in context: 
http://r.789695.n4.nabble.com/is-na-for-S4-object-tp4708201p4708234.html
Sent from the R help mailing list archive at Nabble.com.

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