Re: [R] How to access https page

2015-03-09 Thread Prof Brian Ripley

On 09/03/2015 22:39, Hui Du wrote:

Hi All,

I am trying to parse some information from website, say, a linkedin page.
The linkedin url was

url = "http://www.linkedin.com/in/huidu";

I had no problem to use readLines and XML package to collect the
information I need. However, that url became "
https://www.linkedin.com/in/huidu"; now.

url = "https://www.linkedin.com/in/huidu";

It failed readLines function.


readLines(url)

Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : unsupported URL scheme


Do you know any way to read-in web information if the url is https? Thanks
a lot.


Try R-devel, soon to become R 3.2.0.  That has support for this on 
platforms where libcurl is installed (which should be possible almost 
everywhere).


You did not give the 'at a minimum' information required by the posting 
guide.  This has long been possible on Windows with --internet2.




Hui

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




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


Re: [R] Alpha not working in geom_rect

2015-03-09 Thread Jeff Newmiller
I have run into this a couple of times ... If you generate the rectangles once 
per row of your data, the fill gets more and more "dense" so your alpha seems 
to not work. The annotate call only paints the rectangle once so you don't have 
this problem.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On March 9, 2015 3:24:23 PM PDT, adel daoud  wrote:
>Hi Jim,
>
>Thanks for the input but that did not work. I am suing Rstudio by the
>way
>and I guess that has a better device that would support ggplot output.
>
>The annotate options works but that does not explain why the geom_area
>does
>not work:
>annotate("rect", xmin=2, xmax=10, ymin=0,  ymax=1, fill="black",
>alpha=0.5)
>
>Best
>Adel
>
>
>--
>
>Adel Daoud, PhD, Researcher
>
>
>
>The New School for Social Research,
>
>Visiting Scholar in the Economics Department,
>
>6 East 16th Street New York, NY 10003,
>
>dao...@newschool.edu
>
>
>
>
>
>University of Gothenburg
>
>Department of Sociology and Work Science,
>
>Box 720
>
>405 30, Göteborg, Sweden
>
>Visiting address: Sprängkullsgatan 25, room F411
>
>Sprängkullsgatan 25, room K109
>
>+46 031-786 41 73
>
>adel.da...@sociology.gu.se
>
>On Sun, Mar 8, 2015 at 12:46 AM, Jim Lemon 
>wrote:
>
>> Hi Adel,
>> Almost certainly because the device you were using doesn't support
>> transparency.Try it with a PDF device and check the resulting file in
>a PDF
>> reader:
>>
>> pdf("ad.pdf")
>> print(p)
>> dev.off()
>>
>> Jim
>>
>>
>> On Sun, Mar 8, 2015 at 4:39 AM, Adel  wrote:
>>
>>> Hi
>>> I am trying to activate the alpha argument to work, but for some
>reason it
>>> does not to play with me. Anybody has an idea why?
>>>
>>>
>>> p <- ggplot(data = prediction_df, aes(x=x, y=prediction,
>fill=threshold))
>>> +
>>> geom_area(colour="black", size=.2, alpha=.4) +
>>> scale_fill_brewer(palette="Set1",
>>> breaks=rev(levels(prediction_df$threshold)))
>>> p + geom_rect(aes(xmin=2, xmax=10, ymin=(0), ymax=(1)),
>fill="black",
>>> alpha=0.5)
>>>
>>>
>>> prediction_df
>>>  x prediction  threshold
>>> 1  -10  0.5694161   noAF
>>> 2   -9  0.5700513   noAF
>>> 3   -8  0.5706863   noAF
>>> 4   -7  0.5713211   noAF
>>> 5   -6  0.5719556   noAF
>>> 6   -5  0.5725899   noAF
>>> 7   -4  0.5732240   noAF
>>> 8   -3  0.5738578   noAF
>>> 9   -2  0.5744914   noAF
>>> 10  -1  0.5751247   noAF
>>> 11   0  0.5757578   noAF
>>> 12   1  0.5763906   noAF
>>> 13   2  0.5770232   noAF
>>> 14   3  0.5776556   noAF
>>> 15   4  0.5782876   noAF
>>> 16   5  0.5789195   noAF
>>> 17   6  0.5795510   noAF
>>> 18   7  0.5801823   noAF
>>> 19   8  0.5808134   noAF
>>> 20   9  0.5814441   noAF
>>> 21  10  0.5820747   noAF
>>> 22 -10  0.2359140   singleAF
>>> 23  -9  0.2356847   singleAF
>>> 24  -8  0.2354550   singleAF
>>> 25  -7  0.2352249   singleAF
>>> 26  -6  0.2349943   singleAF
>>> 27  -5  0.2347634   singleAF
>>> 28  -4  0.2345321   singleAF
>>> 29  -3  0.2343003   singleAF
>>> 30  -2  0.2340682   singleAF
>>> 31  -1  0.2338356   singleAF
>>> 32   0  0.2336027   singleAF
>>> 33   1  0.2333694   singleAF
>>> 34   2  0.2331357   singleAF
>>> 35   3  0.2329016   singleAF
>>> 36   4  0.2326671   singleAF
>>> 37   5  0.2324322   singleAF
>>> 38   6  0.2321969   singleAF
>>> 39   7  0.2319613   singleAF
>>> 40   8  0.2317253   singleAF
>>> 41   9  0.2314889   singleAF
>>> 42  10  0.2312522   singleAF
>>> 43 -10  0.1946699 multipleAF
>>> 44  -9  0.1942640 multipleAF
>>> 45  -8  0.1938587 multipleAF
>>> 46  -7  0.1934540 multipleAF
>>> 47  -6  0.1930500 multipleAF
>>> 48  -5  0.1926467 multipleAF
>>> 49  -4  0.1922440 multipleAF
>>> 50  -3  0.1918419 multipleAF
>>> 51  -2  0.1914404 multipleAF
>>> 52  -1  0.1910397 multipleAF
>>> 53   0  0.1906395 multipleAF
>>> 54   1  0.1902400 multipleAF
>>> 55   2  0.1898411 multipleAF
>>> 56   3  0.1894429 multipleAF
>>> 57   4  0.1890453 multipleAF
>>> 58   5  0.1886483 multipleAF
>>> 59   6  0.1882520 multipleAF
>>> 60   7  0.1878564 multipleAF
>>> 61   8  0.1874613 multipleAF
>>> 62   9  0.1870669 multipleAF
>>> 63  10  0.1866732 multipleAF
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
>http://r.789695.n4.nabble.com/Alpha-not-working-in-geom-rect-tp4704291.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 g

Re: [R] Change the argument function inside R function in GPfit package

2015-03-09 Thread C W
I guess I should re-frame my question with real data.

> xx
 [,1]
[1,]  0.0
[2,]  0.2
[3,]  0.4
[4,]  0.6
[5,]  0.8
> yy
  [,1]
[1,] 0.000
[2,] 0.1652000
[3,] 0.4343223
[4,] 0.5996505
[5,] 0.7195857
> cor.mat
[,1]   [,2]  [,3]   [,4][,5]
[1,] 1.0 0.64822376 0.1873066 0.02489388 0.001546431
[2,] 0.648223760 1. 0.6482238 0.18730656 0.024893894
[3,] 0.187306626 0.64822376 1.000 0.64822364 0.187306626
[4,] 0.024893881 0.18730656 0.6482236 1. 0.648223880
[5,] 0.001546431 0.02489389 0.1873066 0.64822388 1.0


or
xx <- structure(c(0, 0.19994947575, 0.3998989515,
0.60028498471,
0.799797903), .Dim = c(5L, 1L))
yy <- structure(c(0, 0.165199951246566, 0.43432234091,
0.599650488376824,
0.719585664934966), .Dim = c(5L, 1L))
cor.mat <- structure(c(1, 0.648223760165366, 0.187306626057348,
0.0248938807581023,
0.00154643121052443, 0.648223760165366, 1, 0.648223760165366,
0.187306559286623, 0.0248938938021518, 0.187306626057348,
0.648223760165366,
1, 0.648223640552069, 0.187306626057348, 0.0248938807581023,
0.187306559286623, 0.648223640552069, 1, 0.64822387977866,
0.00154643121052443,
0.0248938938021518, 0.187306626057348, 0.64822387977866, 1), .Dim = c(5L,
5L))


Now if I do,
> GP_fit(xx, yy, corr=cor.mat)
Error in corr$type : $ operator is invalid for atomic vectors


How could I fix it?

Thanks!

-M

On Mon, Mar 9, 2015 at 2:14 PM, C W  wrote:

> Hi R list,
>
> I am using the GPfit package to fit Gaussian Process model.
>
> The kernel in the package is,
> K(x, x') = sigma^2 * exp(x-x')^2
>
> My kernel have an extra term,
> K((x, z), (x', z')) = sigma^2 * exp(x-x')^2 * exp(z-z')^2
>
> The function corr_matrix() is,
> corr_matrix(X, beta, corr=list(type="exponential",power=1.95))
> github source: https://github.com/cran/GPfit/blob/master/R/corr_matrix.R
>
> I am changing the corr argument, so it looks like mine.  How should I do
> it?
>
> Also, what package do you guys recommend for GP modeling?  I know GPstuff
> or GPML but that's Matlab.
>
> Thanks very much.
>
> Mike
>

