[R] Sampling

2015-03-30 Thread Partha Sinha
I have 1000 data points.  i want to take 30 samples and find mean. I
also want to repeat this process 100 times. How to go about it?
Regards
Parth

__
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-es] Resumen de R-help-es, Vol 73, Envío 40

2015-03-30 Thread miguel.angel.rodriguez.muinos
Por lo que comentas parece que tuvieras Java de 32 bits y que quisieras
hacerlo funcionar con R de 64 bits.
Lo mejor es que tengas las dos versiones de Java instaladas puesto que
hay software que lo requiere en 32bits y otro en 64.
Ejemplo: Aunque tu sistema operativo sea de 64 bits, si usas un
navegador de 32 bits, necesitarás Java de 32bits.

Un Saludo,
Miguel.


El 27/03/2015 a las 17:11, Our Utopy escribió:
 Muchísimas gracias, lo he probado y ya me funciona la interconectividad con
 Excel, pero con el R de 32 bits, ya que con el de 64 bits me sigue dando
 problemas. Os cuento tan pronto lo resuelva. Creo sospechar que el Java
 está involucrado y que si uso 64 bits todo tiene que ser de 64 bits... o
 algo así. Saludos






Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso_confidencialidad.htm

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] generating phi using function()

2015-03-30 Thread Daniel Nordlund


The argument 'K' is missing since you are only passing four arguments to 
the phi() function, but you defined it with five formal parameters. It 
looks like the argument 'j' is not necessary in the function.  It is an 
unnecessary carry-over from the summation notation and it is never used 
in the function.


Dan


On 3/29/2015 4:08 PM, Jim Lemon wrote:

Hi T.,
Your translation of the formula looks okay, and the error message is about
a missing argument. Perhaps you have not included the necessary arguments
to phi in the call to mls.

Jim


On Sun, Mar 29, 2015 at 11:59 PM, T.Riedle tr...@kent.ac.uk wrote:


Hi everybody,
I am trying to generate the formula shown in the attachment. My formula so
far looks as follows:

phi - function(w1, w2, j, k, K){
zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
return( zaehler/nenner )
}

Unfortunately something must be wrong here as I get the following message
when running a midas regression

m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1)))
Error in phi(c(1, 1), 44L, 1) : argument K is missing, with no default
Called from: .rs.breakOnError(TRUE)
Browse[1] K-125
Browse[1] 125

Could anybody look into my phi formula and tell me what is wrong with it?

Thanks in advance.


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




--
Daniel Nordlund
Bothell, WA USA

__
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] temporal autocorrelation in MCMCglmm

2015-03-30 Thread David Villegas Ríos
Hi,
For a number of individuals, I have measured several behavioral traits in
the wild. Those traits (e.g. home range) can be estimated on different
temporal scales, for example daily, weekly or monthly. I want to estimate
repeatability of those traits, assuming that the daily/weekly/monthly
measurements represent replicates. I have 3 months (90 days) of data for
each trait. Two questions:

1) How can assess if there is temporal autocorrelation in my model? I guess
that if I consider daily measurements as replicates (90 replicates), I will
have some autocorrelation, but if I use just monthly measurements (3
replicates) maybe I avoid it.

2) How can account for temporal autocorrelation in MCMCglmm?

Sorry for this pretty basic questions but I haven't found an answer so far.

Thanks!

David

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

2015-03-30 Thread Daniel Nordlund

On 3/29/2015 11:10 PM, Partha Sinha wrote:

I have 1000 data points.  i want to take 30 samples and find mean. I
also want to repeat this process 100 times. How to go about it?
Regards
Parth

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



see ?replicate and ?sample.  Simple example where yourdata is a simple 
vector of values, and assuming you want to sample without replacement. 
Generalizing it to other data structures is left as an exercise for the 
reader.


replicate(100,mean(sample(yourdata,30, replace=FALSE)))

hope this is helpful,

Dan

--
Daniel Nordlund
Bothell, WA USA

__
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-es] Nueva publicación en blog en r-es.org

2015-03-30 Thread web
Nueva publicación en blog: Cursos, CURSO NO PRESENCIAL CONTROL DE CALIDAD CON 
R, por vaamonde en 30/03/15 10:27h

Ver el blog en:
http://r-es.org/tiki-view_blog_post.php?blogId=4postId=98

Si no desea recibir estas notificaciones siga este enlace:
http://r-es.org/tiki-user_watches.php?id=49


___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] matrix manipulation question

2015-03-30 Thread Berend Hasselman

 On 30-03-2015, at 09:59, Stéphane Adamowicz 
 stephane.adamow...@avignon.inra.fr wrote:
 
 
 Le 27 mars 2015 à 18:01, David Winsemius dwinsem...@comcast.net a écrit :
 
 
 On Mar 27, 2015, at 3:41 AM, Stéphane Adamowicz wrote:
 
 Well, it seems to work with me.
 
 
 No one is doubting that it worked for you in this instance. What Peter D. 
 was criticizing was the construction :
 
 complete.cases(t(Y))==T
 
 ... and it was on two bases that it is wrong. The first is that `T` is not 
 guaranteed to be TRUE. The second is that the test ==T (or similarly ==TRUE) 
 is completely unnecessary because `complete.cases` returns a logical vector 
 and so that expression is a waste of time.
 
 
 Indeed, You are right, the following code was enough :
 «  Z - Y[, complete.cases(t(Y) ] »
 
 
 However, in order to help me understand, would you be so kind as to give me a 
 matrix or data.frame example where « complete.cases(X)== T » or « 
 complete.cases(X)== TRUE » would give some unwanted result ?

T can be redefined.
Try this in your example with airquality:

T - hello
Z - Y[,complete.cases(t(Y))==T]
Z

TRUE is a reserved word and cannot be changed. But why use ==TRUE if not 
necessary?
All of this mentioned already by David Winsemius in a previous reply.

Berend

__
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 manipulation question

2015-03-30 Thread peter dalgaard

 On 30 Mar 2015, at 09:59 , Stéphane Adamowicz 
 stephane.adamow...@avignon.inra.fr wrote:
 
 
 However, in order to help me understand, would you be so kind as to give me a 
 matrix or data.frame example where « complete.cases(X)== T » or « 
 complete.cases(X)== TRUE » would give some unwanted result ?

The standard problem with T for TRUE is if T has been used for some other 
purpose, like a time variable. E.g., T - 0 ; complete.cases(X)==T.

complete.cases()==TRUE is just silly, like (x==0)==TRUE or 
((x==0)==TRUE)==TRUE). 

(However, notice that x==TRUE is different from as.logical(x) if x is numeric, 
so ifelse(x,y,z) may differ from ifelse(x==TRUE,y,z).) 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- 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] POSIX and ecdf()

2015-03-30 Thread Doran, Harold
Below is some working code that, generally speaking, accomplishes why I want, 
but am looking for a necessary improvement in the final step. The code below 
scrapes data from a website (thousands of pages actually) and organizes 
athlete�s scores in a data frame. The final variable, called Workout05 in the 
original data is a timed event. So, I use strplit() to pull out the data I want 
in that column and format it using as.POSIXct() as you can see in the code 
below (using a regular expression I�m sure would improve on how to pull out 
those data in the column, but that is not my primary question).

After I have all data, I want to find the empirical CDF of the data, so I use 
ecdf() on those data just as I would on other variables. Now, the main issue 
I�m interested is in the final step where you plug in a specific time to find 
its percentile

## These are below in context of the real problem as well
fn - ecdf(dat$score5)
fn(dat$score5[1])

This works, but not in the way I want. What I want is for a user to easily be 
able to enter their time in �lay� terms such as 5:35 and from that it would 
return the percentile rank.

So, I�d like something like the following to be able to work

fn(5:35)

The larger context for this problem for why I want this can be seen if you 
visit my web app built using shiny. I�ve built a site where athletes can build 
customized reports based on their performance on certain events by entering in 
data. This specific issue would be found on the �get my percentile� tab where a 
user can use the text input box to enter their time in a way humans typically 
understand it and then it gets passed to the R fn() function that runs in the 
background and builds the plot for them.

https://hdoran.shinyapps.io/openAnalysis/

So, my question is how can I structure this such that a time can be expressed 
as simply minute:seconds (e.g., 4:52) in a text box so that it would still work 
to return a percentile rank as I�ve described here.

Thanks



library(XML)

i = 1; j = 0; division = 1
url -

paste(paste('http://games.crossfit.com/scores/leaderboard.php?stage=5sort=0page=',
 i, sep=''), paste('division=1region=', j, sep=''), 
'numberperpage=100competition=0frontpage=0expanded=1year=15full=1showtoggles=0hidedropdowns=0showathleteac=1=is_mobile=0',
 sep='')
tmp - try(readHTMLTable(readLines(url), which=1, header=TRUE))
if(!is.null(dim(tmp))){ # new part here
names(tmp) - gsub(\\n, , names(tmp))
names(tmp) - gsub( +, , names(tmp))
tmp[] - lapply(tmp, function(x) gsub(\\n, , x))
tmp$region - j
}
dat - tmp

   aa - strsplit(dat$Workout05, split = '\\(')
bb - sapply(aa, function(x) x[2])
aa - strsplit(bb, split = '\\)')

dat$score5 - as.character(sapply(strsplit(bb, split = '\\)'), function(x) x))
dat$score5 - as.POSIXct(dat$score5, format=%M:%S)

fn - ecdf(dat$score5)
fn(dat$score5[1])

