[R] Empirical k-quantile function

2017-02-16 Thread Art U
Hello,

Suppose I have one vector of values or even matrix of those vectors and I
want to calculate q_k(V/k), where V is the vector, k is a quantile and q_k
is empirical k-quantile function. Finally I want to calculate Q_k=min(1,
q_k) for k=(0,1).

Can you please help me with this code?
quantile function provides value

Basically I'm trying to reproduce results from paper "P-values for
High-Dimensional Regression", Meinshausen, Meier, Buhlmann.

Thank you in advance.
Art

-- 
*I like to pretend I'm alone*. *Completely alone*. *Maybe post-apocalypse
or plague*... *Whatever*. *No-one left to act normal for. No need to hide
who I really am. It would be... freeing*. *...*

[[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] Sobre gráficos

2017-02-16 Thread javier.ruben.marcuzzi
Estimado Nivaildo

Por su correo creo que usted es de Cuba, entiendo que todo le debe salir muy 
caro, pero hay alternativas gratis, algunos libros son gratis y buenos.

La mayoría está en inglés, sobre minería de datos hay uno gratis, en español 
hay uno gráficos con R (creo que escrito en Colombia), hay una revista visual 
studio de Microsoft que está en internet y ahora tiene algunas cosas de R.

Justo ahora no tengo tiempo para buscar las referencias, pero busque algo como 
free book R, hay editoriales que tienen la versión paga y la gratuita para 
descargar, todo legal y libros de calidad. La página de CRAN, tiene o tenía, 
una sección con libros.

Javier Rubén Marcuzzi

De: npola...@uij.edu.cu
Enviado: jueves, 16 de febrero de 2017 18:59
Para: Carlos Ortega
CC: Lista R
Asunto: Re: [R-es] Sobre gráficos
Importancia: Alta

Hola a todos, alguien que ya tenga en sus manos esos libros y/o otros más sobre 
todo sobre estadística descriptiva, inferencial, minería de datos y big data, o 
cualesquiera de R y que aunque haya pagado la ostia, no le importe compartirlo 
conmigo que no tengo la posibilidad de pagar por ellos, por favor, le estaría 
eternamente agradecido.

Fraternalmente, Nivaildo.

- Mensaje original -
De: "Carlos Ortega" 
Para: "Hector Gómez Fuerte" 
CC: "Lista R" 
Enviados: Jueves, 16 de Febrero 2017 20:18:04
Asunto: Re: [R-es] Sobre gráficos

Hola,

Aunque hay un libro de Hadley Wickham dedicado a "ggplot2":


   -
   
https://www.amazon.es/ggplot2-Elegant-Graphics-Data-Analysis/dp/331924275X/ref=sr_1_1?ie=UTF8=1487276170=8-1=ggplot2


Yo te recomendaría este otro:


   -
   
https://www.amazon.es/R-Graphics-Cookbook-Winston-Chang/dp/1449316956/ref=sr_1_1?ie=UTF8=1487276054=8-1=r+graphics+cookbook


Y sobre hacer gráficos al "estilo Excel".
Puedes utilizar el paquete "ggthemes" que te permite crear gráficos con
diferentes tipos de acabados, entre ellos en formato "Excel 2003"...:


   - https://github.com/jrnold/ggthemes

Saludos,
Carlos Ortega
www.qualityexcellence.es


El 16 de febrero de 2017, 19:07, "Hector Gómez Fuerte" 
escribió:

> Supongo que esta pregunta ya ha salido en esta lista. ¿Qué libro o
> documento me recomiendan para aprender a manejar el paquete ggplot2?
> ¿Existe algún paquete para crear gráficos al "estilo Excel"?
> Muchas gracias y saludos.
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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

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


[[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] cluster data in lattice dotplot and show stdev

2017-02-16 Thread Duncan Mackay
Hi Luigi

I think your data is duplicated

> xtabs(~cluster+type+target,my.data)
, , target = A

   type
cluster blank negative positive
  run_1 222
  run_2 000

, , target = B

   type
cluster blank negative positive
  run_1 000
  run_2 222

> xtabs(~cluster+target,my.data)
   target
cluster A B
  run_1 6 0
  run_2 0 6

I am not sure exactly what you want partly because what Jim has plotted.
I have thought of 2 ways. I have added columns coding the factors as numeric
to make it flexible

1. By runs
my.data$Target <- paste0(rep(LETTERS[1:2],each= 6),rep(1:2,each=3))
my.data$x <- rep(c(0.8,1.2),each=3)
my.data$xrun <- rep(1:3)

xyplot(value ~ x|target,my.data,
   groups = type,
   xlim = c(0.5,1.5),
   scales = list(x = list(at= c(0.8,1.2),
 label=paste("Run",1:2)),
 alternating = 1),
   auto.key = list(points = T,
   lines = F),
   pch=16,
   panel = panel.superpose,
   panel.groups = function(x,y,...){
   
panel.xyplot(x,y, ...)

   
   }
)

2. By type

xyplot(value ~ xrun|target,my.data,
   groups = run,
   xlim = c(0,4),   
  par.settings = list(strip.background = list(col = "transparent")),
   scales = list(x = list(at= c(1:3),
 label= unique(my.data$type),
 alternating = 1)),
   auto.key = list(points = T,
   lines = F),
   pch=16,
   panel = panel.superpose,
   panel.groups = function(x,y,...){

panel.xyplot(x,y, ...)


   }
)

If you want error bars use the functions in 
demo(lattice::intervals)
or use your own panel .segments

If you decide not to use default colours etc use 

panel.settings = list(superpose.symbol = list(pch = ... ,
  col = ... ,
  cex = 1))

makes keys easier

example by hand error bars

xyplot(value ~ xrun|target,my.data,
   groups = run,
   xlim = c(0,4),
   par.settings = list(strip.background = list(col = "transparent"),
  grid.pars = list(lineend =
"butt")),
   scales = list(x = list(at= c(1:3),
 label= unique(my.data$type),
 alternating = 1)),
   auto.key = list(points = T,
   lines = F),
   pch=16,
   panel = panel.superpose,
   panel.groups = function(x,y,...,group.number){

panel.xyplot(x,y, ...)

panel.arrows(group.number+0.3, group.number-0.6,
group.number+0.3, group.number-0.4,
  length = 0.04,
  unit = "inches",
  angle = 90,
  code = 3)

   }
)

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
Marongiu
Sent: Friday, 17 February 2017 02:31
To: r-help
Subject: [R] cluster data in lattice dotplot and show stdev

dear all,
i have a set of data that is separated in the variables: cluster (two
runs), type (blank, negative and positive) and target (A and B), each
duplicated. I am plotting it with lattice and the result is a 2x2 matrix
plot in which the top two cells (or panels) are relative to run 2, the
lower to run 2; each panel is then subdivided in target A or B and I have
colour-coded the dots to match the target.
However i would like to have a 1x2 panel plot representing the targets, and
within each panel having a cluster of 3 dots (representing the types) for
run 1 and another for run 2. I tried to represent such requirement in the
rough construction at the end of the example.
also, since each run is actually formed by duplicates, each dot should
indicate the standard deviation of the values.
How would I do that? any tips?
thanks
luigi

>>>
cluster <- c(rep("run_1", 6), rep("run_2", 6))
type <- rep(c("blank", "positive", "negative"),2)
target <- c(rep("A", 6), rep("B", 6))
value <- c(0.01, 1.1, 0.5,
   0.02, 1.6, 0.8,
   0.07, 1.4, 0.7,
   0.03, 1.4, 0.4)
my.data <- data.frame(cluster, type, target, value)

library(lattice)
dotplot(
  value ~ type|cluster + target,
  my.data,
  groups = type,
  pch=21,
  main = "Luminex analysis MTb humans",
  xlab = "Target", ylab = "Reading",
  col = c("grey", "green", "red"),
  par.settings = list(strip.background = list(col="paleturquoise")),
  scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
  key = list(
space = "top",
columns = 3,
text = list(c("Blank", "Negative", 

Re: [R-es] Sobre gráficos

2017-02-16 Thread npolanco
Hola a todos, alguien que ya tenga en sus manos esos libros y/o otros más sobre 
todo sobre estadística descriptiva, inferencial, minería de datos y big data, o 
cualesquiera de R y que aunque haya pagado la ostia, no le importe compartirlo 
conmigo que no tengo la posibilidad de pagar por ellos, por favor, le estaría 
eternamente agradecido.

Fraternalmente, Nivaildo.

- Mensaje original -
De: "Carlos Ortega" 
Para: "Hector Gómez Fuerte" 
CC: "Lista R" 
Enviados: Jueves, 16 de Febrero 2017 20:18:04
Asunto: Re: [R-es] Sobre gráficos

Hola,

Aunque hay un libro de Hadley Wickham dedicado a "ggplot2":


   -
   
https://www.amazon.es/ggplot2-Elegant-Graphics-Data-Analysis/dp/331924275X/ref=sr_1_1?ie=UTF8=1487276170=8-1=ggplot2


Yo te recomendaría este otro:


   -
   
https://www.amazon.es/R-Graphics-Cookbook-Winston-Chang/dp/1449316956/ref=sr_1_1?ie=UTF8=1487276054=8-1=r+graphics+cookbook


Y sobre hacer gráficos al "estilo Excel".
Puedes utilizar el paquete "ggthemes" que te permite crear gráficos con
diferentes tipos de acabados, entre ellos en formato "Excel 2003"...:


   - https://github.com/jrnold/ggthemes

Saludos,
Carlos Ortega
www.qualityexcellence.es


El 16 de febrero de 2017, 19:07, "Hector Gómez Fuerte" 
escribió:

> Supongo que esta pregunta ya ha salido en esta lista. ¿Qué libro o
> documento me recomiendan para aprender a manejar el paquete ggplot2?
> ¿Existe algún paquete para crear gráficos al "estilo Excel"?
> Muchas gracias y saludos.
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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

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


Re: [R] cluster data in lattice dotplot and show stdev

2017-02-16 Thread Jim Lemon
Hi Luigi,
Are you looking for something like this?

library(plotrix)
ylim=c(0,1.7)
png("lmplot.png",width=600,height=300)
par(mfrow=c(1,2))
brkdn.plot(value~type,data=my.data[my.data$target=="A",],
 main="Run 1",ylab="Value",xlab="",xaxlab="target",ylim=ylim,
 mct="mean",md="sd",pch=c("B","N","P"))
brkdn.plot(value~type,data=my.data[my.data$target=="B",],
 main="Run 2",ylab="Value",xlab="",xaxlab="target",ylim=ylim,
 mct="mean",md="sd",pch=c("B","N","P"))
dev.off()

Jim


On Fri, Feb 17, 2017 at 2:30 AM, Luigi Marongiu
 wrote:
> dear all,
> i have a set of data that is separated in the variables: cluster (two
> runs), type (blank, negative and positive) and target (A and B), each
> duplicated. I am plotting it with lattice and the result is a 2x2 matrix
> plot in which the top two cells (or panels) are relative to run 2, the
> lower to run 2; each panel is then subdivided in target A or B and I have
> colour-coded the dots to match the target.
> However i would like to have a 1x2 panel plot representing the targets, and
> within each panel having a cluster of 3 dots (representing the types) for
> run 1 and another for run 2. I tried to represent such requirement in the
> rough construction at the end of the example.
> also, since each run is actually formed by duplicates, each dot should
> indicate the standard deviation of the values.
> How would I do that? any tips?
> thanks
> luigi
>

> cluster <- c(rep("run_1", 6), rep("run_2", 6))
> type <- rep(c("blank", "positive", "negative"),2)
> target <- c(rep("A", 6), rep("B", 6))
> value <- c(0.01, 1.1, 0.5,
>0.02, 1.6, 0.8,
>0.07, 1.4, 0.7,
>0.03, 1.4, 0.4)
> my.data <- data.frame(cluster, type, target, value)
>
> library(lattice)
> dotplot(
>   value ~ type|cluster + target,
>   my.data,
>   groups = type,
>   pch=21,
>   main = "Luminex analysis MTb humans",
>   xlab = "Target", ylab = "Reading",
>   col = c("grey", "green", "red"),
>   par.settings = list(strip.background = list(col="paleturquoise")),
>   scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
>   key = list(
> space = "top",
> columns = 3,
> text = list(c("Blank", "Negative", "Positive"), col="black"),
> rectangles = list(col=c("grey", "green", "red"))
>   )
> )
>
> x <- 1:7
> plot(x , c(max(my.data$value), min(my.data$value), my.data$value[1:5]),
> col="white", xaxt = "n", ylab="value", xlab="target")
> points(x[1], mean(my.data$value[1], my.data$value[4]), col="grey")
> points(x[2], mean(my.data$value[2], my.data$value[5]), col="red")
> points(x[3], mean(my.data$value[3], my.data$value[6]), col="green")
> points(x[5], mean(my.data$value[7], my.data$value[10]), col="grey")
> points(x[6], mean(my.data$value[8], my.data$value[11]), col="red")
> points(x[7], mean(my.data$value[9], my.data$value[12]), col="green")
> axis(side=1, at = x[2], lab = "A", cex.axis=1)
> axis(side=1, at = x[6], lab = "B", cex.axis=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.
__
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] R version 3.3.2, Windows 10 -- gstat.predict() function often return NaN values (GSTAT Package)

2017-02-16 Thread Rathore, Saubhagya Singh
I am adding my message in the mail body as I found it missing from the mail 
that finally got posted on the list. 

I am trying to simulate a combination of two different random fields (yy1 and 
yy2 different mean and correlation length) with an irregular boundary. I have 
attached the picture of my expected outcome. The code is not giving such output 
consistently and I am frequently getting atleast one of the yy1 and yy2 as as 
NaN, which results in the Undesired output as shown in image. 

The key steps I used are:

1)  Created two gsat objects with different means and psill (rf1 and rf2)
2)  Created two computational grids (one for each random field) in the form 
of data frame with two variables "x" and "y" coordinates. 
3)  Predicted two random fields using unconditional simulation. 

The code is fairly small hence I am pasting in here itself. Any help in this 
regard would be highly appreciated. 

## Code starts 
===
library(gstat)

xy <- expand.grid(1:150, 1:200) # grid is created in the form of a dataframe 
with x and y vectors
names(xy)<-c('x','y') # giving names to the variables

# Creating gsat objects

rf1<-gstat(formula=z~1,locations=~x+y,dummy = T,beta=c(1,0,0), 
model=vgm(psill=0.025, range=5, model='Exp'), nmax=20)  # dummy=T treats this 
as a unditional simulation
rf2<-gstat(formula=z~1,locations=~x+y,dummy = T,beta=c(4,0,0), 
model=vgm(psill=0.025, range=10, model='Exp'), nmax=20)  # dummy=T treats this 
as a unditional simulation

# Splitting the computational grid into two

rows<-nrow(xy)
xy_shift <- expand.grid(60:90, 75:100)
names(xy_shift)<-c('x','y')

library(dplyr) # for antijoin
xy1<-xy[1:(rows/2),]
xy1<-anti_join(xy1, xy_shift, by = c("x","y")) # creating the irregular boundary
xy2<-rbind(xy[(rows/2+1):rows,],xy_shift)

# Simulation

yy1<- predict(rf1, newdata=xy1, nsim=1) # random field 1
yy2<- predict(rf2, newdata=xy2, nsim=1) # random field 2

yy<-rbind(yy1,yy2)

# Plotting the field

library(sp)
gridded(yy) = ~x+y
spplot(obj=yy[1])

## Code 
ends=

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rathore, 
Saubhagya Singh
Sent: Wednesday, February 15, 2017 12:37 PM
To: r-help@r-project.org
Subject: [R] R version 3.3.2, Windows 10 -- gstat.predict() function often 
return NaN values (GSTAT Package)

__
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] non-linear optimisation ODE models

2017-02-16 Thread David Winsemius

> On Feb 15, 2017, at 1:43 PM, Jim Lemon  wrote:
> 
> Hi Malgorzata,
> The function "rxnrate" seems to want three values in a list with the
> names "k1", "k2" and "k3". If you are passing something with different
> names, it is probably going to complain, so the names "A", "B" and "C"
> may be your problem. I can't run the example, so this is a guess.

There's a more readable version at:
http://stackoverflow.com/questions/42256509/how-to-feed-data-into-ide-while-doing-optimisation

It can be run, but does not produce the errors offered when I do so.

-- 
David.

> 
> Jim
> 
> 
>> On 15 Feb 2017, at 11:32, Malgorzata Wieteska via R-help 
>>  wrote:
>> 
>> Hello,
>> I'm new to R, so sorry for this question. I found a piece of code on stack 
>> overflow community, title: r-parameter and initial conditions fitting ODE 
>> models with nls.lm.
>> I've tried to implement a change suggested, but I get an error: Error in 
>> unname(myparms[4], B = 0, C = 0) :   unused arguments (B = 0, C = 0)
>> I'll appreciate any hint.
>> Malgosia
>> 
>> #set working directorysetwd("~/R/wkspace")#load 
>> librarieslibrary(ggplot2)library(reshape2)library(deSolve)library(minpack.lm)time=c(0,0.263,0.526,0.789,1.053,1.316,1.579,1.842,2.105,2.368,2.632,2.895,3.158,3.421,3.684,3.947,4.211,4.474,4.737,5)ca=c(0.957,0.557,0.342,0.224,0.123,0.079,0.035,0.029,0.025,0.017,-0.002,0.009,-0.023,0.006,0.016,0.014,-0.009,-0.03,0.004,-0.024)cb=c(-0.031,0.33,0.512,0.499,0.428,0.396,0.303,0.287,0.221,0.148,0.182,0.116,0.079,0.078,0.059,0.036,0.014,0.036,0.036,0.028)cc=c(-0.015,0.044,0.156,0.31,0.454,0.556,0.651,0.658,0.75,0.854,0.845,0.893,0.942,0.899,0.942,0.991,0.988,0.941,0.971,0.985)df<-data.frame(time,ca,cb,cc)dfnames(df)=c("time","ca","cb","cc")#plot
>>  
>> datatmp=melt(df,id.vars=c("time"),variable.name="species",value.name="conc")ggplot(data=tmp,aes(x=time,y=conc,color=species))+geom_point(size=3)#rate
>>  functionrxnrate=function(t,c,parms){  #rate constant passed through a list 
>> called  k1=parms$k1  k2=parms$k2  k3=parms$k3  #c is the concentrati!
 o!
>> n of species  #derivatives dc/dt are computed below  r=rep(0,length(c))  
>> r[1]=-k1*c["A"] #dcA/dt  r[2]=k1*c["A"]-k2*c["B"]+k3*c["C"] #dcB/dt  
>> r[3]=k2*c["B"]-k3*c["C"] #dcC/dt  return(list(r))}# predicted concentration 
>> for a given parametercinit=c(A=1,B=0,C=0)t=df$timeparms=list(k1=2, k2=1, 
>> k3=3)out=ode(y=cinit,times=t,func=rxnrate,parms=list(k1=k1,k2=k2,k3=k3))head(out)
>>> ssq=function(myparms){  #initial concentration  
>>> cinit=c(A=myparms[4],B=0,C=0)  cinit=c(A=unname(myparms[4],B=0,C=0))  
>>> print(cinit)  #time points for which conc is reported  #include the points 
>>> where data is available  t=c(seq(0,5,0.1),df$time)  t=sort(unique(t))  
>>> #parameters from the parameters estimation  k1=myparms[1]  k2=myparms[2]  
>>> k3=myparms[3]  #solve ODE for a given set of parameters  
>>> out=ode(y=cinit,times=t,func=rxnrate,parms=list(k1=k1,k2=k2,k3=k3))  
>>> #Filter data that contains time points  outdf=data.frame(out)  
>>> outdf=outdf[outdf$time%in% df$time,]  #Evaluate predicted vs experimental 
>>> residual  
>>> preddf=melt(outdf,id.var="time",variable.name="species",value.name="conc")  
>>> expdf=melt(df,id.var="time",variable.name="species",value.name="conc")  
>>> ssqres=preddf$conc-expdf$conc  return(ssqres)}# parameter fitting using 
>>> levenberg marquart#initial guess for 
>>> parametersmyparms=c(k1=0.5,k2=0.5,k3=3,1)cinit=c(A=unname(myparms[4],B=0,C=0))print(cinit)#fittingfitval=nls.lm(par=p!
 a!
> r!
>> ms,fn=ssq)#summary of fitsummary(fitval)
>> 
>> 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.

David Winsemius
Alameda, CA, 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] Sobre gráficos

2017-02-16 Thread Hector Gómez Fuerte
Supongo que esta pregunta ya ha salido en esta lista. ¿Qué libro o documento me recomiendan para aprender a manejar el paquete ggplot2? ¿Existe algún paquete para crear gráficos al "estilo Excel"?

Muchas gracias y saludos.

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

Re: [R-es] media

2017-02-16 Thread eric

hola, aqui una forma de hacerlo usando stack() y data.table()


library(data.table)
d <- read.csv("/home/neo/Desktop/beta.csv", header=TRUE, sep="\t")
d
d <- stack(d)
d <- as.data.table(d)
d[, mean(values), by=ind]


saludos,

Eric.





On 02/16/2017 01:11 PM, jbetanco...@iscmc.cmw.sld.cu wrote:


Estimados

Quisiera calcular las medias de cada semana de una sola vez con un script.
Apreciaría su ayuda

sem01   sem02   sem03   sem04
43  46  49  42
67  57  74  87
33  39  38  34
82  55  59  44
33  39  38  34

saludos
José



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

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



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Master in Sciences of Natural Resources
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city 
standards for living


Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.


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


Re: [R-es] Ayuda con Date

2017-02-16 Thread Mauricio Monsalvo
Carlos, probé en primer lugar tu propuesta. Pero:
as.data.table(datos)[, .N, by=pprfecbaja]
pprfecbajaN
 1: 0001-01-01 2000
 2: 1994-08-26   20
 3: 2005-07-06  585
 4: 2005-03-07   29
 5: 2004-03-23   33
 6: 2004-10-181
 7: 1997-09-019
 8: 1997-09-04   16
 9: 1996-05-293
...
datos$pprfecbaja <- ymd(datos$pprfecbaja)
Warning message:
 764 failed to parse.
> as.data.table(datos)[, .N, by=pprfecbaja]
pprfecbajaN
 1:2770
 2: 2001-01-059
 3: 2001-01-08   16
 4: 2001-01-077
 5: 2001-09-071
 6: 2001-05-121
 7: 2001-10-221
 8: 2001-12-271
 9: 2001-08-201
10: 2001-03-091
Es decir, ymd() lleva todos los datos a unas fechas que no existen, todas
del año 2001.

Por otro lado, la opción de Gerar:
datos$pprfecbaja<-strptime(datos$pprfecbaja, "%Y-%m-%d")  ##transformar la
variable de formato Character a formato POSIXlt
Warning messages:
1: In `[<-.data.table`(x, j = name, value = value) :
  Supplied 11 items to be assigned to 2808 items of column 'pprfecbaja'
(recycled leaving remainder of 3 items).
2: In `[<-.data.table`(x, j = name, value = value) :
  Coerced 'list' RHS to 'character' to match the column's type. Either
change the target column to 'list' first (by creating a new 'list' vector
length 2808 (nrows of entire table) and assign that; i.e. 'replace'
column), or coerce RHS to 'character' (e.g. 1L, NA_[real|integer]_, as.*,
etc) to make your intent clear and for speed. Or, set the column type
correctly up front when you create the table and stick to it, please.
Da valores raros a las celdas, algo así como (el print sale truncado):
c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ... 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, NA, NA, NA, NA, NA, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

Finlmente, la opción de Freddy *andó:*
datos$pprfecbaja<-replace(as.Date(datos$pprfecbaja),
datos$pprfecbaja=="0001-01-01", NA)
as.data.table(datos)[, .N, by=pprfecbaja]
 pprfecbajaN
 1:2006
 2: 1994-08-26   20
 3: 2005-07-06  585
 4: 2005-03-07   29
 5: 2004-03-23   33
 6: 2004-10-181
 7: 1997-09-019
 8: 1997-09-04   16
 9: 1996-05-293
10: 1997-09-037

El 16 de febrero de 2017, 12:43, Carlos Ortega 
escribió:

> Hola,
>
> Así funciona...
>
> #
>
> library(lubridate)
> datos <- read.table("datos.csv", header = TRUE, sep = ";", as.is = TRUE)
> #Primero quito fechas malas
> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
> datos$pprfecbaja)
>
> # Convierto campo fechas en clase Date
> datos$pprfecbaja <- ymd(datos$pprfecbaja)
>
> # Comprobacion de la clase
> tail(datos)
> class(datos$pprfecbaja[2808])
>
> #
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
> El 16 de febrero de 2017, 13:34, Mauricio Monsalvo 
> escribió:
>
>> Hola.
>> Tengo una duda con esta sintaxis. Tengo una variable con formato Date que
>> por algún motivo (el data.table viene de una consulta con PostgreSQL):
>> datos <- prov[, pprid, pprfecbaja]
>>   str(datos)
>> Cuando intento quitar las fechas de bajas inválidas (0001-01-01) y
>> convertirlas a NA, la variable resultante "pierde" su condición de Date.
>> Probé con distintas formas, siempre con el mismo resultado:
>> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
>> datos$pprfecbaja)
>> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
>> as.Date(datos$pprfecbaja))
>> datos$pprfecbaja <- ifelse(year(datos$pprfecbaja) < 1994, NA,
>> as.Date(datos$pprfecbaja))
>> ¿Podrían por favor ayudarme a correr la sintaxis correcta?
>> Adjunto los datos de ejemplo.
>> ​Muchas gracias.​
>>
>> --
>> Mauricio
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>



