[R] Proc Mixed variance of random effects in R

2015-06-17 Thread Grams Robins
Hi, I'm trying to convert the following SAS code in R to get the same result 
that I get from SAS. Here is the SAS code:
DATA plants; 
INPUT  sample $  treatmt $ y ; 
cards; 

1   trt16.426264755 
1   trt16.95419631 
1   trt16.64385619 
1   trt27.348728154 
1   trt26.247927513 
1   trt26.491853096 
2   trt12.807354922 
2   trt12.584962501 
2   trt13.584962501 
2   trt23.906890596 
2   trt23 
2   trt23.459431619 
3   trt12 
3   trt14.321928095 
3   trt13.459431619 
3   trt23.807354922 
3   trt23 
3   trt22.807354922 
4   trt10 
4   trt10 
4   trt10 
4   trt20 
4   trt20 
4   trt20 
; 
RUN; 

PROC MIXED ASYCOV NOBOUND  DATA=plants ALPHA=0.05 method=ML; 
CLASS sample treatmt; 
MODEL  y = treatmt ; 
RANDOM int treatmt/ subject=sample ; 
RUN; I get the following covariance estimates from SAS:Intercept sample == 
5.5795treatmt sample == -0.08455Residual == 0.3181I tried the following in R, 
but I get different results.   options(contrasts = c(factor = contr.SAS, 
ordered = contr.poly))
df$sample=as.factor(df$sample) 
lmer(y~ 1+treatmt+(1+treatmt|sample),REML=FALSE, data = df) Since the 
results from R are standard deviations, I have to square all results to get the 
variances.sample== 2.357412^2 = 5.557391
sample*treatmt==0.004977^2 = 2.477053e-05
residual==0.517094^2 = 0.2673862As shown above, the results from SAS and R 
are different. Do you know how to get the exact values in R?I appreciate any 
help.Thanks,Gram

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

2015-06-17 Thread Sarah Bazzocco



Hello, 

� 

I am a R-beginner and I need some help.�The question is very simple: I need to 
do a pearson correlations (r,p-value and FDR with BH) from an Expression array 
(with several thousand genes for lets say 20 cell lines)�with some features of 
those cell lines. 



My problem I have is the organization of the excel sheets and how to introduce 
the data into R and run the script. I though the easiest and more organized for 
me would be two expcel sheets: 

1- Only Expression data (in rows the�genes and in colums cell lines) 

2- Only the features (In row the features (e.g. a) growth rate, b) sensitivity 
to some drugs) and in columns the cell lines). 



--That would creat both sheets with 20 colums. 



Now I would like to get a correlation of the gene 1: the expression of all 
lines with the growth rate. 

the same for gene2... and soforth. I sould obtain as many r,p and BH(FDR) as 
genes there are. 

the same I would need to do for the sensitivity... and so on. 



Do you think this is doable? I am not at all a bioinformatic expert, so all 
help is very welcome. 



Thank you very much! 



Kind regards, 



Sarah 



-- 


Sarah Bazzocco, PhD student 
Group of Molecular Oncology, 
CIBBIM-Nanomedicine, 
Vall d'Hebron Hospital Research Institute, 
Passeig Vall d'Hebron 119-129, 
Barcelona 08035, Spain. 
Tel: +34-93-489-4056 

Fax: +34-93-489-3893 
Email: sarah.bazzo...@vhir.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.

Re: [R] Replace values in a dataframe

2015-06-17 Thread Grams Robins via R-help
Try this: 
dat=structure(list(Color = c(5, 4,5, 5, 5), Unit = 
c(Hazen,Hazen,Hazen, Hazen, Hazen)), .Names = c(Color, Unit), 
row.names =c(1:2,1:3, 1:4, 1:5,1:6), class = data.frame)
dat=as.data.frame(dat)dat$col2 - rep( , nrow(dat))dat[dat$Color == 4, ][, 
col2] - 2dat[dat$Color == 5, ][, col2] - 2.5 



 On Wednesday, June 17, 2015 1:33 PM, Shane Carey careys...@gmail.com 
wrote:
   

 Hey all,

I have a dataframe that consists of:

structure(list(Color = c(5, 4,5, 5, 5), Unit = c(Hazen,
Hazen,
Hazen, Hazen, Hazen)), .Names = c(Color, Unit), row.names =
c(1:2,
1:3, 1:4, 1:5,1:6), class = data.frame)

I need to find the 4 and have a new column with the result of 4 ÷ 2 = 2

Similarly

I need to find the 5 and have the new column with the result of 5 ÷ 2 = 2.5


All other numeric values would be added to the new column also to end up
with:



  Color New value Unit 1:2 5 5 Hazen 1:3 4 2 Hazen 1:4 5 5 Hazen 1:5 5
2.5 Hazen 1:6 5 5 Hazen



Thanks for your help!!

-- 
Shane

    [[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] mlogit.effects()

2015-06-17 Thread Simon Kiss
Dear colleagues,
I am struggling mightily with the mlogit package.  First, the reason that I am 
using mlogit as opposed to multinom() in nnet is because my data is ranked, not 
just ordinal.  So, I’m really trying to fit an exploded logit or rank-ordered 
model.  All of the covariates of interest are individual-specific, none are 
alternative specific.  The code below produces a model with my covariates of 
interest, so that is good. But, I cannot get predict.mlogit or effects.mlogit 
to work *at all*.  The help package is quite unclear as to how to format the 
sample data that is fed to either of those two functions.
Can any one help in that regard?  Failing that, can anyone provide a suggestion 
for an alternative way of modelling ranked categorical data? I’m aware of the 
pmr and Rankcluster packages. The former however is also poorly documented and 
the latter is computationally intense to select clusters.  
I’m trying to do this as simply as possible while remaining loyal to the ranked 
structure of the data. 

Thanks, Simon Kiss

#Loadpackages 
library(RCurl)
library(mlogit)
library(tidyr)
library(dplyr)
#URL where data is stored
dat.url-  
'https://raw.githubusercontent.com/sjkiss/Survey/master/mlogit.out.csv'
#Get data
dat-read.csv(dat.url)
#Complete cases only as it seems mlogit cannot handle missing values or tied 
data which in this case you might get because of median imputation
dat-dat[complete.cases(dat),]
#Tidy data to get it into long format
dat.out-dat %%
  gather(Open, Rank, -c(1,9:12)) %%
  arrange(X, Open, Rank)
#Create mlogit object
mlogit.out-mlogit.data(dat.out, shape='long',alt.var='Open',choice='Rank', 
ranked=TRUE,chid.var='X')
#Fit Model
mod1-mlogit(Rank~1|gender+age+economic+Job,data=mlogit.out)

__
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] Replace values in a dataframe

2015-06-17 Thread Sarah Goslee
Hi Shane,

On Wed, Jun 17, 2015 at 1:31 PM, Shane Carey careys...@gmail.com wrote:
 Hey all,

 I have a dataframe that consists of:

 structure(list(Color = c(5, 4,5, 5, 5), Unit = c(Hazen,
 Hazen,
 Hazen, Hazen, Hazen)), .Names = c(Color, Unit), row.names =
 c(1:2,
 1:3, 1:4, 1:5,1:6), class = data.frame)