[[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-es] Comparaciones múltiples

2015-03-30 Thread Pedro Concejero Cerezo
Hola,
Quizas puedas considerar tus contrastes como comparaciones o contrastes 
planificados (planned contrasts o creo que tambi�n llamados por algunos 
a-priori contrasts).
Una b�squeda r�pida da algunos buenos ejemplos:
https://www.google.es/search?q=r+anova+planned+contrasts

Por ejemplo
http://faculty.smu.edu/kyler/courses/7311/planned_4up.pdf

Saludos,
Pedro

El 30/03/2015 a las 12:00, 
r-help-es-requ...@r-project.orgmailto:r-help-es-requ...@r-project.org 
escribi�:

 Message: 2
 Date: Sat, 28 Mar 2015 23:10:04 +0100
 From: Carlos Hern�ndez-Castellano
 
carlos.hernandezcastell...@gmail.commailto:carlos.hernandezcastell...@gmail.com
 To: r-help-es@r-project.orgmailto:r-help-es@r-project.org
 Subject: [R-es] Comparaciones m�ltiples
 Message-ID:
 
cafqssgjvun3tssut8gyo0ggaktd8mymszld2stnbwfw6o9f...@mail.gmail.commailto:cafqssgjvun3tssut8gyo0ggaktd8mymszld2stnbwfw6o9f...@mail.gmail.com
 Content-Type: text/plain; charset=UTF-8

 Saludos,

 tengo una base de datos con tres variables: especie,
 tratamiento y
 abundancia.

 Quiero hacer comparaciones m�ltiples con Tukey.
 Ya hab�a usado el comando TukeyHSD(aov(x~y)).

 La cuesti�n esque ahora tengo varios niveles del factor
 especie y varios
 niveles del factor tratamiento.
 Si hago TukeyHSD(aov(abundancia~especie:tratamiento)) me
 salen todas las
 comparaciones posibles, pero yo s�lo estoy interesado en
 que para cada
 especie (i.e. para cada nivel del factor especie) me salgan
 las
 comparaciones de los datos de abundancia para cada par de
 tratamientos
 (niveles del factor tratamiento).

 Una soluci�n laboriosa ser�a partir el documento original
 en tantos como
 especies, pero seguro que alguien me puede sugerir una
 soluci�n m�s
 inteligente.

 Saludos y gracias,


 --
 *?*

 *Carlos Hern�ndez-Castellano*

 Environmental Scientist

 Student, MSc Terrestrial Ecology and Biodiversity
 Management

 Research Collaborator at Centre of Ecological Research and
 Forestry
 Applications (CREAF)

 Ecology Unit - Department of Animal Biology, Plant Biology
 and Ecology;
 Faculty of Sciences, Autonomous University of Barcelona
 (UAB)

 08193 Bellaterra, Spain

 Email: 
carlos.hernandezcastell...@gmail.commailto:carlos.hernandezcastell...@gmail.com

 [[alternative HTML version deleted]]



 --

 Message: 3
 Date: Sat, 28 Mar 2015 23:31:44 +
 From: V�ctor Granda Garc�a 
victorgrandagar...@gmail.commailto:victorgrandagar...@gmail.com
 To: Carlos Hern�ndez-Castellano
 
carlos.hernandezcastell...@gmail.commailto:carlos.hernandezcastell...@gmail.com,
 r-help-es@r-project.orgmailto:r-help-es@r-project.org
 Subject: Re: [R-es] Comparaciones m�ltiples
 Message-ID:
 
caopgseatessjj0kju0y7dumtuomd8zr+a3bov3hy3tmppn4...@mail.gmail.commailto:caopgseatessjj0kju0y7dumtuomd8zr+a3bov3hy3tmppn4...@mail.gmail.com
 Content-Type: text/plain; charset=UTF-8

 Hola Carlos.

 La orden TukeyHSD tiene un par�metro which que te permite
 indicar para
 que variable explicativa quieres las comparaciones.

 Mira la ayuda de TukeyHSD con '?TukeyHSD' donde tienes un
 ejemplo, aunque
 en tu caso ser�a algo parecido a esto:

 modelo - aov(abundancia~especie:tratamiento)
 TukeyHSD(modelo, tratamiento)

 Espero que te sirva, un saludo.

 El s�b., 28 de marzo de 2015 a las 23:10, Carlos
 Hern�ndez-Castellano (
 
carlos.hernandezcastell...@gmail.commailto:carlos.hernandezcastell...@gmail.com)
 escribi�:

  Saludos,
 
  tengo una base de datos con tres variables: especie,
 tratamiento y
  abundancia.
 
  Quiero hacer comparaciones m�ltiples con Tukey.
  Ya hab�a usado el comando TukeyHSD(aov(x~y)).
 
  La cuesti�n esque ahora tengo varios niveles del
 factor especie y varios
  niveles del factor tratamiento.
  Si hago TukeyHSD(aov(abundancia~especie:tratamiento))
 me salen todas las
  comparaciones posibles, pero yo s�lo estoy interesado
 en que para cada
  especie (i.e. para cada nivel del factor especie) me
 salgan las
  comparaciones de los datos de abundancia para cada par
 de tratamientos
  (niveles del factor tratamiento).
 
  Una soluci�n laboriosa ser�a partir el documento
 original en tantos como
  especies, pero seguro que alguien me puede sugerir una
 soluci�n m�s
  inteligente.
 
  Saludos y gracias,
 
 
  --
  **
 
  *Carlos Hern�ndez-Castellano*
 
  Environmental Scientist
 
  Student, MSc Terrestrial Ecology and Biodiversity
 Management
 
  Research Collaborator at Centre of Ecological Research
 and Forestry
  Applications (CREAF)
 
  Ecology Unit - Department of Animal Biology, Plant
 Biology and Ecology;
  Faculty of Sciences, Autonomous University of Barcelona
 (UAB)
 
  08193 Bellaterra, Spain
 
  Email: 
  carlos.hernandezcastell...@gmail.commailto:carlos.hernandezcastell...@gmail.com
 
  [[alternative
 HTML version deleted]]
 
  ___
  R-help-es mailing list
  R-help-es@r-project.orgmailto:R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es
 

 [[alternative 

Re: [R] matrix manipulation question

2015-03-30 Thread Stéphane Adamowicz

Le 27 mars 2015 � 18:01, David Winsemius dwinsem...@comcast.net a �crit :

 
 On Mar 27, 2015, at 3:41 AM, St�phane Adamowicz wrote:
 
 Well, it seems to work with me.
 
 
 No one is doubting that it worked for you in this instance. What Peter D. was 
 criticizing was the construction :
 
 complete.cases(t(Y))==T
 
 ... and it was on two bases that it is wrong. The first is that `T` is not 
 guaranteed to be TRUE. The second is that the test ==T (or similarly ==TRUE) 
 is completely unnecessary because `complete.cases` returns a logical vector 
 and so that expression is a waste of time.
 

Indeed, You are right, the following code was enough :
�  Z - Y[, complete.cases(t(Y) ] �


However, in order to help me understand, would you be so kind as to give me a 
matrix or data.frame example where � complete.cases(X)== T � or � 
complete.cases(X)== TRUE � would give some unwanted result ?

St�phane


[[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] Fwd: non-conformable arguments

2015-03-30 Thread Soheila Khodakarim
Dear Thierry Onkelinx,

Thank you so much to answer me. But I do not know what information I should
send for you
I want to run neural network on my data.I run these codes and I saw this
Error in the last line

#load mydata
dim(mydata)
# 20 3111
library(neuralnet)
fm - as.formula(paste(resp ~, paste(colnames(mydata)[1:3110],
collapse=+)))
out - neuralnet(fm,data=mydata, hidden = 4, lifesign = minimal,
linear.output = FALSE, threshold = 0.1)
Call: neuralnet(formula = fm, data = mydata, hidden = 4, threshold = 0.1,
  lifesign = minimal, linear.output = FALSE)

1 repetition was calculated.

Error Reached Threshold Steps
1 2.402157856 0.06958374995 9
#load testset
dim(testset)
# 20 3111
out.results - compute(out, testset)
Error in neurons[[i]] %*% weights[[i]] : non-conformable arguments


Regards,
Soheila

[[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] non-conformable arguments

2015-03-30 Thread Thierry Onkelinx
We need enough information to run your code on our computer and get the
same error as you. In this case we are missing the data. See e.g.
http://adv-r.had.co.nz/Reproducibility.html If you can't provide the
original data, then try to make a (small) example which reproduces your
problem.

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie  Kwaliteitszorg / team Biometrics  Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-03-30 14:47 GMT+02:00 Soheila Khodakarim lkhodaka...@gmail.com:

 Dear Thierry Onkelinx,

 Thank you so much to answer me. But I do not know what information I
 should send for you
 I want to run neural network on my data.I run these codes and I saw this
 Error in the last line

 #load mydata
 dim(mydata)
 # 20 3111
 library(neuralnet)
 fm - as.formula(paste(resp ~, paste(colnames(mydata)[1:3110],
 collapse=+)))
 out - neuralnet(fm,data=mydata, hidden = 4, lifesign = minimal,
 linear.output = FALSE, threshold = 0.1)
 Call: neuralnet(formula = fm, data = mydata, hidden = 4, threshold = 0.1,
 lifesign = minimal, linear.output = FALSE)

 1 repetition was calculated.

 Error Reached Threshold Steps
 1 2.402157856 0.06958374995 9
 #load testset
 dim(testset)
 # 20 3111
 out.results - compute(out, testset)
 Error in neurons[[i]] %*% weights[[i]] : non-conformable arguments


 Regards,
 Soheila



[[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] A problem someone should know about

2015-03-30 Thread Peter Claussen
Rich,

You’ve probably reported the error to the wrong group.

A quick search suggests this is not an R issue, but an RStudio issue. The error 
message is unique enough. Google returns this as the first link:

https://support.rstudio.com/hc/communities/public/questions/200807456-Error-when-plotting-graphics-on-Mac-OSX-Mavericks

Peter

 On Mar 29, 2015, at 9:21 PM, Richard M. Heiberger r...@temple.edu wrote:
 
 This looks like a specific Macintosh error that appears at random intervals.
 I get it at random, and unreproducible times.  I reported it (or
 perhaps a close relative)
 to the r-sig-mac list in September 2014.
 
 Rich
 
 
 On Sun, Mar 29, 2015 at 9:59 PM, Rolf Turner r.tur...@auckland.ac.nz wrote:
 On 30/03/15 11:52, Ian Lester wrote:
 
 I’m a novice and this message looks like it shouldn’t be ignored. Someone
 who knows what they’re doing should probably take a look.
 Thanks
 Ian Lester
 
 logfat.lm-(lm(body.fat~log(BMI)))
 plot(logfat)
 
 Error in plot(logfat) : object 'logfat' not found
 
 plot(logfat.lm)
 
 Hit Return to see next plot:
 Hit Return to see next plot:
 Hit Return to see next plot:
 Mar 29 18:10:18 iansimac.gateway rsession[69550] Error: Error: this
 application, or a library it uses, has passed an invalid numeric
 value (NaN, or not-a-number) to CoreGraphics API. This is a serious
 error and contributes to an overall degradation of system stability
 and reliability. This notice is a courtesy: please fix this problem.
 It will become a fatal error in an upcoming update.
 
 
 Please make your examples *reproducible* as the posting guide requests.
 
 I *presume* that your data are the fat data from the UsingR package,
 which you did not mention.
 
 After installing and loading UsingR I did
 
 logfat.lm - lm(body.fat~log(BMI),data=fat)
 plot(logfat.lm)
 
 and got a sequence of plots, with no error thrown. It would appear that
 whatever is causing the error that you saw is peculiar to your system.
 
 cheers,
 
 Rolf Turner
 
 --
 Rolf Turner
 Technical Editor ANZJS
 Department of Statistics
 University of Auckland
 Phone: +64-9-373-7599 ext. 88276
 Home phone: +64-9-480-4619
 
 
 __
 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.

[R] changing column labels for data frames inside a list

2015-03-30 Thread Vikram Chhatre
 summary(mygenfreqt)
  Length Class  Mode
dat1.str 59220  -none- numeric
dat2.str 59220  -none- numeric
dat3.str 59220  -none- numeric

 head(mylist[[1]])
   1 2 3 4 5 6 7 8 91011
 12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
0.725

I want to change 1:12 to pop1:pop12

mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))

What this is doing is replacing the data frames with just names
pop1:pop12.  I just want to replace the column labels.

Thanks for any suggestions.

[[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] Joint distribution of wind data

2015-03-30 Thread Nasr Al-Dhurafi
* Hi,
** I'm dealing with wind data and I'd like to model their**
distribution.** Wind** direction *
* are typically following a vonmises distribution and wind speeds
**follow a weibull distribution. I'd like to build a joint**
distribution** of directions and speeds as a VonMises-Weibull
bivariate*
* distribution.
**An alternative in such cases (i.e., when marginals are available
but** the** joint is difficult to postulate) is to use copulas, which
can** construct*



* multivariate distributions from univariate marginals. Therefore, if
anyone has an idea of how to do whether joint distribution or copula
forwind data in R,Please, contact with me.*


*Best Regards *

*Nasr *

[[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] vif in package car: there are aliased coefficients in the model

2015-03-30 Thread Rodolfo Pelinson
Thanks a lot for the answer and I'm sorry for the silly question!

Also thanks for the conceptual advice! It was also a doubt of me and my
advisors.


Best!

2015-03-28 15:17 GMT-03:00 John Fox j...@mcmaster.ca:

 Dear Rodolfo,

 Sending the data helps, though if you had done what I suggested, you would
 have seen what's going on:

  snip --

  dim(data)
 [1] 8 8

  summary(lm(response_variable ~ predictor_1 + predictor_2 + predictor_3 +
 predictor_4
 + + predictor_5 + predictor_6 + predictor_7, data = data))

 Call:
 lm(formula = response_variable ~ predictor_1 + predictor_2 +
 predictor_3 + predictor_4 + predictor_5 + predictor_6 + predictor_7,
 data = data)

 Residuals:
 ALL 8 residuals are 0: no residual degrees of freedom!

 Coefficients: (1 not defined because of singularities)
 Estimate Std. Error t value Pr(|t|)
 (Intercept)  -5.1905 NA  NA   NA
 predictor_1yellow 2.4477 NA  NA   NA
 predictor_2fora   6.5056 NA  NA   NA
 predictor_2interior   6.0769 NA  NA   NA
 predictor_3   0.6750 NA  NA   NA
 predictor_4   3.0742 NA  NA   NA
 predictor_5   0.6715 NA  NA   NA
 predictor_6  -0.9850 NA  NA   NA
 predictor_7   NA NA  NA   NA

 Residual standard error: NaN on 0 degrees of freedom
 Multiple R-squared:  1, Adjusted R-squared:NaN
 F-statistic:   NaN on 7 and 0 DF,  p-value: NA

  snip --

 So the data set that you're using has 8 cases and 8 variables, one of
 which is a factor with 3 levels. Consequently, the model you're fitting my
 LS has 9 coefficients. Necessarily the rank of the model matrix is
 deficient. When you eliminate a coefficient, you get a perfect fit: 8
 coefficients fit to 8 cases with 0 df for error.

 This is of course nonsense: You don't have enough data to fit a model of
 this complexity. In fact, you might not have enough data to reasonably fit
 a model with just 1 predictor.

 I'm cc'ing this response to the r-help email list, where you started this
 thread.

 Best,
  John

 On Sat, 28 Mar 2015 12:04:05 -0300
  Rodolfo Pelinson rodolfopelin...@gmail.com wrote:
  Thanks a lot for your answer and your time! But Im still having the same
  problem.
 
  That's the script I am using:
 
 
  library(car)
 
  data -read.table(data_vif.txt, header = T, sep = \t, row.names = 1)
  data
 
  vif(lm(response_variable ~ predictor_1 + predictor_2 + predictor_3 +
  predictor_4 + predictor_5 + predictor_6 + predictor_7, data = data))
 
  vif(lm(response_variable ~ predictor_1 + predictor_2 + predictor_3 +
  predictor_4 + predictor_5 + predictor_6, data = data))
 
 
 
  the first vif function above returns me the following error:
 
  Error in vif.default(lm(response_variable ~ predictor_1 + predictor_2
 +  :
there are aliased coefficients in the model
 
  Then if I remove any one of the predictors (in the script I removed
  predictor_7 as an example), it returns this:
 
  GVIF Df GVIF^(1/(2*Df))
  predictor_1  NaN  1 NaN
  predictor_2  NaN  2 NaN
  predictor_3  NaN  1 NaN
  predictor_4  NaN  1 NaN
  predictor_5  NaN  1 NaN
  predictor_6  NaN  1 NaN
  Warning message:
  In cov2cor(v) : diag(.) had 0 or NA entries; non-finite result is
 doubtful
 
 
  Can you help me with this? I even attached to this e-mail my data set.
 It's
  a small table.
 
  Sorry for the question.
 
 
 
  2015-03-27 21:51 GMT-03:00 John Fox j...@mcmaster.ca:
 
   Dear Rodolfo,
  
   It's apparently the case that at least one of the columns of the model
   matrix for your model is perfectly collinear with others.
  
   There's not nearly enough information here to figure out exactly what
 the
   problem is, and the information that you provided certainly falls
 short of
   allowing me or anyone else to reproduce your problem and diagnose it
   properly. It's not even clear from your message exactly what the
 structure
   of the model is, although localizacao  is apparently a factor with 3
   levels.
  
  
   If you look at the summary() output for your model or just print it,
 you
   should at least see which coefficients are aliased, and that might
 help you
   understand what went wrong.
  
   I hope this helps,
John
  
   ---
   John Fox, Professor
   McMaster University
   Hamilton, Ontario, Canada
   http://socserv.mcmaster.ca/jfox/
  
  
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf 

[R] Multiple Plots using ggplot

2015-03-30 Thread Frederic Ntirenganya
Dear All,

I want to plot multiple using ggplot function from a data frame of
many columns. I want to plot only str1, str2 and str3 and I failed to
make it. What I want is to compare str1, str2 and str3 by plotting
vertical line. I also need to add points to the plot to be able to
separate them.


Here is how the data look like and how I tried to make it.

Date NumberofRaindays TotalRains str1 str2 str3 1/1/1952 86 1360.5 92 120
112 1/1/1953 96 1100 98 100 110
...   
 ...  

df1 -data.frame(data)
df1
df2 - melt(df1 ,  id = 'Date', variable_name = 'start of Rains')
df2

ggplot(df2, aes(Date,value)) + geom_line(aes(colour =red),type = h)

Kindly any help is welcome. Thanks

Regards,
Frederic.

Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

[[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] Ayuda con un árbol de regresión

2015-03-30 Thread Jose Iparraguirre

Miguel,

Sin tus datos es imposible brindarte una respuesta precisa pero ten en cuenta 
que la descripción del argumento 'fórmula' en la función tree del paquete del 
mismo nombre dice que la variable dependiente -PRECIO en tu caso- debe ser un 
vector numérico si quieres estimar un árbol de regressión o un factor si deseas 
producir un árbol de clasificación. No veo términos de interacción en tu 
fórmula, cuya presencia no es permitida, por lo que te sugiero revises qué 
clase de objeto es PRECIO, para lo cual puedes escribir str(CARROST$PRECIO). 
Puede que necesites modificar la clase a vector numérico.

Without any of your data we can't give you a precise answer, but take into 
account that the description of the formula argument of the tree function 
(package tree) reads: The left-hand-side (response) should be either a 
numerical vector when a regression tree will be fitted or a factor, when a 
classification tree is produced. The right-hand-side should be a series of 
numeric or factor variables separated by +; there should be no interaction 
terms. Your formula contains no interaction terms, so I'd suggest you should 
check what class of object PRECIO is -type str(CARROST$PRECIO). You may need to 
change it to a numerical vector.

José



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Dewey
Sent: 24 March 2015 18:16
To: Miguel angel Lopez Martinez; r-help@r-project.org
Subject: Re: [R] Ayuda con un árbol de regresión

Miguel, si prefieres escribir en espanol

https://stat.ethz.ch/mailman/listinfo/r-help-es

(This is the address of the Spanish language mailing list)

On 23/03/2015 20:13, Miguel angel Lopez Martinez wrote:
 ARBOL-tree(PRECIO~CILINDRAJE_DEL_MOTOR+MODELO,data=CARROST)
 ARBOL
 plot(ARBOL)
 text(ARBOL,cex=0.9)

   este es el código que utilizamos las variables cilindraje y modelo 
 son categóricas transformadas por que si utilizamos las varibales como 
 factor no las reconoce

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

 -
 No virus found in this message.
 Checked by AVG - www.avg.com
 Version: 2015.0.5751 / Virus Database: 4315/9373 - Release Date: 
 03/24/15


--
Michael
http://www.dewey.myzen.co.uk

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

Age UK Group

Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798) Registered office: 
Tavis House, 1-6 Tavistock Square, London WC1H 9NA. 

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited. Age UK Enterprises Limited is 
authorised and regulated by the Financial Conduct Authority.

Charitable Services are offered through Age UK (the Charity) and commercial 
products and services are offered by the Charity’s subsidiary companies. The 
Age UK Group comprises of Age UK, and its subsidiary companies and charities, 
dedicated to improving the lives of people in later life. Our network includes 
the three national charities Age Cymru, Age NI and Age Scotland and more than 
160 local Age UK charities.

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you receive a message in error, please advise the sender and delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not necessarily 
reflect the opinions of Age UK or its subsidiaries and associated companies. 
Age UK monitors all e-mail transmissions passing through its network and may 
block or modify mails which are deemed to be unsuitable.
__
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] data.frame: data-driven column selections that vary by row??

2015-03-30 Thread David Wolfskill
Sorry if that's confusing: I'm probably confused. :-(

I am collecting and trying to analyze data regarding performance of
computer systems.

After extracting the data from its repository, I have created and
used a Perl script to generate a (relatively) simple CSV, each
record of which contains:
* a POSIXct timestamp
* a hostname
* a collection of metrics for the interval identified by the timestamp,
  and specific to the host in question, as well as some factors to
  group the hosts (e.g., whether it's in a control vs. a test
  group; a broad categorization of how the host is provisioned; which
  version of the software it was running at the time...).  (Each
  metric and factor is in a uniquely-named column.)

As extracted from the repository, there were several records for each
such hostname/timestamp pair -- e.g., there would be separate records
for:
* Input bandwidth utilization for network interface 1
* Output bandwidth utilization for network interface 1
* Input bandwidth utilization for network interface 2
* Output bandwidth utilization for network interface 2

(And the same field would be used for each of these -- the
interpretation being driven by the content of other fields in teh
record.)

Working with the data as described (immediately) above directly in R
seemed... daunting, at best: thus the excursion into Perl.

And for some of the data, what I have works well enough.

But now I also want to analyze information from disk drives, and things
get messy (as far as I can see).

First, each disk drive has a collection of 17 metrics (such as
busy_pct, kb_per_transfer_read, and transfers_per_second_write),
as well as a factor (dev_type).  Each also has a device name that is
unique within the host where it resides (e.g. da1, da2, da3).
(The dev_type factor identifies whether the drive is a solid-state
device or a spinning disk.)

I have thus made the corresponding columns unique by pasting the drive
name and the name of the metric (or factor), separating the two with
_ (e.g. da7_busy_pct; ada0_mb_per_second_write;
ada4_queue_length).  I am not certain that's the best thing I could
have done -- and I'm open to changing the approach.

The challenge for me is that different (classes of) machines are
provisioned differently; some consequennces of that:
* While da1 may be a spinning disk on host A, that has no bearing on
  whether or not the da1 on host B is a spinning disk or an SSD.
* Host C may not even have a da1 device.
* Host D may be of a type that normally has a da1, but in this case,
  the drive has failed and has been disabled (so host D won't report
  anything about da1).

(I'm not too bothered about the non-reporting case, but cite it so we
all know about it.)

I expect I will want to be using groupings:
* All disk devices -- this one is easy.
* All SSD devices (excluding spinning disks).
* All spinning disks (excluding SSDs).

I'm having trouble with the latter two (though, certainly, if I solve
one, the other is also solved).

Also, for some  of the metrics, I will want to sum them; for others,
I will want to do other things -- find minima or maxima, or average
them.  So pre-calculating such aggregates in the Perl script isn't
something that appeals to me.

Finally (as far as complications go), I'm trying to write the code in
such a way that if we deploy a new configuration of machine that has
(say) twice as many drives as the biggest one we presently deploy, the
code Just Works -- I shouldn't need to update the code merely to adapt
to another hardware configuration.

I have been able to write a function that takes the data.frame obtained
by reading the above-cited CSV, and generates a data.frame with a row
for each host, and depicts the dev_type for each device for that host;
here's an abbreviated (and slightly redacted) copy of its output to
illustrate some of the above:

   ada0 ada1 ada2 ada3 ada4 ada5 da30 da31 da32 da33 da34 da35 da36 da3
host_A  ssd  ssd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd hdd
host_B  ssd  ssd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd  hdd hdd
host_G  ssd  ssd  ssd  ssd  ssd  ssdssd
host_H  ssd  ssd  ssd  ssd  ssd  ssdssd
host_M  ssd  ssd  ssd  ssd  ssd  ssdssd
host_N  ssd  ssd  ssd  ssd  ssd  ssdssd

(That function is written with the explicit assumption(!) that for the
period covered by a given set of input data, a given host's
configuration remains static: we won't have drives changing type
mid-stream.)

So the point of this lengthy(!) note is to ask if there's a
somewhat-sane way to be able to group the metrics for the ssd devices
(for example), given the above.

(So far, the least obnoxious way that comes to mind is to actually
create 2 columns for each device metric: one for the device if it's an
ssd;l the other for hdd -- so instead of columns such as:
* da3_busy_pct
* da3_dev_type
* 

Re: [R] generating phi using function()

2015-03-30 Thread JLucke
Your function phi has 5 arguments with no defaults.  Your call only has 3 
arguments.  Hence the error message.


 phi - function(w1, w2, j, k, K){
+   zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+   nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+   return( zaehler/nenner )
+ }
 phi(c(1, 1), 44L, 1)
Error in phi(c(1, 1), 44L, 1) : argument k is missing, with no default




 





T.Riedle tr...@kent.ac.uk 
Sent by: R-help r-help-boun...@r-project.org
03/29/2015 08:59 AM

To
r-help@r-project.org r-help@r-project.org, 
cc

Subject
[R] generating phi using function()






Hi everybody,
I am trying to generate the formula shown in the attachment. My formula so 
far looks as follows:

phi - function(w1, w2, j, k, K){
zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
return( zaehler/nenner )
}

Unfortunately something must be wrong here as I get the following message 
when running a midas regression

m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = 
list(rvh=c(1,1)))
Error in phi(c(1, 1), 44L, 1) : argument K is missing, with no default
Called from: .rs.breakOnError(TRUE)
Browse[1] K-125
Browse[1] 125

Could anybody look into my phi formula and tell me what is wrong with it?

Thanks in advance.

__
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] Again: A problem someone should know about

2015-03-30 Thread Ian Lester
i have no idea what to do

 plot(body.fat, BMI,xlab=Body fat,ylab=BMI,main=“Figure 2.1: BMI vs Body 
 fat (n=252)”)
Error: unexpected input in plot(body.fat, BMI,xlab=Body 
fat,ylab=BMI,main=�
 plot(body.fat, BMI,xlab=Body fat,ylab=BMI)
 serious error. This application, or a library it uses, is using an invalid 
context  and is thereby contributing to an overall degradation of system 
stability and reliability. This notice is a courtesy: please fix this problem. 
It will become a fatal error in an upcoming update.
 
 Begin forwarded message:
 
 From: Ian Lester ihles...@mensa.org.au
 Reply-To: ihles...@mensa.org.au
 Subject: A problem someone should know about
 Date: 30 March 2015 9:52:54 am AEDT
 To: r-help@r-project.org
 
 I’m a novice and this message looks like it shouldn’t be ignored. Someone who 
 knows what they’re doing should probably take a look.
 Thanks
 Ian Lester
 
 logfat.lm-(lm(body.fat~log(BMI)))
 plot(logfat)
 Error in plot(logfat) : object 'logfat' not found
 plot(logfat.lm)
 Hit Return to see next plot: 
 Hit Return to see next plot: 
 Hit Return to see next plot: 
 Mar 29 18:10:18 iansimac.gateway rsession[69550] Error: Error: this 
 application, or a library it uses, has passed an invalid numeric value (NaN, 
 or not-a-number) to CoreGraphics API. This is a serious error and contributes 
 to an overall degradation of system stability and reliability. This notice is 
 a courtesy: please fix this problem. It will become a fatal error in an 
 upcoming update.


[[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] non-conformable arguments

2015-03-30 Thread Soheila Khodakarim
Dear All,

I want to run neural network on my data.

i run these codes:

#load mydata
dim(mydata)
# 20 3111
library(neuralnet)
fm - as.formula(paste(resp ~, paste(colnames(mydata)[1:3110],
collapse=+)))
out - neuralnet(fm,data=mydata, hidden = 4, lifesign = minimal,
linear.output = FALSE, threshold = 0.1)
#load testset
dim(testset)
# 20 3111
out.results - compute(out, testset)
Error in neurons[[i]] %*% weights[[i]] : non-conformable arguments

what should I do now?

Regards,
Soheila

[[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-es] Comparaciones múltiples

2015-03-30 Thread Javier Villacampa González
Hola Miguel yo tengo una función para hacer comparaciones multiples ( muy
util si hacer medidas repetidas, ya que en el otro caso tienes la función
HSD)

t.test.Comparison.Function.Ch - function( data, StringResponse,
StringFactor){
  
  # Factor
  
  data[,StringFactor ] - factor(data[,StringFactor ] )

  
  # Create data.frame
  
  T.Test - data.frame(Name = NA, LevelOne =NA, LevelTwo= NA,statistic =
NA, df = NA, df = NA, p.value = NA )
  T.Test - T.Test[-1,]
  NumberOfFactors - length(levels(data[, StringFactor]) )

  
  # t.test computation
  
  for(i in 1:(  NumberOfFactors - 1 ) ){
LevelOne - levels(data[, StringFactor])[i]
for(j in (i+1):( NumberOfFactors) ){
  LevelTwo - levels(data[, StringFactor])[j]
  x -t.test( x =data[data[, StringFactor] == LevelOne, StringResponse]
,
  y =data[data[, StringFactor] == LevelTwo, StringResponse]
)

  T.Test - rbind( T.Test,
   data.frame(Name = paste(LevelOne,LevelTwo, sep= .),
  LevelOne = LevelOne,
  LevelTwo= LevelTwo,
  statistic = x$statistic, df =
x$parameter, p.value = x$p.value )
  )
}
  }

  
  # Significacion
  
  T.Test$Sign - n.s.
  if(dim( T.Test[  T.Test$p.value = 0.1  T.Test$p.value  0.05 ,] )[1] 
0 ){
T.Test[  T.Test$p.value = 0.1  T.Test$p.value  0.05 ,]$Sign - ·
  }

  if(dim( T.Test[  T.Test$p.value = 0.05  T.Test$p.value  0.01 ,] )[1] 
0 ){
T.Test[  T.Test$p.value = 0.05  T.Test$p.value  0.01 ,]$Sign - *
  }

  if(dim( T.Test[  T.Test$p.value = 0.01  T.Test$p.value  0.001 ,] )[1]
 0 ){
T.Test[  T.Test$p.value = 0.01  T.Test$p.value  0.001 ,]$Sign - **
  }

  if(dim( T.Test[  T.Test$p.value = 0.001 ,] )[1]  0 ){
T.Test[  T.Test$p.value = 0.001  ,]$Sign - ***
  }

  
  # Bonferroni p.value
  
  T.Test$p.value.Adjusted - p.adjust(T.Test$p.value, method = bonferroni)

  
  # Significacion
  
  T.Test$Sign.Adjusted - n.s.
  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.1  T.Test$p.value.Adjusted
 0.05 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.1  T.Test$p.value.Adjusted 
0.05 ,]$Sign.Adjusted - ·
  }

  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.05 
T.Test$p.value.Adjusted  0.01 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.05  T.Test$p.value.Adjusted 
0.01 ,]$Sign.Adjusted - *
  }

  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.01 
T.Test$p.value.Adjusted  0.001 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.01  T.Test$p.value.Adjusted 
0.001 ,]$Sign.Adjusted - **
  }

  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.001 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.001  ,]$Sign.Adjusted - ***
  }


  
  # Effect Size
  
  t - T.Test$statistic
  df -T.Test$df
  T.Test$Effect.Size - sqrt( t^2/(t^2+df) )

  T.Test$statistic - round( T.Test$statistic, digits = 3)
  T.Test$df - round( T.Test$df, digits = 3)
  T.Test$p.value - round( T.Test$p.value, digits = 3)
  T.Test$p.value.Adjusted - round( T.Test$p.value.Adjusted, digits = 3)
  T.Test$Effect.Size - round( T.Test$Effect.Size, digits = 3)


  return(T.Test)


}


--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] non-conformable arguments

2015-03-30 Thread Thierry Onkelinx
You should sent us a commented, minimal, self-contained, reproducible code
as the posting guide tells you to do.
Your code is not self-contained. So we can only speculate what when wrong.

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie  Kwaliteitszorg / team Biometrics  Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-03-30 14:10 GMT+02:00 Soheila Khodakarim lkhodaka...@gmail.com:

 Dear All,

 I want to run neural network on my data.

 i run these codes:

 #load mydata
 dim(mydata)
 # 20 3111
 library(neuralnet)
 fm - as.formula(paste(resp ~, paste(colnames(mydata)[1:3110],
 collapse=+)))
 out - neuralnet(fm,data=mydata, hidden = 4, lifesign = minimal,
 linear.output = FALSE, threshold = 0.1)
 #load testset
 dim(testset)
 # 20 3111
 out.results - compute(out, testset)
 Error in neurons[[i]] %*% weights[[i]] : non-conformable arguments

 what should I do now?

 Regards,
 Soheila

 [[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] Multiple Plots using ggplot

2015-03-30 Thread stephen sefick
Hi Frederic,

Can you provide a minimal reproducible example including either real data
(dput), or simulated data that mimics your situation? This will allow more
people to help.

Stephen

On Mon, Mar 30, 2015 at 8:39 AM, Frederic Ntirenganya ntfr...@gmail.com
wrote:

 Dear All,

 I want to plot multiple using ggplot function from a data frame of
 many columns. I want to plot only str1, str2 and str3 and I failed to
 make it. What I want is to compare str1, str2 and str3 by plotting
 vertical line. I also need to add points to the plot to be able to
 separate them.


 Here is how the data look like and how I tried to make it.

 Date NumberofRaindays TotalRains str1 str2 str3 1/1/1952 86 1360.5 92 120
 112 1/1/1953 96 1100 98 100 110
 ...   
  ...  

 df1 -data.frame(data)
 df1
 df2 - melt(df1 ,  id = 'Date', variable_name = 'start of Rains')
 df2

 ggplot(df2, aes(Date,value)) + geom_line(aes(colour =red),type = h)

 Kindly any help is welcome. Thanks

 Regards,
 Frederic.

 Frederic Ntirenganya
 Maseno University,
 African Maths Initiative,
 Kenya.
 Mobile:(+254)718492836
 Email: fr...@aims.ac.za
 https://sites.google.com/a/aims.ac.za/fredo/

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




-- 
Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods.  We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

A big computer, a complex algorithm and a long time does not equal
science.

  -Robert Gentleman

[[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] Again: A problem someone should know about

2015-03-30 Thread Sarah Goslee
On Mon, Mar 30, 2015 at 1:59 AM, Ian Lester ianleste...@gmail.com wrote:
 i have no idea what to do

One of the other responses already told you it was probably an Rstudio
problem, so not using Rstudip seems like a good place to start.

Sarah


 plot(body.fat, BMI,xlab=Body fat,ylab=BMI,main=“Figure 2.1: BMI vs Body 
 fat (n=252)”)
 Error: unexpected input in plot(body.fat, BMI,xlab=Body 
 fat,ylab=BMI,main=�
 plot(body.fat, BMI,xlab=Body fat,ylab=BMI)
  serious error. This application, or a library it uses, is using an invalid 
 context  and is thereby contributing to an overall degradation of system 
 stability and reliability. This notice is a courtesy: please fix this 
 problem. It will become a fatal error in an upcoming update.

 Begin forwarded message:


__
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] changing column labels for data frames inside a list

2015-03-30 Thread MacQueen, Don
Assuming that the elements of mylist are data frames, try this:

mylist - lapply(mylist, function(e) { names(e) - paste0('pop',1:12) ; e})


With certain exceptions, the result of a function is the result of the
last expression in the function body. As you defined it, the last
expression was
  colnames(e) - paste0('pop',1:12)
that is, the column names (not labels, but names).

If the elements really are data frames, then names() can be used instead
of colnames(), but colnames() is ok. I don't know if one of them is better
than the other for data frames.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/30/15, 6:54 AM, Vikram Chhatre crypticline...@gmail.com wrote:

 summary(mygenfreqt)
  Length Class  Mode
dat1.str 59220  -none- numeric
dat2.str 59220  -none- numeric
dat3.str 59220  -none- numeric

 head(mylist[[1]])
   1 2 3 4 5 6 7 8 91011
 12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
0.725

I want to change 1:12 to pop1:pop12

mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))

What this is doing is replacing the data frames with just names
pop1:pop12.  I just want to replace the column labels.

Thanks for any suggestions.

   [[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] changing column labels for data frames inside a list

2015-03-30 Thread Ivan Calandra
I am not sure it would do it since there is no reproducible example, but 
try names() instead of colnames().


HTH,
Ivan

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 30/03/15 15:54, Vikram Chhatre a écrit :

summary(mygenfreqt)

   Length Class  Mode
dat1.str 59220  -none- numeric
dat2.str 59220  -none- numeric
dat3.str 59220  -none- numeric


head(mylist[[1]])

1 2 3 4 5 6 7 8 91011
  12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
0.725

I want to change 1:12 to pop1:pop12

mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))