-- 
Mauricio

[[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-es] Resumen de R-help-es, Vol 96, Envío 27

2017-02-16 Thread patricio fuenmayor
Hola, intenta convirtiendo "0001-01-01" a fecha con as.Date:
datos$pprfecbaja <- ifelse(datos$pprfecbaja==as.Date("0001-01-01"), NA,
datos$pprfecbaja)
ya que estas comparando una fecha con un string ("0001-01-01")

El 16 de febrero de 2017, 7:34,  escribió:

> 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. Ayuda con Date (Mauricio Monsalvo)
>
>
> -- Mensaje reenviado --
> From: Mauricio Monsalvo 
> To: r-help-es 
> Cc:
> Date: Thu, 16 Feb 2017 10:34:10 -0200
> Subject: [R-es] Ayuda con Date
> Hola.
> Tengo una duda con esta sintaxis. Tengo una variable con formato Date que
> por algún motivo (el data.table viene de una consulta con PostgreSQL):
> datos <- prov[, pprid, pprfecbaja]
>   str(datos)
> Cuando intento quitar las fechas de bajas inválidas (0001-01-01) y
> convertirlas a NA, la variable resultante "pierde" su condición de Date.
> Probé con distintas formas, siempre con el mismo resultado:
> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
> datos$pprfecbaja)
> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
> as.Date(datos$pprfecbaja))
> datos$pprfecbaja <- ifelse(year(datos$pprfecbaja) < 1994, NA,
> as.Date(datos$pprfecbaja))
> ¿Podrían por favor ayudarme a correr la sintaxis correcta?
> Adjunto los datos de ejemplo.
> ​Muchas gracias.​
>
> --
> Mauricio
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

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