Thanks for providing data.


 I need to find the 4 and have a new column with the result of 4 ÷ 2 = 2

 Similarly

 I need to find the 5 and have the new column with the result of 5 ÷ 2 = 2.5

Are 4 and 5 the only possible non-numeric values? If so, this is
an easy way to do it:

 mydata - structure(list(Color = c(5, 4,5, 5, 5), Unit = 
 c(Hazen,
+ Hazen,
+ Hazen, Hazen, Hazen)), .Names = c(Color, Unit), row.names =
+ c(1:2,
+ 1:3, 1:4, 1:5,1:6), class = data.frame)
 mydata
Color  Unit
1:2 5 Hazen
1:34 Hazen
1:4 5 Hazen
1:55 Hazen
1:6 5 Hazen
 mydata$NewColor - ifelse(mydata$Color == 4, 4/2, ifelse(mydata$Color == 
 5, 5/2, as.numeric(mydata$Color)))
 mydata
Color  Unit NewColor
1:2 5 Hazen  5.0
1:34 Hazen  2.0
1:4 5 Hazen  5.0
1:55 Hazen  2.5
1:6 5 Hazen  5.0

This will throw a warning message that you can safely ignore.


 All other numeric values would be added to the new column also to end up
 with:

   Color New value Unit 1:2 5 5 Hazen 1:3 4 2 Hazen 1:4 5 5 Hazen 1:5 5
 2.5 Hazen 1:6 5 5 Hazen

Bonus points for providing data, demerits for posting in HTML so your
email got mangled.

Sarah

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

[R] Problems using nlmrt package

2015-06-17 Thread Carlos Ortiz Oñate
Hello to everybody,