What this is doing is replacing the data frames with just names
pop1:pop12.  I just want to replace the column labels.

Thanks for any suggestions.

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


[R] error MANOVA in R

2015-03-30 Thread Gian Maria Niccolò Benucci
Dear R-usrs,

I am trying to perform a MANOVA on a data frame with 31 columns about soil
parameters and 1 column containing the explanatory variable (Fraction) that
have three levels.
my code is the following:

datam - read.table(data_manova2.csv, header=T, sep=,)
names(datam)

manova_fraction2 - manova(cbind(pH, AWC, WEOC, WEN, C.mic, CO2.C, Ca, Mg,
K, Na, sol.exch.Fe, easily.reducible.Fe, amourphou.Fe.oxide...Fe.OM,
crystalline.Fe.oxides, TN, TOC, NH4.N, NO3.N, N.org, organic.P, avaiable.P,
Total.PLFA, Tot.Bat, Gram., Gram..1, Funghi, AMF, protozoa, actinomiceti,
non.specifici) ~ as.factor(Fraction), data= datam)

summary(manova_fraction2)

when I did the summary I got this error

 summary(manova_fraction2)
Error in summary.manova(manova_fraction2) : residuals have rank 18  30

​Is this error possibly due to high correlation between my variables?

Many thanks in advance,