[[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 to access https page

2015-03-09 Thread Hui Du
Hi All,

I am trying to parse some information from website, say, a linkedin page.
The linkedin url was

url = "http://www.linkedin.com/in/huidu";

I had no problem to use readLines and XML package to collect the
information I need. However, that url became "
https://www.linkedin.com/in/huidu"; now.

url = "https://www.linkedin.com/in/huidu";

It failed readLines function.

> readLines(url)
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : unsupported URL scheme


Do you know any way to read-in web information if the url is https? Thanks
a lot.

Hui

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

2015-03-09 Thread Simon Blomberg

It's hard to tell what you did exactly. Did you do:

mytree <- compute.brlen(mytree)

? That should have worked. I've cc'ed this message to r-sig-phylo, which 
is the more appropriate forum.


Cheers,

Simon.

On 10/03/15 07:05, Beth Williams wrote:

Dear All,


I am having some trouble with R and would be extremely grateful if anyone has a way around this. I have loaded a nexus 
tree from PAUP into R using the command read.nexus and this loaded,  it was reported as "rooted; with no branch 
lengths". I then used the command "compute.brlen(mytree)" to compute the branch lengths and this was 
reported as "rooted; includes branch lengths". I added my community data (samp) and then tried to compute the 
phylogenetic diversity with the command "> pd(samp, mytree, include.root=TRUE)" however it said it could not 
calculate the PD as there were no branch lengths. Is there a way to incorporate the branch lengths into the calculation 
for PD?


Thanks for your time,

Beth

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


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Senior Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Basically, I'm not interested in doing research
and I never have been. I'm interested in
understanding, which is quite a different thing.
- David Blackwell

__
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 access https page

2015-03-09 Thread Jorge I Velez
Hi Hui,

I have used the source_url function in the devtools package with good
results.  Give it a shot!

Best,
Jorge.-


On Tue, Mar 10, 2015 at 9:39 AM, Hui Du  wrote:

> Hi All,
>
> I am trying to parse some information from website, say, a linkedin page.
> The linkedin url was
>
> url = "http://www.linkedin.com/in/huidu";
>
> I had no problem to use readLines and XML package to collect the
> information I need. However, that url became "
> https://www.linkedin.com/in/huidu"; now.
>
> url = "https://www.linkedin.com/in/huidu";
>
> It failed readLines function.
>
> > readLines(url)
> Error in file(con, "r") : cannot open the connection
> In addition: Warning message:
> In file(con, "r") : unsupported URL scheme
>
>
> Do you know any way to read-in web information if the url is https? Thanks
> a lot.
>
> Hui
>
> [[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] svg2swf - controlling the looping of flash files

2015-03-09 Thread Paul Sweeting
Hi

 

I'm using svg2swf to collate a number of svg outputs into an swf file.  I've
got this working (mainly.) except that I can't control the looping behaviour
of the swf file.  In other words, when it's loaded into html it loops
continuously.  Is there any way to stop the animation looping, so it just
plays through once when loaded?  The code I use is (broadly):

 

   svg("testplot%d.svg",onefile = FALSE)

   for(j in 1:360){

  print(cloud(x~y*z, groups=tail,
data=norm_dots_chart, screen=list(z=0,x=0,y=j)))

   }

   dev.off()

   output = svg2swf(sprintf("testplot%d.svg", 1:360), interval =
0.04)

   swf2html(output) 

 

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] R can't find tcl-tk

2015-03-09 Thread Imran Akbar
Hi,

I've installed the latest version of R from source on Amazon Linux with the
following config flags:
./configure --with-tcl-config=/opt/ActiveTcl-8.6/lib/tclConfig.sh
--with-tk-config=/opt/ActiveTcl-8.6/lib/tkConfig.sh

After running make and make install, I try to run R and install the
'anesrake' package, but one of the dependencies fails with this error:

error: Tcl/Tk support is not available on this system

How can I fix this?

regards,
imran

[[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] question about the geometric distribution, please

2015-03-09 Thread Huang, JS
Maybe you are looking for rnbinom?

JS Huang
636.536.5635


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess
Sent: Monday, March 09, 2015 3:52 PM
To: R help
Subject: [R] question about the geometric distribution, please

Hello!

The function rgeom is based on the geometric distribution such that x = 0, 1, 


Is there a function which produces the geometric results such that x = 1, 2, ...
please?

Thought I'd check before I started coding.

Thank you!

Sincerely,
Erin


--
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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

Confidentiality Notice: This e-mail communication and any
attachments may contain confidential and privileged information for
the use of the designated recipients named above. If you are not
the intended recipient, you are hereby notified that you have
received this communication in error and that any review,
disclosure, dissemination, distribution or copying of it or its
contents is prohibited. If you have received this communication in
error, please notify me immediately by replying to this message and
deleting it from your computer. Thank you.

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


Re: [R] Alpha not working in geom_rect

2015-03-09 Thread adel daoud
Hi Jim,

Thanks for the input but that did not work. I am suing Rstudio by the way
and I guess that has a better device that would support ggplot output.

The annotate options works but that does not explain why the geom_area does
not work:
annotate("rect", xmin=2, xmax=10, ymin=0,  ymax=1, fill="black", alpha=0.5)

Best
Adel


--

Adel Daoud, PhD, Researcher



The New School for Social Research,

Visiting Scholar in the Economics Department,

6 East 16th Street New York, NY 10003,

dao...@newschool.edu





University of Gothenburg

Department of Sociology and Work Science,

Box 720

405 30, Göteborg, Sweden

Visiting address: Sprängkullsgatan 25, room F411

Sprängkullsgatan 25, room K109

+46 031-786 41 73

adel.da...@sociology.gu.se

On Sun, Mar 8, 2015 at 12:46 AM, Jim Lemon  wrote:

> Hi Adel,
> Almost certainly because the device you were using doesn't support
> transparency.Try it with a PDF device and check the resulting file in a PDF
> reader:
>
> pdf("ad.pdf")
> print(p)
> dev.off()
>
> Jim
>
>
> On Sun, Mar 8, 2015 at 4:39 AM, Adel  wrote:
>
>> Hi
>> I am trying to activate the alpha argument to work, but for some reason it
>> does not to play with me. Anybody has an idea why?
>>
>>
>> p <- ggplot(data = prediction_df, aes(x=x, y=prediction, fill=threshold))
>> +
>> geom_area(colour="black", size=.2, alpha=.4) +
>> scale_fill_brewer(palette="Set1",
>> breaks=rev(levels(prediction_df$threshold)))
>> p + geom_rect(aes(xmin=2, xmax=10, ymin=(0), ymax=(1)), fill="black",
>> alpha=0.5)
>>
>>
>> prediction_df
>>  x prediction  threshold
>> 1  -10  0.5694161   noAF
>> 2   -9  0.5700513   noAF
>> 3   -8  0.5706863   noAF
>> 4   -7  0.5713211   noAF
>> 5   -6  0.5719556   noAF
>> 6   -5  0.5725899   noAF
>> 7   -4  0.5732240   noAF
>> 8   -3  0.5738578   noAF
>> 9   -2  0.5744914   noAF
>> 10  -1  0.5751247   noAF
>> 11   0  0.5757578   noAF
>> 12   1  0.5763906   noAF
>> 13   2  0.5770232   noAF
>> 14   3  0.5776556   noAF
>> 15   4  0.5782876   noAF
>> 16   5  0.5789195   noAF
>> 17   6  0.5795510   noAF
>> 18   7  0.5801823   noAF
>> 19   8  0.5808134   noAF
>> 20   9  0.5814441   noAF
>> 21  10  0.5820747   noAF
>> 22 -10  0.2359140   singleAF
>> 23  -9  0.2356847   singleAF
>> 24  -8  0.2354550   singleAF
>> 25  -7  0.2352249   singleAF
>> 26  -6  0.2349943   singleAF
>> 27  -5  0.2347634   singleAF
>> 28  -4  0.2345321   singleAF
>> 29  -3  0.2343003   singleAF
>> 30  -2  0.2340682   singleAF
>> 31  -1  0.2338356   singleAF
>> 32   0  0.2336027   singleAF
>> 33   1  0.2333694   singleAF
>> 34   2  0.2331357   singleAF
>> 35   3  0.2329016   singleAF
>> 36   4  0.2326671   singleAF
>> 37   5  0.2324322   singleAF
>> 38   6  0.2321969   singleAF
>> 39   7  0.2319613   singleAF
>> 40   8  0.2317253   singleAF
>> 41   9  0.2314889   singleAF
>> 42  10  0.2312522   singleAF
>> 43 -10  0.1946699 multipleAF
>> 44  -9  0.1942640 multipleAF
>> 45  -8  0.1938587 multipleAF
>> 46  -7  0.1934540 multipleAF
>> 47  -6  0.1930500 multipleAF
>> 48  -5  0.1926467 multipleAF
>> 49  -4  0.1922440 multipleAF
>> 50  -3  0.1918419 multipleAF
>> 51  -2  0.1914404 multipleAF
>> 52  -1  0.1910397 multipleAF
>> 53   0  0.1906395 multipleAF
>> 54   1  0.1902400 multipleAF
>> 55   2  0.1898411 multipleAF
>> 56   3  0.1894429 multipleAF
>> 57   4  0.1890453 multipleAF
>> 58   5  0.1886483 multipleAF
>> 59   6  0.1882520 multipleAF
>> 60   7  0.1878564 multipleAF
>> 61   8  0.1874613 multipleAF
>> 62   9  0.1870669 multipleAF
>> 63  10  0.1866732 multipleAF
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Alpha-not-working-in-geom-rect-tp4704291.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.
>>
>
>

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

2015-03-09 Thread Beth Williams
Dear All,


I am having some trouble with R and would be extremely grateful if anyone has a 
way around this. I have loaded a nexus tree from PAUP into R using the command 
read.nexus and this loaded,  it was reported as "rooted; with no branch 
lengths". I then used the command "compute.brlen(mytree)" to compute the branch 
lengths and this was reported as "rooted; includes branch lengths". I added my 
community data (samp) and then tried to compute the phylogenetic diversity with 
the command "> pd(samp, mytree, include.root=TRUE)" however it said it could 
not calculate the PD as there were no branch lengths. Is there a way to 
incorporate the branch lengths into the calculation for PD?


Thanks for your time,

Beth

[[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] question about the geometric distribution, please

2015-03-09 Thread David Winsemius

On Mar 9, 2015, at 1:52 PM, Erin Hodgess wrote:

> Hello!
> 
> The function rgeom is based on the geometric distribution such that x = 0,
> 1, 
> 
> Is there a function which produces the geometric results such that x = 1,
> 2, ...
> please?
> 
> Thought I'd check before I started coding.

This seemed unclear or trivial. Cannot decide which from the description. The 
arguments to rgeom are "n" and "prob". If you want a geometric-like result with 
a "shifted" range, then just add one to the rgeom result.


> 
> Thank you!
> 
> Sincerely,
> Erin
> 
> 
> -- 
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
> 
>   [[alternative HTML version deleted]]

-- 

David Winsemius
Alameda, CA, USA

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


[R] increase max. console output lines

2015-03-09 Thread Thomas

Hi,

I have a lengthy R script, which just got a bit too long for the console 
output to cache all executions history, i.e. when scrolling to the top 
the first few commands executed are not listed any more.

What is the current limit (characters? lines?) and how do I increase it?

R is 2.14, Win7, 64-bit if that matters.

thanks, Thomas

__
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] Revolutions blog: February roundup

2015-03-09 Thread David Smith
For more than 6 years, Revolution Analytics staff and guests have
written about R every weekday at the Revolutions blog:
 http://blog.revolutionanalytics.com
and every month I post a summary of articles from the previous month
of particular interest to readers of r-help.

In case you missed them, here are some articles related to R from the
month of February:

The John M. Chambers Statistical Software Award announcement for 2015:
http://bit.ly/1CWIfXT

The new R package "distcomp" allows researchers to collaborate on data
spread across multiple sites: http://bit.ly/1CWIfXU

I gave an interview to theCUBE on R, data science, and Microsoft's
acquisition of Revolution Analytics: http://bit.ly/1CWIfaC

R is used to measure impact of climate change, and other Strata
keynote presentations: http://bit.ly/1CWIfqQ

Some tricks for monitoring the progress on parallel R jobs using
foreach: http://bit.ly/1CWIfaD

"Analytics Marketplaces" are all the rage today, but CRAN was there
first: http://bit.ly/1CWIfXS

A preview of some of the major R-related conferences and events of
2015: http://bit.ly/1CWIfXV

The checkpoint package has been updated to make it even easier to run
R scripts with fixed R package versions: http://bit.ly/1CWIfqS

A tutorial to introduce R to users of Microsoft Excel: http://bit.ly/1CWIfqT

R used to assess the "virality" of posts on new-media sites like
Buzzfeed: http://bit.ly/1CWIfqU

A review of the HP Workshop on Distributed Computing in R featuring
Luke Tierney, Dirk Eddelbuettel, Martin Morgan, Simon Urbanek and
other R luminaries: http://bit.ly/1CWIfXX

R is the top-ranked language on GitHub, as measured by the number of
forks per repository: http://bit.ly/1CWIfXW

You can use the rcrunchbase package to access data on startup
companies: http://bit.ly/1CWIfXY

The R package "syuzhet" applies sentiment analysis to novels to infer
their dramatic arc: http://bit.ly/1CWIfqX

The new "quickcheck" package provides assertion-based testing with
random inputs for R: http://bit.ly/1CWIfqY

A theorem for calculating an upper bound for the generalization error
of a machine learning classifier: http://bit.ly/1CWIfXZ

Some practical advice for sharing Shiny applications with
shinyapps.io: http://bit.ly/1CWIfqZ

A visualization of Paris's street orientations reveals the history of
the city: http://bit.ly/1CWIfY0

General interest stories (not related to R) in the past month
included: how our brains trick us into seeing the wrong colors
(http://bit.ly/1CWIfr0), an hilarious parody of cooking shows
(http://bit.ly/1CWIfr4), a new ASA website to help journalists with
Statistics (http://bit.ly/1CWIfY1), the statistical model behind the
rules of cricket (http://bit.ly/1CWIfY2), and why rivers meander
(http://bit.ly/1CWIfr6).

Meeting times for local R user groups (http://bit.ly/eC5YQe) can be
found on the updated R Community Calendar at: http://bit.ly/bb3naW

If you're looking for more articles about R, you can find summaries
from previous months at http://blog.revolutionanalytics.com/roundups/.
You can receive daily blog posts via email using services like
blogtrottr.com, or join the Revolution Analytics mailing list at
http://revolutionanalytics.com/newsletter to be alerted to new
articles on a monthly basis.

As always, thanks for the comments and please keep sending suggestions
to me at da...@revolutionanalytics.com or via Twitter (I'm
@revodavid).

Cheers,
# David

-- 
David M Smith 
Chief Community Officer, Revolution Analytics
http://blog.revolutionanalytics.com
Tel: +1 (650) 646-9523 (Chicago IL, USA)
Twitter: @revodavid

__
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] calculate value in dependence of target value

2015-03-09 Thread David L Carlson
This works for your example data, but I'd recommend testing it carefully before 
using it.

> dat <- data.frame(ID=11:14, VALUE=c(1, 5, 3, 2)*1)
> HURD <- c(50, 75, 100)*1000
> PCT <- c(.02, .04, .08, .1)
> dat$CVALUE <- cumsum(dat$VALUE)
> dat$LVALUE <- dat$CVALUE - dat$VALUE
> dat
  ID VALUE CVALUE LVALUE
1 11 1  1  0
2 12 5  6  1
3 13 3  9  6
4 14 2 11  9
> 
> for (idx in seq_len(nrow(dat))) {
+ rng <- sort(c(HURD, unlist(dat[idx,3:4])))
+ a <- which(names(rng) == "LVALUE")
+ b <- which(names(rng) == "CVALUE")
+ diff(rng[a:b])
+ ng <- length(diff(rng[a:b]))
+ dat$MARGE[idx] <- sum(PCT[a:(a+ng-1)]* diff(rng[a:b]))
+ }
> dat
  ID VALUE CVALUE LVALUE MARGE
1 11 1  1  0   200
2 12 5  6  1  1200
3 13 3  9  6  1800
4 14 2 11  9  1800

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

-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] 
Sent: Monday, March 9, 2015 2:22 PM
To: Matthias Weber
Cc: David L Carlson; r-help@r-project.org
Subject: Re: [R] calculate value in dependence of target value


> target <- 10
>
> breakpts <- data.frame( PctTarget=c(50,75,100,Inf), Mult=c(2,4,8,10) )
> breakpts$LastPct <- c( 0, breakpts$PctTarget[ -nrow( breakpts ) ] )
> breakpts$Range <- cut( breakpts$PctTarget, c( 0, breakpts$PctTarget ), 
include.lowest=TRUE )
> breakpts$DeltaPct <- with( breakpts, diff( c( 0, PctTarget ) ) )
> breakpts$CumMARGE <- target / 1e4 * with( breakpts, cumsum( DeltaPct * 
Mult ) )
> breakpts$LastCumMARGE <- c( 0, breakpts$CumMARGE[ -nrow( breakpts ) ] )
>
> dta <- data.frame( ID=11:14, VALUE=c(1,5,3,2) )
> dta$CumVALUE <- cumsum( dta$VALUE )
> dta$CumPct <- 100 * dta$CumVALUE / target
> dta$Range <- cut( dta$CumPct, c( 0, breakpts$PctTarget ), 
include.lowest=TRUE )
>
> dta
   ID VALUE CumVALUE CumPct Range
1 11 11 10[0,50]
2 12 56 60   (50,75]
3 13 39 90  (75,100]
4 14 2   11110 (100,Inf]
> breakpts
   PctTarget Mult LastPct Range DeltaPct CumMARGE LastCumMARGE
1502   0[0,50]   50 10000
2754  50   (50,75]   25 2000 1000
3   1008  75  (75,100]   25 4000 2000
4   Inf   10 100 (100,Inf]  Inf  Inf 4000
>
> #dta2 <- merge( dta, breakpts, all.x=TRUE, by="Range" )
> #dta2 <- dta2[ order( dta2$ID ), ]
>
> dta2 <- cbind( dta, breakpts[ match( dta$Range, breakpts$Range ), 
-which( "Range"==names( breakpts ) ) ] )
>
> dta2$CumMARGE <- with( dta2, Mult/100 * ( CumVALUE - target * LastPct / 
100 ) + LastCumMARGE )
> dta2$MARGE <- with( dta2, diff( c( 0, CumMARGE ) ) )
>
> dta2
   ID VALUE CumVALUE CumPct Range PctTarget Mult LastPct DeltaPct 
CumMARGE LastCumMARGE MARGE
1 11 11 10[0,50]502   0   50 
2000   200
2 12 56 60   (50,75]754  50   25 
1400 1000  1200
3 13 39 90  (75,100]   1008  75   25 
3200 2000  1800
4 14 2   11110 (100,Inf]   Inf   10 100  Inf 
5000 4000  1800
>
>
> target <- 10
>
> breakpts <- data.frame( PctTarget=c(50,75,100,Inf), Mult=c(2,4,8,10) )
> breakpts$LastPct <- c( 0, breakpts$PctTarget[ -nrow( breakpts ) ] )
> breakpts$Range <- cut( breakpts$PctTarget, c( 0, breakpts$PctTarget ), 
include.lowest=TRUE )
> breakpts$DeltaPct <- with( breakpts, diff( c( 0, PctTarget ) ) )
> breakpts$CumMARGE <- target / 1e4 * with( breakpts, cumsum( DeltaPct * 
Mult ) )
> breakpts$LastCumMARGE <- c( 0, breakpts$CumMARGE[ -nrow( breakpts ) ] )
>
> dta <- data.frame( ID=11:14, VALUE=c(1,5,3,2) )
> dta$CumVALUE <- cumsum( dta$VALUE )
> dta$CumPct <- 100 * dta$CumVALUE / target
> dta$Range <- cut( dta$CumPct, c( 0, breakpts$PctTarget ), 
include.lowest=TRUE )
>
> dta
   ID VALUE CumVALUE CumPct Range
1 11 11 10[0,50]
2 12 56 60   (50,75]
3 13 39 90  (75,100]
4 14 2   11110 (100,Inf]
> breakpts
   PctTarget Mult LastPct Range DeltaPct CumMARGE LastCumMARGE
1502   0[0,50]   50 10000
2754  50   (50,75]   25 2000 1000
3   1008  75  (75,100]   25 4000 2000
4   Inf   10 100 (100,Inf]  Inf  Inf 4000
>
> #dta2 <- merge( dta, breakpts, all.x=TRUE, by="Range" )
> #dta2 <- dta2[ order( dta2$ID ), ]
>
> dta2 <- cbind( dta, breakpts[ match( dta$Range, breakpts$Range ), 
-which( "Range"==names( breakpts ) ) ] )
>
> dta2$CumMARGE <- with( dta2, Mult/100 * ( CumVALUE - target * LastPct / 
100 ) + LastCumMARGE )
> dta2$MARGE <- diff( c( 0, dta2$CumMARGE ) )
>
> dta2
   ID VALUE CumVALUE CumPct R

[R] question about the geometric distribution, please

2015-03-09 Thread Erin Hodgess
Hello!

The function rgeom is based on the geometric distribution such that x = 0,
1, 

Is there a function which produces the geometric results such that x = 1,
2, ...
please?

Thought I'd check before I started coding.

Thank you!

Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[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] calculate value in dependence of target value

2015-03-09 Thread Jeff Newmiller



target <- 10

breakpts <- data.frame( PctTarget=c(50,75,100,Inf), Mult=c(2,4,8,10) )
breakpts$LastPct <- c( 0, breakpts$PctTarget[ -nrow( breakpts ) ] )
breakpts$Range <- cut( breakpts$PctTarget, c( 0, breakpts$PctTarget ), 

include.lowest=TRUE )

breakpts$DeltaPct <- with( breakpts, diff( c( 0, PctTarget ) ) )
breakpts$CumMARGE <- target / 1e4 * with( breakpts, cumsum( DeltaPct * 

Mult ) )

breakpts$LastCumMARGE <- c( 0, breakpts$CumMARGE[ -nrow( breakpts ) ] )

dta <- data.frame( ID=11:14, VALUE=c(1,5,3,2) )
dta$CumVALUE <- cumsum( dta$VALUE )
dta$CumPct <- 100 * dta$CumVALUE / target
dta$Range <- cut( dta$CumPct, c( 0, breakpts$PctTarget ), 

include.lowest=TRUE )


dta

  ID VALUE CumVALUE CumPct Range
1 11 11 10[0,50]
2 12 56 60   (50,75]
3 13 39 90  (75,100]
4 14 2   11110 (100,Inf]

breakpts

  PctTarget Mult LastPct Range DeltaPct CumMARGE LastCumMARGE
1502   0[0,50]   50 10000
2754  50   (50,75]   25 2000 1000
3   1008  75  (75,100]   25 4000 2000
4   Inf   10 100 (100,Inf]  Inf  Inf 4000


#dta2 <- merge( dta, breakpts, all.x=TRUE, by="Range" )
#dta2 <- dta2[ order( dta2$ID ), ]

dta2 <- cbind( dta, breakpts[ match( dta$Range, breakpts$Range ), 

-which( "Range"==names( breakpts ) ) ] )


dta2$CumMARGE <- with( dta2, Mult/100 * ( CumVALUE - target * LastPct / 

100 ) + LastCumMARGE )

dta2$MARGE <- with( dta2, diff( c( 0, CumMARGE ) ) )

dta2
  ID VALUE CumVALUE CumPct Range PctTarget Mult LastPct DeltaPct 
CumMARGE LastCumMARGE MARGE
1 11 11 10[0,50]502   0   50 
2000   200
2 12 56 60   (50,75]754  50   25 
1400 1000  1200
3 13 39 90  (75,100]   1008  75   25 
3200 2000  1800
4 14 2   11110 (100,Inf]   Inf   10 100  Inf 
5000 4000  1800



target <- 10

breakpts <- data.frame( PctTarget=c(50,75,100,Inf), Mult=c(2,4,8,10) )
breakpts$LastPct <- c( 0, breakpts$PctTarget[ -nrow( breakpts ) ] )
breakpts$Range <- cut( breakpts$PctTarget, c( 0, breakpts$PctTarget ), 

include.lowest=TRUE )

breakpts$DeltaPct <- with( breakpts, diff( c( 0, PctTarget ) ) )
breakpts$CumMARGE <- target / 1e4 * with( breakpts, cumsum( DeltaPct * 

Mult ) )

breakpts$LastCumMARGE <- c( 0, breakpts$CumMARGE[ -nrow( breakpts ) ] )

dta <- data.frame( ID=11:14, VALUE=c(1,5,3,2) )
dta$CumVALUE <- cumsum( dta$VALUE )
dta$CumPct <- 100 * dta$CumVALUE / target
dta$Range <- cut( dta$CumPct, c( 0, breakpts$PctTarget ), 

include.lowest=TRUE )


dta

  ID VALUE CumVALUE CumPct Range
1 11 11 10[0,50]
2 12 56 60   (50,75]
3 13 39 90  (75,100]
4 14 2   11110 (100,Inf]

breakpts

  PctTarget Mult LastPct Range DeltaPct CumMARGE LastCumMARGE
1502   0[0,50]   50 10000
2754  50   (50,75]   25 2000 1000
3   1008  75  (75,100]   25 4000 2000
4   Inf   10 100 (100,Inf]  Inf  Inf 4000


#dta2 <- merge( dta, breakpts, all.x=TRUE, by="Range" )
#dta2 <- dta2[ order( dta2$ID ), ]

dta2 <- cbind( dta, breakpts[ match( dta$Range, breakpts$Range ), 

-which( "Range"==names( breakpts ) ) ] )


dta2$CumMARGE <- with( dta2, Mult/100 * ( CumVALUE - target * LastPct / 

100 ) + LastCumMARGE )

dta2$MARGE <- diff( c( 0, dta2$CumMARGE ) )

dta2
  ID VALUE CumVALUE CumPct Range PctTarget Mult LastPct DeltaPct 
CumMARGE LastCumMARGE MARGE
1 11 11 10[0,50]502   0   50 
2000   200
2 12 56 60   (50,75]754  50   25 
1400 1000  1200
3 13 39 90  (75,100]   1008  75   25 
3200 2000  1800
4 14 2   11110 (100,Inf]   Inf   10 100  Inf 
5000 4000  1800




On Mon, 9 Mar 2015, Matthias Weber wrote:


Hi David,

thanks for the reply. My spelling of the numbers was not correct. What I mean 
with 100.000 is 10.00 !
I have corrected the values in my example below me.

Maybe you can understand it better now.

Crucially is, that the "MARGE" rises up in dependence of the ID. The ID 11 will 
be count with 2% because we don't reach the 50% hurdle (5). The ID 12 will reach the 
50% hurdle, so the ID 12 should be count with 1200 (result of 4 * 2% + 1 * 4%). 
The 1 with 4% will be credited more, because they exceed the 50% Target Value.

Thanks for your help.

Best regards.

Mat

-Urspr?ngliche Nachricht-
Von: David L Carlson [mailto:dcarl...@tamu.edu]
Gesendet: Montag, 9. M?rz 2015 16:08
An: Matthias Weber; r-help@r-project.org
Betreff: RE: calculate value in dependence of target value

It 

Re: [R] SPSS command "match files" for merging one-to-many (hierarchical) equivalent in R?

2015-03-09 Thread Marc Schwartz

> On Mar 9, 2015, at 1:53 PM, Duncan Murdoch  wrote:
> 
> On 09/03/2015 1:40 PM, Kristina Loderer wrote:
>> Dear R community,
>> 
>> to combine data sets of hierarchical, nested nature (i.e., data sets
>> linked by, for example, the variable "study ID" and then also by
>> "outcome_variable_1" and "outcome_variable_2") I can use the match files
>> command in SPSS. What is the equivalent command / function in R? Is it
>> the merge function, or the match function? The more I read, the more
>> confused I become..
>> 
> 
> I don't know SPSS at all, so I can't help you.  If nobody else does, you 
> might try putting together a tiny example in R showing what you're starting 
> with, and what you want to produce.  From what you wrote, I'd guess merge(), 
> not match(), but you might really be asking for something completely 
> different.
> 
> Duncan Murdoch


Based upon the info here:

  http://www.ats.ucla.edu/stat/spss/modules/merge.htm

I would go with ?merge, since the desired functionality appears to be a 
relational join operation.

Regards,

Marc Schwartz

__
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] SPSS command "match files" for merging one-to-many (hierarchical) equivalent in R?

2015-03-09 Thread Duncan Murdoch

On 09/03/2015 1:40 PM, Kristina Loderer wrote:

Dear R community,

to combine data sets of hierarchical, nested nature (i.e., data sets
linked by, for example, the variable "study ID" and then also by
"outcome_variable_1" and "outcome_variable_2") I can use the match files
command in SPSS. What is the equivalent command / function in R? Is it
the merge function, or the match function? The more I read, the more
confused I become..



I don't know SPSS at all, so I can't help you.  If nobody else does, you 
might try putting together a tiny example in R showing what you're 
starting with, and what you want to produce.  From what you wrote, I'd 
guess merge(), not match(), but you might really be asking for something 
completely different.


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] Help with optim() to maximize log-likelihood

2015-03-09 Thread Sophia Kyriakou
yes Ben, this works indeed! Thanks a million!!

On Mon, Mar 9, 2015 at 7:17 PM, Ben Bolker  wrote:

> Sophia Kyriakou  gmail.com> writes:
>
> >
> > hello, I am using the optim function to maximize the log likelihood of a
> > generalized linear mixed model and I am trying to replicate glmer's
> > estimated components. If I set both the sample and subject size to
> q=m=100
> > I replicate glmer's results for the random intercept model with
> parameters
> >  beta=-1 and sigma^2=1. But if I change beta to 2 glmer works and optim
> > gives me the error message "function cannot be evaluated at initial
> > parameters".
> >
> > If anyone could please help?
> > Thanks
>
>  snip to make gmane happy.
>
> It looks like you're getting floating-point under/overflow.  If you do
> all the computations on the log scale first and then exponentiate,
> it seems to work, i.e.:
>
> piYc_ir[i,] <- lchoose(m,Y[i]) + Y[i]*(z+beta) +
> (-z^2/(2*exp(psi))) -
> m*(log1p(exp(z+beta))) - 0.5*(log(2*pi)+psi)
> piYc_ir[i,] <- exp(piYc_ir[i,])
>
> follow-ups should probably go to r-sig-mixed-mod...@r-project.org
> instead ...
>
>   Ben Bolker
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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 fevd fuction to list R

2015-03-09 Thread Zilefac Elvis
I have data for 90 climate stations. For each station, I have made 100+ 
simulations using a statistical model. So, in R, I have 90 dataframes, each 
dataframe has 100+ simulations arranged column-wise. 

Now, I would like to fit an extreme value distribution (EVD) to each climate 
station. That is, fit an EVD each to the 100+ simulations and make an average 
of the results. Repeat the same for all other climate stations. 


So far, I can apply 'fevd' function to each column in a dataframe. How can I 
apply this on list object?

library(extRemes) 

out.df <- lapply(df, fevd,type="GEV",method = c("MLE"))# fit GEv to each column 
of dataframe 
#lapply(out.df,plot) # make plots for all columns 
rlcis<-lapply(out.df,return.level, 
do.ci=TRUE,method="normal",return.period=c(2,5,10,20,50,100))# calc return and 
CIs for all columns 

lst=list(df,df,df,df) 

df=structure(list(Sim001 = c(120.79, 59.35, 51.14, 104.85, 51.09, 
138.91, 254.94, 56.44, 68.3, 51.69, 51.31, 51.08, 37.17, 38.02, 
62.13, 111.48, 118.38, 45.54, 44.87, 49.59), Sim002 = c(50.25, 
31.17, 67.48, 104.56, 59.82, 38.09, 50.76, 70.25, 35.8, 59.2, 
47.89, 55.21, 74.38, 51.88, 124.09, 91.86, 109.28, 65.61, 69.54, 
55.89), Sim003 = c(30.22, 50.07, 57.66, 57.97, 62.73, 43.84, 
103.61, 53.05, 60.71, 46.57, 65.87, 33.27, 60.24, 43.63, 115.68, 
37.24, 43.27, 46.38, 122.97, 86.02), Sim004 = c(38.6, 39.02, 
45.74, 201.55, 110.78, 49.91, 63.5, 48.65, 94.43, 37.01, 32.61, 
46.39, 120.25, 45.38, 70.26, 94.02, 67.35, 55.62, 59.3, 33.96 
), Sim005 = c(43.54, 68.42, 86.02, 78.9, 40.68, 59.97, 34.5, 
48.47, 68.81, 32, 49.53, 51.23, 51.42, 61.17, 38.02, 52.96, 45.25, 
39.18, 42.33, 97.15), Sim006 = c(45.96, 65.21, 94.81, 106.71, 
46.95, 26.93, 39.45, 33.79, 50.36, 31.22, 128.37, 177.03, 82.07, 
58.02, 32.5, 96.37, 73.77, 48.96, 143.52, 50.14), Sim007 = c(66.3, 
53.99, 162.7, 100.22, 48.76, 74.06, 49.3, 62.66, 158, 82.57, 
94.07, 93.01, 53.88, 160.91, 63.71, 44.93, 63.82, 56.7, 58.92, 
101.52), Sim008 = c(130.62, 75.48, 126.46, 49.97, 71.69, 66.81, 
89.33, 52.68, 29.19, 75.88, 89.69, 59.41, 84.16, 104.49, 65.04, 
66.41, 88.5, 56.64, 62.48, 77.08), Sim009 = c(60.58, 71.85, 62.08, 
57.4, 63.08, 45.38, 50.97, 59.42, 159.44, 120.94, 58.66, 54.57, 
77.45, 49.63, 48.88, 91.03, 103.42, 56.9, 97.04, 69.89), Sim010 = c(48.63, 
51.07, 65.13, 47.59, 94.73, 42.43, 68.77, 95.83, 42.16, 133.1, 
67.2, 56.91, 138.57, 39.26, 79.75, 123.67, 64.27, 64.83, 78.88, 
89.74), Sim011 = c(59.85, 53.73, 116.88, 95.06, 113.44, 87.64, 
47.37, 42.42, 36.69, 39.11, 76.91, 59.85, 76.29, 118.37, 39.14, 
50.76, 98.06, 40.71, 53.03, 42.93), Sim012 = c(128.35, 60.21, 
60.19, 51.69, 51.47, 35.44, 101.72, 82.83, 50.72, 68.66, 80.84, 
59.98, 79.84, 35.52, 128.69, 53.35, 84.77, 18.38, 28.98, 48), 
Sim013 = c(52.88, 117.11, 103.3, 103.59, 119.06, 62.66, 65.64, 
75.91, 81.78, 80.31, 22.83, 79.22, 51.33, 79.63, 86.26, 54.44, 
42.86, 63.95, 166.87, 58.48), Sim014 = c(50.28, 123.9, 35.87, 
133.52, 94.28, 62.35, 58.54, 42.08, 67.7, 101.44, 34.68, 
45.98, 60.99, 60.06, 79.76, 61.93, 59.4, 42.02, 56.45, 81.41 
), Sim015 = c(50.32, 39.01, 100.3, 105.38, 55.49, 36.36, 
56.49, 107.52, 38.7, 73.09, 98.22, 44.19, 50.17, 56.69, 44.82, 
44.09, 57.57, 52.55, 90.37, 78.62), Sim016 = c(35.2, 62.77, 
35.25, 52.05, 93.51, 65.84, 43.85, 54.52, 39.17, 62.02, 47.6, 
34.42, 190.57, 38.46, 94.9, 73.34, 78.5, 52.84, 103.7, 51.48 
), Sim017 = c(69.03, 58.19, 130.37, 80.04, 52.96, 65.14, 
65.08, 45.95, 65.35, 41.95, 78.67, 78.41, 56.51, 63.52, 52.93, 
52.32, 70.14, 81.59, 70.99, 105.02), Sim018 = c(55.98, 44.37, 
59.07, 36.65, 44.16, 26.62, 125.38, 75.54, 75.46, 25.62, 
22.95, 65.74, 72.86, 53.5, 32.05, 58.98, 70.87, 30.95, 78.25, 
54.75), Sim019 = c(147.82, 37.48, 161.91, 46.28, 95.4, 74.79, 
53.51, 58.73, 50.96, 32.03, 50.08, 60.03, 76.75, 45.31, 58.29, 
52.91, 42.84, 74.52, 83.19, 43.8), Sim020 = c(59.33, 218.52, 
64.55, 73.07, 59.9, 39.09, 129.88, 61.53, 56.7, 38.55, 62.2, 
29.25, 52.74, 57.86, 46.04, 80.03, 44.61, 88.52, 45.36, 93.97 
), Sim021 = c(93.44, 41.32, 67.08, 99.15, 89.43, 31.64, 38.59, 
65.08, 58.9, 52.7, 47.39, 47.91, 90.93, 54.57, 51.26, 44.59, 
33.52, 38.69, 44.92, 50.46), Sim022 = c(43.37, 43.47, 63.15, 
77.19, 117.13, 77.32, 65.36, 67.49, 49.18, 87.66, 70.09, 
110.66, 70.85, 46.71, 55.36, 45.53, 30.55, 51.7, 46.08, 65.91 
), Sim023 = c(65.76, 42.75, 50.2, 58.23, 69.27, 75.63, 46.72, 
72.47, 62.53, 50.87, 58.8, 63.61, 39.99, 91.36, 66.07, 100.32, 
55.34, 32.59, 59.8, 43.96), Sim024 = c(174.2, 70.17, 47.86, 
71.24, 91.39, 40.5, 28.66, 64.57, 33.02, 46.27, 68.56, 56.68, 
97.28, 46.24, 65.76, 72.53, 60.26, 128.26, 85.63, 107.29), 
Sim025 = c(84.66, 38.95, 43.63, 41.33, 108.67, 62.94, 64.73, 
57.26, 42.11, 100.24, 28, 35.95, 175.8, 61.64, 81.42, 67.55, 
68.12, 35.1, 46.63, 105.43), Sim026 = c(64.17, 55.25, 59.21, 
49.21, 104.75, 129.05, 76.05, 69.88, 110.19, 40.71, 103.17, 
74.32, 64.18, 55.66, 105.93, 36.25, 81.08, 75.96, 81.67, 
99.22), Sim027 = c(55.07, 53.32, 71.68, 37.51, 96.35, 42.25, 
41.22, 41.09, 67.46, 69.64

[R] SPSS command "match files" for merging one-to-many (hierarchical) equivalent in R?

2015-03-09 Thread Kristina Loderer
Dear R community,

to combine data sets of hierarchical, nested nature (i.e., data sets
linked by, for example, the variable "study ID" and then also by
"outcome_variable_1" and "outcome_variable_2") I can use the match files
command in SPSS. What is the equivalent command / function in R? Is it
the merge function, or the match function? The more I read, the more
confused I become..

Thank your for help in advance!

Kristina Loderer

-
Kristina Loderer
Ludwig-Maximilians-Universität München
Department Psychologie
Leopoldstr. 13
D-80802 München

Telefon: +49 (89) 2180-6047
Email: kristina.lode...@psy.lmu.de

-

__
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] Change the argument function inside R function in GPfit package

2015-03-09 Thread C W
Hi R list,

I am using the GPfit package to fit Gaussian Process model.

The kernel in the package is,
K(x, x') = sigma^2 * exp(x-x')^2

My kernel have an extra term,
K((x, z), (x', z')) = sigma^2 * exp(x-x')^2 * exp(z-z')^2

The function corr_matrix() is,
corr_matrix(X, beta, corr=list(type="exponential",power=1.95))
github source: https://github.com/cran/GPfit/blob/master/R/corr_matrix.R

I am changing the corr argument, so it looks like mine.  How should I do it?

Also, what package do you guys recommend for GP modeling?  I know GPstuff
or GPML but that's Matlab.

Thanks very much.

Mike

[[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] R/3.1.3 source installation

2015-03-09 Thread Prof Brian Ripley
This is the wrong list: see the posting guide.  As it is about compiled 
code, R-help is quite inappropriate, and as it is Mac-specific, post to 
R-sig-mac.


The issue appears to be that you did not follow the R-admin manual and 
used the wrong Fortran compiler: gfortran-4.2.3 is documented for 
Mountain Lion or earlier.  But you did not say exactly what you did use 


On 09/03/2015 17:47, White Sky wrote:

R 3.1.3 is available for installation via source-code.
However ./configure terminates with








checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... unknown
configure: WARNING: unknown Fortran name-mangling scheme
checking whether gfortran appends underscores to external names... unknown
configure: error: cannot use Fortran
Mac OSX 10.9.5 gfortran-4.2.3 (64bit)
Underscores are appended to external names by default but this doesn't seem to 
be recognised.
I have a feeling the problem might in the configure* file## DANGER!  We really 
needs the results of _AC_F77_NAME_MANGLING as## stored in the cache var 
ac_cv_f77_mangling which is not documented









## and hence may change ...
and then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${F77} appends underscores to external names" 
>&5$as_echo_n "checking whether ${F77} appends underscores to external names... " >&6; }









if ${r_cv_prog_f77_append_underscore+:} false; then :

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




--
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] R/3.1.3 source installation

2015-03-09 Thread White Sky
R 3.1.3 is available for installation via source-code.
However ./configure terminates with








checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... unknown
configure: WARNING: unknown Fortran name-mangling scheme
checking whether gfortran appends underscores to external names... unknown
configure: error: cannot use Fortran
Mac OSX 10.9.5 gfortran-4.2.3 (64bit)
Underscores are appended to external names by default but this doesn't seem to 
be recognised.
I have a feeling the problem might in the configure* file## DANGER!  We really 
needs the results of _AC_F77_NAME_MANGLING as## stored in the cache var 
ac_cv_f77_mangling which is not documented









## and hence may change ...
and then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${F77} appends 
underscores to external names" >&5$as_echo_n "checking whether ${F77} appends 
underscores to external names... " >&6; }









if ${r_cv_prog_f77_append_underscore+:} false; then :
  
[[alternative HTML version deleted]]

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


Re: [R] plotting the one-dimensional density of events in time

2015-03-09 Thread Christopher W. Ryan
Tom and Bill--

Thanks! Both excellent solutions.

--Chris

Christopher W. Ryan, MD, MS
cryanatbinghamtondotedu

Early success is a terrible teacher. You’re essentially being rewarded
for a lack of preparation, so when you find yourself in a situation
where you must prepare, you can’t do it. You don’t know how.
--Chris Hadfield, An Astronaut's Guide to Life on Earth

William Dunlap wrote:
> You could change the x component of density's output back into a Date object
> and let plot choose a Date axis in its usual way.  E.g.,
>   > den <- density(as.numeric(dd))
>   > den$x <- as.Date(den$x, origin=as.Date("1970-01-01"))
>   > plot(den$x, den$y)
> (You probably will also want to normalize the y component to be on a
> specific
> per time unit, say day or year, basis.)
> 
> 
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com 
> 
> On Fri, Mar 6, 2015 at 1:03 PM, Christopher W. Ryan
> mailto:cr...@binghamton.edu>> wrote:
> 
> I have the dates of occurence of a repetitive event. I would like to
> plot the density of these events, as well as their specific temporal
> location.  This is as far as I have gotten:
> 
> # generate some sample data: dates in 2014
> random.dates <- sample(1:31, 100, replace=TRUE)
> random.months <- sample(1:12, 100, replace=TRUE)
> dd <- as.Date(as.character((paste(random.dates, random.months, "2014",
> sep="-"))), format="%d-%m-%Y")
> dd <- dd[!is.na (dd)]
> 
> # plot density with a "rug".
> density(as.numeric(dd))
> plot(density(as.numeric(dd)))
> rug(as.numeric(dd))
> 
> # But horizontal axis label is not very informative
> # would prefer labeling the start of each month
> plot(density(as.numeric(dd)), axes=FALSE)
> library(zoo)
> new.axis <- as.yearmon(dd)
> 
> # but then what? This is where I get stuck--adding back a sensible axis
> 
> Grateful for any guidance.
> 
> Thanks.
> 
> --Chris
> --
> Christopher W. Ryan, MD, MS
> cryanatbinghamtondotedu
> 
> Early success is a terrible teacher. You’re essentially being rewarded
> for a lack of preparation, so when you find yourself in a situation
> where you must prepare, you can’t do it. You don’t know how.
> --Chris Hadfield, An Astronaut's Guide to Life on Earth
> 
> 
> ---
> 
> __
> R-help@r-project.org  mailing list --
> To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 


---

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

Re: [R] Help with optim() to maximize log-likelihood

2015-03-09 Thread Ben Bolker
Sophia Kyriakou  gmail.com> writes:

> 
> hello, I am using the optim function to maximize the log likelihood of a
> generalized linear mixed model and I am trying to replicate glmer's
> estimated components. If I set both the sample and subject size to q=m=100
> I replicate glmer's results for the random intercept model with parameters
>  beta=-1 and sigma^2=1. But if I change beta to 2 glmer works and optim
> gives me the error message "function cannot be evaluated at initial
> parameters".
> 
> If anyone could please help?
> Thanks

 snip to make gmane happy.

It looks like you're getting floating-point under/overflow.  If you do
all the computations on the log scale first and then exponentiate,
it seems to work, i.e.:

piYc_ir[i,] <- lchoose(m,Y[i]) + Y[i]*(z+beta) + (-z^2/(2*exp(psi))) - 
m*(log1p(exp(z+beta))) - 0.5*(log(2*pi)+psi)
piYc_ir[i,] <- exp(piYc_ir[i,])

follow-ups should probably go to r-sig-mixed-mod...@r-project.org
instead ...

  Ben Bolker

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


[R] Book: Beginner's Guide to Data Exploration and Visualisation with R.

2015-03-09 Thread Highland Statistics Ltd


We are please to announce the following book:

Title: Beginner's Guide to Data Exploration and Visualisation with R.
Authors: Ieno & Zuur


Book website: http://www.highstat.com/BGDEV.htm

Paperback or EBook can be order (exclusively) from:
http://www.highstat.com/bookorder.htm

TOC: http://www.highstat.com/BGS/DV/TOC_Online.pdf
Price: 29 GBP


Outline:
In 2010 we published a paper in the journal Methods in Ecology and Evolution 
entitled ‘A protocol for data exploration to avoid common statistical 
problems’. Little did we know at the time that this paper would become one of 
the journal’s all-time top papers, both top downloaded and top cited papers, 
with 22,472 downloads between 2010 and 2014.

Based on this success we decided to extend the material in the paper into a 
book. It is part of our 'Beginner’s Guide to ...' book series. We tried to 
write this book in such a way that the statistical knowledge level is as low as 
possible. A knowledge of linear regression is all that you need.


Keywords:
Outliers, normality, homogeneity, collinearity, relationships, confounding. 
Case studies



Kind regards,

Alain Zuur

--
Dr. Alain F. Zuur

First author of:
1. Beginner's Guide to GAMM with R (2014).
2. Beginner's Guide to GLM and GLMM with R (2013).
3. Beginner's Guide to GAM with R (2012).
4. Zero Inflated Models and GLMM with R (2012).
5. A Beginner's Guide to R (2009).
6. Mixed effects models and extensions in ecology with R (2009).
7. Analysing Ecological Data (2007).

Highland Statistics Ltd.
9 St Clair Wynd
UK - AB41 6DZ Newburgh
Tel:   0044 1358 788177
Email: highs...@highstat.com
URL:   www.highstat.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] calculate value in dependence of target value

2015-03-09 Thread David L Carlson
It is very hard to figure out what you are trying to do. 

1. All of the VALUEs are greater than the target of 100
2. Your description of what you want does not match your example.

Perhaps VALUE should be divided by 1000 (e.g. not 1, but 10)?
Perhaps your targets do not apply to VALUE, but to cumulative VALUE?

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



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Matthias Weber
Sent: Monday, March 9, 2015 7:46 AM
To: r-help@r-project.org
Subject: [R] calculate value in dependence of target value

Hello together,

i have a litte problem. Maybe anyone can help me.

I have to calculate a new column in dependence of a target value.

As a example: My target value is 100.000
At the moment I have a data.frame with the following values.

 IDVALUE
1   111
2   125
3   133
4   142

The new column ("MARGE") should be calculated with the following graduation:
Until the VALUE reach 50% of the target value (50.000) = 2%
Until the VALUE reach 75% of the target value (75.000) = 4%
Until the VALUE reach 100% of the target value (<100.000) = 8%
If the VALUE goes above 100% of the value (>100.000) = 10%

The result looks like this one:

 IDVALUE  MARGE
1   111  200  (result of 10.000 * 2%)
2   125 1200 (result of 40.000 * 2% + 10.000 * 4%)
3   133 1800 (result of 15.000 * 4% + 15.000 * 8%)
4   142 1800 (result of 10.000 * 8% + 10.000 * 10%)

Is there anyway to calculate the column "MARGE" automatically in R?

Thanks a lot for your help.

Best regards.

Mat


This e-mail may contain trade secrets, privileged, undisclosed or otherwise 
confidential information. If you have received this e-mail in error, you are 
hereby notified that any review, copying or distribution of it is strictly 
prohibited. Please inform us immediately and destroy the original transmittal. 
Thank you for your cooperation.

Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige 
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich 
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine 
Vervielfaeltigung oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte 
benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.

[[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] Add sum line to plot of multiple x values

2015-03-09 Thread Loris Bennett
PIKAL Petr  writes:

> Hi
>
> Not extremely clear what do you want to plot. Do you want to add a
> line which marks total number of files each day regardless of user? Or
> a total number of files regardless of date coloured by user?

Sorry, I was unclear.  I meant that I would like to plot the following:

1. For each user: the number of files for each date (my code does this)
2. The sum of files of all users for each date (this is what I still
   need) 

> In each case you shall search functions geom_hline or geom_abline
>
> http://stackoverflow.com/questions/13254441/add-a-horizontal-line-to-plot-and-legend-in-ggplot2

So I don't want a straight line

> ggplot is rather complicated but very flexible

I don't mind ggplot being complicated, but I find the documentation a
little impenetrable.

Cheers,

Loris


>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Loris
>> Bennett
>> Sent: Monday, March 09, 2015 2:56 PM
>> To: r-h...@stat.math.ethz.ch
>> Subject: [R] Add sum line to plot of multiple x values
>>
>> Hi,
>>
>> Here are my data:
>>
>> > d
>>user files   date
>> 1 alice18 2013-09-15
>> 2   bob 5 2013-09-15
>> 3 carol21 2013-09-15
>> 4 alice22 2013-09-08
>> 5   bob 9 2013-09-08
>> 6 carol14 2013-09-08
>> 7 alice26 2013-09-01
>> 8   bob 3 2013-09-01
>> 9 carol22 2013-09-01
>>
>> I would like to plot the number of files against date for all users, so
>> I have:
>>
>>   library(ggplot2)
>>
>>   people <- c("alice","bob","carol")
>>   user <- c(rep(people,3))
>>   files <- c(18,5,21,22,9,14,26,3,22)
>>   date <- c(rep("2013-09-15",3),rep("2013-09-08",3),rep("2013-09-
>> 01",3))
>>   d <- data.frame(user=user,files=files,date=date)
>>
>>   p <- ggplot()
>>   p <- p + geom_line(data=d,aes(x=date,y=files,group=user,colour=user))
>>
>> I would now like to add a line to show the total number of files as a
>> function of date.  I tried
>>
>>   p <- p +
>> geom_line(data=d,aes(x=date,y=sum(files),group=date),colour='black')
>>
>> I don't get a black line, but the plot is scaled such that I can see
>> that sum(file) for all values of 'file', rather than those for each
>> date, is being used.
>>
>> I would like to know how to do this correctly, but I would rather be
>> able to work it out for myself.  However, if I decide, say, that I
>> don't
>> know exactly what the 'group' argument does, how do I find it out?
>>
>> ?geom_line doesn't have it, although the examples there use it. ?ggplot
>> doesn't mention it. ?group gives me stuff about formatting text
>> arguments. ??group only leads me to ?ggplot2::add_group, which also
>> does
>> not seem to help.
>>
>> Am I at fault for trying to learn R in an ad hoc manner, to which the
>> documentation of R does not lend itself, or am I missing something?
>>
>> Cheers,
>>
>> Loris
>>
>> --
>> This signature is currently under construction.
>>
>> __
>> 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 re

Re: [R] calculate value in dependence of target value

2015-03-09 Thread Matthias Weber
Hi David,

thanks for the reply. My spelling of the numbers was not correct. What I mean 
with 100.000 is 10.00 !
I have corrected the values in my example below me.

Maybe you can understand it better now.

Crucially is, that the "MARGE" rises up in dependence of the ID. The ID 11 will 
be count with 2% because we don't reach the 50% hurdle (5). The ID 12 will 
reach the 50% hurdle, so the ID 12 should be count with 1200 (result of 4 * 
2% + 1 * 4%). The 1 with 4% will be credited more, because they exceed 
the 50% Target Value.

Thanks for your help.

Best regards.

Mat

-Ursprüngliche Nachricht-
Von: David L Carlson [mailto:dcarl...@tamu.edu]
Gesendet: Montag, 9. März 2015 16:08
An: Matthias Weber; r-help@r-project.org
Betreff: RE: calculate value in dependence of target value

It is very hard to figure out what you are trying to do.

1. All of the VALUEs are greater than the target of 100 2. Your description of 
what you want does not match your example.

Perhaps VALUE should be divided by 1000 (e.g. not 1, but 10)?
Perhaps your targets do not apply to VALUE, but to cumulative VALUE?

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



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Matthias Weber
Sent: Monday, March 9, 2015 7:46 AM
To: r-help@r-project.org
Subject: [R] calculate value in dependence of target value

Hello together,

i have a litte problem. Maybe anyone can help me.

I have to calculate a new column in dependence of a target value.

As a example: My target value is 10. At the moment I have a data.frame with 
the following values.

 IDVALUE
1   111
2   125
3   133
4   142

The new column ("MARGE") should be calculated with the following graduation:
Until the VALUE reach 50% of the target value (5) = 2%

Until the VALUE reach 75% of the target value (75000) = 4%

Until the VALUE reach 100% of the target value (<10) = 8%

If the VALUE goes above 100% of the value (>10) = 10%

The result looks like this one:

 IDVALUE  MARGE
1   111  200  (result of 1 * 2%)
2   125 1200 (result of 4 * 2% + 1 * 4%)
3   133 1800 (result of 15000 * 4% + 15000 * 8%)
4   142 1800 (result of 1 * 8% + 1 * 10%)

Is there anyway to calculate the column "MARGE" automatically in R?

Thanks a lot for your help.

Best regards.

Mat

This e-mail may contain trade secrets, privileged, undisclosed or otherwise 
confidential information. If you have received this e-mail in error, you are 
hereby notified that any review, copying or distribution of it is strictly 
prohibited. Please inform us immediately and destroy the original transmittal. 
Thank you for your cooperation.

Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige 
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich 
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine 
Vervielfaeltigung oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte 
benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.

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


[R] Help with optim() to maximize log-likelihood

2015-03-09 Thread Sophia Kyriakou
hello, I am using the optim function to maximize the log likelihood of a
generalized linear mixed model and I am trying to replicate glmer's
estimated components. If I set both the sample and subject size to q=m=100
I replicate glmer's results for the random intercept model with parameters
 beta=-1 and sigma^2=1. But if I change beta to 2 glmer works and optim
gives me the error message "function cannot be evaluated at initial
parameters".

If anyone could please help?
Thanks

 # likelihood function
 ll <- function(x,Y,m){
 beta <- x[1]
 psi <- x[2]
 q <- length(Y)
  p <- 20
 rule20 <- gaussHermiteData(p)
 wStar <- exp(rule20$x * rule20$x + log(rule20$w))
 # Integrate over(-Inf, +Inf) using adaptive Gauss-Hermite quadrature
 g <- function(alpha, beta, psi, y, m) {-y+m*exp(alpha + beta)/(1 +
exp(alpha + beta)) + alpha/exp(psi)}
 DDfLik <- deriv(expression(-y+m*exp(alpha + beta)/(1 + exp(alpha + beta))
+ alpha/exp(psi)),
 namevec = "alpha", func = TRUE,function.arg = c("alpha", "beta", "psi",
"y", "m"))
   int0 <- rep(NA,q)
 piYc_ir <- matrix(NA,q,p)
 for (i in 1:q){
 muHat <- uniroot(g, c(-10, 10),extendInt ="yes", beta = beta, psi = psi, y
= Y[i], m = m)$root
 jHat <- attr(DDfLik(alpha = muHat, beta, psi, Y[i], m), "gradient")
 sigmaHat <- 1/sqrt(jHat)
 z <- muHat + sqrt(2) * sigmaHat * rule20$x
 piYc_ir[i,] <-
choose(m,Y[i])*exp(Y[i]*(z+beta))*exp(-z^2/(2*exp(psi)))/((1+exp(z+beta))^m*sqrt(2*pi*exp(psi)))
 int0[i] <- sqrt(2)*sigmaHat*sum(wStar*piYc_ir[i,])
 }
 ll <- -sum(log(int0))
 ll
 }

 beta <- 2
 sigma2 <- 1
 m <- 100
 q <- 100

 cl <- seq.int(q)
 tot <- rep(m,q)

 set.seed(123)
 alpha <- rnorm(q, 0, sqrt(sigma2))
 Y <- rbinom(q,m,plogis(alpha+beta))

 dat <- data.frame(y = Y, tot = tot, cl = cl)
 f1 <- glmer(cbind(y, tot - y) ~ 1 + (1 | cl), data = dat,family =
binomial(),nAGQ = 20)
 betaH <- summary(f1)$coefficients[1]
 sigma2H <- as.numeric(summary(f1)$varcor)
 thetaglmer <- c(betaH,sigma2H)

 logL <- function(x) ll(x,Y,m)
 thetaMLb <- optim(c(plogis(sum(Y/m)),log(sigma2H)),fn=logL)$par
 Error in optim(c(plogis(sum(Y/m)), log(sigma2H)), fn = logL) :  function
cannot be evaluated at initial parameters

thetaglmer
[1] 2.1128529 0.8311484
 (thetaML <- c(thetaMLb[1],exp(thetaMLb[2])))

[[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] Extract year from date

2015-03-09 Thread MacQueen, Don
You need to solve step 1 (converting to Date class) before you can solve
step 2 (getting the year as a number).

In the data you are starting with, the first value in the Date column is
41163. You don't say whether that column is numeric or character, so let's
try it both ways:

> as.Date('41163','%m/%d/%Y')
[1] NA

> as.Date(41163,'%m/%d/%Y')
Error in charToDate(x) :
  character string is not in a standard unambiguous format


Whatever it is, it is not formatted "%m/%d/%Y", so step 1 fails.


On the other hand, if you start with something that is in fact formatted
as a date:

> tmp <-  as.Date('3/2/2015','%m/%d/%Y')
> format(tmp,'%Y')
[1] "2015"
> as.numeric(format(tmp,'%Y'))
[1] 2015


you get the year as a number, using the method you tried.

So, what do 41163 and all the rest of the numbers in your Date column
actually represent???

Mark Sharp is probably correct in expecting that they represent the number
of days since some base date, and an easy way to see that would be to try
the core of step 1:

> as.Date(41163)
Error in as.Date.numeric(41163) : 'origin' must be supplied

It would be up to you, of course, to find out what the origin is. If
1/1/1900 is correct, then


> as.numeric( format( as.Date( 41163, origin='1900-1-1'), '%Y'))
[1] 2012


(I personally prefer to use base R as much as possible)

-Don

-- 
Don MacQueen

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





On 3/7/15, 11:50 PM, "Steve Archambault"  wrote:

>Hi all,
>
>I am trying in vain to create a new object "Year" in my data frame from
>existing Date data. I have tried many different approaches, but can't seem
>to get it to work. Here is an example of some code I tried.
>
>date1<- as.Date(wells$Date,"%m/%d/%Y")
>wells$year<-as.numeric(format(date1, "%Y"))
>
>I am starting with data that looks like this.
>
>ID  Date DepthtoWater_bgs test test2
>1  BC-0004 41163   260.603 1
>2  BC-0004 41255   261.654 2
>3  BC-0003 41345   166.585 3
>4  BC-0002 41351   317.856 4
>5  BC-0004 41355   262.157 5
>6  BC-0003 41438   167.558 6
>7  BC-0004 41438   265.459 7
>8  BC-0002 41443   317.25   10 8
>9  BC-0002 41521   321.25   11 9
>10 BC-0003 41522   168.65   1210
>11 BC-0004 41522   266.15   1311
>12 BC-0003 41627   168.95   1412
>13 BC-0004 41627   265.25   1513
>14 BC-0002 41634   312.31   1614
>15 BC-0003 41703   169.25   1715
>16 BC-0004 41703   265.05   1816
>17 BC-0002 41710   313.01   1917
>18 BC-0003 41795   168.85   2018
>19 BC-0004 41795   266.95   2119
>20 BC-0002 41801   330.41   2220
>21 BC-0003 41905   169.75   2321
>22 BC-0004 41905   267.75   2422
>23 BC-0002 41906   321.01   2523
>
>Any help would be greatly appreciated!
>
>-Steve
>Sent from my iPhone
>
>__
>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] Add sum line to plot of multiple x values

2015-03-09 Thread PIKAL Petr
Hi

Not extremely clear what do you want to plot. Do you want to add a line which 
marks total number of files each day regardless of user? Or a total number of 
files regardless of date coloured by user?

In each case you shall search functions geom_hline or geom_abline

http://stackoverflow.com/questions/13254441/add-a-horizontal-line-to-plot-and-legend-in-ggplot2

ggplot is rather complicated but very flexible

Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Loris
> Bennett
> Sent: Monday, March 09, 2015 2:56 PM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Add sum line to plot of multiple x values
>
> Hi,
>
> Here are my data:
>
> > d
>user files   date
> 1 alice18 2013-09-15
> 2   bob 5 2013-09-15
> 3 carol21 2013-09-15
> 4 alice22 2013-09-08
> 5   bob 9 2013-09-08
> 6 carol14 2013-09-08
> 7 alice26 2013-09-01
> 8   bob 3 2013-09-01
> 9 carol22 2013-09-01
>
> I would like to plot the number of files against date for all users, so
> I have:
>
>   library(ggplot2)
>
>   people <- c("alice","bob","carol")
>   user <- c(rep(people,3))
>   files <- c(18,5,21,22,9,14,26,3,22)
>   date <- c(rep("2013-09-15",3),rep("2013-09-08",3),rep("2013-09-
> 01",3))
>   d <- data.frame(user=user,files=files,date=date)
>
>   p <- ggplot()
>   p <- p + geom_line(data=d,aes(x=date,y=files,group=user,colour=user))
>
> I would now like to add a line to show the total number of files as a
> function of date.  I tried
>
>   p <- p +
> geom_line(data=d,aes(x=date,y=sum(files),group=date),colour='black')
>
> I don't get a black line, but the plot is scaled such that I can see
> that sum(file) for all values of 'file', rather than those for each
> date, is being used.
>
> I would like to know how to do this correctly, but I would rather be
> able to work it out for myself.  However, if I decide, say, that I
> don't
> know exactly what the 'group' argument does, how do I find it out?
>
> ?geom_line doesn't have it, although the examples there use it. ?ggplot
> doesn't mention it. ?group gives me stuff about formatting text
> arguments. ??group only leads me to ?ggplot2::add_group, which also
> does
> not seem to help.
>
> Am I at fault for trying to learn R in an ad hoc manner, to which the
> documentation of R does not lend itself, or am I missing something?
>
> Cheers,
>
> Loris
>
> --
> This signature is currently under construction.
>
> __
> 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

[R] Add sum line to plot of multiple x values

2015-03-09 Thread Loris Bennett
Hi,

Here are my data:

> d
   user files   date
1 alice18 2013-09-15
2   bob 5 2013-09-15
3 carol21 2013-09-15
4 alice22 2013-09-08
5   bob 9 2013-09-08
6 carol14 2013-09-08
7 alice26 2013-09-01
8   bob 3 2013-09-01
9 carol22 2013-09-01

I would like to plot the number of files against date for all users, so
I have:

  library(ggplot2)

  people <- c("alice","bob","carol")
  user <- c(rep(people,3))
  files <- c(18,5,21,22,9,14,26,3,22)
  date <- c(rep("2013-09-15",3),rep("2013-09-08",3),rep("2013-09-01",3))
  d <- data.frame(user=user,files=files,date=date)

  p <- ggplot()
  p <- p + geom_line(data=d,aes(x=date,y=files,group=user,colour=user))

I would now like to add a line to show the total number of files as a
function of date.  I tried

  p <- p + geom_line(data=d,aes(x=date,y=sum(files),group=date),colour='black')

I don't get a black line, but the plot is scaled such that I can see
that sum(file) for all values of 'file', rather than those for each
date, is being used.

I would like to know how to do this correctly, but I would rather be
able to work it out for myself.  However, if I decide, say, that I don't
know exactly what the 'group' argument does, how do I find it out?

?geom_line doesn't have it, although the examples there use it. ?ggplot
doesn't mention it. ?group gives me stuff about formatting text
arguments. ??group only leads me to ?ggplot2::add_group, which also does
not seem to help. 

Am I at fault for trying to learn R in an ad hoc manner, to which the
documentation of R does not lend itself, or am I missing something?

Cheers,

Loris

-- 
This signature is currently under construction.

__
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] calculate value in dependence of target value

2015-03-09 Thread Matthias Weber
Hello together,

i have a litte problem. Maybe anyone can help me.

I have to calculate a new column in dependence of a target value.

As a example: My target value is 100.000
At the moment I have a data.frame with the following values.

 IDVALUE
1   111
2   125
3   133
4   142

The new column ("MARGE") should be calculated with the following graduation:
Until the VALUE reach 50% of the target value (50.000) = 2%
Until the VALUE reach 75% of the target value (75.000) = 4%
Until the VALUE reach 100% of the target value (<100.000) = 8%
If the VALUE goes above 100% of the value (>100.000) = 10%

The result looks like this one:

 IDVALUE  MARGE
1   111  200  (result of 10.000 * 2%)
2   125 1200 (result of 40.000 * 2% + 10.000 * 4%)
3   133 1800 (result of 15.000 * 4% + 15.000 * 8%)
4   142 1800 (result of 10.000 * 8% + 10.000 * 10%)

Is there anyway to calculate the column "MARGE" automatically in R?

Thanks a lot for your help.

Best regards.

Mat


This e-mail may contain trade secrets, privileged, undisclosed or otherwise 
confidential information. If you have received this e-mail in error, you are 
hereby notified that any review, copying or distribution of it is strictly 
prohibited. Please inform us immediately and destroy the original transmittal. 
Thank you for your cooperation.

Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige 
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich 
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine 
Vervielfaeltigung oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte 
benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.

[[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] R: Reverse Complementary Base Problem

2015-03-09 Thread Boris Steipe
Use reverseComplement() in the Biostrings package.
B.


On Mar 8, 2015, at 10:08 PM, saran wai  wrote:

> Hi I'm new to R programming and trying to write program for Reverse and 
> Complementary Base. the objective is to Design A DNA primer. So I have a DNA 
> sequence with base A T C G and A complement to T; T=A;C=G;G=C.  I just figure 
> out How to Reverse It Already. but for the Complement i can only make it 
> answer for just 1 base but cant be all of the sequence.  and i dont know how 
> to combine reverse and complement function. here is my code and im totallt 
> confuse with it. Cn someone help me with this problem? You will be my life 
> savior! thank you! strReverse <- function(x)   sapply(lapply(strsplit(x, 
> NULL), rev), paste, collapse="") strReverse(c("ATCGGTCAATCGA")) 
> complement.base = function(base){   if(base == 'A' | base ==  'a')   
> print("T")   if(base == 'T' | base == 't') print("A")   if(base == 'G' | base 
> == 'g') print("C")   if(base == 'C' | base == 'c') print("G")} 
> complement.base(base="A") 
>   [[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] Rstudio R-devel libR.so

2015-03-09 Thread Jeff Newmiller
Please read the Posting Guide. Unreleased versions of R are off-topic in this 
mailing list (see the R-devel mailing list). RStudio-specific questions are 
also off-topic here (should be about R, not IDEs).
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On March 9, 2015 4:48:11 AM PDT, Karim Mezhoud  wrote:
>Thanks Pascal. Not yet resolved.
>Here is an example of symbolic link between libR.so
>https://support.rstudio.com/hc/communities/public/questions/200661703-R-shared-library-usr-local-lib-R-lib-libR-so-not-found-UBUNTU-11-
>
>When I get a symbolic link with:
>
> sudo ln -s  /usr/lib/R/lib/libR.so /usr/local/R-devel//lib/libR.so
>
>
>The R session had a fatal error.
>
>
>ERROR r error 4 (R code execution error) [errormsg=Error in
>.Internal(getOption(x)) :
>
>there is no .Internal function 'getOption'
>
>]; OCCURRED AT: core::Error r::exec::evaluateString(const std::string&,
>SEXPREC**, r::sexp::Protect*) /home/ubuntu/rstudio/src/cpp/r/RExec.cpp:
>
>
>
>On Mon, Mar 9, 2015 at 10:53 AM, Pascal Oettli 
>wrote:
>
>> Hello,
>>
>> There is a dedicated support to RStudio here:
>https://support.rstudio.com
>>
>> Regards,
>> Pascal
>>
>> On Mon, Mar 9, 2015 at 7:41 PM, Karim Mezhoud 
>wrote:
>> > Dear All,
>> > I am actually on R-devel using shell consol. When I run RStudio, it
>can't
>> > find libR.so in the new /lib folder where is libRblas.so 
>libRlapack.so.
>> > At first step I configure R-devel to share library with ./configure
>> > --enable-R-shlib.
>> >
>> > when I copied libR.so from  /usr/lib/R/lib/libR.so (stable version
>R 3.1)
>> > to /usr/local/R-devel/lib/libR.so (R-devel version), That doesn't
>work.
>> >
>> > please find the detail  at below.
>> > Karim mezhoud
>> >
>> >
>> >
>> >
>> > $which R
>> > /usr/bin/R
>> > $R
>> >> R.Version()[13]
>> > $version.string
>> > [1] "R version 3.1.2 (2014-10-31)
>> >
>> >> Sys.getenv("R_HOME")
>> > [1] "/usr/lib/R"
>> >
>> >> .Library
>> > [1] "/usr/lib/R/library"
>> >> .libPaths()
>> > [1] "/home/mezhoud/R/x86_64-pc-linux-gnu-library/3.1"
>> > [2] "/usr/local/lib/R/site-library"
>> > [3] "/usr/lib/R/site-library"
>> > [4] "/usr/lib/R/library"
>> > "
>> >
>> >
>> > $sudo apt-get build-dep r-base
>> > $sudo apt-get install subversion ccache
>> > $mkdir ~/svn/
>> > $cd ~/svn/
>> > $svn co https://svn.r-project.org/R/trunk r-devel/R
>> >
>> > $cd /svn/r-devel/R
>> > $./configure --enable-R-shlib
>> > $make
>> > $make check
>> > $sudo make install rhome=/usr/local/R-devel
>> >
>> > $which R
>> > /usr/local/bin/R
>> >
>> > $cd /usr/local/bin
>> > $R
>> >
>> >>R.Version()[13]
>> > $version.string
>> > [1] "R Under development (unstable) (2015-03-07 r67951)"
>> >
>> >> .libPaths()
>> > [1] "/usr/local/R-devel/library"
>> >> .Library
>> > [1] "/usr/local/R-devel/library"
>> >
>> >> Sys.getenv("R_HOME")
>> > [1] "/usr/local/R-devel"
>> >
>> > $rstudio
>> > R shared library (/usr/local/R-devel/lib/libR.so) not found.
>> > If this is a custom build of R, was it built with the
>--enable-R-shlib
>> > option?
>> >
>> > $export RSTUDIO_WHICH_R=/usr/local/bin/R
>> > $rstudio
>> > R shared library (/usr/local/R-devel/lib/libR.so) not found.
>> > If this is a custom build of R, was it built with the
>--enable-R-shlib
>> > option?
>> >
>> > $export RSTUDIO_WHICH_R=/usr/local/R-devel/bin/R
>> > $rstudio
>> > R shared library (/usr/local/R-devel/lib/libR.so) not found.
>> > If this is a custom build of R, was it built with the
>--enable-R-shlib
>> > option?
>> >
>> > $sudo locate libR.so
>> > /usr/lib/libR.so
>> > /usr/lib/R/lib/libR.so
>> >
>> > [[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.
>>
>>
>>
>> --
>> Pascal Oettli
>> Project Scientist
>> JAMSTEC
>> Yokohama, Japan
>>
>
>   [[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/mail

[R] R: Reverse Complementary Base Problem

2015-03-09 Thread saran wai
Hi I'm new to R programming and trying to write program for Reverse and 
Complementary Base. the objective is to Design A DNA primer. So I have a DNA 
sequence with base A T C G and A complement to T; T=A;C=G;G=C.  I just figure 
out How to Reverse It Already. but for the Complement i can only make it answer 
for just 1 base but cant be all of the sequence.  and i dont know how to 
combine reverse and complement function. here is my code and im totallt confuse 
with it. Cn someone help me with this problem? You will be my life savior! 
thank you! strReverse <- function(x)   sapply(lapply(strsplit(x, NULL), rev), 
paste, collapse="") strReverse(c("ATCGGTCAATCGA")) complement.base = 
function(base){   if(base == 'A' | base ==  'a')   print("T")   if(base == 'T' 
| base == 't') print("A")   if(base == 'G' | base == 'g') print("C")   if(base 
== 'C' | base == 'c') print("G")} complement.base(base="A") 
  
[[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] Show all elements

2015-03-09 Thread Leandro Marino
Hi,

Look to the following code:

set.seed(1)
dados =
data.frame(valor=rnorm(100),var=sample(LETTERS[c(1,2,3,5)],100,replace=T),peso=rpois(100,2))
dados[1:10,]
dados$var <- factor(dados$var,levels=LETTERS[1:5])
table(dados$var)
 A  B  C  D  E
31 31 19  0 19

When I try to use summarize, Hmisc package it shows me the result without D
category.

g1 <- function(y) wtd.mean(y[,1],y[,2])
summarize(dados[,c(1,3)], llist(var=dados$var), g1,stat.name = 'med')
  var med
1   A  0.02589377
2   B  0.37123239
3   C -0.57820359
4   E  0.39584514

How do I get med = NA or something else with summarize?

I realy need to the function to return all factors in the var even it they
are an empty set.

thanks in advance.

leandro

[[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] "survMisc" package

2015-03-09 Thread Andrews, Chris
The package maintainer may be able to give help.  However, I don't get the same 
output as you (3.1.2).  Perhaps you can update and solve your problem.

> require(survMisc)
Loading required package: survMisc
Loading required package: survival
Loading required package: splines
Loading required package: ggplot2

Attaching package: ‘survMisc’

The following object is masked from ‘package:ggplot2’:

autoplot

The following objects are masked from ‘package:stats’:

AIC, BIC, median, quantile

> data(kidney,package="KMsurv")
> s1 <- survfit(Surv(time=time, event=delta) ~ type, data=kidney )
> comp(s1)
$tne
   t   n e n_type=1 e_type=1 n_type=2 e_type=2
 1:  0.5 119 6   766   430
 2:  1.5 103 1   600   431
 3:  2.5  98 2   562   420
 4:  3.5  89 2   491   401
 5:  4.5  79 2   430   362
 6:  5.5  73 1   400   331
 7:  6.5  66 1   351   310
 8:  8.5  55 2   300   252
 9:  9.5  49 1   270   221
10: 10.5  45 1   250   201
11: 11.5  40 1   220   181
12: 15.5  25 2   141   111
13: 16.5  23 1   130   101
14: 18.5  20 1   11091
15: 23.5   9 15041
16: 26.5   5 13021

$tests
$tests$lrTests
ChiSq df   p
Log-rank  2.529506318  1 0.11174
Gehan-Breslow (mod~ Wilcoxon) 0.002084309  1 0.96359
Tarone-Ware   0.402738202  1 0.52568
Peto-Peto 1.399160019  1 0.23686
Mod~ Peto-Peto (Andersen) 1.275908836  1 0.25866
Flem~-Harr~ with p=1, q=1 9.834062861  1 0.00171

$tests$supTests
   Q   p
Log-rank1.590442 0.22347
Gehan-Breslow (mod~ Wilcoxon)   1.430499 0.30511
Tarone-Ware 1.260498 0.41467
Peto-Peto   1.166979 0.48551
Mod~ Peto-Peto (Andersen)   1.185549 0.47085
Renyi Flem~-Harr~ with p=1, q=1 7.460348 0.0




-Original Message-
From: Endy BlackEndy [mailto:pert...@gmail.com] 
Sent: Sunday, March 08, 2015 12:44 PM
To: r-help
Subject: [R] "survMisc" package

Hi R users. I have some problems with the package “survMisc”. When I am
loading it I am getting the following



> library(survMisc)

Loading required package: survival

Loading required package: splines

Loading required package: km.ci

Loading required package: ggplot2

Loading required package: data.table

data.table 1.9.4  For help type: ?data.table

*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.

Loading required package: gridExtra

Loading required package: grid

Loading required package: rpart



Attaching package: ‘survMisc’



The following objects are masked from ‘package:stats’:



AIC, BIC, median, quantile



   In the above output I noticed the line with the three stars (*). In
order to restore the data.table in its previous behavior I tried to locate
the README file but I couldn’t.

   I ignored that NB in the previous output and I continue to run the
example given in the above mentioned package for the routine comp(). The
commands and the output are given below.

> ### 2 curves

> data(kidney,package="KMsurv")

> s1 <- survfit(Surv(time=time, event=delta) ~ type, data=kidney )

> comp(s1)

$tne

   t  n  e   n_type=1   e_type=1   n_type=2   e_type=2

 1:  1.586 2   431
431

 2:  3.580 2   401
401

 3:  4.572 4   362
362

 4:  5.566 2   331
331

 5:  8.560 4   302  30
   2

 6:  9.554 2   271
271

 7: 10.5   50 2   251
251

 8: 11.544 2   22   1
221

 9: 15.528 4   14   2
142

10: 16.5   26 2   13   1
131

11: 18.5   22 2   11   1
  111

12: 23.5 8 24 1
41

13: 26.5 6 23 1
31



$tests

$tests$lrTests

ChiSq df p

Log-rank0  1 1

Gehan-Breslow (mod~ Wilcoxon) 0  1 1

Tarone-Ware  0  1 1

Peto-Peto  0  1 1

Mod~ Peto-Peto (Andersen)0  1 1

Flem~-Harr~ with p=1, q=1   

Re: [R] Rstudio R-devel libR.so

2015-03-09 Thread Karim Mezhoud
Thanks Pascal. Not yet resolved.
Here is an example of symbolic link between libR.so
https://support.rstudio.com/hc/communities/public/questions/200661703-R-shared-library-usr-local-lib-R-lib-libR-so-not-found-UBUNTU-11-

When I get a symbolic link with:

 sudo ln -s  /usr/lib/R/lib/libR.so /usr/local/R-devel//lib/libR.so


The R session had a fatal error.


ERROR r error 4 (R code execution error) [errormsg=Error in
.Internal(getOption(x)) :

there is no .Internal function 'getOption'

]; OCCURRED AT: core::Error r::exec::evaluateString(const std::string&,
SEXPREC**, r::sexp::Protect*) /home/ubuntu/rstudio/src/cpp/r/RExec.cpp:



On Mon, Mar 9, 2015 at 10:53 AM, Pascal Oettli  wrote:

> Hello,
>
> There is a dedicated support to RStudio here: https://support.rstudio.com
>
> Regards,
> Pascal
>
> On Mon, Mar 9, 2015 at 7:41 PM, Karim Mezhoud  wrote:
> > Dear All,
> > I am actually on R-devel using shell consol. When I run RStudio, it can't
> > find libR.so in the new /lib folder where is libRblas.so  libRlapack.so.
> > At first step I configure R-devel to share library with ./configure
> > --enable-R-shlib.
> >
> > when I copied libR.so from  /usr/lib/R/lib/libR.so (stable version R 3.1)
> > to /usr/local/R-devel/lib/libR.so (R-devel version), That doesn't work.
> >
> > please find the detail  at below.
> > Karim mezhoud
> >
> >
> >
> >
> > $which R
> > /usr/bin/R
> > $R
> >> R.Version()[13]
> > $version.string
> > [1] "R version 3.1.2 (2014-10-31)
> >
> >> Sys.getenv("R_HOME")
> > [1] "/usr/lib/R"
> >
> >> .Library
> > [1] "/usr/lib/R/library"
> >> .libPaths()
> > [1] "/home/mezhoud/R/x86_64-pc-linux-gnu-library/3.1"
> > [2] "/usr/local/lib/R/site-library"
> > [3] "/usr/lib/R/site-library"
> > [4] "/usr/lib/R/library"
> > "
> >
> >
> > $sudo apt-get build-dep r-base
> > $sudo apt-get install subversion ccache
> > $mkdir ~/svn/
> > $cd ~/svn/
> > $svn co https://svn.r-project.org/R/trunk r-devel/R
> >
> > $cd /svn/r-devel/R
> > $./configure --enable-R-shlib
> > $make
> > $make check
> > $sudo make install rhome=/usr/local/R-devel
> >
> > $which R
> > /usr/local/bin/R
> >
> > $cd /usr/local/bin
> > $R
> >
> >>R.Version()[13]
> > $version.string
> > [1] "R Under development (unstable) (2015-03-07 r67951)"
> >
> >> .libPaths()
> > [1] "/usr/local/R-devel/library"
> >> .Library
> > [1] "/usr/local/R-devel/library"
> >
> >> Sys.getenv("R_HOME")
> > [1] "/usr/local/R-devel"
> >
> > $rstudio
> > R shared library (/usr/local/R-devel/lib/libR.so) not found.
> > If this is a custom build of R, was it built with the --enable-R-shlib
> > option?
> >
> > $export RSTUDIO_WHICH_R=/usr/local/bin/R
> > $rstudio
> > R shared library (/usr/local/R-devel/lib/libR.so) not found.
> > If this is a custom build of R, was it built with the --enable-R-shlib
> > option?
> >
> > $export RSTUDIO_WHICH_R=/usr/local/R-devel/bin/R
> > $rstudio
> > R shared library (/usr/local/R-devel/lib/libR.so) not found.
> > If this is a custom build of R, was it built with the --enable-R-shlib
> > option?
> >
> > $sudo locate libR.so
> > /usr/lib/libR.so
> > /usr/lib/R/lib/libR.so
> >
> > [[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.
>
>
>
> --
> Pascal Oettli
> Project Scientist
> JAMSTEC
> Yokohama, Japan
>

[[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] Rstudio R-devel libR.so

2015-03-09 Thread Pascal Oettli
Hello,

There is a dedicated support to RStudio here: https://support.rstudio.com

Regards,
Pascal

On Mon, Mar 9, 2015 at 7:41 PM, Karim Mezhoud  wrote:
> Dear All,
> I am actually on R-devel using shell consol. When I run RStudio, it can't
> find libR.so in the new /lib folder where is libRblas.so  libRlapack.so.
> At first step I configure R-devel to share library with ./configure
> --enable-R-shlib.
>
> when I copied libR.so from  /usr/lib/R/lib/libR.so (stable version R 3.1)
> to /usr/local/R-devel/lib/libR.so (R-devel version), That doesn't work.
>
> please find the detail  at below.
> Karim mezhoud
>
>
>
>
> $which R
> /usr/bin/R
> $R
>> R.Version()[13]
> $version.string
> [1] "R version 3.1.2 (2014-10-31)
>
>> Sys.getenv("R_HOME")
> [1] "/usr/lib/R"
>
>> .Library
> [1] "/usr/lib/R/library"
>> .libPaths()
> [1] "/home/mezhoud/R/x86_64-pc-linux-gnu-library/3.1"
> [2] "/usr/local/lib/R/site-library"
> [3] "/usr/lib/R/site-library"
> [4] "/usr/lib/R/library"
> "
>
>
> $sudo apt-get build-dep r-base
> $sudo apt-get install subversion ccache
> $mkdir ~/svn/
> $cd ~/svn/
> $svn co https://svn.r-project.org/R/trunk r-devel/R
>
> $cd /svn/r-devel/R
> $./configure --enable-R-shlib
> $make
> $make check
> $sudo make install rhome=/usr/local/R-devel
>
> $which R
> /usr/local/bin/R
>
> $cd /usr/local/bin
> $R
>
>>R.Version()[13]
> $version.string
> [1] "R Under development (unstable) (2015-03-07 r67951)"
>
>> .libPaths()
> [1] "/usr/local/R-devel/library"
>> .Library
> [1] "/usr/local/R-devel/library"
>
>> Sys.getenv("R_HOME")
> [1] "/usr/local/R-devel"
>
> $rstudio
> R shared library (/usr/local/R-devel/lib/libR.so) not found.
> If this is a custom build of R, was it built with the --enable-R-shlib
> option?
>
> $export RSTUDIO_WHICH_R=/usr/local/bin/R
> $rstudio
> R shared library (/usr/local/R-devel/lib/libR.so) not found.
> If this is a custom build of R, was it built with the --enable-R-shlib
> option?
>
> $export RSTUDIO_WHICH_R=/usr/local/R-devel/bin/R
> $rstudio
> R shared library (/usr/local/R-devel/lib/libR.so) not found.
> If this is a custom build of R, was it built with the --enable-R-shlib
> option?
>
> $sudo locate libR.so
> /usr/lib/libR.so
> /usr/lib/R/lib/libR.so
>
> [[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.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
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] Rstudio R-devel libR.so

2015-03-09 Thread Karim Mezhoud
Dear All,
I am actually on R-devel using shell consol. When I run RStudio, it can't
find libR.so in the new /lib folder where is libRblas.so  libRlapack.so.
At first step I configure R-devel to share library with ./configure
--enable-R-shlib.

when I copied libR.so from  /usr/lib/R/lib/libR.so (stable version R 3.1)
to /usr/local/R-devel/lib/libR.so (R-devel version), That doesn't work.

please find the detail  at below.
Karim mezhoud




$which R
/usr/bin/R
$R
> R.Version()[13]
$version.string
[1] "R version 3.1.2 (2014-10-31)

> Sys.getenv("R_HOME")
[1] "/usr/lib/R"

> .Library
[1] "/usr/lib/R/library"
> .libPaths()
[1] "/home/mezhoud/R/x86_64-pc-linux-gnu-library/3.1"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"
"


$sudo apt-get build-dep r-base
$sudo apt-get install subversion ccache
$mkdir ~/svn/
$cd ~/svn/
$svn co https://svn.r-project.org/R/trunk r-devel/R

$cd /svn/r-devel/R
$./configure --enable-R-shlib
$make
$make check
$sudo make install rhome=/usr/local/R-devel

$which R
/usr/local/bin/R

$cd /usr/local/bin
$R

>R.Version()[13]
$version.string
[1] "R Under development (unstable) (2015-03-07 r67951)"

> .libPaths()
[1] "/usr/local/R-devel/library"
> .Library
[1] "/usr/local/R-devel/library"

> Sys.getenv("R_HOME")
[1] "/usr/local/R-devel"

$rstudio
R shared library (/usr/local/R-devel/lib/libR.so) not found.
If this is a custom build of R, was it built with the --enable-R-shlib
option?

$export RSTUDIO_WHICH_R=/usr/local/bin/R
$rstudio
R shared library (/usr/local/R-devel/lib/libR.so) not found.
If this is a custom build of R, was it built with the --enable-R-shlib
option?

$export RSTUDIO_WHICH_R=/usr/local/R-devel/bin/R
$rstudio
R shared library (/usr/local/R-devel/lib/libR.so) not found.
If this is a custom build of R, was it built with the --enable-R-shlib
option?

$sudo locate libR.so
/usr/lib/libR.so
/usr/lib/R/lib/libR.so

[[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] problem with function that adds rows to dataframe based on conditional statement

2015-03-09 Thread PIKAL Petr
Hi

As you do not accept solution with adding so many NA rows for those you do not 
have repetitions I think that merge together with some preparation is the way 
to go.

First of all do not use cbind when constructing data frame

comAn=data.frame(animals,animalYears,animalMass)

# indicator variable how many repetitions in each combination animal year have
comAn$ind<-ave(comAn$animalYears, paste(comAn$animals, comAn$animalYears), 
FUN=table)

# expected levels (depends on how many years and repetitions for each year do 
you have)
lev<-expand.grid(levels(comAn$animals), 1:2, 2)

# to correct names
names(lev)[1:2]<-names(comAn)[1:2]
names(lev)[3]<-"ind"

merge(lev, comAn, all=T)

leads to put NA to the row in which required combination is missing.

You can then propagate this NA to any column you wish.

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Curtis
> Burkhalter
> Sent: Friday, March 06, 2015 10:01 PM
> To: Tom Wright
> Cc: r-help@r-project.org
> Subject: Re: [R] problem with function that adds rows to dataframe
> based on conditional statement
>
> Hey Tom,
>
> This solution works great, but if I try to then insert it in my
> function that I've displayed above and apply it to my split dataframe I
> get the error message:
>
> Error in `[.default`(xj, i) : invalid subscript type 'list'
>
> The reason why I need to try and get this to work within the function
> is that I'm trying to apply it to a much larger dataframe
> (nrow=12000,ncol=14). The actual data I'm working with consists of a
> sampling year, a site, and a bunch of response variables. For each
> sampling year by site combination I have 3 within year sampling
> occasions. For the sampling year by site combinations that don't have 3
> sampling events I need to fill in the missing occasions with the NAs.
>
> Can you see why I might be getting this error message?
>
> Thanks
>
>
>
> On Fri, Mar 6, 2015 at 1:48 PM, Tom Wright  wrote:
>
> > If all you want is to add a row of na's could you just do something
> > like:
> >
> > nExpectedRows<-length(unique(animals)) * length(unique(animalYears))
> *
> > 2
> >
> > newDf<-data.frame(animals=rep(NA,nExpectedRows-nrow(comAn)),
> >   animalYears=rep(NA,nExpectedRows-nrow(comAn)),
> >   animalMass=rep(NA,nExpectedRows-nrow(comAn)))
> >
> > comAn = rbind(comAn,newDf)
> >
> >
> >
> > On Thu, 2015-03-05 at 13:41 -0700, Curtis Burkhalter wrote:
> > > Hello everyone,
> > >
> > > I'm having a problem with a function that I wrote that is supposed
> > > to
> > add a
> > > row to dataframe based upon a conditional statement. To explain
> I've
> > > used an example below:
> > >
> > > #create data frame
> > > animals=c("bird","dog","cat")
> > > animals=rep(animals,each=4)
> > > animals=animals[1:11]
> > > animalYears=c(1,1,2,2,1,1,2,2,1,1,2)
> > > animalMass=round(runif(11,min=10,max=50),0)
> > >
> > > comAn=as.data.frame(cbind(animals,animalYears,animalMass))
> > > comAn
> > >
> > >   * animals* *animalYears* *animalMass*
> > > 1 bird   1 30
> > > 2 bird   1 32
> > > 3 bird   2 27
> > > 4 bird   2 16
> > > 5  dog   1 22
> > > 6  dog   1 25
> > > 7  dog   2 41
> > > 8  dog   2 22
> > > 9  cat   1 30
> > > 10 cat   1 37
> > > 11 cat   2 49
> > >
> > > We can see here that for every type of animal I have two years of
> > > mass measurements, except for the cat in year 2. What I want to do
> > > is add an additional row to the end of the dataframe that consists
> > > strictly of NAs and then I can substitute those out later.
> > >
> > > So what I first did was split the 'comAn' dataframe into the
> > > different Animal by Year combos.
> > >
> > > #This line splits 'com_An' into a list ordered by the Animal by
> Year
> > combos
> > > comAn_split=split(comAn, paste(comAn$animals,comAn$animalYear))
> > >
> > > Then I wrote the function that identifies whether a particular
> > > Animal by Year combo is less than two rows in length and if so it
> > > should add
> > another
> > > row that consists only of NAs using the vector 'NAs':
> > >
> > > #This function identifies the length of each Animal by Year combo
> > > and
> > then
> > > #uses the rbind function built in R to add a row #to each animal by
> > > year combo if they have less than 2 samples
> > >
> > > addNA <- function(comAn) {
> > >   NAs=c(NA,NA,NA)
> > > ind <- seq_len(nrow(comAn))
> > > comAn[ifelse(length(ind)<2,rbind(NAs),length(ind)),]
> > > }
> > >
> > > #This applies the function addNs to the animals data organized in
> > > list format addedNAcomAn <- do.call(rbind, lapply(comAn_split,
> > > addNA)) addedNAcomAn
> > >
> > > When I apply the function to the list of the different Animal by
> > > Year combos this is what I get:
> > >

[R] R 3.1.3 is released

2015-03-09 Thread Peter Dalgaard
The build system rolled up R-3.1.3.tar.gz (codename "Smooth Sidewalk") this 
morning.

The list below details the changes in this release.

You can get the source code from

http://cran.r-project.org/src/base/R-3/R-3.1.3.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team

Peter Dalgaard


These are the md5sums for the freshly created files, in case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = cebbdd1eb8cd620bf2a6ac84c9e731c2
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = a699fa0eeef280b78134f0abe0b1c1b0
MD5 (INSTALL) = 3964b9119adeaab9ceb633773fc94aac
MD5 (NEWS) = 8790db3a8000910f0bf00fb1ee039634
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = 8e2f4d1d5228663ae598a09bf1e2bc6b
MD5 (R-latest.tar.gz) = 53a85b884925aa6b5811dfc361d73fc4
MD5 (R.css) = 444535b9cb76ddff1bab1e1865a3fb14
MD5 (README) = aece1dfbd18c1760128c3787f5456af6
MD5 (RESOURCES) = a59076c1ac7e9bab0f0a38b3f57a3914
MD5 (THANKS) = 1989ce89fb3891420c9964dc418ab71c
MD5 (R-3/R-3.1.3.tar.gz) = 53a85b884925aa6b5811dfc361d73fc4


This is the relevant part of the NEWS file

CHANGES IN R 3.1.3:

  NEW FEATURES:

* The internal method of download.file() can now handle files
  larger than 2GB on 32-bit builds which support such files (tested
  on 32-bit R running on 64-bit Windows).

* kruskal.test() warns on more types of suspicious input.

* The as.dendrogram() method for "hclust" objects gains a check
  argument protecting against memory explosion for invalid inputs.

* capabilities() has a new item long.double which indicates if the
  build uses a long double type which is longer than double.

* nlm() no longer modifies the callback argument in place (a new
  vector is allocated for each invocation, which mimics the
  implicit duplication that occurred in R < 3.1.0); note that this
  is a change from the previously documented behavior. (PR#15958)

* icuSetCollate() now accepts locale = "ASCII" which uses the basic
  C function strcmp and so collates strings byte-by-byte in
  numerical order.

* sessionInfo() tries to report the OS version in use (not just
  that compiled under, and including details of Linux
  distributions).

* model.frame() (used by lm() and many other modelling functions)
  now warns when it drops contrasts from factors.  (Wish of
  PR#16119)

* install.packages() and friends now accept the value type =
  "binary" as a synonym for the native binary type on the platform
  (if it has one).

* Single source or binary files can be supplied for
  install.packages(type = "both") and the appropriate type and
  repos = NULL will be inferred.

* New function pcre_config() to report on some of the configuration
  options of the version of PCRE in use.  In particular, this
  reports if regular expressions using \p{xx} are supported.

* (Windows.) download.file(cacheOK = FALSE) is now supported when
  internet2.dll is used.

* browseURL() has been updated to work with Firefox 36.0 which has
  dropped support for the -remote interface.

  INSTALLATION and INCLUDED SOFTWARE:

* The included version of PCRE has been updated to 8.36.

* configure accepts MAKEINFO=texi2any as another way to ensure
  texinfo 5.x is used when both 5.x and 4.x are installed.

  UTILITIES:

* R CMD check now checks the packages used in \donttest sections of
  the examples are specified in the DESCRIPTION file.  (These are
  needed to run the examples interactively.)

* R CMD check checks for the undeclared use of GNU extensions in
  Makefiles, and for Makefiles with a missing final linefeed.

  R CMD build will correct line endings in all Makefiles, not just
  those in the src directory.

* R CMD check notes uses of library() and require() in package
  code: see the section 'Suggested packages' of 'Writing R
  Extensions' for good practice.

  DEPRECATED AND DEFUNCT:

* The configure option --with-valgrind-instrumentation=3 is
  deprecated and will be removed in R 3.2.0.

  BUG FIXES:

* (Windows.) Rscript.exe was missing a manifest specifying the
  modern style for common controls (e.g., the download progress
  bar).

* If a package had extra documentation files but no vignette, the
  HTML help system produced an empty index page.

* The parser now gives an error if a null character is included in
  a string using Unicode escapes. (PR#16046)

* qr.Q() failed on complex arguments due to pre-3.0(!) typo.
  (PR#16054)

* abs() failed with named arguments when the argument was complex.
  (PR#16047)

* "noquote" objects may now be used as columns in dataframes.
  (PR#15997)

* Some value