I want to implement a non-linear least square curve fitting and I am using
the package nlmrt, concretely the function nlxb. I have a dataset with
three variables and 176 values, one response variables (R) and two
predicting variables (T and H). When I fit a model of the form R ~
a*b^((T-10)/10) to my data using the function nlxb seems to be all ok with
a complet output; the same happens when I fit a model R ~ a + b*H - c*H^2.
But due to my research interest, when I try to fit a model result of the
product of the above models (R ~ (b1*b2^((T-10)/10))*(b3 + b4*H - b5*H^2) I
do obtain NA values in the SE, tstat and pval fields from the nlxb output,
as showed below:

nlmrt class object: x
residual sumsquares =  25348  on  176 observations
after  4Jacobian and  5 function evaluations
  namecoeff  SE   tstat  pval
gradientJSingval
R100.0619936NA NA NA
7.494e-068822
Q10  2.27113NA NA NA
5.422e-08   217.5
a 133.85NA NA NA
-2.288e-09   75.96
b56.8145NA NA NA
8.058e-09   0.658
c1.11775NA NA NA
2.8e-07   1.928e-15



I would like to know which error do you think I am making. Attached is the
document which contain the data.

Thank you very much in advance,

Carlos.

-- 
Carlos Ortiz Oñate

PhD student

Department of Agricultural Production

Technical University of Madrid

e-mail: ortiz.onate.car...@gmail.com t...@life.ku.dk
R   T   H
36.47   14.10   5.95
34.28   14.25   5.65
35.86   14.90   7.78
38.18   18.10   4.53
33.52   14.40   6.15
29.44   14.60   4.55
34.79   14.80   6.78
20.38   16.70   3.58
26.70   14.90   3.00
33.30   14.90   3.65
20.28   15.00   3.58
51.18   16.90   2.78
29.76   14.90   2.48
14.90   15.10   2.40
21.05   15.30   3.10
16.18   17.10   2.85
26.50   11.40   10.85
37.69   11.90   7.08
37.37   11.90   7.30
27.02   12.00   5.83
42.16   7.2026.03
47.75   7.7020.15
53.05   7.9017.78
26.48   8.0013.53
47.50   7.2011.45
28.47   7.4020.85
45.62   7.4015.23
42.31   7.9016.45
18.10   4.1027.35
27.71   5.5017.58
34.27   5.6028.33
27.75   5.7021.03
33.09   4.2037.28
19.05   4.2041.63
14.08   4.8036.48
23.15   5.3028.93
24.64   4.3031.48
35.80   4.4033.50
23.41   4.4032.63
29.63   4.6025.25
78.01   10.00   25.45
60.40   10.20   28.28
61.32   10.20   32.35
48.25   10.30   28.45
54.62   11.00   18.63
55.19   11.10   21.18
69.03   11.80   22.03
64.01   14.40   15.78
41.20   12.70   16.43
39.20   12.80   12.63
35.20   12.90   12.88
79.98   15.30   11.03
69.60   13.80   27.65
64.32   14.00   18.20
93.22   14.30   24.58
91.86   15.80   22.23
50.28   14.40   4.73
37.03   14.50   5.03
47.23   14.90   5.33
47.65   16.80   3.93
48.68   14.90   8.38
73.43   14.90   10.00
47.31   15.10   7.38
75.10   15.90   11.93
45.40   12.60   10.13
47.86   12.90   9.28
49.39   13.10   12.05
37.27   13.70   5.53
41.63   8.4011.43
53.83   9.1011.48
36.66   9.208.85
44.03   9.6011.23
45.94   5.9029.70
60.64   6.6014.98
48.91   6.6023.83
47.02   6.6025.13
13.62   1.3014.98
24.86   1.6013.75
27.28   1.8017.08
28.16   2.2014.13
23.29   2.6039.65
23.23   2.6036.35
25.10   2.7036.05
25.68   3.4032.85
54.88   9.9026.80
39.19   10.50   25.23
59.74   10.90   25.03
42.39   12.50   26.23
49.24   6.8030.65
52.70   7.0030.00
49.18   7.5029.43
69.69   7.6029.30
56.05   9.8028.78
45.72   9.9026.53
56.07   10.30   28.70
48.40   11.80   29.25
39.10   14.60   11.15
58.45   14.90   9.58
78.41   15.50   6.50
65.89   15.70   12.05
45.25   13.40   5.40
45.87   14.00   5.00
32.47   14.40   7.05
46.08   16.70   1.65
43.08   16.70   4.18
50.24   17.10   6.43
39.22   17.60   4.83
26.41   17.70   5.30
37.58   12.30   5.78
20.67   12.90   3.15
25.80   12.90   2.63
27.71   13.20   3.80
22.74   13.20   4.50
17.18   13.40   4.50
17.95   13.70   5.75
15.77   14.30   4.75
80.91   6.6024.25
37.71   6.8017.00
60.88   7.3017.50
47.62   7.3015.00
45.92   4.4027.50
19.28   5.7019.50
32.94   6.1022.25
52.46   6.4019.50
20.03   1.2025.88
26.29   1.9023.75
25.09   2.4021.00
35.26   2.8023.10
11.00   1.3027.60
23.49   1.6022.70
48.21   2.4021.38
17.76   3.1024.95
10.95   1.7027.60
20.90   1.8024.95
28.61   1.9022.70
47.77   2.0021.38
24.96   3.1019.55
20.90   6.1019.75
24.63   6.2017.45
27.10   6.2022.30
28.96   10.00   18.70
32.04   10.00   15.80
44.78   10.20   19.60
50.55   10.80   21.40
33.81   11.70   9.80
42.71   12.00   12.60
42.32   12.10   11.90
56.49   16.80   11.20
53.77   12.50   12.10
81.96   12.80   12.00
67.85   13.40   9.00
38.25   13.60   9.90
58.57   16.00   3.40
44.80   16.00   3.40
27.37   16.30   

[R-es] funciones en estructura data.table

2015-06-17 Thread Patricio Fuenmayor Viteri


-Mensaje original-

De: Patricio Fuenmayor Viteri patricio.fuenma...@outlook.com
Enviado: 17 de junio de 2015 6:37 PM
Para: r-help...@r-ptoject.org, patricio.fuenma...@outlook.com
Asunto: funciones en estructura data.table

hola...
luego de haber migrado la mayoria de mis procesos a data.table. aun me kedan 
ciertos detalles por afinar.. eate es un ejemplo de eso..
tengo una tabla de emails y necesito hacer un analisis de dominios... para 
separar el nombre de usuario el dominio uso la funcion str_split del paquete 
stringr... pero el resultado me queda en una sola columna y separada por una 
coma... mi pregunta es ... como puedo hacer ke los multiples resultados de una 
funcion ... se guarden en diferentes columnas de mi data.table
email01[,.(str_split(email))]

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


Re: [R] Replace values in a dataframe

2015-06-17 Thread Bert Gunter
Is the following what you want:

(z is your data frame)

 change -c(2,2.5)
 names(change) - c(4,5)

(note: this can be automated using regular expressions and will work for
lots more values to change. Sarah's ifelse() solution is fine for the
example, but becomes too cumbersome (as she intimated) for more values.)

 z$newcol - with(z,{
+   for(nm in names(change))Color[Color == nm]-change[nm]
+   as.numeric(Color)
+ })
 z
Color  Unit newcol
1:2 5 Hazen5.0
1:34 Hazen2.0
1:4 5 Hazen5.0
1:55 Hazen2.5
1:6 5 Hazen5.0

Incidentally, if this is how you are attempting to deal with censored data,
it may be a very bad idea. For why, consult a local statistician or post on
a statistics list like stats.stackexchange.com

Cheers,
Bert


Bert Gunter

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

On Wed, Jun 17, 2015 at 10:31 AM, Shane Carey careys...@gmail.com wrote:

 Hey all,

 I have a dataframe that consists of:

 structure(list(Color = c(5, 4,5, 5, 5), Unit = c(Hazen,
 Hazen,
 Hazen, Hazen, Hazen)), .Names = c(Color, Unit), row.names =
 c(1:2,
 1:3, 1:4, 1:5,1:6), class = data.frame)

 I need to find the 4 and have a new column with the result of 4 ÷ 2 = 2

 Similarly

 I need to find the 5 and have the new column with the result of 5 ÷ 2 =
 2.5


 All other numeric values would be added to the new column also to end up
 with:



   Color New value Unit 1:2 5 5 Hazen 1:3 4 2 Hazen 1:4 5 5 Hazen 1:5 5
 2.5 Hazen 1:6 5 5 Hazen



 Thanks for your help!!

 --
 Shane

 [[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] generating a data frame for plm regression

2015-06-17 Thread T.Riedle
Hi everybody,

I am working with the plm package. I am struggling with the generation of the 
data frame in the plm() function. An example of my data are found in the 
attachment and I want to run a pooled regression on those. Hence, I need to 
generate a data frame using pdata.frame() function and this is what I get:

pdata.frame(plm.CoVaR,index=c(Sector,Date))-data
 head(data,100)
 Sector   Date   DeltaCoVaR
1-01/02/2000  1 01/02/2000 -2.331174662
1-01/02/2001  1 01/02/2001 -2.091099896
1-01/02/2002  1 01/02/2002 -2.126445804
1-01/02/2005  1 01/02/2005 -1.580493046
1-01/02/2006  1 01/02/2006 -1.648100073
1-01/02/2007  1 01/02/2007 -1.494696604

The problem is that I do not understand the first column. Furthermore, I have 
daily data but the variables are not sorted by their date. The ordering looks 
confusing and some years are omitted in the R output.

What is wrong here? Can anybody 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-es] funciones en estructura data.table

2015-06-17 Thread javier.ruben.marcuzzi
Estimado Patricio Fuenmayor Viteri


De cran.r-project.org/web/packages/stringr/stringr.pdf  página 17, interpreto 
que van la cadena y la separación (el tercer parámetro no iría en su caso).


Tendría que probarlo pero estoy casi seguro que es eso.






Javier Rubén Marcuzzi
Técnico en Industrias Lácteas
Veterinario





De: Patricio Fuenmayor Viteri
Enviado el: ‎miércoles‎, ‎17‎ de ‎junio‎ de ‎2015 ‎09‎:‎26‎ ‎p.m.
Para: R-help-es@r-project.org







-Mensaje original-

De: Patricio Fuenmayor Viteri patricio.fuenma...@outlook.com
Enviado: 17 de junio de 2015 6:37 PM
Para: r-help...@r-ptoject.org, patricio.fuenma...@outlook.com
Asunto: funciones en estructura data.table

hola...
luego de haber migrado la mayoria de mis procesos a data.table. aun me kedan 
ciertos detalles por afinar.. eate es un ejemplo de eso..
tengo una tabla de emails y necesito hacer un analisis de dominios... para 
separar el nombre de usuario el dominio uso la funcion str_split del paquete 
stringr... pero el resultado me queda en una sola columna y separada por una 
coma... mi pregunta es ... como puedo hacer ke los multiples resultados de una 
funcion ... se guarden en diferentes columnas de mi data.table
email01[,.(str_split(email))]

___
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] Read text file

2015-06-17 Thread William Dunlap
I am not sure what you mean by a block, but you can probably use
scan() instead of read.table():
   txt - 1 21 41 61 81
   d - data.frame(Numbers=scan(text=txt, what=numeric, quiet=TRUE))
   d
Numbers
  1   1
  2  21
  3  41
  4  61
  5  81


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jun 17, 2015 at 10:10 PM, Steven Yen sye...@gmail.com wrote:

 How do I read a block of space-delimited numbers into a column vector
 using the read.table command? Thank you.

 --
 Steven Yen

 __
 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] Read text file

2015-06-17 Thread Olivier Crouzet
Hi, 

I think that you need scan() but you should at least give us an example of your 
text data.

Olivier.

--
Olivier Crouzet
LLING - Laboratoire de Linguistique de Nantes - EA3827
Université de Nantes

-Original Message-
From: Steven Yen sye...@gmail.com
Sender: R-help r-help-boun...@r-project.orgDate: Thu, 18 Jun 2015 01:10:39 
To: r-helpr-help@r-project.org
Reply-To: sye...@gmail.com
Subject: [R] Read text file

How do I read a block of space-delimited numbers into a column vector 
using the read.table command? Thank you.

-- 
Steven Yen

__
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-es] funciones en estructura data.table

2015-06-17 Thread Freddy Omar López Quintero
​​No limpió, no fijó y no dio esplendor nunca...