-- 
Gian

[[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] changing column labels for data frames inside a list

2015-03-30 Thread Bert Gunter
Sarah's statement is correct.

So is yours. They are not contradictory, and I believe Sarah's point
was that the OP needed to learn the appropriate syntax.

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
Clifford Stoll




On Mon, Mar 30, 2015 at 7:56 AM, Sven E. Templer sven.temp...@gmail.com wrote:
 On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:

 colnames(e) - paste0('pop',1:12)

 isn't a function and doesn't return anything.


 But
 function(e){colnames(e) - paste0('pop', 1:2)}
 is a function and it returns something (the last evaluated expression! -
 here the paste0 return):

 mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2)})
 mylist2
 [[1]]
 [1] pop1 pop2

 [[2]]
 [1] pop1 pop2

 [[3]]
 [1] pop1 pop2

  from ?return:

 If the end of a function is reached without calling return, the value of
 the last evaluated expression is returned.


  mylist - list(
 + data.frame(a = runif(10), b = runif(10)),
 + data.frame(c = runif(10), d = runif(10)),
 + data.frame(e = runif(10), f = runif(10)))
  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2);
 e})
  colnames(mylist2[[1]])
 [1] pop1 pop2

 Sarah

 On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
 crypticline...@gmail.com wrote:
  summary(mygenfreqt)
Length Class  Mode
  dat1.str 59220  -none- numeric
  dat2.str 59220  -none- numeric
  dat3.str 59220  -none- numeric
 
  head(mylist[[1]])
 1 2 3 4 5 6 7 8 91011
   12
  L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
  0.275
  L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
  0.725
 
  I want to change 1:12 to pop1:pop12
 
  mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))
 
  What this is doing is replacing the data frames with just names
  pop1:pop12.  I just want to replace the column labels.
 
  Thanks for any suggestions.
 

 --
 Sarah Goslee
 http://www.functionaldiversity.org

 __
 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-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] Again: A problem someone should know about

2015-03-30 Thread David L Carlson
In your first example you created logfat.lm and then tried to plot logfat so 
you got an error indicating that logfat did not exist. 

In your second example we have no idea what body.fat. You must make your 
examples reproducible so that we can reproduce your error. It looks like you 
could also benefit from spending a little time learning about R using a free 
tutorial.

-
David L Carlson
Department of Anthropology
Texas AM University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ian Lester
Sent: Monday, March 30, 2015 12:59 AM
To: r-help@r-project.org
Subject: [R] Again: A problem someone should know about

i have no idea what to do

 plot(body.fat, BMI,xlab=Body fat,ylab=BMI,main=“Figure 2.1: BMI vs Body 
 fat (n=252)”)
Error: unexpected input in plot(body.fat, BMI,xlab=Body 
fat,ylab=BMI,main=�
 plot(body.fat, BMI,xlab=Body fat,ylab=BMI)
 serious error. This application, or a library it uses, is using an invalid 
context  and is thereby contributing to an overall degradation of system 
stability and reliability. This notice is a courtesy: please fix this problem. 
It will become a fatal error in an upcoming update.
 
 Begin forwarded message:
 
 From: Ian Lester ihles...@mensa.org.au
 Reply-To: ihles...@mensa.org.au
 Subject: A problem someone should know about
 Date: 30 March 2015 9:52:54 am AEDT
 To: r-help@r-project.org
 
 I’m a novice and this message looks like it shouldn’t be ignored. Someone who 
 knows what they’re doing should probably take a look.
 Thanks
 Ian Lester
 
 logfat.lm-(lm(body.fat~log(BMI)))
 plot(logfat)
 Error in plot(logfat) : object 'logfat' not found
 plot(logfat.lm)
 Hit Return to see next plot: 
 Hit Return to see next plot: 
 Hit Return to see next plot: 
 Mar 29 18:10:18 iansimac.gateway rsession[69550] Error: Error: this 
 application, or a library it uses, has passed an invalid numeric value (NaN, 
 or not-a-number) to CoreGraphics API. This is a serious error and contributes 
 to an overall degradation of system stability and reliability. This notice is 
 a courtesy: please fix this problem. It will become a fatal error in an 
 upcoming update.


[[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] changing column labels for data frames inside a list

2015-03-30 Thread Sarah Goslee
colnames(e) - paste0('pop',1:12)

isn't a function and doesn't return anything.

 mylist - list(
+ data.frame(a = runif(10), b = runif(10)),
+ data.frame(c = runif(10), d = runif(10)),
+ data.frame(e = runif(10), f = runif(10)))
 mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2); e})
 colnames(mylist2[[1]])
[1] pop1 pop2

Sarah

On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
crypticline...@gmail.com wrote:
 summary(mygenfreqt)
   Length Class  Mode
 dat1.str 59220  -none- numeric
 dat2.str 59220  -none- numeric
 dat3.str 59220  -none- numeric

 head(mylist[[1]])
1 2 3 4 5 6 7 8 91011
  12
 L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
 0.275
 L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
 0.725

 I want to change 1:12 to pop1:pop12

 mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))

 What this is doing is replacing the data frames with just names
 pop1:pop12.  I just want to replace the column labels.

 Thanks for any suggestions.


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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] changing column labels for data frames inside a list

2015-03-30 Thread Sven E. Templer
On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:

 colnames(e) - paste0('pop',1:12)

 isn't a function and doesn't return anything.


But
function(e){colnames(e) - paste0('pop', 1:2)}
is a function and it returns something (the last evaluated expression! -
here the paste0 return):

 mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2)})
 mylist2
[[1]]
[1] pop1 pop2

[[2]]
[1] pop1 pop2

[[3]]
[1] pop1 pop2

 from ?return:

If the end of a function is reached without calling return, the value of
the last evaluated expression is returned.


  mylist - list(
 + data.frame(a = runif(10), b = runif(10)),
 + data.frame(c = runif(10), d = runif(10)),
 + data.frame(e = runif(10), f = runif(10)))
  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2);
 e})
  colnames(mylist2[[1]])
 [1] pop1 pop2

 Sarah

 On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
 crypticline...@gmail.com wrote:
  summary(mygenfreqt)