[R-es] media

2017-02-16 Thread jbetancourt

Estimados

Quisiera calcular las medias de cada semana de una sola vez con un script.
Apreciaría su ayuda

sem01   sem02   sem03   sem04
43  46  49  42
67  57  74  87
33  39  38  34
82  55  59  44
33  39  38  34

saludos
José



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

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


Re: [R-es] Ayuda con Date

2017-02-16 Thread Mauricio Monsalvo
Excelente!
Muchas gracias a todos!!
Saludos.

El 16 de febrero de 2017, 13:06, Freddy Omar López Quintero <
freddy.lopez.quint...@gmail.com> escribió:

> ​Hola.​
>
> 2017-02-16 9:34 GMT-03:00 Mauricio Monsalvo :
>
>> ¿Podrían por favor ayudarme a correr la sintaxis correcta?
>
>
> Esta es otra opción:
>
> ​datos<-read.csv('datos.csv', sep=';', row.names=1)
>> ​​datos$pprfecbaja<-​ replace(as.Date(datos$pprfecbaja),
>> datos$pprfecbaja=="0001-01-01", NA)
>
>
> ​Saludos.​
>
>
> --
> «Pídeles sus títulos a los que te persiguen, pregúntales
> cuándo nacieron, diles que te demuestren su existencia.»
>
> Rafael Cadenas
>
>