2015-06-17 21:26 GMT-03:00 Patricio Fuenmayor Viteri 
patricio.fuenma...@outlook.com:



 -Mensaje original-

 De: Patricio Fuenmayor Viteri patricio.fuenma...@outlook.com
 Enviado: 17 de junio de 2015 6:37 PM
 Para: r-help...@r-ptoject.org, patricio.fuenma...@outlook.com
 Asunto: funciones en estructura data.table

 hola...
 luego de haber migrado la mayoria de mis procesos a data.table. aun me
 kedan ciertos detalles por afinar.. eate es un ejemplo de eso..
 tengo una tabla de emails y necesito hacer un analisis de dominios... para
 separar el nombre de usuario el dominio uso la funcion str_split del
 paquete stringr... pero el resultado me queda en una sola columna y
 separada por una coma... mi pregunta es ... como puedo hacer ke los
 multiples resultados de una funcion ... se guarden en diferentes columnas
 de mi data.table
 email01[,.(str_split(email))]

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




-- 
«No soy aquellas sombras tutelares
que honré con versos que no olvida el tiempo.»

JL Borges

[[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] Replace values in a dataframe

2015-06-17 Thread Shane Carey
Hey all,

I have a dataframe that consists of:

structure(list(Color = c(5, 4,5, 5, 5), Unit = c(Hazen,
Hazen,
Hazen, Hazen, Hazen)), .Names = c(Color, Unit), row.names =
c(1:2,
1:3, 1:4, 1:5,1:6), class = data.frame)

I need to find the 4 and have a new column with the result of 4 ÷ 2 = 2

Similarly

I need to find the 5 and have the new column with the result of 5 ÷ 2 = 2.5


All other numeric values would be added to the new column also to end up
with:



  Color New value Unit 1:2 5 5 Hazen 1:3 4 2 Hazen 1:4 5 5 Hazen 1:5 5
2.5 Hazen 1:6 5 5 Hazen



Thanks for your help!!

-- 
Shane

[[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] how to call rbind using arguments from a list

2015-06-17 Thread Rolf Turner


I *think* you want:

   ZC - do.call(rbind,lapply(a,get))

But why do you make a a *list* of names rather than a vector of names? 
Generally one uses lists to hold complicated structures.

A sequence of character scalars is best stored in an atomic vector.

cheers,

Rolf Turner

P. S.  Thank you for providing a reproducible example! :-)

R. T.

On 17/06/15 21:58, Matteo wrote:

Hello R users,

I am trying to run the command rbind gathering the name of tables to bind
from a list argument.

Unfortunately I am not able to obtain it.

I would appreciate any suggestions.  Below is a reproducible example with
the problem.

Thanks

Matteo



##

ZA-data.frame(x = 1:2, y = 1:10,z=letters[1:5])

ZB-data.frame(x = 1, y = 5:24,z=letters[2])

a-as.list(ls(pattern= ^Z?));a

#

I_would_like_ZC-rbind(ZA,ZB)  # this is what I would like to have

#

b-(paste(a, collapse = ','))

call(rbind,(b)) # I am not able to remove 

b-noquote(paste(a, collapse = ','))

call(rbind,(b)) # I am not able to remove  



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

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


[R] Read text file

2015-06-17 Thread Steven Yen
How do I read a block of space-delimited numbers into a column vector 
using the read.table command? Thank you.


--
Steven Yen

__
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] Problemas al cargar Rcomander en consola de Rstudio

2015-06-17 Thread José Trujillo Carmona

El 16/06/15 a las 21:33, eric escribió:
MaLuz, hasta donde entiendo RStudio y R-commander son entornos de 
trabajo graficos para R, R-commander no es una libreria 
(http://www.rcommander.com/), de modo que me parece raro invocarlo 
desde dentro de R. Segun yo deberias llamar a R-commander tal como 
llamas a RStudio, como un programa desde la consola linux o con un 
shorcut o desde un menu o algo asi. TclTk si es un conjunto de 
librerias graficas, por eso las puedes cargar sin problemas desde 
dentro de R.


Saludos, eric.



Pues no amigo Eric.

RCommander, a diferencia de RStudio, es una libreria o paquete de R , 
que abre su propia ventana gráfica cuando se le invoca. El paquete en 
concreto es Rcmdr.


La primera invocación de RCommander es simplemente:

library(Rcmdr)

Y si por alguna razón se cierra la ventana gráfica de RCommander, se 
vuelve a poner en marcha mediante el comando:


Commander()

RCommander es perfectamente compatible con RStudio, aportándole menús 
para procedimientos estadísticos de nivel básico y general de los que 
carece RStudio. Este está más centrado en el control de los datos y 
objetos del entorno que en proporcionar menús para procedimientos 
estadísticos. Basta con marcar el paquete Rcmdr en la solapa Packages de 
RStudio para incorporar RCommander a RStudio, aunque en estas 
condiciones puede hacer falta retocar la configuración de RCommander 
para que la convivencia sea perfecta (en concreto puede que redirija la 
salida a RStudio en lugar de hacerlo hacia su propio editor de resultados).


Un saludo.





On 16/06/15 05:14, MªLuz Morales wrote:

Hola,
tengo instalado R y Rstudio sobre linux en máquina virtual. en la 
consola

de Rstudio he instalado el interfaz Rcommander con la instrucción:

install.packages(Rcmdr,dependences=TRUE),

pero al cargar el paquete
library(Rcmdr)

obtengo el siguiente error:


Loading required package: splinesLoading required package:
RcmdrMiscLoading required package: carLoading required package:
sandwichError : .onLoad failed in loadNamespace() for 'Rcmdr',
details:
   call: structure(.External(.C_dotTclObjv, objv), class = tclObj)
   error: [tcl] invalid command name tk_messageBox.
In addition: Warning message:In fun(libname, pkgname) : couldn't
connect to display :0Error: package or namespace load failed for
‘Rcmdr’


Esto lo carga sin problemas
library(tcltk)


Gracias
Un saludo
MªLuz

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

2015-06-17 Thread PIKAL Petr
Hi

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Venky
 Sent: Wednesday, June 17, 2015 8:43 AM
 To: R Help R
 Subject: [R] cluster analysis

 Hi friends,

 I have data like this


In R or elsewhere?



 Group
   Employee size WOE Employee size2 Weight of Evidence 1081680995 0
 0.12875537 0.128755 -0.30761 1007079896 1 0.48380133 -0.46544 -0.70464
 1000507407 2 0.26029825 -0.46544 0.070221 1006400720 3 0.12875537
 0.128755
 0.151385 1006916029 4 0.12875537 -0.05955 0.320269 1006717587 5
 0.12875537
 1002032301 6 0.12875537 1007021594 7 0.26029825 1007118066 8 0.26029825
 In this data first variable (Employee size) has 10 rows and variable 2
 (employee size2) has only 5 rows

Extremely messy due to HTML posting. Use plain text post as recommended by 
Posting Guide.


 Question 1:there are different number of rows so that, we can able to
 do K-means cluster or not?

I am not an expert but why not to try it?

 Question 2:If we run k-means clustering in R answer not coming  because
 of NA exists

 I have used dataset-na.omit(dataset)

 But that time also i cannot able to run clustering

Perhaps not enough data remained after NA removing.

To get better answer you shall provide reproducible example or at least some 
usable data.

Cheers
Petr



 Please help me to find this answer

   [[alternative HTML version deleted]]

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


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
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] Polysomnographic data analysis with R?