Length Class  Mode
  dat1.str 59220  -none- numeric
  dat2.str 59220  -none- numeric
  dat3.str 59220  -none- numeric
 
  head(mylist[[1]])
 1 2 3 4 5 6 7 8 91011
   12
  L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
  0.275
  L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
  0.725
 
  I want to change 1:12 to pop1:pop12
 
  mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))
 
  What this is doing is replacing the data frames with just names
  pop1:pop12.  I just want to replace the column labels.
 
  Thanks for any suggestions.
 

 --
 Sarah Goslee
 http://www.functionaldiversity.org

 __
 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] Transformation of the circular variable into linear variable

2015-03-30 Thread Nasr Al-Dhurafi
I am working with a circular data ( wind direction ) and i have problem
in transforming  the circular variable into linear variable. I have found
an equation that can be used to convert the circular variable into linear
variable which is included in this paper * ARMA based approaches for
forecasting the tuple of wind speed and direction. *The equation is called
as the inverse of a link function and i have attached  the summery of it.T
herefore,Please, if you have an idea of how to conduct it in R programming
or  if you have another method for transformation, let me know it. Your
cooperation is highly appreciated.

My Best Regards   All The Best
Nasr

[[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] changing column labels for data frames inside a list

2015-03-30 Thread Vikram Chhatre
First of all, thank you for all the quick replies.  Here is a solution that
worked for me.

mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',1:12);
return(e)})

 head(mylist2[[1]])
pop1  pop2  pop3  pop4  pop5  pop6  pop7  pop8  pop9 pop10 pop11
pop12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
0.725

While we are at this, I wanted to create a 13th column in each data frame
for average of each row.

# Calculate average
myavg - lapply(mylist2, function(e) rowSums(mylist2)/12)

# Attach to the main data frame
mylist3 - cbind(mylist2, myavg)

This does not work the way I imagined it would.  The myavg vector is
attached directly to mylist2, not to individual dataframes within.

p.s. Is it a standard convention to always copy the reply to the last
person who responded?

On Mon, Mar 30, 2015 at 10:56 AM, Sven E. Templer sven.temp...@gmail.com
wrote:

 On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:

  colnames(e) - paste0('pop',1:12)
 
  isn't a function and doesn't return anything.
 

 But
 function(e){colnames(e) - paste0('pop', 1:2)}
 is a function and it returns something (the last evaluated expression! -
 here the paste0 return):

  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2)})
  mylist2
 [[1]]
 [1] pop1 pop2

 [[2]]
 [1] pop1 pop2

 [[3]]
 [1] pop1 pop2

  from ?return:

 If the end of a function is reached without calling return, the value of
 the last evaluated expression is returned.

 
   mylist - list(
  + data.frame(a = runif(10), b = runif(10)),
  + data.frame(c = runif(10), d = runif(10)),
  + data.frame(e = runif(10), f = runif(10)))
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
 1:2);
  e})
   colnames(mylist2[[1]])
  [1] pop1 pop2
 
  Sarah
 
  On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
  crypticline...@gmail.com wrote:
   summary(mygenfreqt)
 Length Class  Mode
   dat1.str 59220  -none- numeric
   dat2.str 59220  -none- numeric
   dat3.str 59220  -none- numeric
  
   head(mylist[[1]])
  1 2 3 4 5 6 7 8 910
 11
12
   L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
 0.350
   0.275
   L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
 0.650
   0.725
  
   I want to change 1:12 to pop1:pop12
  
   mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))
  
   What this is doing is replacing the data frames with just names
   pop1:pop12.  I just want to replace the column labels.
  
   Thanks for any suggestions.
  
 
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
  __
  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.


[[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] changing column labels for data frames inside a list

2015-03-30 Thread Sven E. Templer
On 30 March 2015 at 17:19, Vikram Chhatre crypticline...@gmail.com wrote:

 First of all, thank you for all the quick replies.  Here is a solution that
 worked for me.

 mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',1:12);
 return(e)})

  head(mylist2[[1]])
 pop1  pop2  pop3  pop4  pop5  pop6  pop7  pop8  pop9 pop10 pop11
 pop12
 L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
 0.275
 L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
 0.725

 While we are at this, I wanted to create a 13th column in each data frame
 for average of each row.


For new problems you should use a new topic.



 # Calculate average
 myavg - lapply(mylist2, function(e) rowSums(mylist2)/12)

 # Attach to the main data frame
 mylist3 - cbind(mylist2, myavg)


 This does not work the way I imagined it would.  The myavg vector is
 attached directly to mylist2, not to individual dataframes within.


But it works as expected (read ?cbind).
You try to cbind two lists (myavg and mylist2).
You want to cbind each list object (the data.frames) with each rowSums
output.
So, use cbind within your first lapply.

p.s. Is it a standard convention to always copy the reply to the last
 person who responded?


I guess it depends on which answer you refer to.



 On Mon, Mar 30, 2015 at 10:56 AM, Sven E. Templer sven.temp...@gmail.com
 wrote:

  On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:
 
   colnames(e) - paste0('pop',1:12)
  
   isn't a function and doesn't return anything.
  
 
  But
  function(e){colnames(e) - paste0('pop', 1:2)}
  is a function and it returns something (the last evaluated expression! -
  here the paste0 return):
 
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
 1:2)})
   mylist2
  [[1]]
  [1] pop1 pop2
 
  [[2]]
  [1] pop1 pop2
 
  [[3]]
  [1] pop1 pop2
 
   from ?return:
 
  If the end of a function is reached without calling return, the value of
  the last evaluated expression is returned.
 
  
mylist - list(
   + data.frame(a = runif(10), b = runif(10)),
   + data.frame(c = runif(10), d = runif(10)),
   + data.frame(e = runif(10), f = runif(10)))
mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
  1:2);
   e})
colnames(mylist2[[1]])
   [1] pop1 pop2
  
   Sarah
  
   On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
   crypticline...@gmail.com wrote:
summary(mygenfreqt)
  Length Class  Mode
dat1.str 59220  -none- numeric
dat2.str 59220  -none- numeric
dat3.str 59220  -none- numeric
   
head(mylist[[1]])
   1 2 3 4 5 6 7 8 910
  11
 12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
  0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
  0.650
0.725
   
I want to change 1:12 to pop1:pop12
   
mylist- lapply(mylist, function(e) colnames(e) -
 paste0('pop',1:12))
   
What this is doing is replacing the data frames with just names
pop1:pop12.  I just want to replace the column labels.
   
Thanks for any suggestions.
   
  
   --
   Sarah Goslee
   http://www.functionaldiversity.org
  
   __
   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.
 

 [[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] changing column labels for data frames inside a list

2015-03-30 Thread Sven E. Templer
On 30 March 2015 at 17:31, Bert Gunter gunter.ber...@gene.com wrote:

 Sarah's statement is correct.

 So is yours. They are not contradictory, and I believe Sarah's point
 was that the OP needed to learn the appropriate syntax.


That's why I pointed to ?return.
Sarah's statement was not so clear (and might have been misleading) for me
regarding the R expertise of the OP.


 -- Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

 Data is not information. Information is not knowledge. And knowledge
 is certainly not wisdom.
 Clifford Stoll




 On Mon, Mar 30, 2015 at 7:56 AM, Sven E. Templer sven.temp...@gmail.com
 wrote:
  On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:
 
  colnames(e) - paste0('pop',1:12)
 
  isn't a function and doesn't return anything.
 
 
  But
  function(e){colnames(e) - paste0('pop', 1:2)}
  is a function and it returns something (the last evaluated expression! -
  here the paste0 return):
 
  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
 1:2)})
  mylist2
  [[1]]
  [1] pop1 pop2
 
  [[2]]
  [1] pop1 pop2
 
  [[3]]
  [1] pop1 pop2
 
   from ?return:
 
  If the end of a function is reached without calling return, the value of
  the last evaluated expression is returned.
 
 
   mylist - list(
  + data.frame(a = runif(10), b = runif(10)),
  + data.frame(c = runif(10), d = runif(10)),
  + data.frame(e = runif(10), f = runif(10)))
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
 1:2);
  e})
   colnames(mylist2[[1]])
  [1] pop1 pop2
 
  Sarah
 
  On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
  crypticline...@gmail.com wrote:
   summary(mygenfreqt)
 Length Class  Mode
   dat1.str 59220  -none- numeric
   dat2.str 59220  -none- numeric
   dat3.str 59220  -none- numeric
  
   head(mylist[[1]])
  1 2 3 4 5 6 7 8 910
 11
12
   L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
 0.350
   0.275
   L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
 0.650
   0.725
  
   I want to change 1:12 to pop1:pop12
  
   mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))
  
   What this is doing is replacing the data frames with just names
   pop1:pop12.  I just want to replace the column labels.
  
   Thanks for any suggestions.
  
 
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
  __
  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.


[[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] Vennerable plot

2015-03-30 Thread gktahon
Hi all,

I frequently use Vennerable to design diagrams of my data.
However, when I want to make a weighed diagram for a set of 4 samples, type
ChowRuskey, I get a nice view, but the font size of both numbers and sample
names is too small. Furthermore, the place of the sample names isn't always
that good. It places some names in the diagram (always on the same place).

Does anyone know how to
1) Change font size
2) Place labels somewhere else

This is an example of a plot I make:
library(Vennerable)
Vdemo3 - Venn(SetNames = c(KP2,KP15,KP43, KP53), Weight = c(''
= 0, '1000' = 40, '0100' = 54, '0010' = 38, '0001' = 68,  '1100' = 0, '1010'
= 0, '0110' = 0, '0011' =1, '0101' = 0, '1001' = 1, '1110' = 0, '1101' = 0,
'1011' = 0, '0111' = 0, '' = 0))
plot(Vdemo3, doWeight = TRUE, type = ChowRuskey)


Many thanks in advance,
Guillaume




--
View this message in context: 
http://r.789695.n4.nabble.com/Vennerable-plot-tp4705278.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.


[R] Fwd: changing column labels for data frames inside a list

2015-03-30 Thread Bert Gunter
Sorry, I failed to cc the list.

-- Bert





-- Forwarded message --
From: Bert Gunter bgun...@gene.com
Date: Mon, Mar 30, 2015 at 8:36 AM
Subject: Re: [R] changing column labels for data frames inside a list
To: Vikram Chhatre crypticline...@gmail.com


You really really need to spend (more?) time with a good R tutorial
before posting further. Your questions are entirely due to your
ignorance of standard language syntax that you should learn if you
intend to use R. Of course, feel free to ask for help if there are
places in the tutorials where, after an honest effort, you remain
flummoxed.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
Clifford Stoll




On Mon, Mar 30, 2015 at 8:19 AM, Vikram Chhatre
crypticline...@gmail.com wrote:
 First of all, thank you for all the quick replies.  Here is a solution that
 worked for me.

 mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',1:12);
 return(e)})

 head(mylist2[[1]])
 pop1  pop2  pop3  pop4  pop5  pop6  pop7  pop8  pop9 pop10 pop11
 pop12
 L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
 0.275
 L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
 0.725

 While we are at this, I wanted to create a 13th column in each data frame
 for average of each row.

 # Calculate average
 myavg - lapply(mylist2, function(e) rowSums(mylist2)/12)

 # Attach to the main data frame
 mylist3 - cbind(mylist2, myavg)

 This does not work the way I imagined it would.  The myavg vector is
 attached directly to mylist2, not to individual dataframes within.

 p.s. Is it a standard convention to always copy the reply to the last
 person who responded?

 On Mon, Mar 30, 2015 at 10:56 AM, Sven E. Templer sven.temp...@gmail.com
 wrote:

 On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:

  colnames(e) - paste0('pop',1:12)
 
  isn't a function and doesn't return anything.
 

 But
 function(e){colnames(e) - paste0('pop', 1:2)}
 is a function and it returns something (the last evaluated expression! -
 here the paste0 return):

  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop', 1:2)})
  mylist2
 [[1]]
 [1] pop1 pop2

 [[2]]
 [1] pop1 pop2

 [[3]]
 [1] pop1 pop2

  from ?return:

 If the end of a function is reached without calling return, the value of
 the last evaluated expression is returned.

 
   mylist - list(
  + data.frame(a = runif(10), b = runif(10)),
  + data.frame(c = runif(10), d = runif(10)),
  + data.frame(e = runif(10), f = runif(10)))
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
 1:2);
  e})
   colnames(mylist2[[1]])
  [1] pop1 pop2
 
  Sarah
 
  On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
  crypticline...@gmail.com wrote:
   summary(mygenfreqt)
 Length Class  Mode
   dat1.str 59220  -none- numeric
   dat2.str 59220  -none- numeric
   dat3.str 59220  -none- numeric
  
   head(mylist[[1]])
  1 2 3 4 5 6 7 8 910
 11