-- 
Mauricio

[[alternative HTML version deleted]]

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

[R] cluster data in lattice dotplot and show stdev

2017-02-16 Thread Luigi Marongiu
dear all,
i have a set of data that is separated in the variables: cluster (two
runs), type (blank, negative and positive) and target (A and B), each
duplicated. I am plotting it with lattice and the result is a 2x2 matrix
plot in which the top two cells (or panels) are relative to run 2, the
lower to run 2; each panel is then subdivided in target A or B and I have
colour-coded the dots to match the target.
However i would like to have a 1x2 panel plot representing the targets, and
within each panel having a cluster of 3 dots (representing the types) for
run 1 and another for run 2. I tried to represent such requirement in the
rough construction at the end of the example.
also, since each run is actually formed by duplicates, each dot should
indicate the standard deviation of the values.
How would I do that? any tips?
thanks
luigi

>>>
cluster <- c(rep("run_1", 6), rep("run_2", 6))
type <- rep(c("blank", "positive", "negative"),2)
target <- c(rep("A", 6), rep("B", 6))
value <- c(0.01, 1.1, 0.5,
   0.02, 1.6, 0.8,
   0.07, 1.4, 0.7,
   0.03, 1.4, 0.4)
my.data <- data.frame(cluster, type, target, value)

