Re: [R] sd, mean with a frequency distribution matrix

2015-02-16 Thread JS Huang
Hi,

  For the second one,
sqrt((sum(p[,1]^2*p[,2])-(sum(p[,1]*p[,2]))^2/sum(p[,2]))/(sum(p[,2])-1)),
please refer to the following link for an example to explain how it works.

http://www.lboro.ac.uk/media/wwwlboroacuk/content/mlsc/downloads/var_stand_deviat_group.pdf

  For the first one:
sd(unlist(sapply(1:dim(p)[1],function(i)rep(p[i,1],p[i,2].\:

sapply(1:dim(p)[1],function(i)rep(p[i,1],p[i,2])) to get all in the first
column of the matrix repeated the number of times in the second column.

After that, make the resulting list to become a vector so that it can be
executed with sd function.

  Here is some illustrative example.
 p
 [,1] [,2]
[1,]   103
[2,]   204
[3,]   305
 sapply(1:dim(p)[1],function(i)rep(p[i,1],p[i,2]))
[[1]]
[1] 10 10 10

[[2]]
[1] 20 20 20 20

[[3]]
[1] 30 30 30 30 30
 unlist(sapply(1:dim(p)[1],function(i)rep(p[i,1],p[i,2])))
 [1] 10 10 10 20 20 20 20 30 30 30 30 30
 sd(unlist(sapply(1:dim(p)[1],function(i)rep(p[i,1],p[i,2]
[1] 8.348471




--
View this message in context: 
http://r.789695.n4.nabble.com/sd-mean-with-a-frequency-distribution-matrix-tp4703218p4703338.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] Loop over regression results

2015-02-16 Thread Thierry Onkelinx
Or even easier is you use lmList() from the nlme package

library(nlme)
data(iris)
regression.list - lmList(Sepal.Width ~ Petal.Width | Species, data = iris)
summary(regression.list)
coef(regression.list)


Best regards,

Thierry

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

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

2015-02-16 16:17 GMT+01:00 David L Carlson dcarl...@tamu.edu:

 Or for the slopes and t-values:

  do.call(rbind, lapply(mod, function(x) summary(x)[[coefficients]][2,]))
 Estimate Std. Error  t value Pr(|t|)
 setosa 0.8371922  0.5049134 1.658091 1.038211e-01
 versicolor 1.0536478  0.1712595 6.152348 1.41e-07
 virginica  0.6314052  0.1428938 4.418702 5.647610e-05

 David C

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L
 Carlson
 Sent: Monday, February 16, 2015 8:52 AM
 To: Ronald Kölpin; r-help@r-project.org
 Subject: Re: [R] Loop over regression results

 In R you would want to combine the results into a list. This could be done
 when you create the regressions or afterwards. To repeat your example using
 a list:

 data(iris)
 taxon - levels(iris$Species)
 mod - lapply(taxon, function (x) lm(Sepal.Width ~ Petal.Width,
 data=iris, subset=Species==x))
 names(mod) - taxon
 lapply(mod, summary)
 coeffs - do.call(rbind, lapply(mod, coef, [1))
 coeffs
 # (Intercept) Petal.Width
 # setosa3.222051   0.8371922
 # versicolor1.372863   1.0536478
 # virginica 1.694773   0.6314052

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




 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ronald
 Kölpin
 Sent: Monday, February 16, 2015 7:37 AM
 To: r-help@r-project.org
 Subject: [R] Loop over regression results

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Dear all,

 I have a problem when trying to present the results of several
 regression. Say I have run several regressions on a dataset and saved
 the different results (as in the mini example below). I then want to
 loop over the regression results in order so save certain values to a
 matrix (in order to put them into a paper or presentation).

 Aside from the question of how to access certain information stored by
 lm() (or printed by summary()) I can't seem to so loop over lm()
 objects -- no matter whether they are stored in a vector or a list.
 They are always evaluated immediately when called. I tried quote() or
 substitute() but that didn't work either as Objects of type 'symbol'
 cannot be indexed.

 In Stata I would simply do something like

 forvalues k = 1/3 {
  quietly estimates restore mod`k'
 // [...]
 }

 and I am looking for the R equivalent of that syntax.

 Kind regard and thanks

 RK


 attach(iris)
 mod1 - lm(Sepal.Width ~ Petal.Width, data=iris, subset=Species==setosa)
 mod2 - lm(Sepal.Width ~ Petal.Width, data=iris,
 subset=Species==versicolor)
 mod3 - lm(Sepal.Width ~ Petal.Width, data=iris,
 subset=Species==virginica)

 summary(mod1); summary(mod2); summary(mod3)

 mat - matrix(data=NA, nrow=3, ncol=5,
   dimnames=list(1:3, c(Model, Intercept, p(T  |T|),
 Slope, R^2)))

 mods - c(mod1, mod2, mod3)

 for(k in 1:3)
 {
 mod - mods[k]
 mat[2,k] - as.numeric(coef(mod))[1]
 mat[3,k] - as.numeric(coef(mod))[1]
 }
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1

 iQEcBAEBAgAGBQJU4fJnAAoJEKdHe5EUSrVeafwIALerOj+rsZTnbSKOUX6vYpr4
 Uqsx0X2g+IgJw0KLdyqnlDmOut4wW6sWExtVgiugo/bkN8g5rDotGAl06d0UYRQV
 17aLQqQjI6EGXKV9swwlm2DBphtXCIYUCXnDWUoG4Y2wC/4hDnaLbZ9yJFF1GSjn
 +aN/PFf1mPPZLvF1NgMmzLdszP76VYzEgcOcEUfbmB7RU/2WEBLeBYJ8+FD1utPJ
 cnh03rSc/0dgvphP8FO47Nj7mbqqhKL76a9oQqJSJiZJoCFCGiDIIgzq7vwGWc4T
 9apwC/R3ahciB18yYOSMq7ZkVdQ+OpsqDTodnnIIUZjrVIcn9AI+GE0eq1VdLSE=
 =x+gM
 -END PGP SIGNATURE-

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

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

Re: [R] list of list

2015-02-16 Thread peter dalgaard

On 16 Feb 2015, at 17:43 , Troels Ring tr...@gvdnet.dk wrote:

 Dear friends - this is simple I know but I can figure it out without your 
 help.
 I have for each of 2195 instances 10 variables measured at specific times 
 from 6 to several hundred, so if I just take one of the instances, I can make 
 a list of the 10 variables together with their variable times. But when I 
 have 2195 such instances I cannot get it how to make a list of these 
 individual lists
 
 As a toy example demonstrating mercilessly my problem, if ASL[j] is mean to 
 take the list of here 5 entries made in RES[[i]] and I write this (ignoring 
 the times) it certainly doesn't work
 ASL - list()
 RES - list()
 for (j in 1:5){
 for (i in 1:5)
 ASL[[j]] -
 RES[[i]] - i^j }

Your description doesn't quite make sense to me, but if you really want ASL to 
be a list of lists, you want each member to be a list and the (i,j)th item 
accessed as ASL[[i]][[j]]. So I'd expect to see something like

for (j  {
ASL[[j]] - list()
for (i 
ASL[[j]][[|]] - 
}

You also really don't want to start with an empty list and extend it on every 
iteration. If you need an n-element list, preallocate it using vector(n, 
mode=list).

If the above doesn't make sense, rephrase the question


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

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


Re: [R] ggplot2 shifting bars to only overlap in groups

2015-02-16 Thread Hörmetjan Yiltiz
Again, I come to think about violin plots which is more informative than
the error bars. But for some reason, the violin in the *west* became way
too slimmer than the *east* one, though the density plot tells me that is
not necessarily the case. I am still trying to figure that out, and that
would be even more irrelevant as long as *shifting bars in gorups*. So
maybe I will come up with another post later when I got the solution.

祝好,

He who is worthy to receive his days and nights is worthy to receive* all
else* from you (and me).
 The Prophet, Gibran Kahlil


On Mon, Feb 16, 2015 at 9:59 PM, John Kane jrkrid...@inbox.com wrote:

 Lovely, a much more elegant solution.

 John Kane
 Kingston ON Canada

 -Original Message-
 From: hyil...@gmail.com
 Sent: Mon, 16 Feb 2015 02:30:09 +0800
 To: jrkrid...@inbox.com, djmu...@gmail.com
 Subject: Re: [R] ggplot2 shifting bars to only overlap in groups

 Thanks so much, John and Dennis (who did not respond in the mailing list
 for some reason). I feel quite obliged to keep you thinking about this.

 I do agree that not using the bar chart with error bars is a better
 option. And since *condition* is an important ordinal factor for me, it
 would be much better to have *condition* be positioned at a relative order.
 Thus, only color coding it as John's latest solution would not be optimal.

 It would have been better with the random data, but with my actual data,
 it does seem necessary to do a jitter for the *male* since it got clattered
 in the *west*. Here is the actual data along with the solution based on
 Dennis' code:

 ## data

 dat1 -  structure(list(t = c(1.2454860689532, 0.627186899108052,
 0.877176019393987,

1.26720638917869, 1.16906482219006,
 0.889738853288831, 0.852034797572489,

1.30007600828822, 1.22896141479778,
 0.820236562746995, 0.822197641624559,

1.39529772379005, 1.10479557445486,
 0.760017179713665, 0.761340230517717,

1.11132156961026, 1.30042963441715,
 0.811425854755042, 0.979421690403349,

1.3297658281305, 1.13377482477157,
 0.895243910826397, 0.874181486658082,

1.15728885642541, 1.11121780853125,
 0.703348405369258, 0.850897112058048,

1.14260584106012, 1.09383015337114,
 0.911388765620587, 0.84622335453925,

1.09847968194129), condition = structure(c(4L, 4L,
 4L, 4L, 1L,

   1L, 1L,
 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L,

   1L, 1L,
 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), .Label = c(c1,

   c2,
 c2, c4), class = factor), direction = structure(c(1L,

1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L,
 2L, 2L, 1L,

1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L,
 2L, 2L), .Label = c(up,

down), class = factor), location =
 structure(c(2L, 1L, 2L,

   1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,

   1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c(east,

   west), class = factor), gender = structure(c(2L, 2L, 2L,

   2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,

   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(male,

   female), class = factor), ci = c(0.0307396796826649,
 0.0302954863637637,

 0.0400142340797275, 0.0527186825100342, 0.051675810189946,
 0.0368383294010065,

 0.0404823188495183, 0.0526312391852324, 0.0347332720922338,
 0.0354587857740343,

 0.0303368490163547, 0.0710445198259065, 0.0229339653012889,
 0.0261217906562281,

 0.0285673216713352, 0.0351642108247828, 0.0542657646932069,
 0.0566816739316165,

 0.0481239729953889, 0.0434272572423839, 0.0497366325101659,
 0.0342004255233646,

 0.0349733697554762, 0.0405364256564456, 0.0478372176424872,
 0.0341294939361437,

 0.0424566961614424, 0.0463489561778199, 0.0191707406475215,
 0.0501106812754005,

 0.0321562411182704, 0.0218613299095178)), .Names = c(t, condition,

 direction, location, gender, ci), row.names = c(NA, -32L

 ), class = data.frame)

 pp - ggplot(dat1, aes(x = condition, y = t, color = gender, linetype =
 direction)) +

   geom_errorbar(aes(ymin = t - ci, ymax = t + ci),

 position = position_dodge(width = 0.6), size = 1,

 width = 0.5) +

   geom_point(position = position_dodge(width = 0.6), size = 2.5) +

   facet_wrap(~ location) +

   scale_color_manual(values = c(blue, darkorange))+

   theme_bw()+

   scale_y_continuous(breaks=seq(0.6,1.5,0.1))

 pp

 ## EOF

 I have also attached the output.

  Best
 ,
 
 He who is worthy to receive his days and nights is worthy to receive* all
 

Re: [R] list of list

2015-02-16 Thread Jeff Newmiller
You have two named objects when your goal is to have one that contains five 
others.

ASL - vector( list, 5 )
for (j in 1:5){
  ASL[[j]] - vector( list, 5 )
  for (i in 1:5) {
ASL[[j]][[i]] - i^j 
  }
}

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

On February 16, 2015 8:43:51 AM PST, Troels Ring tr...@gvdnet.dk wrote:
Dear friends - this is simple I know but I can figure it out without 
your help.
I have for each of 2195 instances 10 variables measured at specific 
times from 6 to several hundred, so if I just take one of the
instances, 
I can make a list of the 10 variables together with their variable 
times. But when I have 2195 such instances I cannot get it how to make
a 
list of these individual lists

As a toy example demonstrating mercilessly my problem, if ASL[j] is
mean 
to take the list of here 5 entries made in RES[[i]] and I write this 
(ignoring the times) it certainly doesn't work
ASL - list()
RES - list()
for (j in 1:5){
for (i in 1:5)
ASL[[j]] -
  RES[[i]] - i^j }

All best wishes
Troels Ring
Aalborg, Denmark

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

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


[R] list of list

2015-02-16 Thread Troels Ring
Dear friends - this is simple I know but I can figure it out without 
your help.
I have for each of 2195 instances 10 variables measured at specific 
times from 6 to several hundred, so if I just take one of the instances, 
I can make a list of the 10 variables together with their variable 
times. But when I have 2195 such instances I cannot get it how to make a 
list of these individual lists


As a toy example demonstrating mercilessly my problem, if ASL[j] is mean 
to take the list of here 5 entries made in RES[[i]] and I write this 
(ignoring the times) it certainly doesn't work

ASL - list()
RES - list()
for (j in 1:5){
for (i in 1:5)
ASL[[j]] -
 RES[[i]] - i^j }

All best wishes
Troels Ring
Aalborg, Denmark

__
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] list of list

2015-02-16 Thread jim holtman
Is this what you mean:

ASL - list()
for (j in 1:5){
RES - list()
for (i in 1:5) RES[[i]] - i ^ j  # create list
ASL[[j]] - RES  # store 'list of list'
}


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Mon, Feb 16, 2015 at 11:43 AM, Troels Ring tr...@gvdnet.dk wrote:

 Dear friends - this is simple I know but I can figure it out without your
 help.
 I have for each of 2195 instances 10 variables measured at specific times
 from 6 to several hundred, so if I just take one of the instances, I can
 make a list of the 10 variables together with their variable times. But
 when I have 2195 such instances I cannot get it how to make a list of these
 individual lists

 As a toy example demonstrating mercilessly my problem, if ASL[j] is mean
 to take the list of here 5 entries made in RES[[i]] and I write this
 (ignoring the times) it certainly doesn't work
 ASL - list()
 RES - list()
 for (j in 1:5){
 for (i in 1:5)
 ASL[[j]] -
  RES[[i]] - i^j }

 All best wishes
 Troels Ring
 Aalborg, Denmark

 __
 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] P-value from Matching

2015-02-16 Thread Rob Wood
Hi Peter,

That was my first port of call before I posted this thread. Unfortunately,
it does not seem to explicitly state which test is used or how the p-value
is calculated.

Thanks,

Rob.



--
View this message in context: 
http://r.789695.n4.nabble.com/P-value-from-Matching-tp4703309p4703345.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] Comparing gam models fitted using ti()

2015-02-16 Thread Bert Gunter
I wonder if this might be better asked on a statistical list -- e.g.
stats.stackexchange.com
 -- as this seems to involve complex statistical model comparison
issues, which are normally OT here.

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Mon, Feb 16, 2015 at 10:13 AM, Arnaud Mosnier a.mosn...@gmail.com wrote:
 Dear R-Help list,

 I want to compare gam models including interaction with simpler models.
 For interaction models, I used gam(Y~ti(X1) + ti(X2) + ti(X1,X2))
 removing the interaction, the models end as Y~ti(X1) + ti(X2)

 How those models compare with models with the form Y ~ s(X1) + s(X2)

 In my case, the former (i.e. ti() ) have a better AIC value than those with
 s().

 Should I keep the ti() form or use only the s() form when I have no
 interaction ?

 Thanks for your help !

 Arnaud

 [[alternative HTML version deleted]]

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

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


[R] Comparing gam models fitted using ti()

2015-02-16 Thread Arnaud Mosnier
Dear R-Help list,

I want to compare gam models including interaction with simpler models.
For interaction models, I used gam(Y~ti(X1) + ti(X2) + ti(X1,X2))
removing the interaction, the models end as Y~ti(X1) + ti(X2)

How those models compare with models with the form Y ~ s(X1) + s(X2)

In my case, the former (i.e. ti() ) have a better AIC value than those with
s().

Should I keep the ti() form or use only the s() form when I have no
interaction ?

Thanks for your help !

Arnaud

[[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] list of list

2015-02-16 Thread Troels Ring

Thanks to Jim, Peter and Jeff who all saw the solution!
Best wishes
Troels

Den 16-02-2015 kl. 18:46 skrev Jeff Newmiller:

You have two named objects when your goal is to have one that contains five 
others.

ASL - vector( list, 5 )
for (j in 1:5){
   ASL[[j]] - vector( list, 5 )
   for (i in 1:5) {
 ASL[[j]][[i]] - i^j
   }
}

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

On February 16, 2015 8:43:51 AM PST, Troels Ring tr...@gvdnet.dk wrote:

Dear friends - this is simple I know but I can figure it out without
your help.
I have for each of 2195 instances 10 variables measured at specific
times from 6 to several hundred, so if I just take one of the
instances,
I can make a list of the 10 variables together with their variable
times. But when I have 2195 such instances I cannot get it how to make
a
list of these individual lists

As a toy example demonstrating mercilessly my problem, if ASL[j] is
mean
to take the list of here 5 entries made in RES[[i]] and I write this
(ignoring the times) it certainly doesn't work
ASL - list()
RES - list()
for (j in 1:5){
for (i in 1:5)
ASL[[j]] -
  RES[[i]] - i^j }

All best wishes
Troels Ring
Aalborg, Denmark

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

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



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


Re: [R] list of list

2015-02-16 Thread William Dunlap
You can let lapply() do the preallocation and the looping for you with

   ASL - lapply(1:5, function(j) lapply(1:5, function(i) i^j))

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Feb 16, 2015 at 9:46 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us
wrote:

 You have two named objects when your goal is to have one that contains
 five others.

 ASL - vector( list, 5 )
 for (j in 1:5){
   ASL[[j]] - vector( list, 5 )
   for (i in 1:5) {
 ASL[[j]][[i]] - i^j
   }
 }

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

 On February 16, 2015 8:43:51 AM PST, Troels Ring tr...@gvdnet.dk wrote:
 Dear friends - this is simple I know but I can figure it out without
 your help.
 I have for each of 2195 instances 10 variables measured at specific
 times from 6 to several hundred, so if I just take one of the
 instances,
 I can make a list of the 10 variables together with their variable
 times. But when I have 2195 such instances I cannot get it how to make
 a
 list of these individual lists
 
 As a toy example demonstrating mercilessly my problem, if ASL[j] is
 mean
 to take the list of here 5 entries made in RES[[i]] and I write this
 (ignoring the times) it certainly doesn't work
 ASL - list()
 RES - list()
 for (j in 1:5){
 for (i in 1:5)
 ASL[[j]] -
   RES[[i]] - i^j }
 
 All best wishes
 Troels Ring
 Aalborg, Denmark
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[[alternative HTML version deleted]]

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


[R] plm function plm r.squared error

2015-02-16 Thread fay constanze
 
DearGiovanni,Congratulationsfor the truly helpful plm package! Being new to R, 
I have a problem with the plm function for financial markets timeseries data: 
After having defined a large, unbalanced panel pdata.frame 
(https://www.dropbox.com/s/2r9t1cu9v65gobk/Database_CN_2004.csv?dl=0)and 
running a simple OLS model of two variables regressing company returns(Perf) on 
index returns (PerfIn)synch -plm (Perf ~ PerfIn , data=pCN04, na.action = 
na.omit, index=c(Unit, Week), model=pooling) I keepreceiving the 
following error:Error in model.matrix.pFormula(formula, data, rhs =1, model = 
model,  :   NA in theindividual index variableIn addition:Warning message:In 
`[.data.frame`(index, as.numeric(rownames(mf)),) :  NAsintroduced by coercion
There aremuch more NAs in y (Perf) than in x (PerfIn) and I have tried to get 
rid ofthem with na.omit. Another error I have is with the same model for the 
r.squaredfunction r.squared(pCN04,model=NULL, Perf ~ PerfIn, type= ess)Error 
in tss.default(object, model = model) :   unused argument (model = model)In 
addition: Warning message:In mean.default(haty) : argument is not numeric or 
logical: returning NAMany thanks in advance,your help is very precious to 
me!Constanze



[[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] consultas formularios web

2015-02-16 Thread javier.ruben.marcuzzi




Estimado Carlos Ortega


Gracias, lo voy a mirar, estaba casi seguro que en el grupo esto se había 
tratado.


Javier Marcuzzi





De: Carlos Ortega
Enviado el: ‎lunes‎, ‎16‎ de ‎febrero‎ de ‎2015 ‎06‎:‎59‎ ‎p.m.
Para: Javier Ruben Marcuzzi
CC: R-help-es@r-project.org






Hola,



Tienes una presentación sobre esto que hizo Gregorio Serrano en el Grupo de 
Madrid:
http://madrid.r-es.org/martes-20-mayo-de-2014/
Webscrapping with el paquete Relenium





Y otra alternativa es utilizar RSelenium:
http://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-basics.html





Saludos,
Carlos Ortega
www.qualityexcellence.es




El 16 de febrero de 2015, 20:13, javier.ruben.marcu...@gmail.com escribió:

Estimados


Les consulto por lo siguiente, incluso creo que de esto se habló en una 
oportunidad en esta lista, por ese motivo cualquier sugerencia es bienvenida.


Hay algo de información que me hace falta para un trabajo, pero esta no es de 
una única fuente, y desconozco si brindan los registros, pero lo que es 
accesible son los sitios web donde estas fuentes publican un formulario HTML 
simple, la respuesta es otro HTML simple, luego puede ser otro HTML simple con 
algunas tablas. Es decir, algo de información hay pero necesita de trabajo, 
nada que un script y consultas automatizadas junto a una base de datos y un 
excelente diseño no pueda lograr.


Una alternativa podría ser el siguiente paquete 
http://cran.r-project.org/web/packages/httr/index.html (como otros tanto que 
tendría que estudiar), o simplemente curl, tengo que organizar desde el inicio.



¿Alguna sugerencia o recomendación?​


Recuerdo que yo mismo participe en debates sobre como tomar información desde 
internet a R, pero como hace un tiempo no uso esa tecnología, puedo estar muy 
desactualizado.


Javier Marcuzzi
[[alternative HTML version deleted]]

___
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] consultas formularios web

2015-02-16 Thread Carlos Ortega
Hola,

Tienes una presentación sobre esto que hizo Gregorio Serrano en el Grupo de
Madrid:
http://madrid.r-es.org/martes-20-mayo-de-2014/
Webscrapping with el paquete Relenium

Y otra alternativa es utilizar RSelenium:
http://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-basics.html

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 16 de febrero de 2015, 20:13, javier.ruben.marcu...@gmail.com escribió:

 Estimados


 Les consulto por lo siguiente, incluso creo que de esto se habló en una
 oportunidad en esta lista, por ese motivo cualquier sugerencia es
 bienvenida.


 Hay algo de información que me hace falta para un trabajo, pero esta no es
 de una única fuente, y desconozco si brindan los registros, pero lo que es
 accesible son los sitios web donde estas fuentes publican un formulario
 HTML simple, la respuesta es otro HTML simple, luego puede ser otro HTML
 simple con algunas tablas. Es decir, algo de información hay pero necesita
 de trabajo, nada que un script y consultas automatizadas junto a una base
 de datos y un excelente diseño no pueda lograr.


 Una alternativa podría ser el siguiente paquete
 http://cran.r-project.org/web/packages/httr/index.html (como otros tanto
 que tendría que estudiar), o simplemente curl, tengo que organizar desde el
 inicio.



 ¿Alguna sugerencia o recomendación?​


 Recuerdo que yo mismo participe en debates sobre como tomar información
 desde internet a R, pero como hace un tiempo no uso esa tecnología, puedo
 estar muy desactualizado.


 Javier Marcuzzi
 [[alternative HTML version deleted]]

 ___
 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] method of moments estimation

2015-02-16 Thread hms Dreams
Hi,
I'm trying to use method of moments estimation to estimate 3 unkown paramters 
delta,k and alpha.
so I had system of 3 non linear equations:
 
1)  [delta^(1/alpha) *gamma (k-(1/alpha)) ]/gamma(k) = xbar
2)  [delta^(2/alpha) *gamma (k-(2/alpha)) ]/gamma(k) = 1/n *sum (x^2)
3)   [delta^(3/alpha) *gamma (k-(3/alpha)) ]/gamma(k) = 1/n *sum (x^3)
where gamma is a gamma function and  n is the sample size 

 How can I solve these system , Is there a package on R can give me MOM ??
 
Thank you ,
Sara 

 
  
[[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] Fitting gamma distribution

2015-02-16 Thread Rolf Turner

On 17/02/15 12:59, smart hendsome wrote:

I'm very new to r-programming. I have rainfall data. I have tried to fit gamma 
into my data but there is error. Anyone can help me please.
My rainfall data as I uploaded. When I try run the coding:
library(MASS)

KLT1-read.csv('C:/Users/User/Dropbox/PhD 
Materials/Coding_PhD_Thesis/Kelantan_Average/K1.csv')

KLT-KLT1$Amount
fd_g - fitdistr(KLT, gamma)
Error in stats::optim(x = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  :
   initial value in 'vmmin' is not finite
Anyone can help me? Thanks.


No.  No one can help.  Not unless you provided a self-contained 
reproducible example as the posting guide requests.


cheers,

Rolf Turner

P. S. I am not sure, but the error may be indicating that your data
begin with a long string of zeros.  (In which case fitting a gamma 
distribution is simply idiotic.)  Rainfall data often contain many 
zeroes.  (There are, contrary to popular belief, many dry days.)


What you *may* want to fit is a mixture of a gamma distribution and a 
point-mass (atom) at 0.


R. T.

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

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


Re: [R] split dataframe to several dataframes in R

2015-02-16 Thread Aravind Jayaraman
Hi,

I think you need not split the data.frame to get the desired result.
You can work with your list lst4 itself.

#Convert the vectors in the list to data.frames.
lst4 - lapply(lst4, function(x) {as.data.frame(t(iris1.csv))})
#Get the data.frames in the list to the global environment
list2env(lst4 ,.GlobalEnv)

Regards

On 17 February 2015 at 09:23, Zilefac Elvis via R-help
r-help@r-project.org wrote:
 Hi All,I have a dataframe called 'means' as shown below:iris1.csv - iris
 iris2.csv - iris
 names - c(iris1.csv, iris2.csv)
 dat - mget(names)
 lst4 - lapply(dat, function(x) apply(x[,-5], 2, mean))

 # Build the new data frame
 means - as.data.frame(do.call(rbind, lst4))
 means$source - names(lst4)
 means
 #   Sepal.Length Sepal.Width Petal.Length Petal.Width   isv
 source
 # iris1.csv 5.843.0573333.7581.199333 0.333 
 iris1.csv
 # iris2.csv 5.843.0573333.7581.199333 0.333 
 iris2.csvQUESTION: How can I split 'means' such that there are two files 
 (dataframes) on my workspace:datframe 1#   Sepal.Length Sepal.Width 
 Petal.Length Petal.Width   isv
 # iris1.csv 5.843.0573333.7581.199333 
 0.333dataframe 2:#   Sepal.Length Sepal.Width Petal.Length 
 Petal.Width   isv# iris2.csv 5.843.0573333.758
 1.199333 0.333
 Many thanks,Asong.
 [[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.



-- 
J.Aravind
Scientist
Germplasm Conservation Division
ICAR-National Bureau of Plant Genetic Resources
New Delhi - 110 012

__
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] compute values by condition in DF by rownames

2015-02-16 Thread JS Huang
Hi,

  I hope that someone can provide a better way to implement it.  This is my
implementation.

 data
  X2 gbm_tcga   lusc_tcga ucec_tcga_pub
1   gbm_tcga  1.0  0.14053719  -0.102847164
2   gbm_tcga  1.0  0.04413434   0.013568055
3   gbm_tcga  1.0 -0.20003971   0.038971817
4   gbm_tcga  1.0  0.14569916   0.009947045
5  lusc_tcga  0.140537191  1.   0.133080708
6  lusc_tcga  0.044134345  1.   0.062024713
7  lusc_tcga -0.200039712  1.  -0.130239551
8  lusc_tcga  0.145699156  1.   0.041796670
9  ucec_tcga_pub -0.102847164  0.13308071   1.0
10 ucec_tcga_pub  0.013568055  0.06202471   1.0
11 ucec_tcga_pub  0.038971817 -0.13023955   1.0
12 ucec_tcga_pub  0.009947045  0.04179667   1.0
 test
function(x)
{
  tempMatrix - matrix(0,nrow=3,ncol=3)
  lev - levels(x$X2)
  for (i in 1:length(lev))
  {
tempMatrix[i,1] = sum(ifelse(abs(x[x$X2==lev[i],2])0.2,1,0))
tempMatrix[i,2] = sum(ifelse(abs(x[x$X2==lev[i],3])0.2,1,0))
tempMatrix[i,3] = sum(ifelse(abs(x[x$X2==lev[i],4])0.2,1,0))
  }
  result - data.frame(lev,tempMatrix)
  names(result) - c(X2,gbm_tcga,lusc_tcga,tcga_pub)
  return(result)
}
 test(data)
 X2 gbm_tcga lusc_tcga tcga_pub
1  gbm_tcga4 10
2 lusc_tcga1 40
3 ucec_tcga_pub0 04
 



--
View this message in context: 
http://r.789695.n4.nabble.com/compute-values-by-condition-in-DF-by-rownames-tp4703351p4703374.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] split dataframe to several dataframes in R

2015-02-16 Thread js . huang
quote author='R help mailing list-2'
Hi All,I have a dataframe called 'means' as shown below:iris1.csv - iris
iris2.csv - iris
names - c(iris1.csv, iris2.csv)
dat - mget(names)
lst4 - lapply(dat, function(x) apply(x[,-5], 2, mean))

# Build the new data frame
means - as.data.frame(do.call(rbind, lst4))
means$source - names(lst4)
means
#   Sepal.Length Sepal.Width Petal.Length Petal.Width   isv   
source
# iris1.csv 5.843.0573333.7581.199333 0.333
iris1.csv
# iris2.csv 5.843.0573333.7581.199333 0.333
iris2.csvQUESTION: How can I split 'means' such that there are two files
(dataframes) on my workspace:datframe 1#   Sepal.Length Sepal.Width
Petal.Length Petal.Width   isv
# iris1.csv 5.843.0573333.7581.199333
0.333dataframe 2:#   Sepal.Length Sepal.Width Petal.Length
Petal.Width   isv# iris2.csv 5.843.0573333.758   
1.199333 0.333
Many thanks,Asong.
[[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.

/quote
Quoted from: 
http://r.789695.n4.nabble.com/split-dataframe-to-several-dataframes-in-R-tp4703372.html


_
Sent from http://r.789695.n4.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] Loop over regression results

2015-02-16 Thread Ronald Kölpin
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dear all,

I have a problem when trying to present the results of several
regression. Say I have run several regressions on a dataset and saved
the different results (as in the mini example below). I then want to
loop over the regression results in order so save certain values to a
matrix (in order to put them into a paper or presentation).

Aside from the question of how to access certain information stored by
lm() (or printed by summary()) I can't seem to so loop over lm()
objects -- no matter whether they are stored in a vector or a list.
They are always evaluated immediately when called. I tried quote() or
substitute() but that didn't work either as Objects of type 'symbol'
cannot be indexed.

In Stata I would simply do something like

forvalues k = 1/3 {
 quietly estimates restore mod`k'
// [...]
}

and I am looking for the R equivalent of that syntax.

Kind regard and thanks

RK


attach(iris)
mod1 - lm(Sepal.Width ~ Petal.Width, data=iris, subset=Species==setosa)
mod2 - lm(Sepal.Width ~ Petal.Width, data=iris,
subset=Species==versicolor)
mod3 - lm(Sepal.Width ~ Petal.Width, data=iris,
subset=Species==virginica)

summary(mod1); summary(mod2); summary(mod3)

mat - matrix(data=NA, nrow=3, ncol=5,
  dimnames=list(1:3, c(Model, Intercept, p(T  |T|),
Slope, R^2)))

mods - c(mod1, mod2, mod3)

for(k in 1:3)
{
mod - mods[k]
mat[2,k] - as.numeric(coef(mod))[1]
mat[3,k] - as.numeric(coef(mod))[1]
}
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJU4fJnAAoJEKdHe5EUSrVeafwIALerOj+rsZTnbSKOUX6vYpr4
Uqsx0X2g+IgJw0KLdyqnlDmOut4wW6sWExtVgiugo/bkN8g5rDotGAl06d0UYRQV
17aLQqQjI6EGXKV9swwlm2DBphtXCIYUCXnDWUoG4Y2wC/4hDnaLbZ9yJFF1GSjn
+aN/PFf1mPPZLvF1NgMmzLdszP76VYzEgcOcEUfbmB7RU/2WEBLeBYJ8+FD1utPJ
cnh03rSc/0dgvphP8FO47Nj7mbqqhKL76a9oQqJSJiZJoCFCGiDIIgzq7vwGWc4T
9apwC/R3ahciB18yYOSMq7ZkVdQ+OpsqDTodnnIIUZjrVIcn9AI+GE0eq1VdLSE=
=x+gM
-END PGP SIGNATURE-

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


Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread John Kane

You may have good reason to distrust the Excel solver :)

See below

John Kane
Kingston ON Canada


 -Original Message-
 From: rzw...@ets.org
 Sent: Sat, 14 Feb 2015 23:53:55 +
 To: r-help@r-project.org
 Subject: [R] Nonlinear integer programming (again)

 Oddly, Excel's Solver will produce a solution to such problems but (1) I
 don't trust it and (2) it cannot handle a large number of constraints.

From IIRC a discussion on the R-help list but which I forgot to save the link.

The idea that the Excel solver has a good reputation for being fast and 
accurate does not withstand an examination of the Excel solver's ability to 
solve the StRD nls test problems. Solver's ability is abysmal. 13 of 27 
answers have zero accurate digits, and three more have fewer than two 
accurate digits --and this is after tuning the solver to get a good answer.
...
Excel solver does have the virtue that it will always produce an answer, albeit 
one with zero accurate digits.
Bruce McCullough


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

__
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 do I provide path character string to extdata content?

2015-02-16 Thread Duncan Murdoch
On 16/02/2015 6:37 AM, Ulrike Grömping wrote:
 Dear helpeRs,
 
 I have some png files in the inst/extdata directory of a package (e.g.,
 man.png), and I want to provide character strings containing the paths to
 these files; of course, these path strings have to depend on the individual
 installation. So far, I have written a function that - if called - writes
 the correct strings to the global environment, but that is not CRAN
 compatible.

The system.file() function does this.  For example, if your package
named foo contains inst/fig/man.png, you would use
system.file(fig/man.png, package=foo).

 
 Ideally, I want the package namespace to export these text strings. I have
 played with .onLoad without luck. I do not have a good understanding of
 which hook is for which purpose. How can I go about this?

Rather than exporting the strings, it's easier to export a function that
produces the strings, e.g.

fig - function(name) system.file(file.path(fig, name), package=foo)

to be called as

fig(man.png)

Duncan Murdoch

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


Re: [R] Selection/filtering from Data

2015-02-16 Thread John Kane
? subset.  You have most of the command already written

John Kane
Kingston ON Canada


 -Original Message-
 From: pnsinh...@gmail.com
 Sent: Mon, 16 Feb 2015 13:31:33 +0530
 To: r-help@r-project.org
 Subject: [R] Selection/filtering from Data
 
 From a dataset , I want select age =36 and income1. How to do ?
 parth
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

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


Re: [R] P-value from Matching

2015-02-16 Thread peter dalgaard

On 16 Feb 2015, at 00:31 , Rob Wood robert.w...@adelphigroup.com wrote:

 Hi all,
 
 When using the match command from the matching package, the output reports
 the treatment effect, standard error, t-statistic and a p-value. Which test
 is used to generate this p-value, or how us it generated?
 


I would assume this information to be available via the references on the help 
page for Match() (sic) in the Matching (sic) package.

Peter D.

 Thanks,
 
 Rob.
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/P-value-from-Matching-tp4703309.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.

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

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


Re: [R] ggplot2 shifting bars to only overlap in groups

2015-02-16 Thread John Kane
Lovely, a much more elegant solution.  

John Kane
Kingston ON Canada

-Original Message-
From: hyil...@gmail.com
Sent: Mon, 16 Feb 2015 02:30:09 +0800
To: jrkrid...@inbox.com, djmu...@gmail.com
Subject: Re: [R] ggplot2 shifting bars to only overlap in groups

Thanks so much, John and Dennis (who did not respond in the mailing list for 
some reason). I feel quite obliged to keep you thinking about this. 

I do agree that not using the bar chart with error bars is a better option. And 
since *condition* is an important ordinal factor for me, it would be much 
better to have *condition* be positioned at a relative order. Thus, only color 
coding it as John's latest solution would not be optimal. 

It would have been better with the random data, but with my actual data, it 
does seem necessary to do a jitter for the *male* since it got clattered in the 
*west*. Here is the actual data along with the solution based on Dennis' code:

## data

dat1 -  structure(list(t = c(1.2454860689532, 0.627186899108052, 
0.877176019393987, 

                       1.26720638917869, 1.16906482219006, 0.889738853288831, 
0.852034797572489, 

                       1.30007600828822, 1.22896141479778, 0.820236562746995, 
0.822197641624559, 

                       1.39529772379005, 1.10479557445486, 0.760017179713665, 
0.761340230517717, 

                       1.11132156961026, 1.30042963441715, 0.811425854755042, 
0.979421690403349, 

                       1.3297658281305, 1.13377482477157, 0.895243910826397, 
0.874181486658082, 

                       1.15728885642541, 1.11121780853125, 0.703348405369258, 
0.850897112058048, 

                       1.14260584106012, 1.09383015337114, 0.911388765620587, 
0.84622335453925, 

                       1.09847968194129), condition = structure(c(4L, 4L, 4L, 
4L, 1L, 

                                                                  1L, 1L, 1L, 
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 

                                                                  1L, 1L, 1L, 
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), .Label = c(c1, 

                                                                  c2, c2, 
c4), class = factor), direction = structure(c(1L, 

                       1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 
2L, 1L, 

                       1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 
2L), .Label = c(up, 

                       down), class = factor), location = structure(c(2L, 
1L, 2L, 

  1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 

  1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c(east, 

  west), class = factor), gender = structure(c(2L, 2L, 2L, 

  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 

  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(male, 

  female), class = factor), ci = c(0.0307396796826649, 0.0302954863637637, 

0.0400142340797275, 0.0527186825100342, 0.051675810189946, 0.0368383294010065, 

0.0404823188495183, 0.0526312391852324, 0.0347332720922338, 0.0354587857740343, 

0.0303368490163547, 0.0710445198259065, 0.0229339653012889, 0.0261217906562281, 

0.0285673216713352, 0.0351642108247828, 0.0542657646932069, 0.0566816739316165, 

0.0481239729953889, 0.0434272572423839, 0.0497366325101659, 0.0342004255233646, 

0.0349733697554762, 0.0405364256564456, 0.0478372176424872, 0.0341294939361437, 

0.0424566961614424, 0.0463489561778199, 0.0191707406475215, 0.0501106812754005, 

0.0321562411182704, 0.0218613299095178)), .Names = c(t, condition, 

direction, location, gender, ci), row.names = c(NA, -32L

), class = data.frame)

pp - ggplot(dat1, aes(x = condition, y = t, color = gender, linetype = 
direction)) +

  geom_errorbar(aes(ymin = t - ci, ymax = t + ci),

                position = position_dodge(width = 0.6), size = 1,

                width = 0.5) +

  geom_point(position = position_dodge(width = 0.6), size = 2.5) +

  facet_wrap(~ location) +

  scale_color_manual(values = c(blue, darkorange))+

  theme_bw()+

  scale_y_continuous(breaks=seq(0.6,1.5,0.1))

pp

## EOF

I have also attached the output. 

 Best 
,

He who is worthy to receive his days and nights is worthy to receive* all 
else* from you (and me).
                                                 The Prophet, Gibran Kahlil


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
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] split dataframe to several dataframes in R

2015-02-16 Thread Zilefac Elvis via R-help
Hi All,I have a dataframe called 'means' as shown below:iris1.csv - iris
iris2.csv - iris
names - c(iris1.csv, iris2.csv)
dat - mget(names)
lst4 - lapply(dat, function(x) apply(x[,-5], 2, mean))

# Build the new data frame
means - as.data.frame(do.call(rbind, lst4))
means$source - names(lst4)
means
#   Sepal.Length Sepal.Width Petal.Length Petal.Width   isv
source
# iris1.csv 5.843.0573333.7581.199333 0.333 
iris1.csv
# iris2.csv 5.843.0573333.7581.199333 0.333 
iris2.csvQUESTION: How can I split 'means' such that there are two files 
(dataframes) on my workspace:datframe 1#   Sepal.Length Sepal.Width 
Petal.Length Petal.Width   isv
# iris1.csv 5.843.0573333.7581.199333 
0.333dataframe 2:#   Sepal.Length Sepal.Width Petal.Length 
Petal.Width   isv# iris2.csv 5.843.0573333.758
1.199333 0.333
Many thanks,Asong.
[[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] Fitting gamma distribution

2015-02-16 Thread smart hendsome
I'm very new to r-programming. I have rainfall data. I have tried to fit gamma 
into my data but there is error. Anyone can help me please.
My rainfall data as I uploaded. When I try run the coding:
library(MASS)

KLT1-read.csv('C:/Users/User/Dropbox/PhD 
Materials/Coding_PhD_Thesis/Kelantan_Average/K1.csv')

KLT-KLT1$Amount
fd_g - fitdistr(KLT, gamma)
Error in stats::optim(x = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  : 
  initial value in 'vmmin' is not finite
Anyone can help me? Thanks.



__
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] Gráfico de serie temporal de datos

2015-02-16 Thread javier.ruben.marcuzzi
Estimado Rafa Poquet




En lo personal creo que los datos están en una forma confusa, lo claro sería 
data.frame(fecha, medición), en cambio usted tiene la misma fecha en dos 
columnas.


Javier Marcuzzi





De: Rafa Poquet - gmail
Enviado el: ‎lunes‎, ‎16‎ de ‎febrero‎ de ‎2015 ‎08‎:‎41‎ ‎a.m.
Para: R-help-es@r-project.org





Hola a tod@s,



Tengo un problema al tratar de elaborar un gr�fico de serie temporal con
unos datos de consumo de agua.

El caso es que se trata de lecturas de contador de la compa��a
suministradora, realizadas en fechas concretas.

A continuaci�n expongo la tabla de datos base:




Inicio

Fin

agua_m3


1

23/11/2011

20/01/2012

593


2

20/01/2012

15/03/2012

774


3

15/03/2012

17/05/2012

853


4

17/05/2012

11/07/2012

932


5

11/07/2012

04/09/2012

4192


6

04/09/2012

30/10/2012

1348


7

30/10/2012

08/01/2013

777


8

08/01/2013

01/03/2013

630


9

01/03/2013

06/05/2013

980


10

06/05/2013

03/07/2013

1083


11

03/07/2013

02/09/2013

342


12

02/09/2013

29/10/2013

874





Lo que pretendo conseguir es un gr�fico en el que observar la evoluci�n
temporal del consumo de agua, de modo que tenga:

� En el eje �y�: consumo de agua (m3) en el periodo de lectura
correspondiente (agua_m3)

� En el eje �x�: fecha de lectura de contador (Inicio)



Por ahora, si utilizo la funci�n plot.ts() el problema me surge a la hora de
hacer que los valores temporales los coja directamente de la columna
�Inicio� y que no los tenga que definir como una serie temporal regular (con
observaciones cada mes, cada dos meses,�).



Soy nuevo en la comunidad R por lo que si necesit�is de m�s datos o
aclaraciones me lo dec�s.



Gracias de antemano por vuestra colaboraci�n,



Rafa



---
El software de antivirus Avast ha analizado este correo electr�nico en busca de 
virus.


 [[alternative HTML version deleted]]
[[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] difference between max in summary table and max function

2015-02-16 Thread Franckx Laurent
Thanks for the clarification. The basic error on my side was that I had 
misunderstood the digits option in the summary, I had not understood that 
even integer numbers might end up being rounded. Problem is solved now.

-Original Message-
From: Allen Bingham [mailto:aebingh...@gmail.com]
Sent: zaterdag 14 februari 2015 8:16
To: 'Martyn Byng'; r-help@r-project.org
Cc: Franckx Laurent
Subject: RE: [R] difference between max in summary table and max function

I thought I'd chime in ... submitting the following:

   ?summary

Provides the following documentation for the default for generalized argument 
(other than class=data.frame, factor, or matrix):

   ## Default S3 method:
   summary(object, ..., digits = max(3, getOption(digits)-3))

so passing along the object testrow w/o a corresponding argument for digits 
... defaults to digits=4 (assuming your system has the same default option of 
digits = 7 that mine does).

... and since later in the documentation it indicates that digits is an:

   integer, used for number formatting with signif()

so noting that all of the values you reported from summary(testrow) all have
4 significant digits (including the Max. of 131500) (excepting the min value of 
1), summary() is doing what it is documented to do.

... sorry for being pedantic --- but doing so to point out how helpful the ? 
command can be sometimes.

Hope this helps.

__
Allen Bingham
Bingham Statistical Consulting
aebingh...@gmail.com
LinkedIn Profile: www.linkedin.com/pub/allen-bingham/3b/556/325





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Martyn Byng
Sent: Friday, February 13, 2015 3:15 AM
To: Franckx Laurent; r-help@r-project.org
Subject: Re: [R] difference between max in summary table and max function

Its a formatting thing, try

summary(testrow,digits=20)

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Franckx Laurent
Sent: 13 February 2015 11:00
To: r-help@r-project.org
Subject: [R] difference between max in summary table and max function

Dear all

I have found out that the max in the summary of an integer vector is not always 
equal to the actual maximum of that vector. For example:


 testrow - c(1:131509)
 summary(testrow)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
  1   32880   65760   65760   98630  131500
 max(testrow)
[1] 131509

This has occurred both in a Windows and in a Linux environment.

Does this mean that the max value in the summary is only an approximation?

Best regards

Laurent Franckx, PhD
Senior researcher sustainable mobility
VITO NV | Boeretang 200 | 2400 Mol
Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | 
laurent.fran...@vito.be | Twitter @LaurentFranckx




VITO Disclaimer: http://www.vito.be/e-maildisclaimer

__
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 has been scanned for all viruses by Star.\ _...{{dropped:11}}

__
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] Loop over regression results

2015-02-16 Thread David L Carlson
In R you would want to combine the results into a list. This could be done when 
you create the regressions or afterwards. To repeat your example using a list:

data(iris)
taxon - levels(iris$Species)
mod - lapply(taxon, function (x) lm(Sepal.Width ~ Petal.Width, 
data=iris, subset=Species==x))
names(mod) - taxon
lapply(mod, summary)
coeffs - do.call(rbind, lapply(mod, coef, [1))
coeffs
# (Intercept) Petal.Width
# setosa3.222051   0.8371922
# versicolor1.372863   1.0536478
# virginica 1.694773   0.6314052

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




-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ronald Kölpin
Sent: Monday, February 16, 2015 7:37 AM
To: r-help@r-project.org
Subject: [R] Loop over regression results

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dear all,

I have a problem when trying to present the results of several
regression. Say I have run several regressions on a dataset and saved
the different results (as in the mini example below). I then want to
loop over the regression results in order so save certain values to a
matrix (in order to put them into a paper or presentation).

Aside from the question of how to access certain information stored by
lm() (or printed by summary()) I can't seem to so loop over lm()
objects -- no matter whether they are stored in a vector or a list.
They are always evaluated immediately when called. I tried quote() or
substitute() but that didn't work either as Objects of type 'symbol'
cannot be indexed.

In Stata I would simply do something like

forvalues k = 1/3 {
 quietly estimates restore mod`k'
// [...]
}

and I am looking for the R equivalent of that syntax.

Kind regard and thanks

RK


attach(iris)
mod1 - lm(Sepal.Width ~ Petal.Width, data=iris, subset=Species==setosa)
mod2 - lm(Sepal.Width ~ Petal.Width, data=iris,
subset=Species==versicolor)
mod3 - lm(Sepal.Width ~ Petal.Width, data=iris,
subset=Species==virginica)

summary(mod1); summary(mod2); summary(mod3)

mat - matrix(data=NA, nrow=3, ncol=5,
  dimnames=list(1:3, c(Model, Intercept, p(T  |T|),
Slope, R^2)))

mods - c(mod1, mod2, mod3)

for(k in 1:3)
{
mod - mods[k]
mat[2,k] - as.numeric(coef(mod))[1]
mat[3,k] - as.numeric(coef(mod))[1]
}
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJU4fJnAAoJEKdHe5EUSrVeafwIALerOj+rsZTnbSKOUX6vYpr4
Uqsx0X2g+IgJw0KLdyqnlDmOut4wW6sWExtVgiugo/bkN8g5rDotGAl06d0UYRQV
17aLQqQjI6EGXKV9swwlm2DBphtXCIYUCXnDWUoG4Y2wC/4hDnaLbZ9yJFF1GSjn
+aN/PFf1mPPZLvF1NgMmzLdszP76VYzEgcOcEUfbmB7RU/2WEBLeBYJ8+FD1utPJ
cnh03rSc/0dgvphP8FO47Nj7mbqqhKL76a9oQqJSJiZJoCFCGiDIIgzq7vwGWc4T
9apwC/R3ahciB18yYOSMq7ZkVdQ+OpsqDTodnnIIUZjrVIcn9AI+GE0eq1VdLSE=
=x+gM
-END PGP SIGNATURE-

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

__
R-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] compute values by condition in DF by rownames

2015-02-16 Thread Karim Mezhoud
Hi All,
how to compute only abs(value)  0.2 of DF

   X2 gbm_tcga lusc_tcga ucec_tcga_pub
   gbm_tcga  1.0  0.1405371906 -0.1028471639
   gbm_tcga  1.0  0.0441343447  0.0135680550
   gbm_tcga  1.0 -0.2000397119  0.0389718175
gbm_tcga  1.0  0.1456991556  0.0099470445
lusc_tcga  0.140537191  1.00  0.1330807083
lusc_tcga  0.044134345  1.00  0.0620247126
lusc_tcga -0.200039712  1.00 -0.1302395515
 lusc_tcga  0.145699156  1.00  0.0417966700
 ucec_tcga_pub -0.102847164  0.1330807083  1.00
 ucec_tcga_pub  0.013568055  0.0620247126  1.00
 ucec_tcga_pub  0.038971817 -0.1302395515  1.00
 ucec_tcga_pub  0.009947045  0.0417966700  1.00


and return

X2 gbm_tcga lusc_tcga ucec_tcga_pub

gbm_tcga   4   1  0
lusc_tcga1   4  0
 ucec_tcga_pub   0   0   4

Thanks

 Karim

[[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] Loop over regression results

2015-02-16 Thread David L Carlson
Or for the slopes and t-values:

 do.call(rbind, lapply(mod, function(x) summary(x)[[coefficients]][2,]))
Estimate Std. Error  t value Pr(|t|)
setosa 0.8371922  0.5049134 1.658091 1.038211e-01
versicolor 1.0536478  0.1712595 6.152348 1.41e-07
virginica  0.6314052  0.1428938 4.418702 5.647610e-05

David C

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L Carlson
Sent: Monday, February 16, 2015 8:52 AM
To: Ronald Kölpin; r-help@r-project.org
Subject: Re: [R] Loop over regression results

In R you would want to combine the results into a list. This could be done when 
you create the regressions or afterwards. To repeat your example using a list:

data(iris)
taxon - levels(iris$Species)
mod - lapply(taxon, function (x) lm(Sepal.Width ~ Petal.Width, 
data=iris, subset=Species==x))
names(mod) - taxon
lapply(mod, summary)
coeffs - do.call(rbind, lapply(mod, coef, [1))
coeffs
# (Intercept) Petal.Width
# setosa3.222051   0.8371922
# versicolor1.372863   1.0536478
# virginica 1.694773   0.6314052

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




-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ronald Kölpin
Sent: Monday, February 16, 2015 7:37 AM
To: r-help@r-project.org
Subject: [R] Loop over regression results

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dear all,

I have a problem when trying to present the results of several
regression. Say I have run several regressions on a dataset and saved
the different results (as in the mini example below). I then want to
loop over the regression results in order so save certain values to a
matrix (in order to put them into a paper or presentation).

Aside from the question of how to access certain information stored by
lm() (or printed by summary()) I can't seem to so loop over lm()
objects -- no matter whether they are stored in a vector or a list.
They are always evaluated immediately when called. I tried quote() or
substitute() but that didn't work either as Objects of type 'symbol'
cannot be indexed.

In Stata I would simply do something like

forvalues k = 1/3 {
 quietly estimates restore mod`k'
// [...]
}

and I am looking for the R equivalent of that syntax.

Kind regard and thanks

RK


attach(iris)
mod1 - lm(Sepal.Width ~ Petal.Width, data=iris, subset=Species==setosa)
mod2 - lm(Sepal.Width ~ Petal.Width, data=iris,
subset=Species==versicolor)
mod3 - lm(Sepal.Width ~ Petal.Width, data=iris,
subset=Species==virginica)

summary(mod1); summary(mod2); summary(mod3)

mat - matrix(data=NA, nrow=3, ncol=5,
  dimnames=list(1:3, c(Model, Intercept, p(T  |T|),
Slope, R^2)))

mods - c(mod1, mod2, mod3)

for(k in 1:3)
{
mod - mods[k]
mat[2,k] - as.numeric(coef(mod))[1]
mat[3,k] - as.numeric(coef(mod))[1]
}
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJU4fJnAAoJEKdHe5EUSrVeafwIALerOj+rsZTnbSKOUX6vYpr4
Uqsx0X2g+IgJw0KLdyqnlDmOut4wW6sWExtVgiugo/bkN8g5rDotGAl06d0UYRQV
17aLQqQjI6EGXKV9swwlm2DBphtXCIYUCXnDWUoG4Y2wC/4hDnaLbZ9yJFF1GSjn
+aN/PFf1mPPZLvF1NgMmzLdszP76VYzEgcOcEUfbmB7RU/2WEBLeBYJ8+FD1utPJ
cnh03rSc/0dgvphP8FO47Nj7mbqqhKL76a9oQqJSJiZJoCFCGiDIIgzq7vwGWc4T
9apwC/R3ahciB18yYOSMq7ZkVdQ+OpsqDTodnnIIUZjrVIcn9AI+GE0eq1VdLSE=
=x+gM
-END PGP SIGNATURE-

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

__
R-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] Picking Best Discriminant Function Variables

2015-02-16 Thread David L Carlson
Look at the function stepclass() in package klaR.

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

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David Moskowitz
Sent: Sunday, February 15, 2015 11:34 AM
To: n omranian via R-help
Subject: [R] Picking Best Discriminant Function Variables

Is there a way to have the LDA function give me the best 3 (or 4)  predictor 
variables.  When I put in all the variables, LDA uses all the variables, but I 
would like to know what would be the 3 (or 4) best to use out all the available 
variables and the coefficients for those.




Here is the code I am using for Linear Discriminant Function

library(MASS) 



results - lda(data$V1 ~ data$V2 + data$V3 + data$V4 + data$V5 + data$V6 + 
data$V7 + data$V8 + data$V9 + data$V10 + data$V11 + data$V12 + data$V13 + 
data$V14)



Output:

Coefficients of linear discriminants:
LD1   LD2
data$V2 -0.4033997810.8717930699
data$V3 0.165254596 0.3053797325
data$V4 -0.3690752562.3458497486
data$V5 0.154797889 -0.1463807654
data$V6 -0.002163496-0.0004627565
data$V7 0.618052068 -0.0322128171
data$V8 -1.661191235   -0.4919980543
data$V9 -1.495818440   -1.6309537953
data$V10 0.134092628   -0.3070875776
data$V11 0.3550557100.2532306865
data$V12 -0.818036073-1.5156344987
data$V13 -1.1575593760.0511839665
data$V14 -0.0026912060.0028529846




So in the above example, I would like the LDA to return to me the 3 best 
predictors out of the 13 available.


Thank you
[[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] compute values by condition in DF by rownames

2015-02-16 Thread PIKAL Petr
I named your data frame temp

 aggregate(temp[,-1], list(temp[,1]), function(x) sum(abs(x).2))
Group.1 gbm_tcga lusc_tcga ucec_tcga_pub
1  gbm_tcga4 1 0
2 lusc_tcga1 4 0
3 ucec_tcga_pub0 0 4

Cheers
Petr



 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Karim
 Mezhoud
 Sent: Monday, February 16, 2015 4:10 PM
 To: r-help@r-project.org
 Subject: [R] compute values by condition in DF by rownames

 Hi All,
 how to compute only abs(value)  0.2 of DF

X2 gbm_tcga lusc_tcga ucec_tcga_pub
gbm_tcga  1.0  0.1405371906 -0.1028471639
gbm_tcga  1.0  0.0441343447  0.0135680550
gbm_tcga  1.0 -0.2000397119  0.0389718175
 gbm_tcga  1.0  0.1456991556  0.0099470445
 lusc_tcga  0.140537191  1.00  0.1330807083
 lusc_tcga  0.044134345  1.00  0.0620247126
 lusc_tcga -0.200039712  1.00 -0.1302395515
  lusc_tcga  0.145699156  1.00  0.0417966700
  ucec_tcga_pub -0.102847164  0.1330807083  1.00
  ucec_tcga_pub  0.013568055  0.0620247126  1.00
  ucec_tcga_pub  0.038971817 -0.1302395515  1.00
  ucec_tcga_pub  0.009947045  0.0417966700  1.00


 and return

 X2 gbm_tcga lusc_tcga ucec_tcga_pub

 gbm_tcga   4   1  0
 lusc_tcga1   4  0
  ucec_tcga_pub   0   0   4

 Thanks

  Karim

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

Re: [R] Selection/filtering from Data

2015-02-16 Thread Jim Lemon
Hi Parth,
Assume that your dataset is in the form of a data frame, named psdf.

psdf-data.frame(age=sample(0:100,50),income=sample(8000:12000,50))
selectdf-subset(psdf,age = 36  income  1)

Jim

On Mon, Feb 16, 2015 at 7:01 PM, Partha Sinha pnsinh...@gmail.com wrote:
 From a dataset , I want select age =36 and income1. How to do ?
 parth

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

__
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] problems with packages installation

2015-02-16 Thread Prof Brian Ripley

On 16/02/2015 07:49, PIKAL Petr wrote:

Hi Jeff


-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
Sent: Friday, February 13, 2015 3:56 PM
To: PIKAL Petr; r-help@r-project.org
Cc: Richard M. Heiberger
Subject: RE: [R] problems with packages installation

I agree that the PG muddies the water a bit on this topic. However, the
web page from which you downloaded the patched version warns:

This is not an official release of R. Please check bugs in this
version against the official release before reporting them.

When a new version is under  development, the number of bugs often
increases temporarily by quite a bit. Any use you make of a patched or
development version is at your own risk, and should be undertaken for
two reasons only: to address a  specific problem you are having with
the released version, or because you want to help test the unreleased
version out of the goodness of your heart (bless you). In either case,


Yes, that is why I use devel versions but I was not able to find a bug (yet).


chatter about bugs you encounter that are not in the released version
belongs on R-devel.


It was hard to tell what is the problem. It could be that our IT people 
silently changed a firewall or something, which would prevent package 
installation from menu. Far too often I am not able to open some web pages e.g. 
(https://stat.ethz.ch/mailman/listinfo/r-devel) and I do not have power to 
change it.

However it seems to be that this particular problem is in R menu procedure for 
installation as I wrote in my previous mail.



If you can reproduce the problem in a released version, posting on R-
help would be more appropriate, but if you are sure it is a bug then
filling a report is the right thing to do.


It is hard to reproduce and I believe that the problem is probably already 
known by R core (I thank them for their marvellous work).


AFAIK it was already fixed in R-devel at the time of posting.

R-devel is 'under development', and at least until it reaches 'alpha' 
status the R-devel list is the place to report problems (if they persist 
for a few days and after checking with the current version).



For me it is solved by install.packages function.


Actually that is what the menu calls.  The difference is the arguments 
you used (an explicit package rather than NULL for a menu).





Thanks

Best regards
Petr



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

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


[R] Selection/filtering from Data

2015-02-16 Thread Partha Sinha
From a dataset , I want select age =36 and income1. How to do ?
parth

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


Re: [R] Pass additional arguments to do.call(grid.arrange, plots)

2015-02-16 Thread Rolf Turner

On 16/02/15 13:36, Bingzhang Chen wrote:

Hi R users,

I have a problem on how to pass an extra argument to do. call:

The example codes are:

#
require(ggplot2)
plots = lapply(1:5, function(.x) qplot(1:10,rnorm(10), main=paste(plot,.x)))
require(gridExtra)
do.call(grid.arrange,  plots)
#-

I want to force the composite figures into 2 rows by adding 'now = 2'


   You mean 'nrow = 2', but I wasn't fooled for an instant! :-)


in the function 'grid.arrange'. How can I do it?
I searched on google but could not find a workable solution.

I am working on RStudio 0.98.1102 on OSX Yosemite 10.10.2.


Try:

do.call(grid.arrange,c(plots,list(nrow=2))

The second argument to do.call() consists of a list constituting the 
arguments to the first argument.  So just append the argument you want 
to use, to this list.  Easy, once you know. :-)


cheers,

Rolf Turner

P. S.  Thank you for providing a clear and reproducible example.

R. T.

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

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


Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread Hans W Borchers
Zwick, Rebecca J RZwick at ETS.ORG writes:

 Oddly, Excel's Solver will produce a solution to such problems but
 (1) I don't trust it and
 (2) it cannot handle a large number of constraints.
 [...]
 My question is whether there is an R package that can handle this problem.


There are not many free integer (nonlinear) programming (IP, INLP)
solvers available. You could send your problem to one of the MINLP
solvers at NEOS:

http://neos.mcs.anl.gov/neos/solvers/

[See the list of relevant NEOS solvers (commercial and free) on this page:
 http://www.neos-guide.org/content/mixed-integer-nonlinear-programming]

You can also use the 'rneos' package to send your request to one of
these Web services, but most of the time I find it easier to directly
fill the solver template. Please note that you have to format your
problem and data according to the solver's needs, i.e. likely in AMLP
or GAMS syntax.

If you intend to solve such problems more often, I'd suggest to
download one of the commercial solvers with academic licenses (e.g.,
Knitro, Gurobi, ...) and to install a corresponding R package to
access the solver. For more information see the Optimization task
view.

I would *never* trust Excel for these kinds of problems...

By the way, I may not correctly understand your objective, but perhaps
you can formulate it as maximizing a quadratic function (with
constraints).

__
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] #library(party) - Compare predicted results for ctree

2015-02-16 Thread Rodica Coderie via R-help
Hello,

I've created a ctree model called fit using 15 input variables for a factor 
predicted variable Response (YES/NO).
When I run the following :
table(predict(fit2), training_data$response) 
I get the following result:

 NO   YES 
NO  48694   480 
YES 0 0

It appears that the NO responses are predicted with 100% accuracy and the YES 
response are predicted with 0% accuracy.

Why is this happening? It's because of my data or it's something in ctree 
algorithm?

Thanks!
Rodica

__
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] #library(party) - Compare predicted results for ctree

2015-02-16 Thread Achim Zeileis

On Mon, 16 Feb 2015, Rodica Coderie via R-help wrote:


Hello,

I've created a ctree model called fit using 15 input variables for a factor 
predicted variable Response (YES/NO).
When I run the following :
table(predict(fit2), training_data$response)
I get the following result:

NO   YES
NO  48694   480
YES 0 0

It appears that the NO responses are predicted with 100% accuracy and 
the YES response are predicted with 0% accuracy.


Why is this happening? It's because of my data or it's something in 
ctree algorithm?


Your data has less than 1% of YES observations and I would guess that the 
tree cannot separate these in a way such that majority voting gives a YES 
prediction. You might consider a different cutoff (other than 50%) or 
downsampling the NO observations.



Thanks!
Rodica

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



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


[R-es] Gráfico de serie temporal de datos

2015-02-16 Thread Rafa Poquet - gmail
Hola a tod@s,



Tengo un problema al tratar de elaborar un gr�fico de serie temporal con
unos datos de consumo de agua.

El caso es que se trata de lecturas de contador de la compa��a
suministradora, realizadas en fechas concretas.

A continuaci�n expongo la tabla de datos base:




Inicio

Fin

agua_m3


1

23/11/2011

20/01/2012

593


2

20/01/2012

15/03/2012

774


3

15/03/2012

17/05/2012

853


4

17/05/2012

11/07/2012

932


5

11/07/2012

04/09/2012

4192


6

04/09/2012

30/10/2012

1348


7

30/10/2012

08/01/2013

777


8

08/01/2013

01/03/2013

630


9

01/03/2013

06/05/2013

980


10

06/05/2013

03/07/2013

1083


11

03/07/2013

02/09/2013

342


12

02/09/2013

29/10/2013

874





Lo que pretendo conseguir es un gr�fico en el que observar la evoluci�n
temporal del consumo de agua, de modo que tenga:

� En el eje �y�: consumo de agua (m3) en el periodo de lectura
correspondiente (agua_m3)

� En el eje �x�: fecha de lectura de contador (Inicio)



Por ahora, si utilizo la funci�n plot.ts() el problema me surge a la hora de
hacer que los valores temporales los coja directamente de la columna
�Inicio� y que no los tenga que definir como una serie temporal regular (con
observaciones cada mes, cada dos meses,�).



Soy nuevo en la comunidad R por lo que si necesit�is de m�s datos o
aclaraciones me lo dec�s.



Gracias de antemano por vuestra colaboraci�n,



Rafa



---
El software de antivirus Avast ha analizado este correo electr�nico en busca de 
virus.


[[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] How to get the error and error variance after HB using bayesm

2015-02-16 Thread Michael Langmaack
Hi Arnab,

Actually, I don´t think so as in Bayesian Regression the estimation converges 
towards the prior distribution and not a point estimate like in the frequentist 
approach. But I’m not very sure honestly. I used a Bayesian Logit Model in R 
(bayesm, rhierBinLogit by Rossi) to calculate individual pert-worth. I reviewer 
asked me to control for error variance as my results highly depend on it. But I 
do not know how to deal with using the Bayesian approach.

Cheers,
Michael

From: arnabkrma...@gmail.com [mailto:arnabkrma...@gmail.com] On Behalf Of ARNAB 
KR MAITY
Sent: Freitag, 13. Februar 2015 20:46
To: Michael Langmaack
Cc: r-help@r-project.org
Subject: Re: [R] How to get the error and error variance after HB using bayesm

Hello Michael,

I have a question here. Does Bayesian paradigm deal with MSE kind of stuff?

Thanks  Regards,
Arnab



Arnab Kumar Maity
Graduate Teaching Assistant
Division of Statistics
Northern Illinois University
DeKalb, IL 60115
Email: ma...@math.niu.edumailto:ma...@math.niu.edu
Ph: 779-777-3428

On Fri, Feb 13, 2015 at 4:45 AM, Michael Langmaack 
michael.langma...@the-klu.orgmailto:michael.langma...@the-klu.org wrote:
Hello all,

I have a question concerning bayesian regression in R using the package bayesm 
(version 2.2-5) by Peter Rossi. I have binary choice data and estimated 
individual coefficients using the command rhierBinLogit(Data=Data,Mcmc=Mcmc). 
That worked out properly, conversion plots, histograms, parameter are fine. No 
a have to compute the errors and the error variance or something like the MSE. 
But I do not know how to do. I did not find a hint so far. I would be more than 
happy if anybody can help me. Thanks in advance!

Best regards,
Michael

[[alternative HTML version deleted]]

__
R-help@r-project.orgmailto:R-help@r-project.org mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.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] How do I provide path character string to extdata content?

2015-02-16 Thread Ulrike Grömping

Dear helpeRs,

I have some png files in the inst/extdata directory of a package (e.g.,
man.png), and I want to provide character strings containing the paths to
these files; of course, these path strings have to depend on the individual
installation. So far, I have written a function that - if called - writes
the correct strings to the global environment, but that is not CRAN
compatible.

Ideally, I want the package namespace to export these text strings. I have
played with .onLoad without luck. I do not have a good understanding of
which hook is for which purpose. How can I go about this?

Best, Ulrike

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