12
   L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
 0.350
   0.275
   L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
 0.650
   0.725
  
   I want to change 1:12 to pop1:pop12
  
   mylist- lapply(mylist, function(e) colnames(e) - paste0('pop',1:12))
  
   What this is doing is replacing the data frames with just names
   pop1:pop12.  I just want to replace the column labels.
  
   Thanks for any suggestions.
  
 
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
  __
  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.


 [[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] changing column labels for data frames inside a list

2015-03-30 Thread Sarah Goslee
On Mon, Mar 30, 2015 at 11:43 AM, Sven E. Templer
sven.temp...@gmail.com wrote:


 On 30 March 2015 at 17:31, Bert Gunter gunter.ber...@gene.com wrote:

 Sarah's statement is correct.

 So is yours. They are not contradictory, and I believe Sarah's point
 was that the OP needed to learn the appropriate syntax.


 That's why I pointed to ?return.
 Sarah's statement was not so clear (and might have been misleading) for me
 regarding the R expertise of the OP.

You're right: I totally wasn't clear. I got involved making a working
reproducible example and didn't explain what I was doing. And you are
totally correct, the last expression will be returned. Mea culpa.

Sarah



 -- Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

 Data is not information. Information is not knowledge. And knowledge
 is certainly not wisdom.
 Clifford Stoll




 On Mon, Mar 30, 2015 at 7:56 AM, Sven E. Templer sven.temp...@gmail.com
 wrote:
  On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:
 
  colnames(e) - paste0('pop',1:12)
 
  isn't a function and doesn't return anything.
 
 
  But
  function(e){colnames(e) - paste0('pop', 1:2)}
  is a function and it returns something (the last evaluated expression! -
  here the paste0 return):
 
  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
  1:2)})
  mylist2
  [[1]]
  [1] pop1 pop2
 
  [[2]]
  [1] pop1 pop2
 
  [[3]]
  [1] pop1 pop2
 
   from ?return:
 
  If the end of a function is reached without calling return, the value of
  the last evaluated expression is returned.
 
 
   mylist - list(
  + data.frame(a = runif(10), b = runif(10)),
  + data.frame(c = runif(10), d = runif(10)),
  + data.frame(e = runif(10), f = runif(10)))
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
   1:2);
  e})
   colnames(mylist2[[1]])
  [1] pop1 pop2
 
  Sarah
 
  On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
  crypticline...@gmail.com wrote:
   summary(mygenfreqt)
 Length Class  Mode
   dat1.str 59220  -none- numeric
   dat2.str 59220  -none- numeric
   dat3.str 59220  -none- numeric
  
   head(mylist[[1]])
  1 2 3 4 5 6 7 8 910
   11
12
   L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
   0.350
   0.275
   L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
   0.650
   0.725
  
   I want to change 1:12 to pop1:pop12
  
   mylist- lapply(mylist, function(e) colnames(e) -
   paste0('pop',1:12))
  
   What this is doing is replacing the data frames with just names
   pop1:pop12.  I just want to replace the column labels.
  
   Thanks for any suggestions.
  
 
  --
  Sarah Goslee
  http://www.functionaldiversity.org

__
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] Debug package options

2015-03-30 Thread Duncan Murdoch
On 30/03/2015 1:50 PM, Keith S Weintraub wrote:
 Folks,
 
 I would like change some of the options for the Tk window that pops up when 
 using the debug package.
 
 I know how to change the options: e.g. options(debug.font = Courier 12 
 italic”).
 
 Is there a way to “preset” these in my environment so when debug starts up I 
 have all the options set up the way I want them?
 
 Do I do this in a .First file? Does the .First file have to load the debug 
 package every time I start up R?
 
 No need to do my work for me. Just point me to the right doc.

See the ?Startup help topic.  You probably want to use one of the
profile files rather than .First, because .First needs to be in a
workspace, and you shouldn't be loading a workspace every time.

Duncan Murdoch

__
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-es] comparaciones múltiples

2015-03-30 Thread Luciano Selzer
Recomiendo que veas el paquete lsmeans. Podes especificar comparaciones
dentro factores.

Saludos

Luciano

El 29 de marzo de 2015, 11:36, Miguel Lázaro lazar...@yahoo.es escribió:

 Hola a todos,
 yo he tenido el mismo problema y después de hablar con mucha gente que a
 su vez habló con mucha gente, he optado por la solución laboriosa y parto
 la matriz general en tantas matrices como niveles tenga el factor -una vez
 la interacción es significativa. Es un procedimiento laborioso pero
 incontestable para cualquier revisor, creo.
 Saludos
 Miguel
 
 El dom, 29/3/15, r-help-es-requ...@r-project.org 
 r-help-es-requ...@r-project.org escribió:

  Asunto: Resumen de R-help-es, Vol 73, Envío 42
  Para: r-help-es@r-project.org
  Fecha: domingo, 29 de marzo, 2015 11:00

  Envíe los mensajes para la lista
  R-help-es a
  r-help-es@r-project.org

  Para subscribirse o anular su subscripción a través de la
  WEB
  https://stat.ethz.ch/mailman/listinfo/r-help-es

  O por correo electrónico, enviando un mensaje con el texto
  help en
  el asunto (subject) o en el cuerpo a:
  r-help-es-requ...@r-project.org

  Puede contactar con el responsable de la lista escribiendo
  a:
  r-help-es-ow...@r-project.org

  Si responde a algún contenido de este mensaje, por favor,
  edite la
  linea del asunto (subject) para que el texto sea mas
  especifico que:
  Re: Contents of R-help-es digest Además, por favor,
  incluya en
  la respuesta sólo aquellas partes del mensaje a las que
  está
  respondiendo.


  Asuntos del día:

 1. Re: Uso de R a través de Telegram
  (Pedro Herrero Petisco)
 2. Comparaciones múltiples (Carlos
  Hernández-Castellano)
 3. Re: Comparaciones múltiples (Víctor
  Granda García)


  --

  Message: 1
  Date: Sat, 28 Mar 2015 12:06:35 +0100
  From: Pedro Herrero Petisco pedroherreropeti...@gmail.com
  To: Ruben Tobalina Ramirez lagrimaescr...@gmail.com
  Cc: Lista R r-help-es@r-project.org
  Subject: Re: [R-es] Uso de R a través de Telegram
  Message-ID:

  CAM7H6U_EyWwvWKb4STnXWbNys_Z170zeN2+f6dqvz=me6m+...@mail.gmail.com
  Content-Type: text/plain; charset=UTF-8

  Muchas gracias por compartir, la verdad es que está muy
  chulo :-)
  El 28/03/2015 09:29, Ruben Tobalina Ramirez lagrimaescr...@gmail.com
  escribió:

   Buenas,
  
   He descubierto y queria compartirla con vosotros. La
  verdad es que
   tiene buena pinta, es curiosa, pero no sé si tiene
  mucha utilidad.
   Tele R es una app para usar R a través de Telegram.
  Básicamente
   envias el código de R a una cuenta de Telegram que
  esta conectada a un
   servidor en la nube con R y te envia a tu telefono los
  resultados,
   vamos como si tuvieses R en tu móvil. Os envio su werb
  por si os
   interesa: http://telemath.altervista.org/TeleR.html
  
   y existe lo mismo para Octave:
  
  
 http://nbviewer.ipython.org/github/CAChemE/lightning-talks/blob/master/2015-02/TeleOctave.ipynb
  
   Un saludo
  
   Rubén
  
   ___
   R-help-es mailing list
   R-help-es@r-project.org
   https://stat.ethz.ch/mailman/listinfo/r-help-es
  

  [[alternative HTML version deleted]]



  --

  Message: 2
  Date: Sat, 28 Mar 2015 23:10:04 +0100
  From: Carlos Hernández-Castellano
  carlos.hernandezcastell...@gmail.com
  To: r-help-es@r-project.org
  Subject: [R-es] Comparaciones múltiples
  Message-ID:
  cafqssgjvun3tssut8gyo0ggaktd8mymszld2stnbwfw6o9f...@mail.gmail.com
  Content-Type: text/plain; charset=UTF-8

  Saludos,

  tengo una base de datos con tres variables: especie,
  tratamiento y
  abundancia.

  Quiero hacer comparaciones múltiples con Tukey.
  Ya había usado el comando TukeyHSD(aov(x~y)).

  La cuestión esque ahora tengo varios niveles del factor
  especie y varios
  niveles del factor tratamiento.
  Si hago TukeyHSD(aov(abundancia~especie:tratamiento)) me
  salen todas las
  comparaciones posibles, pero yo sólo estoy interesado en
  que para cada
  especie (i.e. para cada nivel del factor especie) me salgan
  las
  comparaciones de los datos de abundancia para cada par de
  tratamientos
  (niveles del factor tratamiento).

  Una solución laboriosa sería partir el documento original
  en tantos como
  especies, pero seguro que alguien me puede sugerir una
  solución más
  inteligente.

  Saludos y gracias,


  --
  *?*

  *Carlos Hernández-Castellano*

  Environmental Scientist

  Student, MSc Terrestrial Ecology and Biodiversity
  Management

  Research Collaborator at Centre of Ecological Research and
  Forestry
  Applications (CREAF)

  Ecology Unit - Department of Animal Biology, Plant Biology
  and Ecology;
  Faculty of Sciences, Autonomous University of Barcelona
  (UAB)

  08193 Bellaterra, Spain

  Email: carlos.hernandezcastell...@gmail.com

  [[alternative HTML version deleted]]



  --

[R] multinomial probabilities with mlogit

2015-03-30 Thread Ingrid Charvet
Hello,

When fitting a logit multinomial model with mlogit I can retrieve the 
response probabilities using
fit$fitted.values (for a given object fit)

However, I am trying to calculate those response probabilities myself using the 
maximum likelihood estimates (i.e. fit$coefficients) given by mlogit.

I have used the model given in Agresti (2002):

Prob_j(x) = exp( linearpredictor_j(x) ) / (1 + sum (linearpredictor(x)))

Which is for a category j the exponential of the linear predictor for category 
j divided by 1 + the sum of all logits across categories, aside from the 
reference category.

But I cannot get my fitted probabilities calculated using this equation to 
match the output of mlogit fit$fitted values.

Can anyone tell me how those fitted values are calculated? Or point me to the 
corresponding documentation (which I cannot seem to find by googling!)

Many thanks
Ingrid

[[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] changing column labels for data frames inside a list

2015-03-30 Thread MacQueen, Don
Regarding the averages, someone else mentioned that it's preferred to
start a new question in a new post to the list.

That said, you are confusing inside the list with outside the list.
Try this:

(the following R expression is supposed to be all on one line, but my
email software may cause a line break)

myavgs - lapply(mylist2, function(e) {cbind( e, avgs=rowSums(e)/12)} )

With no example data I can't test it. The brackets {} are not, strictly
speaking, necessary, but I think they help clarify what is inside the
function with what is outside it.

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/30/15, 8:19 AM, Vikram Chhatre crypticline...@gmail.com wrote:

First of all, thank you for all the quick replies.  Here is a solution
that
worked for me.

mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',1:12);
return(e)})

 head(mylist2[[1]])
pop1  pop2  pop3  pop4  pop5  pop6  pop7  pop8  pop9 pop10 pop11
pop12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475 0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525 0.650
0.725

While we are at this, I wanted to create a 13th column in each data frame
for average of each row.

# Calculate average
myavg - lapply(mylist2, function(e) rowSums(mylist2)/12)

# Attach to the main data frame
mylist3 - cbind(mylist2, myavg)

This does not work the way I imagined it would.  The myavg vector is
attached directly to mylist2, not to individual dataframes within.

p.s. Is it a standard convention to always copy the reply to the last
person who responded?

On Mon, Mar 30, 2015 at 10:56 AM, Sven E. Templer sven.temp...@gmail.com
wrote:

 On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:

  colnames(e) - paste0('pop',1:12)
 
  isn't a function and doesn't return anything.
 

 But
 function(e){colnames(e) - paste0('pop', 1:2)}
 is a function and it returns something (the last evaluated expression! -
 here the paste0 return):

  mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
1:2)})
  mylist2
 [[1]]
 [1] pop1 pop2

 [[2]]
 [1] pop1 pop2

 [[3]]
 [1] pop1 pop2

  from ?return:

 If the end of a function is reached without calling return, the value of
 the last evaluated expression is returned.

 
   mylist - list(
  + data.frame(a = runif(10), b = runif(10)),
  + data.frame(c = runif(10), d = runif(10)),
  + data.frame(e = runif(10), f = runif(10)))
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
 1:2);
  e})
   colnames(mylist2[[1]])
  [1] pop1 pop2
 
  Sarah
 
  On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
  crypticline...@gmail.com wrote:
   summary(mygenfreqt)
 Length Class  Mode
   dat1.str 59220  -none- numeric
   dat2.str 59220  -none- numeric
   dat3.str 59220  -none- numeric
  
   head(mylist[[1]])
  1 2 3 4 5 6 7 8 910
 11
12
   L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
 0.350
   0.275
   L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
 0.650
   0.725
  
   I want to change 1:12 to pop1:pop12
  
   mylist- lapply(mylist, function(e) colnames(e) -
paste0('pop',1:12))
  
   What this is doing is replacing the data frames with just names
   pop1:pop12.  I just want to replace the column labels.
  
   Thanks for any suggestions.
  
 
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
  __
  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.


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


[R] Debug package options

2015-03-30 Thread Keith S Weintraub
Folks,

I would like change some of the options for the Tk window that pops up when 
using the debug package.

I know how to change the options: e.g. options(debug.font = Courier 12 
italic”).

Is there a way to “preset” these in my environment so when debug starts up I 
have all the options set up the way I want them?

Do I do this in a .First file? Does the .First file have to load the debug 
package every time I start up R?

No need to do my work for me. Just point me to the right doc.

Best,
KW

__
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] A problem someone should know about

2015-03-30 Thread Richard M. Heiberger
My error is Mac because I don't use R-Studio.  The phrasing of Ian's
error is similar to the error I reported
and still occasionally get.  As I said, it is random and therefore not
reproducible.

This is consistent with the comments on the rstudio link you pointed us to.

Rich