library(lattice)
dotplot(
  value ~ type|cluster + target,
  my.data,
  groups = type,
  pch=21,
  main = "Luminex analysis MTb humans",
  xlab = "Target", ylab = "Reading",
  col = c("grey", "green", "red"),
  par.settings = list(strip.background = list(col="paleturquoise")),
  scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
  key = list(
space = "top",
columns = 3,
text = list(c("Blank", "Negative", "Positive"), col="black"),
rectangles = list(col=c("grey", "green", "red"))
  )
)

x <- 1:7
plot(x , c(max(my.data$value), min(my.data$value), my.data$value[1:5]),
col="white", xaxt = "n", ylab="value", xlab="target")
points(x[1], mean(my.data$value[1], my.data$value[4]), col="grey")
points(x[2], mean(my.data$value[2], my.data$value[5]), col="red")
points(x[3], mean(my.data$value[3], my.data$value[6]), col="green")
points(x[5], mean(my.data$value[7], my.data$value[10]), col="grey")
points(x[6], mean(my.data$value[8], my.data$value[11]), col="red")
points(x[7], mean(my.data$value[9], my.data$value[12]), col="green")
axis(side=1, at = x[2], lab = "A", cex.axis=1)
axis(side=1, at = x[6], lab = "B", cex.axis=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] Ayuda con Date