2015-06-17 Thread Jim Lemon
Hi Charles,
This looks like the European Data Format (EDF and EDF+), which has a
complete file specification. If there is no existing R package, it
might be possible to write an import function from the specification,
something like the functions in the foreign package.

Jim


On Wed, Jun 17, 2015 at 4:55 AM, Charles Novaes de Santana
charles.sant...@gmail.com wrote:
 Dear all,

 Do you know if there is any R package or function we can use to analyze
 polysomnographic data?

 For example, something that can import an EDF file (or in a different
 format) and can give some properties of the polysomnographic records like
 periods of different sleep phases, etc.

 I looked for it in the web and I didn't find. But maybe I used the wrong
 key-words.

 Any help will be much appreciated!

 Best,

 Charles
 --
 Um axé! :)

 --
 Charles Novaes de Santana, PhD
 http://www.imedea.uib-csic.es/~charles

 [[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] Aggregating on date at Monthly Level

2015-06-17 Thread PIKAL Petr
Hi

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi82
 Sent: Wednesday, June 17, 2015 9:19 AM
 To: r-help@r-project.org
 Subject: [R] Aggregating on date at Monthly Level

 HI All,
 I have situation where i am aggregating weight on monthly and quarterly
 level.
 I need to summarize weight on variable ship date i.e. shipping date .
 As this date is in a character format so used the conversion as:

 Shipdate-as.Date(retail$ship.date, format=%m-%d-%Y). But when i
 see the output of Shipdate the result is NA.

Are you sure that format is in aggreement with ship.date?

 typeof(Shipdate) gives me double. I am not sure what this is var type
 whereas class (Shipdate) is Date so i am a bit puzzled.

 Then i have created a new var which sums weight and gives me the
 desired
 result-
 aggr-aggregate(retail$weight,list(retail$ship.date),mean)

 Now if i want to group the result on a Month level i used the below
 syntax and gives me error:
 cut.Date(aggr,breaks = Month,labels = TRUE). x must be numeric- in
 the above syntax i have created it as a list.

AFAIK aggr is data frame with Group.1 column the ship.date and x column the 
mean weight for each ship.date. If you want to further aggregate on month you 
can use the same approach with second parameter in aggregate an indication of 
months. If you want something else you shall be more specific about your data 
and intended result.


 Is there an easier way to achieve what i am looking for. Kindly
 suggest.

Probably easiest way would be if you familiarise yourself with data types and 
operations e.g. by reading R-intro.

Cheers
Petr

 Thanks, Shivi



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Aggregating-on-date-at-Monthly-Level-
 tp4708741.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.


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

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

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

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

Re: [R] Polysomnographic data analysis with R?

2015-06-17 Thread Charles Novaes de Santana
Dear Jim,

Thank you for your response. Yes, it is the European Data Format you
mention. Actually we can read the data correctly, but I was wondering if
there is any package that can identify different sleep phases automatically
based on the data. I supposed such a package does not exist, it is really
difficult to automatize the identification of sleep phases based only on
data, but I asked here just in case.

Thanks for your attention!

Best,

Charles

On 17 June 2015 at 13:46, Jim Lemon drjimle...@gmail.com wrote:

 Hi Charles,
 This looks like the European Data Format (EDF and EDF+), which has a
 complete file specification. If there is no existing R package, it
 might be possible to write an import function from the specification,
 something like the functions in the foreign package.

 Jim


 On Wed, Jun 17, 2015 at 4:55 AM, Charles Novaes de Santana
 charles.sant...@gmail.com wrote:
  Dear all,
 
  Do you know if there is any R package or function we can use to analyze
  polysomnographic data?
 
  For example, something that can import an EDF file (or in a different
  format) and can give some properties of the polysomnographic records like
  periods of different sleep phases, etc.
 
  I looked for it in the web and I didn't find. But maybe I used the wrong
  key-words.
 
  Any help will be much appreciated!
 
  Best,
 
  Charles
  --
  Um axé! :)
 
  --
  Charles Novaes de Santana, PhD
  http://www.imedea.uib-csic.es/~charles
 
  [[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.




-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

[[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] cluster analysis

2015-06-17 Thread Venky
Hi friends,

I have data like this



Group
  Employee size WOE Employee size2 Weight of Evidence 1081680995 0
0.12875537 0.128755 -0.30761 1007079896 1 0.48380133 -0.46544 -0.70464
1000507407 2 0.26029825 -0.46544 0.070221 1006400720 3 0.12875537 0.128755
0.151385 1006916029 4 0.12875537 -0.05955 0.320269 1006717587 5 0.12875537
1002032301 6 0.12875537 1007021594 7 0.26029825 1007118066 8 0.26029825
In this data first variable (Employee size) has 10 rows and variable 2
(employee size2) has only 5 rows

Question 1:there are different number of rows so that, we can able to do
K-means cluster or not?
Question 2:If we run k-means clustering in R answer not coming  because of
NA exists

I have used dataset-na.omit(dataset)

But that time also i cannot able to run clustering

Please help me to find this answer

[[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] Aggregating on date at Monthly Level

2015-06-17 Thread Shivi82
HI All, 
I have situation where i am aggregating weight on monthly and quarterly
level.
I need to summarize weight on variable ship date i.e. shipping date . As
this date is in a character format so used the conversion as:

Shipdate-as.Date(retail$ship.date, format=%m-%d-%Y). But when i see the
output of Shipdate the result is NA. 
typeof(Shipdate) gives me double. I am not sure what this is var type
whereas class (Shipdate) is Date so i am a bit puzzled. 

Then i have created a new var which sums weight and gives me the desired
result- 
aggr-aggregate(retail$weight,list(retail$ship.date),mean)

Now if i want to group the result on a Month level i used the below syntax
and gives me error:
cut.Date(aggr,breaks = Month,labels = TRUE). x must be numeric- in the
above syntax i have created it as a list.

Is there an easier way to achieve what i am looking for. Kindly suggest. 
Thanks, Shivi



--
View this message in context: 
http://r.789695.n4.nabble.com/Aggregating-on-date-at-Monthly-Level-tp4708741.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] Restricting Decimal Places in the Output

2015-06-17 Thread Shivi82
Good Morning All,

I have working on a data set where I am finding mean and median for weight
variable on a daily basis. 
The code:

aggr-aggregate(retail$weight,list(retail$ship.date),mean)
This is giving me an accurate result however with 4 decimal places for the
mean weight. In order to restrict it i used the following syntax:

format(aggr,digits=2,justify = c(right))
After the execution of this code i have mean weight but now there are no
decimal places. Could you please advice what is incorrect in the syntax.

Thank you, Shivi



--
View this message in context: 
http://r.789695.n4.nabble.com/Restricting-Decimal-Places-in-the-Output-tp4708739.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Restricting Decimal Places in the Output

2015-06-17 Thread PIKAL Petr
Hi

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi82
 Sent: Wednesday, June 17, 2015 7:50 AM
 To: r-help@r-project.org
 Subject: [R] Restricting Decimal Places in the Output

 Good Morning All,

 I have working on a data set where I am finding mean and median for
 weight variable on a daily basis.
 The code:


How about

aggr-aggregate(retail$weight,list(retail$ship.date),function(x) 
round(mean(x,2)))

Cheers
Petr

 This is giving me an accurate result however with 4 decimal places for
 the mean weight. In order to restrict it i used the following syntax:

 format(aggr,digits=2,justify = c(right)) After the execution of this
 code i have mean weight but now there are no decimal places. Could you
 please advice what is incorrect in the syntax.

 Thank you, Shivi



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Restricting-Decimal-Places-in-the-Output-
 tp4708739.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.


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

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

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

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

2015-06-17 Thread PIKAL Petr
Hi

It does not make sense. How you can get same result counting mean and sum? The 
only way I can imagine is that you have only one value per date. So aggregate 
does virtually nothing.

round gives you n decimal places based on its second parameter.

 set.seed(111)
 x-rnorm(1)
 x-x*1000
 round(x,1)
[1] 235.2
 round(x,2)
[1] 235.22
 round(x,3)
[1] 235.221
 round(x,4)
[1] 235.2207
 round(x,10)
[1] 235.2207116

The last item has less than 10 decimal places due to my options(digits) 
setting.

 options(digits=20)
 round(x,10)
[1] 235.2207116136

There are other ways to manipulate with printed digits. You can start with 
?options

Cheers
Petr

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi82
 Sent: Wednesday, June 17, 2015 2:15 PM
 To: r-help@r-project.org
 Subject: Re: [R] Restricting Decimal Places in the Output

 Hi Petr,

 The solution you shared worked though it does not show any decimal
 values.
 The output is
 Group.1 x
 11/1/2015309450
 2   1/10/2015   332780

 Instead of mean i used sum  i think that should be fine.
 aggr-aggregate(retail$weight,list(retail$ship.date),function(x)
 round(sum(x,0)))

 So if i change above code to x,1 it changes values to
 Group.1 x
 11/1/2015309451
 2   1/10/2015   332781

 Thanks, Shivi




 --
 View this message in context:
 http://r.789695.n4.nabble.com/Restricting-Decimal-Places-in-the-Output-
 tp4708739p4708755.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.


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

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

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

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

Re: [R] Error bars and CI

2015-06-17 Thread Mohan.Radhakrishnan
Your sample code is working. But I am missing the logic when my dataset is 
involved.

My full dataset is this. It is the V1 column I am interested in.  I am not 
'grouping' here.

  V1 IDX
1  0.796   1
2  0.542   2
3  0.510   3
4  0.617   4
5  0.482   5
6  0.387   6
7  0.272   7
8  0.536   8
9  0.498   9
10 0.402  10
11 0.328  11
12 0.542  12
13 0.299  13
14 0.647  14
15 0.291  15
16 0.815  16
17 0.680  17
18 0.363  18
19 0.560  19
20 0.334  20

Thanks,
Mohan

-Original Message-
From: Dennis Murphy [mailto:djmu...@gmail.com]
Sent: Tuesday, June 16, 2015 1:18 AM
To: Radhakrishnan, Mohan (Cognizant)
Subject: Re: [R] Error bars and CI

Hi:

Firstly, your dplyr code to generate the summary data frame is unnecessary and 
distracting, particularly since you didn't provide the input data set; you are 
asked to provide a *minimal* reproducible example, which you could easily have 
done with a built-in data set.
That said, to get what I perceive you want, I used the InsectSprays data from 
the autoloaded datasets package.

# Function to compute standard error of a mean sem - function(x) 
sqrt(var(x)/length(x))

## Use insectSprays data for illustration ## Compute mean and SE of count for 
each level of spray

library(dplyr)
library(ggplot2)

insectSumm - InsectSprays %%
  group_by(spray) %%
  summarise(mean = mean(count), se = sem(count))


# Since the x-variable is a factor, need to map group = 1 to # draw lines 
between factor levels. geom_pointrange() can be # used to produce the 99% CIs 
per factor level, geom_errorbar() # for the mean +/- SE. I ordered the geoms so 
that the errorbar # is last, but if you want it (mostly) overwritten, put the # 
geom_pointrange() call last.

ggplot(insectSumm, aes(x = spray, y = mean)) +
   theme_bw() +
   geom_line(aes(group = 1), size = 1, color = darkorange) +
   geom_pointrange(aes(ymin = mean - qt(.995, 11) * se,
  ymax = mean + qt(.995, 11) * se),
   size = 1.5, color = firebrick) +
   geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2,
   size = 1)

Clearly, you can pipe all the way through the ggplot() call, but I wanted to 
check the contents of the summary data frame first.

Dennis

On Mon, Jun 15, 2015 at 3:51 AM,  mohan.radhakrish...@cognizant.com wrote:
 Hi,

 I want to plot a line graph using this data. IDX is x-axis and V1 is y-axis.  
 I also want standard error bars and 99% CI to be shown. My code is given 
 below. The section that plots the graph is the problem.  I don't see all the 
 points in the line graph with error bars. How can I also show the 99% CI in 
 the graph ?

   V1 IDX
 1  0.987  21
 2  0.585  22
 3  0.770  23
 4  0.711  24

 library(stringr)
 library(dplyr)
 library(ggplot2)

 data - read.table(D:\\jmh\\jmh.txt,sep=\t)

 final -data %%
select(V1) %%
   filter(grepl(^Iteration, V1)) %%
 mutate(V1 = str_extract(V1, \\d+\\.\\d*))

 final - mutate(final,IDX = 1:n())

 jc - final %%
   filter(IDX  21)


 #Convert to numeric
 jc - data.frame(sapply(jc, function(x) as.numeric(as.character(x

 print(jc)

 # The following section is the problem.

 sem - function(x){
sd(x)/sqrt(length(x))
 }

 meanvalue - apply(jc,2,mean)
 semvalue - apply(jc, 2, sem)

 mean_sem - data.frame(mean= meanvalue, sem= semvalue,
 group=names(jc))

 #larger font
 theme_set(theme_gray(base_size = 20))

 #plot using ggplot
 p - ggplot(mean_sem, aes(x=group, y=mean)) +
   geom_line(stat='identity') +
   geom_errorbar(aes(ymin=mean-sem, ymax=mean+sem),
width=.2)
 print(p)

 Thanks,
 Mohan
 This e-mail and any files transmitted with it are for the sole use of the 
 intended recipient(s) and may contain confidential and privileged 
 information. If you are not the intended recipient(s), please reply to the 
 sender and destroy all copies of the original message. Any unauthorized 
 review, use, disclosure, dissemination, forwarding, printing or copying of 
 this email, and/or any action taken in reliance on the contents of this 
 e-mail is strictly prohibited and may be unlawful. Where permitted by 
 applicable law, this e-mail and other e-mail communications sent to and from 
 Cognizant e-mail addresses may be monitored.

 [[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.
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized 

Re: [R] Restricting Decimal Places in the Output

2015-06-17 Thread Michael Dewey

Dear Shivi

On 17/06/2015 13:15, Shivi82 wrote:

Hi Petr,

The solution you shared worked though it does not show any decimal values.
The output is
Group.1 x
11/1/2015309450
2   1/10/2015   332780

Instead of mean i used sum  i think that should be fine.
aggr-aggregate(retail$weight,list(retail$ship.date),function(x)
round(sum(x,0)))



That adds all the elements of x and zero and then rounds it


So if i change above code to x,1 it changes values to


That will add all the elements of x and unity and then round it. Notice 
that your result has increased by unity each time.


I think you meant to write round(sum(x), 0) or round(sum(x), 1) as the 
case may be



Group.1 x
11/1/2015309451
2   1/10/2015   332781

Thanks, Shivi




--
View this message in context: 
http://r.789695.n4.nabble.com/Restricting-Decimal-Places-in-the-Output-tp4708739p4708755.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.



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

__
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] Restricting Decimal Places in the Output

2015-06-17 Thread Shivi82
Hi Petr,

The solution you shared worked though it does not show any decimal values.
The output is 
Group.1 x
11/1/2015309450
2   1/10/2015   332780

Instead of mean i used sum  i think that should be fine. 
aggr-aggregate(retail$weight,list(retail$ship.date),function(x)
round(sum(x,0)))

So if i change above code to x,1 it changes values to 
Group.1 x
11/1/2015309451
2   1/10/2015   332781

Thanks, Shivi




--
View this message in context: 
http://r.789695.n4.nabble.com/Restricting-Decimal-Places-in-the-Output-tp4708739p4708755.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-es] Regresión multinivel en R

2015-06-17 Thread José Miguel Contreras García



Hola a todos

Una pregunta, ¿existe algún paquete para trabajar modelos de regresión
multinivel con R?

Saludos

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


Re: [R-es] Regresión multinivel en R

2015-06-17 Thread José Luis Cañadas
Hola. Usa lme4 o MCMCglmm, o rstan

El mié., 17 de junio de 2015 14:39, José Miguel Contreras García 
jmcontre...@ugr.es escribió:



 Hola a todos

 Una pregunta, ¿existe algún paquete para trabajar modelos de regresión
 multinivel con R?

 Saludos

 ___
 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] Error bars and CI

2015-06-17 Thread Mohan.Radhakrishnan
I think it could be something like this. But the mean is for the entire set. 
Not groups.
I get a graph with this code but error bars are not there.


p-ggplot(jc,aes(IDX,V1,colour=V1))
p - p + stat_summary(fun.y=mean,geom=point)
p - p + stat_summary(fun.y=mean,geom=line)
p - p + stat_summary(fun.data=mean_cl_normal,conf.int = .99, geom=errorbar, 
width=0.2)


Thanks,
Mohan

-Original Message-
From: Radhakrishnan, Mohan (Cognizant)
Sent: Wednesday, June 17, 2015 12:54 PM
To: 'Dennis Murphy'
Cc: r-help@r-project.org
Subject: RE: [R] Error bars and CI

Your sample code is working. But I am missing the logic when my dataset is 
involved.

My full dataset is this. It is the V1 column I am interested in.  I am not 
'grouping' here.

  V1 IDX
1  0.796   1
2  0.542   2
3  0.510   3
4  0.617   4
5  0.482   5
6  0.387   6
7  0.272   7
8  0.536   8
9  0.498   9
10 0.402  10
11 0.328  11
12 0.542  12
13 0.299  13
14 0.647  14
15 0.291  15
16 0.815  16
17 0.680  17
18 0.363  18
19 0.560  19
20 0.334  20

Thanks,
Mohan

-Original Message-
From: Dennis Murphy [mailto:djmu...@gmail.com]
Sent: Tuesday, June 16, 2015 1:18 AM
To: Radhakrishnan, Mohan (Cognizant)
Subject: Re: [R] Error bars and CI

Hi:

Firstly, your dplyr code to generate the summary data frame is unnecessary and 
distracting, particularly since you didn't provide the input data set; you are 
asked to provide a *minimal* reproducible example, which you could easily have 
done with a built-in data set.
That said, to get what I perceive you want, I used the InsectSprays data from 
the autoloaded datasets package.

# Function to compute standard error of a mean sem - function(x) 
sqrt(var(x)/length(x))

## Use insectSprays data for illustration ## Compute mean and SE of count for 
each level of spray

library(dplyr)
library(ggplot2)

insectSumm - InsectSprays %%
  group_by(spray) %%
  summarise(mean = mean(count), se = sem(count))


# Since the x-variable is a factor, need to map group = 1 to # draw lines 
between factor levels. geom_pointrange() can be # used to produce the 99% CIs 
per factor level, geom_errorbar() # for the mean +/- SE. I ordered the geoms so 
that the errorbar # is last, but if you want it (mostly) overwritten, put the # 
geom_pointrange() call last.

ggplot(insectSumm, aes(x = spray, y = mean)) +
   theme_bw() +
   geom_line(aes(group = 1), size = 1, color = darkorange) +
   geom_pointrange(aes(ymin = mean - qt(.995, 11) * se,
  ymax = mean + qt(.995, 11) * se),
   size = 1.5, color = firebrick) +
   geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2,
   size = 1)

Clearly, you can pipe all the way through the ggplot() call, but I wanted to 
check the contents of the summary data frame first.

Dennis

On Mon, Jun 15, 2015 at 3:51 AM,  mohan.radhakrish...@cognizant.com wrote:
 Hi,

 I want to plot a line graph using this data. IDX is x-axis and V1 is y-axis.  
 I also want standard error bars and 99% CI to be shown. My code is given 
 below. The section that plots the graph is the problem.  I don't see all the 
 points in the line graph with error bars. How can I also show the 99% CI in 
 the graph ?

   V1 IDX
 1  0.987  21
 2  0.585  22
 3  0.770  23
 4  0.711  24

 library(stringr)
 library(dplyr)
 library(ggplot2)

 data - read.table(D:\\jmh\\jmh.txt,sep=\t)

 final -data %%
select(V1) %%
   filter(grepl(^Iteration, V1)) %%
 mutate(V1 = str_extract(V1, \\d+\\.\\d*))

 final - mutate(final,IDX = 1:n())

 jc - final %%
   filter(IDX  21)


 #Convert to numeric
 jc - data.frame(sapply(jc, function(x) as.numeric(as.character(x

 print(jc)

 # The following section is the problem.

 sem - function(x){
sd(x)/sqrt(length(x))
 }

 meanvalue - apply(jc,2,mean)
 semvalue - apply(jc, 2, sem)

 mean_sem - data.frame(mean= meanvalue, sem= semvalue,
 group=names(jc))

 #larger font
 theme_set(theme_gray(base_size = 20))

 #plot using ggplot
 p - ggplot(mean_sem, aes(x=group, y=mean)) +
   geom_line(stat='identity') +
   geom_errorbar(aes(ymin=mean-sem, ymax=mean+sem),
width=.2)
 print(p)

 Thanks,
 Mohan
 This e-mail and any files transmitted with it are for the sole use of the 
 intended recipient(s) and may contain confidential and privileged 
 information. If you are not the intended recipient(s), please reply to the 
 sender and destroy all copies of the original message. Any unauthorized 
 review, use, disclosure, dissemination, forwarding, printing or copying of 
 this email, and/or any action taken in reliance on the contents of this 
 e-mail is strictly prohibited and may be unlawful. Where permitted by 
 applicable law, this e-mail and other e-mail communications sent to and from 
 Cognizant e-mail addresses may be monitored.

 [[alternative HTML version deleted]]

 

[R] how to call rbind using arguments from a list

2015-06-17 Thread Matteo
Hello R users,

I am trying to run the command rbind gathering the name of tables to bind
from a list argument.

Unfortunately I am not able to obtain it.

I would appreciate any suggestions.  Below is a reproducible example with
the problem.

Thanks

Matteo

 

##

ZA-data.frame(x = 1:2, y = 1:10,z=letters[1:5])

ZB-data.frame(x = 1, y = 5:24,z=letters[2])

a-as.list(ls(pattern= ^Z?));a

#

I_would_like_ZC-rbind(ZA,ZB)  # this is what I would like to have

#

b-(paste(a, collapse = ','))

call(rbind,(b)) # I am not able to remove 

b-noquote(paste(a, collapse = ','))

call(rbind,(b)) # I am not able to remove  


[[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] how to call rbind using arguments from a list

2015-06-17 Thread Bert Gunter
1.  It should be:

a-as.list(ls(pattern= ^Z.))

to get Z at the beginning and 1 further character.

2. Use do.call() instead of call(). The latter does not evaluate the call;
the former does.

3. But most important,  the args argument of do.call() must be a list of
names, not character strings. This can be obtained using as.name().

This can all be effected by:

a-as.list(ls(pattern= ^Z.))
do.call(rbind,lapply(a,as.name))


-- and please post in plain text, not HTML, as HTML often gets mangled when
reproduced on this plain text list.



Cheers,
Bert

Bert Gunter

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

On Wed, Jun 17, 2015 at 2:58 AM, Matteo mmur...@tiscali.it wrote:

 Hello R users,

 I am trying to run the command rbind gathering the name of tables to bind
 from a list argument.

 Unfortunately I am not able to obtain it.

 I would appreciate any suggestions.  Below is a reproducible example with
 the problem.

 Thanks

 Matteo



 ##

 ZA-data.frame(x = 1:2, y = 1:10,z=letters[1:5])

 ZB-data.frame(x = 1, y = 5:24,z=letters[2])

 a-as.list(ls(pattern= ^Z?));a

 #

 I_would_like_ZC-rbind(ZA,ZB)  # this is what I would like to have

 #

 b-(paste(a, collapse = ','))

 call(rbind,(b)) # I am not able to remove 

 b-noquote(paste(a, collapse = ','))

 call(rbind,(b)) # I am not able to remove  


 [[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-es] Regresión logística

2015-06-17 Thread MªLuz Morales
Gracias Freddy, aumentar el número máximo de iteraciones ha funcionado...
Eric, una pequeña muestra de mis datos sería esta,
 In.hospital_death GCS BUN  0 15 10,5  0 15 18  0 5 3  0 15 20  0 15 35  0 9
16,5  0 15 31,5  1 10 59  0 15 22  0 15 19  0 15 56  0 15 9  0 15 17  0 15
85  0 15 42  0 15 18  0 12,5 35  0 15 31  0 11 17  0 15 10  1 15 6  0 15
15,5  0 15 29,5  0 15 55  0 NA 9  0 15 23,5  1 7 22  0 8 24
Donde DatosGLM sería lo anterior definido como data.table,
Este código ya funionaría:
 library(data.table)
GLM - bigglm(In.hospital_death ~ GCS + BUN, data = DatosGLM, family =
binomial(logit), maxit=1000)​.

Ultimamente he descubierto el interfaz gráfico  Rcommander es muy util para
trabajar con los que no estamos muy sueltos con R, para hacer entre otras
cosas, regresiones logísticas. Te permite importar datos directamente entre
otros, desde excel. Yo me lo he instalado pero no me aparece esa opción, no
parece que sea por el sistema operativo (windows 8), porque he probado
sobre windows 7 y me ocurre lo mismo. Alguien sabe cual es el problema???

Gracias (aunque quizá esta pregunta debería haberla puesto como otra
distinta en el foro,
Un saludo
MªLuz

El 16 de junio de 2015, 21:27, eric ericconchamu...@gmail.com escribió:

 MaLuz, podrias adjuntar los datos o una direccion de donde descargarlos
 para ejecutar tu codigo  y replicar el problema ? justo estoy trabajando en
 unas regresiones logisticas y quiza podria darte una mano.

 Saludos, eric.




 On 16/06/15 05:01, MªLuz Morales wrote:

 Gracias!

 El 15 de junio de 2015, 16:54, Freddy Omar López Quintero 
 freddy.vat...@gmail.com escribió:

  ​Holap.​
 
  ran out of iterations and failed to converge
 
 
  ​Prueba aumentando el número de iteraciones, con el argumento maxit:
 
  ​GLM - bigglm(In.hospital_death ~ GCS + BUN, data = DatosGLM, family =
  binomial(logit), maxit=1000)​
 
 
  ​Salud.​
 
  --
  «No soy aquellas sombras tutelares
  que honré con versos que no olvida el tiempo.»
 
  JL Borges
 

 [[alternative HTML version deleted]]

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



[[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] Merra hourly data

2015-06-17 Thread Alemu Tadesse
I am wondering if any has a script to download hourly Merra data (I am
interested in wind speed and temperature)

Thank you for your help

AT

[[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] Problemas al cargar Rcomander en consola de Rstudio

2015-06-17 Thread Freddy Omar López Quintero
Holap.

Loading required package: splinesLoading required package:
 RcmdrMiscLoading required package: carLoading required package:
 sandwichError : .onLoad failed in loadNamespace() for 'Rcmdr',
 details:
   call: structure(.External(.C_dotTclObjv, objv), class = tclObj)
   error: [tcl] invalid command name tk_messageBox.
 In addition: Warning message:In fun(libname, pkgname) : couldn't
 connect to display :0Error: package or namespace load failed for
 ‘Rcmdr’


Quizás peco de ingenuo pero: ¿has verificado que car y sandwich estén
instalados?

[[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] problem in function specieslevel of bipartite

2015-06-17 Thread Bernardo Santos
Dear all,
I have data for an bipartite mutualistic interaction network and I am trying to 
generate network metrics for this data set.
All metrics could be calculated correctly. However, when trying to run 
specieslevel function of the package bipartite, I have the following problem:
xx - specieslevel(matt)
Erro em data.frame(degree = c(16, 11, 6, 5, 6, 4, 5, 4, 2, 5, 7, 4, 4,  : 
  string multibyte inválida 4
orxx - specieslevel(matt, index=species strength)
Erro em data.frame(`species strength` = c(8.60588008182592, 3.82680284670328,  
: 
  string multibyte inválida 4
Do you have a clue on what may be the problem?
Thanks in advance!Best,Bernardo Niebuhr


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