On Mon, Mar 30, 2015 at 9:00 AM, Peter Claussen dakotaj...@mac.com wrote:
 Rich,

 You’ve probably reported the error to the wrong group.

 A quick search suggests this is not an R issue, but an RStudio issue. The 
 error message is unique enough. Google returns this as the first link:

 https://support.rstudio.com/hc/communities/public/questions/200807456-Error-when-plotting-graphics-on-Mac-OSX-Mavericks

 Peter

 On Mar 29, 2015, at 9:21 PM, Richard M. Heiberger r...@temple.edu wrote:

 This looks like a specific Macintosh error that appears at random intervals.
 I get it at random, and unreproducible times.  I reported it (or
 perhaps a close relative)
 to the r-sig-mac list in September 2014.

 Rich


 On Sun, Mar 29, 2015 at 9:59 PM, Rolf Turner r.tur...@auckland.ac.nz wrote:
 On 30/03/15 11:52, Ian Lester wrote:

 I’m a novice and this message looks like it shouldn’t be ignored. Someone
 who knows what they’re doing should probably take a look.
 Thanks
 Ian Lester

 logfat.lm-(lm(body.fat~log(BMI)))
 plot(logfat)

 Error in plot(logfat) : object 'logfat' not found

 plot(logfat.lm)

 Hit Return to see next plot:
 Hit Return to see next plot:
 Hit Return to see next plot:
 Mar 29 18:10:18 iansimac.gateway rsession[69550] Error: Error: this
 application, or a library it uses, has passed an invalid numeric
 value (NaN, or not-a-number) to CoreGraphics API. This is a serious
 error and contributes to an overall degradation of system stability
 and reliability. This notice is a courtesy: please fix this problem.
 It will become a fatal error in an upcoming update.


 Please make your examples *reproducible* as the posting guide requests.

 I *presume* that your data are the fat data from the UsingR package,
 which you did not mention.

 After installing and loading UsingR I did

 logfat.lm - lm(body.fat~log(BMI),data=fat)
 plot(logfat.lm)

 and got a sequence of plots, with no error thrown. It would appear that
 whatever is causing the error that you saw is peculiar to your system.

 cheers,

 Rolf Turner

 --
 Rolf Turner
 Technical Editor ANZJS
 Department of Statistics
 University of Auckland
 Phone: +64-9-373-7599 ext. 88276
 Home phone: +64-9-480-4619


 __
 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] multinomial probabilities with mlogit

2015-03-30 Thread Rolf Turner



Reproducible example???

cheers,

Rolf Turner

P.S.  Where does mlogit come from?  Note fortune(182).

R. T.

On 31/03/15 06:46, Ingrid Charvet wrote:

Hello,

When fitting a logit multinomial model with mlogit I can retrieve
the response probabilities using fit$fitted.values (for a given
object fit)

However, I am trying to calculate those response probabilities myself
using the maximum likelihood estimates (i.e. fit$coefficients) given
by mlogit.

I have used the model given in Agresti (2002):

Prob_j(x) = exp( linearpredictor_j(x) ) / (1 + sum
(linearpredictor(x)))

Which is for a category j the exponential of the linear predictor for
category j divided by 1 + the sum of all logits across categories,
aside from the reference category.

But I cannot get my fitted probabilities calculated using this
equation to match the output of mlogit fit$fitted values.

Can anyone tell me how those fitted values are calculated? Or point
me to the corresponding documentation (which I cannot seem to find by
googling!)


--
Rolf Turner
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Home phone: +64-9-480-4619

__
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] Help with POSIX

2015-03-30 Thread Jeff Newmiller
You seem to be trying to make POSIXt into something it isn't, as though this 
was Excel. 

First, POSIXt is not the same as numeric. You can convert between them, but 
they are not the same. If you want to do numeric operations, convert.

Second, POSIXt is not time of day only. When you provide only minutes and 
seconds to strptime, it includes the current date in the result as well. Thus, 
values converted today will be different than values converted tomorrow. You 
should probably pick a specific date to include in every time value, and 
paste it with the actual data before converting.

Finally, formatting of all non-character data is always associated with 
conversion to character. You either need to reconvert on demand or keep a copy 
of the data around unconverted for use when you need it.

Oh, and your use of HTML is leading to corruption of your code. Learn to use 
your email program so you don't send us garbage to guess at.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On March 30, 2015 6:15:09 PM PDT, Doran, Harold hdo...@air.org wrote:
I�m struggling a bit with learning about POSIX objects to do some basic
things with objects of this class. Suppose I have the following simple
example

times - c(03:20, 29:56, 03:30, 21:03, 56:26)

aa - strptime(times, %M:%S�)

I can do means, and some other basic things, but I cannot correlate the
objects with some other variable

cor(aa, rnorm(5))

Also, for purposes of a user-interface I have built with shiny, I need
for the time to be viewed as simply as minutes:seconds, such as this

format(aa, '%M:%S�)

But of course after doing this I lose the ability to work with this
object as a time variable.

Thank you
Harold

   [[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] Help with POSIX

2015-03-30 Thread David Wolfskill
On Tue, Mar 31, 2015 at 01:15:09AM +, Doran, Harold wrote:
 I?m struggling a bit with learning about POSIX objects to do some basic 
 things with objects of this class. Suppose I have the following simple example
 
 times - c(03:20, 29:56, 03:30, 21:03, 56:26)
 
 aa - strptime(times, %M:%S?)
 
 I can do means, and some other basic things, but I cannot correlate the 
 objects with some other variable
 
 cor(aa, rnorm(5))

I suspect you will find that manipulating times as numeric quantities
(so you can do arithmetic on them) will be easier if you convert to
seconds (possibly using a different vector, leaving times as it was).

 Also, for purposes of a user-interface I have built with shiny, I need for 
 the time to be viewed as simply as minutes:seconds, such as this
 
 format(aa, '%M:%S?)
 
 But of course after doing this I lose the ability to work with this object as 
 a time variable.

So do that with a copy -- the output of format() need not destroy its
input.

...

Peace,
david
-- 
David H. Wolfskill  r...@catwhisker.org
Those who murder in the name of God or prophet are blasphemous cowards.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.


pgpo9NplNcuzH.pgp
Description: PGP signature
__
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] Mann-Kendall test for many independent columns data set at a time

2015-03-30 Thread Desta Yoseph via R-help
I am analyzing trend test using Mann-kendall monotonic trendtest for 10,368 
independent grid cell, each grid has 34 years dataset.  I supposed to find 
Kendall “tau” for each gridcell (each grid has 34 years data). The data is 
arranged in column wise (Iattached  part of the grid dataset  as a sample).

To find Kendall tau, I wrote R script as:


desta-read.csv(rainfall.csv,header=T, sep=,)

require(Kendall) 

MK-function(y) {

     nc-ncol(y)

   MannKendalltau-numeric(nc)

    for(i in 2:nc){

           MannKendalltau[i]-MannKendall(y[,i])

   }

    MannKendalltau

    }

    MK(desta)


The result displayed both “tau” and “2-sided pvalue”.  But, I wantonly “tau” 
value that is printed in organized way. Anyone can tell me how can Iget orderly 
printed “tau” value  for allgrid cells at a time.    


Thank you for your help in advance,Desta WodeboTU-DresdenGermany 
__
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] Plotting using tapply function output

2015-03-30 Thread Alexandra Catena
Hello,

I am trying to plot the hourly standard deviation of wind speeds from
13 different measured locations over many years. I imported the data
using readLines and into a dataframe called finalData. Using tapply, I
determined the standard deviation of the windspeed (ws) for each hour
(hour) from every location (stn) using this command line:

statHour = tapply(finalData$ws,list(finalData$stn,finalData$hour),sd)

I want to plot the standard deviation for each hour of the day, with
hours as the x-axis and the standard deviation for the y-axis, and
each station as a different color.  I've managed to get a boxplot of
this, but ideally, I'd like a scatter plot to determine the variations
between each instrument throughout the day.  The boxplot command is
this:

boxplot(statHour, names=colnames(statHour),xlab='Hour of the
Day',ylab='Standard Deviation of Wind Speed')

I also tried to make a dataframe of the tapply output but it ends up
using the hours as the column names instead of putting it into the
dataframe.  Please help!!

I have R version 3.1.1

Thanks a lot,
Alexandra

__
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] Trying to understand a function passed to lapply

2015-03-30 Thread John Sorkin
Colleagues,
I am trying to understand the syntax of a function passed to apply. The code 
below generates a matrix, and passes the matrix to a function that is called by 
apply. I don't understand the syntax of the function. In some way the function 
computes data[,delta]/data[,SE]. I can't understand how the body of the 
function, x[c1]/x[c2] refers to the columns data and SE of the matrix data. 
Can someone help me understand the syntax? 
Thank you,
John

myfun - function(x, c1, c2) x[c1]/x[c2]
apply(data,1,myfun,c1=delta,c2=SE)

CODE:

data-matrix(data=c(-0.70 ,-0.90, -0.50, 20, 20,
-0.30 ,-0.43, -0.17, 43, 43,
-0.50 ,-1.05,  0.05, 16, 18,
 0.00 ,-0.21,  0.21, 22, 23,
-1.30 ,-1.48, -1.12, 28, 32,
-0.90 ,-1.01, -0.79, 18, 15,
-0.20 ,-0.47,  0.07, 39, 39,
-0.30 ,-0.83,  0.23, 27, 27),
 nrow=8,ncol=5,byrow=TRUE)
dimnames(data) - list(NULL,c(delta,low,high,n1,n2))
data
CI - data[,high]-data[,low]
data - cbind(data,CI)
data
data - cbind(data,SE=data[,CI]/(4*1.96))
data
data - cbind(data,SD=data[,SE]*sqrt(data[,n1]+data[,n2]))
data
myfun - function(x, c1, c2) x[c1]/x[c2]
apply(data,1,myfun,c1=delta,c2=SE)

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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] Trying to understand a function passed to lapply

2015-03-30 Thread William Dunlap
 I can't understand how the body of the function, x[c1]/x[c2] refers to
the columns data and SE of the matrix data.

If you put the line 'str(x)' at the start of myfun(), as in
   myfun - function(x, c1, c2) {
  str(x)
  x[c1]/x[c2]
   }
you would start to see why it works - extracting a row from a matrix gives
you a vector with names copied from the column names of the matrix.
Thus subscripting with a single name (or number) works.
   apply(data,1,myfun,c1=delta,c2=SE)
   Named num [1:8] -0.7 -0.9 -0.5 20 20 ...
   - attr(*, names)= chr [1:8] delta low high n1 ...
   Named num [1:8] -0.3 -0.43 -0.17 43 43 ...
   - attr(*, names)= chr [1:8] delta low high n1 ...
   Named num [1:8] -0.5 -1.05 0.05 16 18 ...
   ...
   Named num [1:8] -0.3 -0.83 0.23 27 27 ...
   - attr(*, names)= chr [1:8] delta low high n1 ...
  [1] -13.72  -9.046154  -3.563636   0.00 -28.31 -32.072727
 -2.903704  -2.218868

By the way, that call to apply is just a slow way of dividing two columns
of the matrix
   data[, delta]/data[, SE]
  [1] -13.72  -9.046154  -3.563636   0.00 -28.31 -32.072727
 -2.903704  -2.218868


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Mar 30, 2015 at 6:48 PM, John Sorkin jsor...@grecc.umaryland.edu
wrote:

 Colleagues,
 I am trying to understand the syntax of a function passed to apply. The
 code below generates a matrix, and passes the matrix to a function that is
 called by apply. I don't understand the syntax of the function. In some way
 the function computes data[,delta]/data[,SE]. I can't understand how
 the body of the function, x[c1]/x[c2] refers to the columns data and SE
 of the matrix data. Can someone help me understand the syntax?
 Thank you,
 John

 myfun - function(x, c1, c2) x[c1]/x[c2]
 apply(data,1,myfun,c1=delta,c2=SE)

 CODE:

 data-matrix(data=c(-0.70 ,-0.90, -0.50, 20, 20,
 -0.30 ,-0.43, -0.17, 43, 43,
 -0.50 ,-1.05,  0.05, 16, 18,
  0.00 ,-0.21,  0.21, 22, 23,
 -1.30 ,-1.48, -1.12, 28, 32,
 -0.90 ,-1.01, -0.79, 18, 15,
 -0.20 ,-0.47,  0.07, 39, 39,
 -0.30 ,-0.83,  0.23, 27, 27),
  nrow=8,ncol=5,byrow=TRUE)
 dimnames(data) - list(NULL,c(delta,low,high,n1,n2))
 data
 CI - data[,high]-data[,low]
 data - cbind(data,CI)
 data
 data - cbind(data,SE=data[,CI]/(4*1.96))
 data
 data - cbind(data,SD=data[,SE]*sqrt(data[,n1]+data[,n2]))
 data
 myfun - function(x, c1, c2) x[c1]/x[c2]
 apply(data,1,myfun,c1=delta,c2=SE)

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:16}}

__
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 with POSIX

2015-03-30 Thread Doran, Harold
I�m struggling a bit with learning about POSIX objects to do some basic things 
with objects of this class. Suppose I have the following simple example

times - c(03:20, 29:56, 03:30, 21:03, 56:26)

aa - strptime(times, %M:%S�)

I can do means, and some other basic things, but I cannot correlate the objects 
with some other variable

cor(aa, rnorm(5))

Also, for purposes of a user-interface I have built with shiny, I need for the 
time to be viewed as simply as minutes:seconds, such as this