2017-02-16 Thread Freddy Omar López Quintero
​Hola.​

2017-02-16 9:34 GMT-03:00 Mauricio Monsalvo :

> ¿Podrían por favor ayudarme a correr la sintaxis correcta?


Esta es otra opción:

​datos<-read.csv('datos.csv', sep=';', row.names=1)
> ​​datos$pprfecbaja<-​ replace(as.Date(datos$pprfecbaja),
> datos$pprfecbaja=="0001-01-01", NA)


​Saludos.​


-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas

[[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-es] Ayuda con Date

2017-02-16 Thread Carlos Ortega
Hola,

Así funciona...

#

library(lubridate)
datos <- read.table("datos.csv", header = TRUE, sep = ";", as.is = TRUE)
#Primero quito fechas malas
datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
datos$pprfecbaja)

# Convierto campo fechas en clase Date
datos$pprfecbaja <- ymd(datos$pprfecbaja)

# Comprobacion de la clase
tail(datos)
class(datos$pprfecbaja[2808])

#

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 16 de febrero de 2017, 13:34, Mauricio Monsalvo 
escribió:

> Hola.
> Tengo una duda con esta sintaxis. Tengo una variable con formato Date que
> por algún motivo (el data.table viene de una consulta con PostgreSQL):
> datos <- prov[, pprid, pprfecbaja]
>   str(datos)
> Cuando intento quitar las fechas de bajas inválidas (0001-01-01) y
> convertirlas a NA, la variable resultante "pierde" su condición de Date.
> Probé con distintas formas, siempre con el mismo resultado:
> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
> datos$pprfecbaja)
> datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
> as.Date(datos$pprfecbaja))
> datos$pprfecbaja <- ifelse(year(datos$pprfecbaja) < 1994, NA,
> as.Date(datos$pprfecbaja))
> ¿Podrían por favor ayudarme a correr la sintaxis correcta?
> Adjunto los datos de ejemplo.
> ​Muchas gracias.​
>
> --
> Mauricio
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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-es] Ayuda con Date

2017-02-16 Thread Reverté Calvet , Gerard
Una opción podria ser: datos$pprfecbaja<-as. character(datos$pprfecbaja) ##transformar la variable de formato Date a formato Characterdatos$pprfecbaja[datos$pprfecbaja=="0001-01-01"]<-"-00-00"  #reemplazar la fecha “0001-01-01” por una fecha inexistente “-00-00”datos$pprfecbaja<-strptime(datos$pprfecbaja, "%Y-%m-%d")  ##transformar la variable de formato Character a formato POSIXlt  Gerard Reverté  De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de Mauricio MonsalvoEnviado el: jueves, 16 de febrero de 2017 13:34Para: r-help-esAsunto: [R-es] Ayuda con Date Hola.Tengo una duda con esta sintaxis. Tengo una variable con formato Date que por algún motivo (el data.table viene de una consulta con PostgreSQL):datos <- prov[, pprid, pprfecbaja]  str(datos)Cuando intento quitar las fechas de bajas inválidas (0001-01-01) y convertirlas a NA, la variable resultante "pierde" su condición de Date. Probé con distintas formas, siempre con el mismo resultado:datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA, datos$pprfecbaja)datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA, as.Date(datos$pprfecbaja))datos$pprfecbaja <- ifelse(year(datos$pprfecbaja) < 1994, NA, as.Date(datos$pprfecbaja))¿Podrían por favor ayudarme a correr la sintaxis correcta? Adjunto los datos de ejemplo.  ​Muchas gracias.​ -- Mauricio 
Avís legal/Aviso legal
La present informació s'envia únicament a la persona a la que va dirigida i pot contenir informació privilegiada o de caràcter confidencial. Qualsevol modificació, retransmissió, difusió o altre ús d'aquesta informació per persones o entitats diferents a la persona a la que va dirigida està prohibida. Si vostè l'ha rebut per error, si us plau contacti amb el remitent i esborri el missatge de qualsevol ordinador. En el cas que aquest missatge vagi a ser contestat per la mateixa via, ha de saber-se que la seva resposta podria ser coneguda per tercers a l'entrar a la xarxa. Per això, si el missatge inclou contrasenyes, números de targetes de crèdit o qualsevol altra informació que vostè consideri confidencial, seria més segur contestar per una altra via i cancel·lar la seva transmissió. L'Ajuntament de Mataró i els seus organismes dependents no poden assumir la responsabilitat derivada del fet de què terceres persones puguin arribar a conèixer el contingut d'aquest missatge durant la seva transmissió.


La presente información se envía únicamente a la persona a la que va dirigida y puede contener información privilegiada o de carácter confidencial. Cualquier modificación, retransmisión, difusión u otro uso de esta información por persones o entidades diferentes a la persona a la que va dirigida está prohibida. Si usted la ha recibido por error, por favor contacte con el remitente y borre el mensaje. En el caso de que este mensaje vaya a ser contestado por la misma vía, ha de saberse que su respuesta podría ser conocida por terceros al entrar en la red. Por este motivo, si el mensaje incluye contraseñas, números de tarjetas de crédito o cualquier otra información que considere confidencial, sería más seguro contestar por otra vía y cancelar su transmisión. El Ayuntamiento de Mataró y sus organismos dependientes no pueden asumir la responsabilidad derivada del hecho de que terceras personas puedan llegar a conocer el contenido de este mensaje durante su transmisión. 
   ___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] R version 3.3.2, Windows 10 -- gstat.predict() function often return NaN values (GSTAT Package)

2017-02-16 Thread Rathore, Saubhagya Singh
__
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] MS SQL Server R Services review.

2017-02-16 Thread John McKown
I just picked this up over on "Vulture Central"
http://www.theregister.co.uk/2017/02/16/r_sql_server_great_but_beware/

The author seems both pleased and not pleased. Mainly digging at R's use
(or abuse) of memory being a cause of many failures. And the fact that is
is "slow" (states Python runs 17x faster) due to being interpreted.

Also, to me, it seems weird to run R within the data base server itself,
rather than on a client using RODBC.

-- 
"Irrigation of the land with seawater desalinated by fusion power is
ancient. It's called 'rain'." -- Michael McClary, in alt.fusion

Maranatha! <><
John McKown

[[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-es] Ayuda con Date

2017-02-16 Thread Mauricio Monsalvo
Hola.
Tengo una duda con esta sintaxis. Tengo una variable con formato Date que
por algún motivo (el data.table viene de una consulta con PostgreSQL):
datos <- prov[, pprid, pprfecbaja]
  str(datos)
Cuando intento quitar las fechas de bajas inválidas (0001-01-01) y
convertirlas a NA, la variable resultante "pierde" su condición de Date.
Probé con distintas formas, siempre con el mismo resultado:
datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
datos$pprfecbaja)
datos$pprfecbaja <- ifelse(datos$pprfecbaja=="0001-01-01", NA,
as.Date(datos$pprfecbaja))
datos$pprfecbaja <- ifelse(year(datos$pprfecbaja) < 1994, NA,
as.Date(datos$pprfecbaja))
¿Podrían por favor ayudarme a correr la sintaxis correcta?
Adjunto los datos de ejemplo.
​Muchas gracias.​

-- 
Mauricio
"";"pprfecbaja";"pprid"
"1";0001-01-01;2328
"2";0001-01-01;128
"3";0001-01-01;2102
"4";0001-01-01;2104
"5";0001-01-01;1894
"6";0001-01-01;2627
"7";0001-01-01;2774
"8";0001-01-01;1895
"9";0001-01-01;925
"10";0001-01-01;2311
"11";0001-01-01;1901
"12";0001-01-01;1912
"13";0001-01-01;1995
"14";0001-01-01;1998
"15";0001-01-01;1999
"16";0001-01-01;2003
"17";0001-01-01;1367
"18";0001-01-01;2807
"19";0001-01-01;2408
"20";0001-01-01;1324
"21";0001-01-01;1252
"22";0001-01-01;1258
"23";0001-01-01;817
"24";0001-01-01;2471
"25";0001-01-01;2647
"26";0001-01-01;2648
"27";0001-01-01;682
"28";0001-01-01;683
"29";0001-01-01;1913
"30";0001-01-01;547
"31";0001-01-01;752
"32";0001-01-01;772
"33";0001-01-01;767
"34";0001-01-01;2458
"35";0001-01-01;2559
"36";0001-01-01;474
"37";0001-01-01;2540
"38";0001-01-01;2076
"39";0001-01-01;377
"40";0001-01-01;957
"41";0001-01-01;911
"42";0001-01-01;394
"43";0001-01-01;395
"44";0001-01-01;244
"45";0001-01-01;1945
"46";0001-01-01;2717
"47";0001-01-01;2323
"48";0001-01-01;2333
"49";0001-01-01;2737
"50";0001-01-01;2542
"51";0001-01-01;2744
"52";0001-01-01;170
"53";0001-01-01;174
"54";0001-01-01;2757
"55";0001-01-01;2769
"56";0001-01-01;2462
"57";0001-01-01;2423
"58";0001-01-01;133
"59";0001-01-01;136
"60";0001-01-01;137
"61";0001-01-01;142
"62";0001-01-01;2659
"63";0001-01-01;1821
"64";0001-01-01;1188
"65";0001-01-01;1213
"66";0001-01-01;2356
"67";0001-01-01;2375
"68";0001-01-01;234
"69";0001-01-01;1075
"70";0001-01-01;2718
"71";0001-01-01;2770
"72";0001-01-01;2765
"73";0001-01-01;828
"74";0001-01-01;1054
"75";0001-01-01;2596
"76";0001-01-01;342
"77";0001-01-01;804
"78";0001-01-01;786
"79";0001-01-01;888
"80";0001-01-01;2749
"81";0001-01-01;972
"82";0001-01-01;740
"83";0001-01-01;2785
"84";0001-01-01;2786
"85";0001-01-01;2004
"86";0001-01-01;1563
"87";0001-01-01;1640
"88";0001-01-01;1107
"89";0001-01-01;979
"90";0001-01-01;826
"91";0001-01-01;1850
"92";0001-01-01;843
"93";0001-01-01;2057
"94";0001-01-01;1618
"95";0001-01-01;1551
"96";0001-01-01;2170
"97";0001-01-01;2566
"98";0001-01-01;2426
"99";0001-01-01;2640
"100";0001-01-01;816
"101";0001-01-01;567
"102";0001-01-01;1494
"103";0001-01-01;107
"104";0001-01-01;685
"105";0001-01-01;753
"106";0001-01-01;2624
"107";0001-01-01;103
"108";0001-01-01;2520
"109";0001-01-01;1470
"110";0001-01-01;1772
"111";0001-01-01;2108
"112";0001-01-01;2019
"113";0001-01-01;2777
"114";0001-01-01;1647
"115";0001-01-01;965
"116";0001-01-01;728
"117";0001-01-01;1495
"118";0001-01-01;1444
"119";0001-01-01;2072
"120";0001-01-01;1330
"121";0001-01-01;19
"122";0001-01-01;2776
"123";0001-01-01;1127
"124";0001-01-01;971
"125";0001-01-01;2517
"126";0001-01-01;1546
"127";0001-01-01;1550
"128";0001-01-01;1559
"129";0001-01-01;748
"130";0001-01-01;343
"131";0001-01-01;958
"132";0001-01-01;844
"133";0001-01-01;2597
"134";0001-01-01;791
"135";0001-01-01;802
"136";0001-01-01;2230
"137";0001-01-01;2712
"138";0001-01-01;2766
"139";0001-01-01;259
"140";0001-01-01;895
"141";0001-01-01;1807
"142";0001-01-01;1790
"143";0001-01-01;1775
"144";0001-01-01;1235
"145";0001-01-01;2435
"146";0001-01-01;982
"147";0001-01-01;2425
"148";0001-01-01;2794
"149";0001-01-01;2802
"150";0001-01-01;2140
"151";0001-01-01;424
"152";0001-01-01;1348
"153";0001-01-01;2155
"154";0001-01-01;14
"155";0001-01-01;17
"156";0001-01-01;20
"157";0001-01-01;1430
"158";0001-01-01;2728
"159";0001-01-01;2762
"160";0001-01-01;1448
"161";0001-01-01;1925
"162";0001-01-01;1929
"163";0001-01-01;2803
"164";0001-01-01;2804
"165";0001-01-01;2805
"166";0001-01-01;2806
"167";0001-01-01;1717
"168";0001-01-01;2808
"169";0001-01-01;2678
"170";0001-01-01;13
"171";0001-01-01;2128
"172";0001-01-01;2741
"173";0001-01-01;2809
"174";0001-01-01;2810
"175";0001-01-01;2791
"176";0001-01-01;1358
"177";0001-01-01;2008
"178";0001-01-01;2009
"179";0001-01-01;2052
"180";0001-01-01;1398
"181";0001-01-01;768
"182";0001-01-01;25
"183";0001-01-01;26
"184";0001-01-01;1856
"185";0001-01-01;2792
"186";0001-01-01;1341
"187";0001-01-01;2
"188";0001-01-01;3
"189";0001-01-01;2793
"190";0001-01-01;584
"191";0001-01-01;548
"192";0001-01-01;545
"193";0001-01-01;2485
"194";0001-01-01;2343
"195";0001-01-01;1607
"196";0001-01-01;21
"197";0001-01-01;1466
"198";0001-01-01;2275
"199";0001-01-01;2334