format(aa, '%M:%S�)

But of course after doing this I lose the ability to work with this object as a 
time variable.

Thank you
Harold

[[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] Plotting using tapply function output

2015-03-30 Thread Jim Lemon
Hi Alexandra,
This produces a rather messy plot, but it might get you started:

finalData-data.frame(ws=sample(0:100,1300,TRUE),
 stn=rep(1:13,each=100),hour=rep(1:24,length.out=1300))
statHour = tapply(finalData$ws,list(finalData$stn,finalData$hour),sd)
# open a wide device
x11(width=13)
# leave room for an external legend
par(mar=c(5,4,4,6))
matplot(1:24,t(statHour),type=b,
 main=Wind speed standard deviation by hour of day,
 xlab=Hour,ylab=Wind speed standard deviation,lty=1)
legend(25.2,40,legend=paste(Stn,1:13,sep=),pch=c(0:9,a,b,c),
 col=1:13,xpd=TRUE)

Jim


On Tue, Mar 31, 2015 at 10:07 AM, Alexandra Catena amc5...@gmail.com
wrote:

 Hello,

 I am trying to plot the hourly standard deviation of wind speeds from
 13 different measured locations over many years. I imported the data
 using readLines and into a dataframe called finalData. Using tapply, I
 determined the standard deviation of the windspeed (ws) for each hour
 (hour) from every location (stn) using this command line:

 statHour = tapply(finalData$ws,list(finalData$stn,finalData$hour),sd)

 I want to plot the standard deviation for each hour of the day, with
 hours as the x-axis and the standard deviation for the y-axis, and
 each station as a different color.  I've managed to get a boxplot of
 this, but ideally, I'd like a scatter plot to determine the variations
 between each instrument throughout the day.  The boxplot command is
 this:

 boxplot(statHour, names=colnames(statHour),xlab='Hour of the
 Day',ylab='Standard Deviation of Wind Speed')

 I also tried to make a dataframe of the tapply output but it ends up
 using the hours as the column names instead of putting it into the
 dataframe.  Please help!!

 I have R version 3.1.1

 Thanks a lot,
 Alexandra

 __
 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] Trying to understand a function passed to lapply

2015-03-30 Thread Jim Lemon
Hi John,
What happens is that you have passed two named arguments to your function
myfun along with the matrix data. Because these arguments have
associated values (delta, SE), these values are substituted into the
expression like this:

x[delta]/x[SE]

which is the return value of myfun. If you just type in:

data[delta]
data[SE]

you will see the values that are successively selected for the calculation
in myfun

Jim


On Tue, Mar 31, 2015 at 12:48 PM, John Sorkin jsor...@grecc.umaryland.edu
wrote:

 Colleagues,
 I am trying to understand the syntax of a function passed to apply. The
 code below generates a matrix, and passes the matrix to a function that is
 called by apply. I don't understand the syntax of the function. In some way
 the function computes data[,delta]/data[,SE]. I can't understand how
 the body of the function, x[c1]/x[c2] refers to the columns data and SE
 of the matrix data. Can someone help me understand the syntax?
 Thank you,
 John

 myfun - function(x, c1, c2) x[c1]/x[c2]
 apply(data,1,myfun,c1=delta,c2=SE)

 CODE:

 data-matrix(data=c(-0.70 ,-0.90, -0.50, 20, 20,
 -0.30 ,-0.43, -0.17, 43, 43,
 -0.50 ,-1.05,  0.05, 16, 18,
  0.00 ,-0.21,  0.21, 22, 23,
 -1.30 ,-1.48, -1.12, 28, 32,
 -0.90 ,-1.01, -0.79, 18, 15,
 -0.20 ,-0.47,  0.07, 39, 39,
 -0.30 ,-0.83,  0.23, 27, 27),
  nrow=8,ncol=5,byrow=TRUE)
 dimnames(data) - list(NULL,c(delta,low,high,n1,n2))
 data
 CI - data[,high]-data[,low]
 data - cbind(data,CI)
 data
 data - cbind(data,SE=data[,CI]/(4*1.96))
 data
 data - cbind(data,SD=data[,SE]*sqrt(data[,n1]+data[,n2]))
 data
 myfun - function(x, c1, c2) x[c1]/x[c2]
 apply(data,1,myfun,c1=delta,c2=SE)

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:16}}

__
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] Multiple Plots using ggplot

2015-03-30 Thread Frederic Ntirenganya
Hi Stephen,

Sorry, the data came in bad way.
Here is the head of the data.

 head(data)Date Number.of.Rain.Days Total.rain Start.of.Rain..i. 
 Start.of.Rain..ii. Start.of.Rain..iii. Start.Rain..iv.
1 1952-01-01  86   1139.95292
  239 112 112
2 1953-01-01  96977.64698
   98 112 112
3 1954-01-01 114   1382.01492
   92 120 120
4 1955-01-01 119   1323.086   100
  100 125 174
5 1956-01-01 123   1266.44492
   92 119 119
6 1957-01-01 124   1235.96492
   92 112 112



Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

On Mon, Mar 30, 2015 at 5:34 PM, stephen sefick ssef...@gmail.com wrote:

 Hi Frederic,

 Can you provide a minimal reproducible example including either real data
 (dput), or simulated data that mimics your situation? This will allow more
 people to help.

 Stephen

 On Mon, Mar 30, 2015 at 8:39 AM, Frederic Ntirenganya ntfr...@gmail.com
 wrote:

 Dear All,

 I want to plot multiple using ggplot function from a data frame of
 many columns. I want to plot only str1, str2 and str3 and I failed to
 make it. What I want is to compare str1, str2 and str3 by plotting
 vertical line. I also need to add points to the plot to be able to
 separate them.


 Here is how the data look like and how I tried to make it.

 Date NumberofRaindays TotalRains str1 str2 str3 1/1/1952 86 1360.5 92 120
 112 1/1/1953 96 1100 98 100 110
 ...   
  ...  

 df1 -data.frame(data)
 df1
 df2 - melt(df1 ,  id = 'Date', variable_name = 'start of Rains')
 df2

 ggplot(df2, aes(Date,value)) + geom_line(aes(colour =red),type = h)

 Kindly any help is welcome. Thanks

 Regards,
 Frederic.

 Frederic Ntirenganya
 Maseno University,
 African Maths Initiative,
 Kenya.
 Mobile:(+254)718492836
 Email: fr...@aims.ac.za
 https://sites.google.com/a/aims.ac.za/fredo/

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




 --
 Stephen Sefick
 **
 Auburn University
 Biological Sciences
 331 Funchess Hall
 Auburn, Alabama
 36849
 **
 sas0...@auburn.edu
 http://www.auburn.edu/~sas0025
 **

 Let's not spend our time and resources thinking about things that are so
 little or so large that all they really do for us is puff us up and make us
 feel like gods.  We are mammals, and have not exhausted the annoying little
 problems of being mammals.

 -K. Mullis

 A big computer, a complex algorithm and a long time does not equal
 science.

   -Robert Gentleman



[[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] generating phi using function()

2015-03-30 Thread T.Riedle
Hi,
I am struggling with following function
 phi - function(w1, w2, j, k, K){
+   zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+   nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+   return( zaehler/nenner )
+ }
 phi(c(1, 1), 44L, 1)
Error in phi(c(1, 1), 44L, 1) : argument k is missing, with no default


Hence, I have changed the function to

phi - function(w, k, K){
+ w1 - w[1]
+ w2 - w[2]
+ zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+ nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+ return( zaehler/nenner )
+ }

 Unfortunately, when running the midas regression I get the following error 
message

 m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1)))

Error in X[, inds] %*% fun(st) : non-conformable arguments

I guess the problem is w but I do not find a solution how to produce the 
formula shown in the attached file where the exponents are w1 and w2, 
respectively.

Thanks for your help


From: jlu...@ria.buffalo.edu [mailto:jlu...@ria.buffalo.edu]
Sent: 30 March 2015 16:01
To: T.Riedle
Cc: r-help@r-project.org; R-help
Subject: Re: [R] generating phi using function()

Your function phi has 5 arguments with no defaults.  Your call only has 3 
arguments.  Hence the error message.
 phi - function(w1, w2, j, k, K){
+   zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+   nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+   return( zaehler/nenner )
+ }
 phi(c(1, 1), 44L, 1)
Error in phi(c(1, 1), 44L, 1) : argument k is missing, with no default









T.Riedle tr...@kent.ac.ukmailto:tr...@kent.ac.uk
Sent by: R-help 
r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org

03/29/2015 08:59 AM

To

r-help@r-project.orgmailto:r-help@r-project.org 
r-help@r-project.orgmailto:r-help@r-project.org,

cc

Subject

[R] generating phi using function()







Hi everybody,
I am trying to generate the formula shown in the attachment. My formula so far 
looks as follows:

phi - function(w1, w2, j, k, K){
zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
return( zaehler/nenner )
}

Unfortunately something must be wrong here as I get the following message when 
running a midas regression

m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1)))
Error in phi(c(1, 1), 44L, 1) : argument K is missing, with no default
Called from: .rs.breakOnError(TRUE)
Browse[1] K-125
Browse[1] 125

Could anybody look into my phi formula and tell me what is wrong with it?

Thanks in advance.

__
R-help@r-project.orgmailto: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.htmlhttp://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] Help with POSIX

2015-03-30 Thread Ben Tupper
Hi,


On Mar 30, 2015, at 9:15 PM, Doran, Harold hdo...@air.org wrote:

 I�m struggling a bit with learning about POSIX objects to do some basic 
 things with objects of this class. Suppose I have the following simple example
 
 times - c(03:20, 29:56, 03:30, 21:03, 56:26)
 
 aa - strptime(times, %M:%S�)
 
 I can do means, and some other basic things, but I cannot correlate the 
 objects with some other variable
 
 cor(aa, rnorm(5))
 


You can cast your POSIXlt values to numeric

cor(as.numeric(aa), rnorm(5))


 Also, for purposes of a user-interface I have built with shiny, I need for 
 the time to be viewed as simply as minutes:seconds, such as this
 
 format(aa, '%M:%S�)
 
 But of course after doing this I lose the ability to work with this object as 
 a time variable.
 

You may need to keep a copy of your times in a POSIX or numeric format in 
addition to converting to character.  It's hard to tell without more 
information.

Cheers,
Ben

 Thank you
 Harold
 
   [[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.

[R] how to deal with changing weighting functions

2015-03-30 Thread T.Riedle
Hi everybody,
Does anybody have an idea how I can generate tau according to the attached 
formula? The point is that phi changes with k and I thought I could make it by 
using a for-function in R but I am not sure how to do that.

Could anyone help me?
Thanks in advance.

__
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] temporal autocorrelation in MCMCglmm

2015-03-30 Thread Ben Bolker
David Villegas Ríos chirleu at gmail.com writes:

 Hi,
 For a number of individuals, I have measured several behavioral traits in
 the wild. Those traits (e.g. home range) can be estimated on different
 temporal scales, for example daily, weekly or monthly. I want to estimate
 repeatability of those traits, assuming that the daily/weekly/monthly
 measurements represent replicates. I have 3 months (90 days) of data for
 each trait. Two questions:
 
 1) How can assess if there is temporal autocorrelation in my model? I guess
 that if I consider daily measurements as replicates (90 replicates), I will
 have some autocorrelation, but if I use just monthly measurements (3
 replicates) maybe I avoid it.
 
 2) How can account for temporal autocorrelation in MCMCglmm?
 
 Sorry for this pretty basic questions but I haven't found an answer so far.

You'll probably be better off asking this question at r-sig-mixed-models
(at) r-project.org.

As a first pass, you might be able take the residuals from your fit and use
acf() to compute the autocorrelation function.  Actually, though, you'll
probably be better off fitting a 'null' lme() model (fixed=resid~1,
random=~1|individual) and then using the ACF() method (not the same
thing as acf()) on the resulting model fit.

  Ben Bolker

__
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] changing column labels for data frames inside a list

2015-03-30 Thread Sven E. Templer
On 30 March 2015 at 17:50, Sarah Goslee sarah.gos...@gmail.com wrote:

 On Mon, Mar 30, 2015 at 11:43 AM, Sven E. Templer
 sven.temp...@gmail.com wrote:
 
 
  On 30 March 2015 at 17:31, Bert Gunter gunter.ber...@gene.com wrote:
 
  Sarah's statement is correct.
 
  So is yours. They are not contradictory, and I believe Sarah's point
  was that the OP needed to learn the appropriate syntax.
 
 
  That's why I pointed to ?return.
  Sarah's statement was not so clear (and might have been misleading) for
 me
  regarding the R expertise of the OP.

 You're right: I totally wasn't clear. I got involved making a working
 reproducible example and didn't explain what I was doing. And you are
 totally correct, the last expression will be returned. Mea culpa.


No one to blame but the missing reproducible example, I agree!

Sven


 Sarah


 
  -- Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Mon, Mar 30, 2015 at 7:56 AM, Sven E. Templer 
 sven.temp...@gmail.com
  wrote:
   On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com
 wrote:
  
   colnames(e) - paste0('pop',1:12)
  
   isn't a function and doesn't return anything.
  
  
   But
   function(e){colnames(e) - paste0('pop', 1:2)}
   is a function and it returns something (the last evaluated
 expression! -
   here the paste0 return):
  
   mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
   1:2)})
   mylist2
   [[1]]
   [1] pop1 pop2
  
   [[2]]
   [1] pop1 pop2
  
   [[3]]
   [1] pop1 pop2
  
from ?return:
  
   If the end of a function is reached without calling return, the value
 of
   the last evaluated expression is returned.
  
  
mylist - list(
   + data.frame(a = runif(10), b = runif(10)),
   + data.frame(c = runif(10), d = runif(10)),
   + data.frame(e = runif(10), f = runif(10)))
mylist2 - lapply(mylist, function(e){colnames(e) - paste0('pop',
1:2);
   e})
colnames(mylist2[[1]])
   [1] pop1 pop2
  
   Sarah
  
   On Mon, Mar 30, 2015 at 9:54 AM, Vikram Chhatre
   crypticline...@gmail.com wrote:
summary(mygenfreqt)
  Length Class  Mode
dat1.str 59220  -none- numeric
dat2.str 59220  -none- numeric
dat3.str 59220  -none- numeric
   
head(mylist[[1]])
   1 2 3 4 5 6 7 8 910
11
 12
L0001.1 0.60 0.500 0.325 0.675 0.600 0.500 0.500 0.375 0.550 0.475
0.350
0.275
L0001.2 0.40 0.500 0.675 0.325 0.400 0.500 0.500 0.625 0.450 0.525
0.650
0.725
   
I want to change 1:12 to pop1:pop12
   
mylist- lapply(mylist, function(e) colnames(e) -
paste0('pop',1:12))
   
What this is doing is replacing the data frames with just names
pop1:pop12.  I just want to replace the column labels.
   
Thanks for any suggestions.
   
  
   --
   Sarah Goslee
   http://www.functionaldiversity.org


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