Re: [R-es] paquete Rcmdr y BiodiversityR

2017-02-16 Thread Luis E
Estimado Manuel,

muchas gracias por responder también.


Aqui están los ejemplos del libro "Tree diversity analysis” que yo estaba 
siguiendo. La version actualizada del paquete BiodiversityR actualizo el 
parámetro method. Entonces method=s ahora es method= pooled.


To calculate the total species richness for separate sites:

   Diversity.2 <-  diversityresult(dune, index=’richness’,
 method=’s’)


   Diversity.2
   summary(Diversity.2)
   Diversity.3 <- diversityresult(dune[1:2,], index=’richness’)
   Diversity.3


To compare the total number of species for various subsets of data:

   Diversity.4 <- diversitycomp(dune, y=dune.env,
 factor1=’Management’, index=’richness’ ,method=’all’)


Diversity.4

To calculate a sample-based species accumulation curve

   Accum.1 <- accumresult(dune, method=’exact’)
   Accum.1
   accumplot(Accum.1)
   Accum.2 <- accumresult(dune, method=’random’,


 permutations=1000)
   Accum.2


   accumplot(Accum.2)



Aqui esta la version aculizada del parametro method:

 Method of calculating the diversity statistics: "pooled" calculates the 
diversity of the entire community (all sites pooled), "each site" calculates 
diversity for each site separetly, "mean" calculates the average diversity of 
the sites, "sd" calculates the standard deviation of the diversity of the 
sites, whereas "jackknife" calculates the jackknifed diversity for the entire 
data frame.



El 16 feb. 2017, a las 00:24, Manuel Spínola 
> escribió:

Hola Luis,

Pero son tus argumentos correctos? Yo no veo un método "s".

diversitycomp(x, y = NULL,
factor1 = NULL ,factor2 = NULL,
index=c("Shannon", "Simpson", "inverseSimpson", "Logalpha", "Berger",
"richness", "abundance", "Jevenness", "Eevenness",
"jack1", "jack2", "chao", "boot"),
method=c("pooled", "mean", "sd", "jackknife"),
sortit=FALSE, digits=8)



El 15 de febrero de 2017, 11:52, Luis E 
> escribió:
Estimados,

Muchas gracias por sua ayuda, ya pude instalar data.table y esta funcionando.

Respecto al paquete biodiversityR, no se porque ahora no me corre. El script 
esta correcto, pero no se porque me tira error.




> fase<-diversitycomp(biobsp, 
> y=biopcat,factor1="Fase",index="richness",method=“s")
Error in diversitycomp(biobsp, y = biopcat, factor1 = "Fase", index = 
"richness",  :
  choose an accepted method, not method: s


Gracias a ambos por su ayuda.


Saludos, Luis


El 15 feb. 2017, a las 12:44, Carlos Ortega 
>>
 escribió:

Ya...
El problema que pareces tener en tu Mac es que no tienes ninguna librería de 
desarrollo instalada y no puedes compilar data.table.
¿Tienes instalado el Xcode?.

Es la aplicación de desarrollo (gratuita) para Mac del propio Apple. Esta 
aplicación contiene diferentes compiladores que te permitirán compilar el 
paquete y otros muchos que necesiten de esta compilación. Para conseguir 
"Xcode" tienes que ir a "Actualización de software..." y dentro de "Comprado" 
te debiera de aparecer. O vaya en tu acceso al AppStore búscala e instálala...

Cuando la instales, la abres y la cierras, de esta forma ya se aplican todas 
las variables de configuración, que permitirán ya decir al compilador de "R" 
donde buscar los compiladores necesarios.

Y ya tras hacer esto, podrás compilar data.table...

Saludos,
Carlos Ortega

2017-02-15 16:36 GMT+01:00 Luis E 
>>:
Gracias Carlos,

ya intente instalar varias veces el paquete data.table, pero no se porque no lo 
puede instalar

Aqui mando la salida:


> install.packages("data.table")

  There is a binary version available but the source version is later:
   binary source needs_compilation
data.table 1.10.0 1.10.4  TRUE

Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package 'data.table'

probando la URL 'https://cran.rstudio.com/src/contrib/data.table_1.10.4.tar.gz'
Content type 'application/x-gzip' length 3068135 bytes (2.9 MB)
==
downloaded 2.9 MB

Durante la inicializaci'on - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
4: Setting LC_MONETARY failed, using "C"
* installing *source* package 'data.table' ...
** package 'data.table' successfully unpacked and MD5 sums checked
** libs
xcrun: error: invalid active developer path 
(/Library/Developer/CommandLineTools), missing xcrun at: 
/Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package 'data.table'
* removing