Re: [R] Extracting windows from time series

2016-04-06 Thread Jim Lemon
Hi Matthias,
It looks to me as though you could do this with a couple of loops:

temps<-rnorm(400,14,0.05)
ttind<-NULL
for(ti in 1:(length(temps)-9)) {
 if(temps[ti]-temps[ti+9] >= 0.1 && max(temps[ti]-temps[ti+1:9]) > -0.05)
  ttind<-c(ttind,ti)
}
cat("\t\t",paste("Year",1:10,sep=""),"\n")
for(ti in 1:length(ttind)) {
 cat("Trend ",ti,":\t",sep="")
 cat(round(temps[ttind[ti]:(ttind[ti]+9)],3),sep="\t","\n")
}

Whether my criteria for determining a trend is correct is another matter.

Jim

On Thu, Apr 7, 2016 at 12:27 AM,   wrote:
> Dear R Users
>
> Thanks for the help in advance and lets get straight to the problem:
> I have a 400 year long temperature time series and I am looking for decades 
> that show a linear trend decrease of approximately -0.1 Kelvin or degrees. 
> --> What I would like to program: A loop/function / command line that prints 
> the values of all the trends (can also be overlapping) into a matrix that 
> could have the following structure :
>
> Year 1 (of Trend1) Year 2 ( ... 2) Year 3 . 
> . .
> Trend 1:
> Trend 2:
> Trend 3:
> ...
> .
> .
>
>  I  first tried to solve the task with a loop but ended up doing it with 
> function but got stuck. Here is what I did so far:
>
> Puls <- Surface_temperature_MA10[10:394] + 1 # give all values in the TS a 
> positive value. Like that
> ## I can easier extract the trends that fullfill the searched condition 
> (decrease of 0.1 Kelvin) --> look  next line
>
> Difference <- diff(Puls,lag=10) # x[(1+lag):n] - x[1:(n-lag)] --> time step 
> 20 - timestep 10 for first calculation --> does that for whole time series
> ID <- c(1:375)
> melted_Difference <- melt(data.frame(Difference,ID),id.vars="ID")
>
> Hiatus <- subset(melted_Difference,value < -0.1)
>
> here the result :
> 23   23 Difference -0.1184901
> 24   24 Difference -0.1723032
> 25   25 Difference -0.1366112
> 26   26 Difference -0.1745479
> 27   27 Difference -0.1805964
> 28   28 Difference -0.2285250
> 29   29 Difference -0.2449096
> 30   30 Difference -0.1052558
> 44   44 Difference -0.1172029
>
> -->23,24,25 etc. corresponds to the first years of the trends that shows a 
> decrease of at least -0.1 Kelvin/decade. So far my method works. The purpose 
> of that was that I could then use the window() function to extract
> the original values from Puls.
> This works, but only for one decade at one time -->
>
> List_Hiatus <- window(Puls,1,start = c(23), end =  c(34))
>> List_Hiatus
>  [1] 1.125813 1.143880 1.123572 1.139369 1.134410 1.137944 1.139320 1.055780 
> 1.026300 1.042695 1.007323 0.971577
> attr(,"tsp")
> [1] 23 34  1
>
> Tried but failed with the following approaches:
>
> Start_H <- as.numeric(Hiatus[,1:1])
> End_H <- as.numeric(Start_H + 10)
> List_Hiatus <- window(Puls,1,start = "Start_H", end =  "End_H")
>
> OR :
> List_Hiatus <- window(Puls,1,start = c(23,24), end =  c(33,34))   # where c 
> could of course be expanded
>
> Or
> apply(Puls,2,window(start=c(Start_H),end=c(End_H)))
>
> Thanks again for your time.
>
> Best Matthias
>
>
>
> [[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] Is this a bug in quantmod::OpCl?

2016-04-06 Thread Joshua Ulrich
On Tue, Apr 5, 2016 at 9:17 PM, James Hirschorn
 wrote:
>
> OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug?
>
Thanks for the minimal, reproducible example.

Looks like a bug.  There's no as.quantmod.OHLC.xts method, so the zoo
method is dispatched.  Calling Op() or Cl() on this zoo-based object
results in a vector (since zoo will drop dimensions, like a matrix or
data.frame), and you can't set column names on a vector.

I'm not sure whether it makes more sense to check for dims in all the
combination transformations (consisting of combined Op, Hi, Lo, Cl) or
to create a as.quantmod.OHLC.xts method.

Can you provide some details about your use case?

> Example error:
>
> x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1
> set.seed(1)
> x <- zoo(matrix(runif(20, 0, 1), nrow=5, ncol=4), x.Date)
> q <- as.quantmod.OHLC(x,c("Open","High","Low","Close"))
>
> # error
> OpCl(q)
> #> Error in `colnames<-`(`*tmp*`, value = "OpCl.q") :
> #>  attempt to set 'colnames' on an object with less than two dimensions
>
> # OK
> OpCl(as.xts(q))
>
> [[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.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.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] Optimization max likelihood problem

2016-04-06 Thread ProfJCNash
At the "solution" -- which nlm seems to find OK -- you have a very
nasty scaling issue. exp(z) has value > 10^300.

Better transform your problem somehow to avoid that. You are taking
log of this except for adding 1, so effectively have just z. But you
should look at it carefully and do a number of checks to actually
evaluate the function.

And I would not trust the results if you cannot get analytic gradient of
your function. If you have the gradient, then you can do just a Jacobian
of it numerically to get the Hessian. numDeriv has a jacobian() function
that works nicely for this, and you are then doing only 1 level of
numerical approximation.

However, if that language doesn't mean anything to you, you probably
should not be attempting this problem yourself.

JN


On 16-04-06 02:31 PM, Alaa Sindi wrote:
> hello all,
> 
> I am getting wrong estimates from this code. do you know what could be the 
> problem. 
> 
> thanks
> 
> 
> x<- c(1.6, 1.7, 1.7, 1.7, 1.8, 1.8, 1.8, 1.8)
> y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
> n <- c(59, 60, 62, 56, 63, 59, 62, 60)
> 
> DF <- data.frame(x, y, n)
> 
> # note: there is no need to have the choose(n, y) term in the likelihood
> fn <- function(p, DF) {
>   z <- p[1]+p[2]*DF$x
>   sum( - (DF$y*z) - DF$n*log(1+exp(z)))
>   
>   #sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))) )
> }
> out <- nlm(fn, p = c(1,1),DF, hessian = TRUE, print.level=2)
> print(out)
> eigen(out$hessian)
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] Revolutions blog: March 2016 Roundup

2016-04-06 Thread David Smith
Since 2008, Microsoft (formerly 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.

And in case you missed them, here are some articles related to R from the month 
of March:

Reviews of new CRAN packages RtutoR, lavaan.shiny, dCovTS, glmmsr, GLMMRR, 
MultivariateRandomForest, genie, kmlShape,
deepboost and rEDM: 
http://blog.revolutionanalytics.com/2016/03/whats-new-on-cran.html

You can now create and host Jupyter notebooks based on R, for free, in Azure ML 
Studio:
http://blog.revolutionanalytics.com/2016/03/jupyter-notebooks.html

Calculating learning curves for predictive models with doParallel:
http://blog.revolutionanalytics.com/2016/03/learning-from-learning-curves.html

An amusing look at some of R's quirks: 
http://blog.revolutionanalytics.com/2016/03/about-those-weird-things-in-r.html

A recording of a recent talk I gave on real-time predictive analytics, 
featuring R:
http://blog.revolutionanalytics.com/2016/03/introductions-to-r-and-predictive-analytics.html

A preview of the New York R Conference: 
http://blog.revolutionanalytics.com/2016/03/get-ready-for-nyr.html

The R Consortium has funded seven community projects and two working groups for 
R projects:
http://blog.revolutionanalytics.com/2016/03/r-consortium-announces-new-grants-for-r-projects-and-working-groups.html

A look at several methods for computing 
http://blog.revolutionanalytics.com/2016/03/com_class_eval_metrics_r.html and
assessing the performance of classification models, with R:
http://blog.revolutionanalytics.com/2016/03/classification-models.html

An application to help airlines prevent unexpected maintenance delays, based on 
predictive models created with R:
http://blog.revolutionanalytics.com/2016/03/predictive-maintenance.html

Using R to predict the winning basketball team in the March Madness competition:
http://blog.revolutionanalytics.com/2016/03/march-madness.html

How to call an R function published to Azure ML from an Excel worksheet:
http://blog.revolutionanalytics.com/2016/03/scoring-r-models-with-excel.html

You can now use magrittr pipes with the out-of-memory XDF data files used by 
Microsoft R Server:
http://blog.revolutionanalytics.com/2016/03/dplyrxdf-update.html

Watch the recorded webinar "Data Preparation Techniques with R", and download 
the free e-book by Nina Zumel:
http://blog.revolutionanalytics.com/2016/03/data-preparation-webinar.html

An R-based application to automatically classify galaxies in the World Wide 
Telescope was featured in a keynote at
Microsoft's Data Driven event: 
http://blog.revolutionanalytics.com/2016/03/sql-server-2016-launch.html

Microsoft R Server is now available in the Azure Marketplace:
http://blog.revolutionanalytics.com/2016/03/r-server-azure-mkt.html

R 3.2.4 was released by the R Core Group on March 10: 
http://blog.revolutionanalytics.com/2016/03/r-324-released.html

Previews of some talks at the Bay Area R Users Group:
http://blog.revolutionanalytics.com/2016/03/barug-at-strata-and-paw.html

R Tools for Visual Studio, which lets you edit and debug R code within Visual 
Studio, is now available:
http://blog.revolutionanalytics.com/2016/03/rtvs-preview.html

A tutorial on creating election maps with R, from ComputerWorld:
http://blog.revolutionanalytics.com/2016/03/interactive-election-maps.html

A history of the R project since the release of version 1.0.0:
http://blog.revolutionanalytics.com/2016/03/16-years-of-r-history.html

Calculating confidence intervals for Random Forest predictions based on a 
corrected jackknife estimator:
http://blog.revolutionanalytics.com/2016/03/confidence-intervals-for-random-forest.html

Microsoft's Data Science Virtual Machine now includes Microsoft R Server:
http://blog.revolutionanalytics.com/2016/03/ds-vm-update.html

Using a pet tracker and R to map the movements of a cat:
http://blog.revolutionanalytics.com/2016/03/analysing-the-movements-of-a-cat.html

General interest stories (not related to R) in the past month included: 
typography in movies
(http://blog.revolutionanalytics.com/2016/03/fonts-from-the-future.html), 
rubiks cube juggling
(http://blog.revolutionanalytics.com/2016/03/because-its-friday-juggle-solve.html),
 pianograms
(http://blog.revolutionanalytics.com/2016/03/because-its-friday-pianograms.html)
 and a robot rebellion
(http://blog.revolutionanalytics.com/2016/03/our-robot-overlords.html).

Meeting times for local R user groups 
(http://blog.revolutionanalytics.com/local-r-groups.html) can be found on the
updated R Community Calendar at: 
http://blog.revolutionanalytics.com/calendar.html
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.

As 

Re: [R] Descriptive Statistics of time series data

2016-04-06 Thread David L Carlson
For mean() and sd() you need to convert the data frame to a matrix (I'm 
guessing here since you did not show us the structure of your data). The min() 
and max() functions should work on the data frame just fine. If you have other 
columns in the data frame, extract the monthly columns first.

> set.seed(42)
> x <- data.frame(matrix(rnorm(100), 20, 5))
> str(x)
'data.frame':   20 obs. of  5 variables:
 $ X1: num  1.371 -0.565 0.363 0.633 0.404 ...
 $ X2: num  -0.307 -1.781 -0.172 1.215 1.895 ...
 $ X3: num  0.206 -0.361 0.758 -0.727 -1.368 ...
 $ X4: num  -0.367 0.185 0.582 1.4 -0.727 ...
 $ X5: num  1.5127 0.2579 0.0884 -0.1209 -1.1943 ...
> mean(as.matrix(x))
[1] 0.03251482
> sd(as.matrix(x))
[1] 1.041357
> min(x)
[1] -2.99309
> max(x)
[1] 2.286645

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

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Saba Sehrish 
via R-help
Sent: Wednesday, April 6, 2016 6:51 AM
To: r-help@r-project.org
Subject: [R] Descriptive Statistics of time series data

Hi

I have four variables and the time series data for each variable consists of 
values for past 10 years on monthly basis. I want to get descriptive stats for 
these four variables separately (mean, median, sd, min, max).

The data I import to R consists of different columns, where each column gives 
values for one month of a particular year (e.g. March 31st, 2010). Right now R 
gives descriptive results for each column, whereas I need it collectively for 
all the years ( one mean, one sd, one min, one max and one median) for each 
variable.

Kindly guide me in this regard.

Thanks.
Saba

Sent from Yahoo Mail on Android


[[alternative HTML version deleted]]

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

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


[R] Optimization max likelihood problem

2016-04-06 Thread Alaa Sindi
hello all,

I am getting wrong estimates from this code. do you know what could be the 
problem. 

thanks


x<- c(1.6, 1.7, 1.7, 1.7, 1.8, 1.8, 1.8, 1.8)
y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
n <- c(59, 60, 62, 56, 63, 59, 62, 60)

DF <- data.frame(x, y, n)

# note: there is no need to have the choose(n, y) term in the likelihood
fn <- function(p, DF) {
  z <- p[1]+p[2]*DF$x
  sum( - (DF$y*z) - DF$n*log(1+exp(z)))
  
  #sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))) )
}
out <- nlm(fn, p = c(1,1),DF, hessian = TRUE, print.level=2)
print(out)
eigen(out$hessian)
__
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] Descriptive Statistics of time series data

2016-04-06 Thread John C Frain
Use the r function scan() to read the entire file into a vector and then
extract the observations for each series (possible using loops?)

John C Frain
3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

On 6 April 2016 at 12:50, Saba Sehrish via R-help 
wrote:

> Hi
>
> I have four variables and the time series data for each variable consists
> of values for past 10 years on monthly basis. I want to get descriptive
> stats for these four variables separately (mean, median, sd, min, max).
>
> The data I import to R consists of different columns, where each column
> gives values for one month of a particular year (e.g. March 31st, 2010).
> Right now R gives descriptive results for each column, whereas I need it
> collectively for all the years ( one mean, one sd, one min, one max and one
> median) for each variable.
>
> Kindly guide me in this regard.
>
> Thanks.
> Saba
>
> Sent from Yahoo Mail on Android
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Plotting data on a map

2016-04-06 Thread Bert Gunter
Did you check the "Spatial" task view page?

https://cran.r-project.org/web/views/Spatial.html

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Apr 6, 2016 at 2:20 AM,   wrote:
> Hello,
>
> I would like to generate a small map (say 10cm x 10cm) of France showing 
> cumulative numbers by Distribution Center
> stored in a database:
>
> DISTRIBUTION_CENTER COUNT
> Paris   122
> Paris   3
> Paris   21
> Lyon12
> Lyon
> Lyon33
> Grenoble55
> Grenoble999
> Grenoble99
> ...
>
> I have looked at different graphing packages such as 'sp', 'raster' and 
> 'ggplot2', but am not sure which one is most
> appropriate for my purposes. Furthermore, I don't understand how you retrieve 
> city coordinates from shp, gadm, etc., maps
> generated, or downloaded from the web and then processed, with those packages 
> (SHP, GADM, etc.), and plot data at those coordinates.
>
> Any help would be much appreciated.
>
> Many thanks.
>
> Philippe
>
> __
> 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] Plotting data on a map

2016-04-06 Thread Giorgio Garziano
Some tutorials and examples may help.

http://www.zoology.ubc.ca/~kgilbert/mysite/Miscellaneous_files/R_MakingMaps.pdf

http://coulmont.com/cartes/rcarto.pdf

https://pakillo.github.io/R-GIS-tutorial/

http://www.milanor.net/blog/maps-in-r-plotting-data-points-on-a-map/

https://www.youtube.com/watch?v=PTti7OMbURo

https://www.nceas.ucsb.edu/scicomp/usecases/CreateMapsWithRGraphics


--

Best,

GG



[[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] HTML help -- as a single document for the entire package

2016-04-06 Thread Holger Hoefling
Hi David,

thanks - I do have that as well. That is a good chance to clarify. The
regular help gives a *separate* page for every single function. The regular
pdf-manual gives one document for *all* functions in a package.

The nice thing about having a single html page for all functions in a
package would be that it is easily searchable in the browser, it is more
lightweight than a pdf and wouldn't be restricted by formatting based on
the notion that it has to be printable to a page on paper.

I was wondering if something like this exists ... and Duncan very quickly
answered that for me.

Thanks

Holger

On Wed, Apr 6, 2016 at 5:57 PM, David Winsemius 
wrote:

>
> > On Apr 6, 2016, at 2:37 AM, Duncan Murdoch 
> wrote:
> >
> > On 06/04/2016 4:17 AM, Holger Hoefling wrote:
> >> Hi,
> >>
> >> I was wondering if there was an equivalent to the pdf-manual for
> >> R-packages, but rendered as a single html page? I am looking for this
> as it
> >> would make reading easier as
> >> - no restriction to the standard paper width, but flowing to the browser
> >> window size
> >> - no page breaks
> >> - full text search across the entire manual.
> >
> > No, there isn't.
>
> My somewhat different understanding may simply be a reflection of a
> different operating system (given my inferior knowledge of the R ecosystems
> to that of Duncan). I run R in the R.app GUI on a Mac and the Help menu
> dropdown choice brings up links (in browser form) to local versions of the
> documents that I thought were  shipped with every new installation.
> Assuming your request is for an html version of "Writing R Extensions",
> then I get one with:
>
> http://127.0.0.1:15834/doc/manual/R-exts.html
>
> --
> David.
>
>
> > 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.
>
> David Winsemius
> Alameda, CA, USA
>
>

[[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-dvel [robustness Simulation study of 2 sample test on several combination of factors ]

2016-04-06 Thread tan sj

Hi, i think i have figured the purpose of using this index (i-1)*5+j in the 
previous example that you gave.

It is because that i have to consider the outer loop and inner loop also... so 
the iterative for i need to minus one because it have ran one times simulation 
already ,then times the number of sizes of inner loop, then plus the iterative 
of j

then for the simulation, i think there will be ((ss-1)*nsds +sim) for the index 
in the body of for loop...
Is it correct?

Sent from my phone

On Jim Lemon , Apr 6, 2016 6:52 PM wrote:
You are running through two loops and putting the output into a
vector. Without this calculation you will overwrite the same elements
of the output vector instead of advancing through it. Try this
example:

# like your 54 element vector of calculations for one condition
testmat1<-rep(0,25)
testmat2<-rep(0,25)
# now try to fill it with the inner loop index
for(i in 1:5) {
 for(j in 1:5) {
  testmat1[j]<-i+j
 }
}
# do it again using a calculation similar to your question
for(i in 1:5) {
 for(j in 1:5) {
  testmat2[(i-1)*5+j]<-i+j
 }
}
testmat1
testmat2

Try out some other things with this. It will give you an idea of how
to index elements of vectors. You could also use a matrix and then
convert it into a vector using as.vector:

testmat3<-matrix(0,nrow=5,ncol=5)
for(i in 1:5) {
 for(j in 1:5) {
  testmat3[i,j]<-i+j
 }
}
as.vector(testmat3)

Jim

On Wed, Apr 6, 2016 at 8:04 PM, tan sj  wrote:
> Hi, i am sorry to interrupt, can I ask about this few problems?
>
>   t_equal[(ss-1)*nsds+i]<-t.test(x_norm1,y_norm2,var.equal=TRUE)$p.value
> 1. From above, what do "[(ss-1)*nsds+i]" brings to the code?
>
> 2. what is the purpose of having i (the iterative) here ? I see that dr. have 
> set the sim as the iterative then why need to set i <-1 and set it as i<-i+1?
>
> they are confusing me.
> I am sorry if these are very simple problem
>
>
> 
> From: Jim Lemon 
> Sent: Wednesday, April 6, 2016 4:00 AM
> To: tan sj; r-help mailing list
> Subject: Re: [R] R-dvel [robustness Simulation study of 2 sample test on 
> several combination of factors ]
>
> You have quite a few mistakes in your example. The code below works
> for me - you can wrap it in a function if you like. I think you will
> need a lot more practice before you can write something like this in R
> as you are missing close braces and haven't really worked out the
> difference between the number of calculations you are doing for each
> replication and the number of replications. It takes 5-10 minutes to
> run.
>
>  ## Put the samples sizes into matrix then use a loop for sample sizes
> sample_sizes<-
>  matrix(c(10,10,10,25,25,25,25,50,25,100,50,25,50,100,100,25,100,100),
>  nrow=2)
>
> #create vector to combine all std deviations
> sds<-c(4,6,8,10,12,14)
> # this number is needed below
> nsds<-length(sds)
> set.seed(8)
>
> #number of simulations
> nSims<-1
> #set significance level,alpha for the whole simulatio
> alpha<-0.05
>
> #set empty vector of length no.of _calculations_ to store p-values
> # Note: you have 54 calculations, not 1
> ncalcs<-dim(sample_sizes)[2]*nsds
> t_equal <-c(rep(0,length=ncalcs))
> t_unequal <-c(rep(0,length=ncalcs))
> mann <-c(rep(0,length=ncalcs))
>
> #set up matrix for storing data from the vectors
> # but you do want 1 replications of each calculation
> matrix_Equal<-matrix(rep(NA,ncalcs*nSims),nrow=nSims)
> matrix_Unequal<-matrix(rep(NA,ncalcs*nSims),nrow=nSims)
> matrix_mann<-matrix(rep(NA,ncalcs*nSims),nrow=nSims)
>
> Simulations
>
> for (sim in 1:nSims){
>  # this loop steps through the sample sizes
>  for(ss in 1:dim(sample_sizes)[2]) {
>   m<-sample_sizes[1,ss]
>   n<-sample_sizes[2,ss]
>   # initialize the index for results
>   i<-1
>   for (sd in sds) {  #first group's standard deviation
>#generate random samples from 2 normal distribution
>x_norm1<-rnorm(m,5,sds)
>y_norm2<-rnorm(n,5,4)
>#extract p-value out and store it in vectors
>t_equal[(ss-1)*nsds+i]<-t.test(x_norm1,y_norm2,var.equal=TRUE)$p.value
>t_unequal[(ss-1)*nsds+i]<-t.test(x_norm1,y_norm2,var.equal=FALSE)$p.value
>mann[(ss-1)*nsds+i] <-wilcox.test(x_norm1,y_norm2)$p.value
>i<-i+1
>   }
>  }
>  #store the current result into matrices by rows
>  matrix_Equal[sim,]<-t_equal
>  matrix_Unequal[sim,]<-t_unequal
>  matrix_mann[sim,]<-mann
> }
> ##print results
> matrix_Equal
> matrix_Unequal
> matrix_mann
>
> Jim
>
> On Wed, Apr 6, 2016 at 12:43 AM, tan sj  wrote:
>> Hi, Jim, i read through your example,
>> I tried to write a code modified yours example and my ideas ...
>> In last email, you replied that 
>> "results[[(ss-1)*nssds+ssd_index]]<-" ,can i know further about 
>> this ? Because i am not very understand about this .
>> I am sorry that i am really a new bird in this field...
>> but the code turn out it have some error 

[R] R simulation help pls

2016-04-06 Thread tan sj

Hi, i am student from malaysia, i am new in r programming field, now i am 
trying to conduct a robustness study on 2 sample test under several combination 
of factors such as sample sizes ,standard deviation ratio and  also 
distribution..

but now i am stucking in how to use for loop or apply function to conduct the 
simulation ?
Then how can i test the test in the combined combination of factors?



Sent from my phone

[[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] HTML help -- as a single document for the entire package

2016-04-06 Thread David L Carlson
It is not quite what you are asking for, but there are several online pdf to 
html conversion websites. I tried a simple package pdf file and it converted 
fine. The page numbers are still there, but it is a single continuous page.

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


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch
Sent: Wednesday, April 6, 2016 4:38 AM
To: Holger Hoefling; R-Help mailing list
Subject: Re: [R] HTML help -- as a single document for the entire package

On 06/04/2016 4:17 AM, Holger Hoefling wrote:
> Hi,
>
> I was wondering if there was an equivalent to the pdf-manual for
> R-packages, but rendered as a single html page? I am looking for this as it
> would make reading easier as
> - no restriction to the standard paper width, but flowing to the browser
> window size
> - no page breaks
> - full text search across the entire manual.

No, there isn't.

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.

__
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] HTML help -- as a single document for the entire package

2016-04-06 Thread Duncan Murdoch

On 06/04/2016 12:06 PM, Holger Hoefling wrote:

Hi David,

thanks - I do have that as well. That is a good chance to clarify. The 
regular help gives a *separate* page for every single function. The 
regular pdf-manual gives one document for *all* functions in a package.


The nice thing about having a single html page for all functions in a 
package would be that it is easily searchable in the browser, it is 
more lightweight than a pdf and wouldn't be restricted by formatting 
based on the notion that it has to be printable to a page on paper.


I was wondering if something like this exists ... and Duncan very 
quickly answered that for me.


If you wanted to write it yourself, you would need to modify the 
tools::Rd2HTML function, and write a wrapper that called it for every Rd 
page.  This would be mostly straightforward:  instead of working for 
just one file, it would need to loop over all of them; it would also 
need to handle links between topics differently than it currently does, 
because some of them would be internal links, others would be external.


The source for the function is in 
https://svn.r-project.org/R/trunk/src/library/tools/R/Rd2HTML.R.


Duncan Murdoch



Thanks

Holger

On Wed, Apr 6, 2016 at 5:57 PM, David Winsemius 
> wrote:



> On Apr 6, 2016, at 2:37 AM, Duncan Murdoch
> wrote:
>
> On 06/04/2016 4:17 AM, Holger Hoefling wrote:
>> Hi,
>>
>> I was wondering if there was an equivalent to the pdf-manual for
>> R-packages, but rendered as a single html page? I am looking
for this as it
>> would make reading easier as
>> - no restriction to the standard paper width, but flowing to
the browser
>> window size
>> - no page breaks
>> - full text search across the entire manual.
>
> No, there isn't.

My somewhat different understanding may simply be a reflection of
a different operating system (given my inferior knowledge of the R
ecosystems to that of Duncan). I run R in the R.app GUI on a Mac
and the Help menu dropdown choice brings up links (in browser
form) to local versions of the documents that I thought were 
shipped with every new installation. Assuming your request is for

an html version of "Writing R Extensions", then I get one with:

http://127.0.0.1:15834/doc/manual/R-exts.html

--
David.


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

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.


Re: [R] HTML help -- as a single document for the entire package

2016-04-06 Thread David Winsemius

> On Apr 6, 2016, at 2:37 AM, Duncan Murdoch  wrote:
> 
> On 06/04/2016 4:17 AM, Holger Hoefling wrote:
>> Hi,
>> 
>> I was wondering if there was an equivalent to the pdf-manual for
>> R-packages, but rendered as a single html page? I am looking for this as it
>> would make reading easier as
>> - no restriction to the standard paper width, but flowing to the browser
>> window size
>> - no page breaks
>> - full text search across the entire manual.
> 
> No, there isn't.

My somewhat different understanding may simply be a reflection of a different 
operating system (given my inferior knowledge of the R ecosystems to that of 
Duncan). I run R in the R.app GUI on a Mac and the Help menu dropdown choice 
brings up links (in browser form) to local versions of the documents that I 
thought were  shipped with every new installation. Assuming your request is for 
an html version of "Writing R Extensions", then I get one with:

http://127.0.0.1:15834/doc/manual/R-exts.html

-- 
David.


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

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.


Re: [R] Memory problem

2016-04-06 Thread Amelia Marsh
Dear Sir,
Thanks for the guidance. Will check. And yes, at the end of each simulation, a 
large result is getting stored. 
Regards
Amelia 

On Wednesday, 6 April 2016 5:48 PM, jim holtman  wrote:
 

 It is hard to tell from the information that you have provided.  Do you have a 
list of the sizes of all the objects that you have in memory?  Are you 
releasing large objects at the end of each simulation run?  Are you using 'gc' 
to garbage collect any memory after deallocating objects?  Collect some 
additional information with a simple function like below:
f_mem_stats <- function(memo='') cat(memo, proc.time(), memory.size(), '\n')

> f_mem_stats(2)2 2.85 11.59 85444.93 NA NA 39.08 
This will print out what you pass in as a parameter, e.g., the iteration 
number, and then outputs the amount of CPU and memory used so far.  I use this 
all the time to keep track of resource consumption in long running scripts.

Jim Holtman
Data Munger Guru
 
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Wed, Apr 6, 2016 at 7:39 AM, Amelia Marsh via R-help  
wrote:

Dear R Forum,

I have about 2000+ FX forward transactions and I am trying to run 1000 
simulations. If I use less no of simulations, I am able to get the desired 
results. However, when I try to use more than 1000 simulations, I get following 
error.

> sorted2 <- ddply(sorted, .(currency_from_exch, id), mutate, change_in_mtm_bc 
> = mtm_bc - mtm_bc[1])

Error: cannot allocate vector of size 15.6 Mb


In addition: Warning messages:
1: Reached total allocation of 3583Mb: see help(memory.size)
2: Reached total allocation of 3583Mb: see help(memory.size)
3: In output[[var]][rng] <- df[[var]] :
Reached total allocation of 3583Mb: see help(memory.size)
4: In output[[var]][rng] <- df[[var]] :
Reached total allocation of 3583Mb: see help(memory.size)
5: In output[[var]][rng] <- df[[var]] :
Reached total allocation of 3583Mb: see help(memory.size)
6: In output[[var]][rng] <- df[[var]] :
Reached total allocation of 3583Mb: see help(memory.size)
7: In output[[var]][rng] <- df[[var]] :
Reached total allocation of 3583Mb: see help(memory.size)
8: In output[[var]][rng] <- df[[var]] :
Reached total allocation of 3583Mb: see help(memory.size)


When I checked -

> memory.size()
[1] 846.83
> memory.limit()
[1] 3583


The code is bit lengthy and unfortunately can't be shared.

Kindly guide how this memory probelm can be tackled? I am using R x64 3.2.0

Regards

Amelia

__
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] Plotting data on a map

2016-04-06 Thread phiroc
Hello,

I would like to generate a small map (say 10cm x 10cm) of France showing 
cumulative numbers by Distribution Center
stored in a database:

DISTRIBUTION_CENTER COUNT
Paris   122
Paris   3
Paris   21
Lyon12
Lyon
Lyon33
Grenoble55
Grenoble999
Grenoble99
...

I have looked at different graphing packages such as 'sp', 'raster' and 
'ggplot2', but am not sure which one is most
appropriate for my purposes. Furthermore, I don't understand how you retrieve 
city coordinates from shp, gadm, etc., maps
generated, or downloaded from the web and then processed, with those packages 
(SHP, GADM, etc.), and plot data at those coordinates.

Any help would be much appreciated.

Many thanks.

Philippe

__
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] Extracting windows from time series

2016-04-06 Thread maettuw
Dear R Users

Thanks for the help in advance and lets get straight to the problem:
I have a 400 year long temperature time series and I am looking for decades 
that show a linear trend decrease of approximately -0.1 Kelvin or degrees. --> 
What I would like to program: A loop/function / command line that prints the 
values of all the trends (can also be overlapping) into a matrix that could 
have the following structure :

Year 1 (of Trend1) Year 2 ( ... 2) Year 3 . 
. .
Trend 1:
Trend 2:
Trend 3:
...
.
.

 I  first tried to solve the task with a loop but ended up doing it with 
function but got stuck. Here is what I did so far:

Puls <- Surface_temperature_MA10[10:394] + 1 # give all values in the TS a 
positive value. Like that
## I can easier extract the trends that fullfill the searched condition 
(decrease of 0.1 Kelvin) --> look  next line

Difference <- diff(Puls,lag=10) # x[(1+lag):n] - x[1:(n-lag)] --> time step 20 
- timestep 10 for first calculation --> does that for whole time series
ID <- c(1:375)
melted_Difference <- melt(data.frame(Difference,ID),id.vars="ID")

Hiatus <- subset(melted_Difference,value < -0.1)

here the result :
23   23 Difference -0.1184901
24   24 Difference -0.1723032
25   25 Difference -0.1366112
26   26 Difference -0.1745479
27   27 Difference -0.1805964
28   28 Difference -0.2285250
29   29 Difference -0.2449096
30   30 Difference -0.1052558
44   44 Difference -0.1172029

-->23,24,25 etc. corresponds to the first years of the trends that shows a 
decrease of at least -0.1 Kelvin/decade. So far my method works. The purpose of 
that was that I could then use the window() function to extract
the original values from Puls.
This works, but only for one decade at one time -->

List_Hiatus <- window(Puls,1,start = c(23), end =  c(34))
> List_Hiatus
 [1] 1.125813 1.143880 1.123572 1.139369 1.134410 1.137944 1.139320 1.055780 
1.026300 1.042695 1.007323 0.971577
attr(,"tsp")
[1] 23 34  1

Tried but failed with the following approaches:

Start_H <- as.numeric(Hiatus[,1:1])
End_H <- as.numeric(Start_H + 10)
List_Hiatus <- window(Puls,1,start = "Start_H", end =  "End_H")

OR :
List_Hiatus <- window(Puls,1,start = c(23,24), end =  c(33,34))   # where c 
could of course be expanded

Or
apply(Puls,2,window(start=c(Start_H),end=c(End_H)))

Thanks again for your time.

Best Matthias



[[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] Issue while building xtable on R on Ubuntu 15.04

2016-04-06 Thread Zaid Golwala
Hi,

I am trying to build xtable on R  on Ubuntu 15.04 but I get following error :


+ R CMD check --no-vignettes --timings xtable_1.8-2.tar.gz

* using log directory 
'/home/jenkins/workspace/Rlang_xtable_Ubuntu15.04/xtable.Rcheck'

* using R version 3.2.3 (2015-12-10)

* using platform: powerpc64le-unknown-linux-gnu (64-bit)

* using session charset: UTF-8

* using option '--no-vignettes

'* checking for file 'xtable/DESCRIPTION' ... OK

* this is package 'xtable' version '1.8-2'

* checking package namespace information ... OK

* checking package dependencies ...Error in .build_vignette_index(vigns) :   In 
'inst' vignettes 'xtableGallery.Rnw' and 'xtableGallery.snw' have the same 
vignette name

Can someone please help me regarding the same.

Regards
Zaid Golwala

DISCLAIMER\ ==\ This e-mail ...{{dropped:14}}

__
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] Memory problem

2016-04-06 Thread Jeff Newmiller
As Jim has indicated, memory usage problems can require very specific 
diagnostics and code changes,  so generic help is tough to give. 

However, in most cases I have found the dplyr package to be more memory 
efficient than plyr, so you could consider that. Also, you can be explicit 
about only saving the minimum results you want to keep rather than making a 
list of complete results and extracting results later. 
-- 
Sent from my phone. Please excuse my brevity.

On April 6, 2016 4:39:59 AM PDT, Amelia Marsh via R-help  
wrote:
>Dear R Forum,
>
>I have about 2000+ FX forward transactions and I am trying to run 1000
>simulations. If I use less no of simulations, I am able to get the
>desired results. However, when I try to use more than 1000 simulations,
>I get following error.
>
>> sorted2 <- ddply(sorted, .(currency_from_exch, id), mutate,
>change_in_mtm_bc = mtm_bc - mtm_bc[1]) 
>
>Error: cannot allocate vector of size 15.6 Mb 
>
>
>In addition: Warning messages: 
>1: Reached total allocation of 3583Mb: see help(memory.size) 
>2: Reached total allocation of 3583Mb: see help(memory.size) 
>3: In output[[var]][rng] <- df[[var]] : 
>Reached total allocation of 3583Mb: see help(memory.size) 
>4: In output[[var]][rng] <- df[[var]] : 
>Reached total allocation of 3583Mb: see help(memory.size) 
>5: In output[[var]][rng] <- df[[var]] : 
>Reached total allocation of 3583Mb: see help(memory.size) 
>6: In output[[var]][rng] <- df[[var]] : 
>Reached total allocation of 3583Mb: see help(memory.size) 
>7: In output[[var]][rng] <- df[[var]] : 
>Reached total allocation of 3583Mb: see help(memory.size) 
>8: In output[[var]][rng] <- df[[var]] : 
>Reached total allocation of 3583Mb: see help(memory.size)
>
>
>When I checked -
>
>> memory.size() 
>[1] 846.83 
>> memory.limit() 
>[1] 3583
>
>
>The code is bit lengthy and unfortunately can't be shared.
>
>Kindly guide how this memory probelm can be tackled? I am using R x64
>3.2.0
>
>Regards
>
>Amelia
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


Re: [R] Memory problem

2016-04-06 Thread jim holtman
You say it is "getting stored"; is this in memory or on disk?  How are you
processing the results of the 1,000 simulations?

So some more insight into the actual process would be useful.  For example,
how are the simulations being done, are the results stored in memory, or
out to a file, what are you doing with the results at the end, etc.


Jim Holtman
Data Munger Guru

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

On Wed, Apr 6, 2016 at 8:44 AM, Amelia Marsh 
wrote:

> Dear Sir,
>
> Thanks for the guidance. Will check. And yes, at the end of each
> simulation, a large result is getting stored.
>
> Regards
>
> Amelia
>
>
> On Wednesday, 6 April 2016 5:48 PM, jim holtman 
> wrote:
>
>
> It is hard to tell from the information that you have provided.  Do you
> have a list of the sizes of all the objects that you have in memory?  Are
> you releasing large objects at the end of each simulation run?  Are you
> using 'gc' to garbage collect any memory after deallocating objects?
> Collect some additional information with a simple function like below:
>
> f_mem_stats <- function(memo='') cat(memo, proc.time(), memory.size(),
> '\n')
>
>
> > f_mem_stats(2)
> 2 2.85 11.59 85444.93 NA NA 39.08
>
> This will print out what you pass in as a parameter, e.g., the iteration
> number, and then outputs the amount of CPU and memory used so far.  I use
> this all the time to keep track of resource consumption in long running
> scripts.
>
>
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> On Wed, Apr 6, 2016 at 7:39 AM, Amelia Marsh via R-help <
> r-help@r-project.org> wrote:
>
> Dear R Forum,
>
> I have about 2000+ FX forward transactions and I am trying to run 1000
> simulations. If I use less no of simulations, I am able to get the desired
> results. However, when I try to use more than 1000 simulations, I get
> following error.
>
> > sorted2 <- ddply(sorted, .(currency_from_exch, id), mutate,
> change_in_mtm_bc = mtm_bc - mtm_bc[1])
>
> Error: cannot allocate vector of size 15.6 Mb
>
>
> In addition: Warning messages:
> 1: Reached total allocation of 3583Mb: see help(memory.size)
> 2: Reached total allocation of 3583Mb: see help(memory.size)
> 3: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 4: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 5: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 6: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 7: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 8: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
>
>
> When I checked -
>
> > memory.size()
> [1] 846.83
> > memory.limit()
> [1] 3583
>
>
> The code is bit lengthy and unfortunately can't be shared.
>
> Kindly guide how this memory probelm can be tackled? I am using R x64 3.2.0
>
> Regards
>
> Amelia
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> 
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Good pointers for understanding the R language implementation

2016-04-06 Thread Christopher Desjardins
This might be useful: http://adv-r.had.co.nz/

On Tue, Apr 5, 2016 at 10:31 AM, Francisco Banha  wrote:

> Dear All,
>
> I'm currently working on a project with
> the purpose of remotely executing R code, which requires me to have to
> work with the code of R itself. I've searched the Internet for good
> information that will help me understand how R is implemented but what
> I've got so far isn't detailed enough.
> I've looked specifically at
> CRAN's manuals on the official website but they only address this issue
> briefly. I've also looked at other contents online but so far nothing
> has turned up that has the level of detail that I need to properly
> understand the inner workings of R.
> For example, I need to understand
>  how exactly an expression is parsed and evaluated, because I will need
> to intervene in the process to decide whether to execute it remotely or
> not.
> Does anyone know of good pointers that would help me understand this?
> Thanks for any help!
>
> Best regards,
> Francisco
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]

2016-04-06 Thread Michael Friendly

On 4/4/2016 9:15 PM, tan sj wrote:

hi, i am new in this field.


do
favorite


If I wish to conduct a simulation on the robustness of two sample test by using 
R language, is that any ways in writing the code?
There are several factors
(sample sizes-(10,10),(10,25),(25,25),(25,50),(25,100),50,25),(50,100), 
(100,25),(100,100))

(standard deviation ratio- (1.00, 1.50, 2.00, 2.50, 3.00 and 3.50))
distribution of gamma distribution with unequal skewness and equal skewness

I wish to test the pooled variance t test and welch t test and mann whitney by 
using the above combination of factors. But how can I combine them by using for 
loop or apply function??
I am intending to use apply function but i am stucking. If i use for loop 
function, can i use for loop with vectors ?
for (a in c(25,50,100)) #first group of sample sizes
{ for (b in c(25,50,100)) #second group of sample sizes
{ for (d in c(4,4.4,5,6,8)) #different SDs of first sample
the above code is an example that I would like to modified but I found I have 
different sets of sample sizes.



Don't try to code this yourself-- you'll run into a mess.  Instead, use 
the lovely SimDesign package, https://github.com/philchalmers/SimDesign

designed for just this purpose.

There are also some nice tutorial examples on a wiki,
https://github.com/philchalmers/SimDesign/wiki

best,
-Michael

__
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] Memory problem

2016-04-06 Thread jim holtman
It is hard to tell from the information that you have provided.  Do you
have a list of the sizes of all the objects that you have in memory?  Are
you releasing large objects at the end of each simulation run?  Are you
using 'gc' to garbage collect any memory after deallocating objects?
Collect some additional information with a simple function like below:

f_mem_stats <- function(memo='') cat(memo, proc.time(), memory.size(), '\n')


> f_mem_stats(2)
2 2.85 11.59 85444.93 NA NA 39.08

This will print out what you pass in as a parameter, e.g., the iteration
number, and then outputs the amount of CPU and memory used so far.  I use
this all the time to keep track of resource consumption in long running
scripts.


Jim Holtman
Data Munger Guru

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

On Wed, Apr 6, 2016 at 7:39 AM, Amelia Marsh via R-help <
r-help@r-project.org> wrote:

> Dear R Forum,
>
> I have about 2000+ FX forward transactions and I am trying to run 1000
> simulations. If I use less no of simulations, I am able to get the desired
> results. However, when I try to use more than 1000 simulations, I get
> following error.
>
> > sorted2 <- ddply(sorted, .(currency_from_exch, id), mutate,
> change_in_mtm_bc = mtm_bc - mtm_bc[1])
>
> Error: cannot allocate vector of size 15.6 Mb
>
>
> In addition: Warning messages:
> 1: Reached total allocation of 3583Mb: see help(memory.size)
> 2: Reached total allocation of 3583Mb: see help(memory.size)
> 3: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 4: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 5: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 6: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 7: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
> 8: In output[[var]][rng] <- df[[var]] :
> Reached total allocation of 3583Mb: see help(memory.size)
>
>
> When I checked -
>
> > memory.size()
> [1] 846.83
> > memory.limit()
> [1] 3583
>
>
> The code is bit lengthy and unfortunately can't be shared.
>
> Kindly guide how this memory probelm can be tackled? I am using R x64 3.2.0
>
> Regards
>
> Amelia
>
> __
> 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] Descriptive Statistics of time series data

2016-04-06 Thread Saba Sehrish via R-help
Hi

I have four variables and the time series data for each variable consists of 
values for past 10 years on monthly basis. I want to get descriptive stats for 
these four variables separately (mean, median, sd, min, max).

The data I import to R consists of different columns, where each column gives 
values for one month of a particular year (e.g. March 31st, 2010). Right now R 
gives descriptive results for each column, whereas I need it collectively for 
all the years ( one mean, one sd, one min, one max and one median) for each 
variable.

Kindly guide me in this regard.

Thanks.
Saba

Sent from Yahoo Mail on Android


[[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] Memory problem

2016-04-06 Thread Amelia Marsh via R-help
Dear R Forum,

I have about 2000+ FX forward transactions and I am trying to run 1000 
simulations. If I use less no of simulations, I am able to get the desired 
results. However, when I try to use more than 1000 simulations, I get following 
error.

> sorted2 <- ddply(sorted, .(currency_from_exch, id), mutate, change_in_mtm_bc 
> = mtm_bc - mtm_bc[1]) 

Error: cannot allocate vector of size 15.6 Mb 


In addition: Warning messages: 
1: Reached total allocation of 3583Mb: see help(memory.size) 
2: Reached total allocation of 3583Mb: see help(memory.size) 
3: In output[[var]][rng] <- df[[var]] : 
Reached total allocation of 3583Mb: see help(memory.size) 
4: In output[[var]][rng] <- df[[var]] : 
Reached total allocation of 3583Mb: see help(memory.size) 
5: In output[[var]][rng] <- df[[var]] : 
Reached total allocation of 3583Mb: see help(memory.size) 
6: In output[[var]][rng] <- df[[var]] : 
Reached total allocation of 3583Mb: see help(memory.size) 
7: In output[[var]][rng] <- df[[var]] : 
Reached total allocation of 3583Mb: see help(memory.size) 
8: In output[[var]][rng] <- df[[var]] : 
Reached total allocation of 3583Mb: see help(memory.size)


When I checked -

> memory.size() 
[1] 846.83 
> memory.limit() 
[1] 3583


The code is bit lengthy and unfortunately can't be shared.

Kindly guide how this memory probelm can be tackled? I am using R x64 3.2.0

Regards

Amelia

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


[R-es] Congreso R-Hispano

2016-04-06 Thread miguel.angel.rodriguez.muinos
Hola.

Como dijo Emilio L. Cano en un correo anterior a este, las Jornadas (que ya son 
las octavas) ser�n en Albacete (16-17 Noviembre).
http://r-es.org/8jornadasR/

El objetivo es coincidir en el espacio-tiempo para socializar y poner en com�n 
nuestras experiencias en el mundo de R. Algunos querr�n exponer sus trabajos, 
otros asistir a alg�n taller, comentar cuestiones t�cnicas/dudas con gente que 
est� dispuesta a hablar de R (y de otras cosas) durante dos d�as seguidos, 
optar a alg�n premio, compartir unas ca�as con R-frikis, ...

Si est�s leyendo esto es que perteneces a una lista especializada y ser�n 
muchas las razones por las que debas asistir a estas Jornadas.

Animaos a enviar trabajos para contarnos a los dem�s vuestras experiencias con 
R (no os imagin�is la heterogeneidad de aplicaciones y campos en los que se 
usa). Y los que no env�en nada, animaos a asistir. Creo que los que han ido a 
alguno de los anteriores congresos no han quedado defraudados.

Ojo con las fechas, que este a�o las propuestas de comunicaciones y/o talleres 
hay que enviarlas ANTES del 1 de Mayo!!!

Nos vemos en Albacete!

Un saludo,
Miguel Rodr�guez
Miembro del Comit� de Programa
VIII Jornadas de Usuarios de R















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

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

See more languages: http://www.sergas.es/aviso-confidencialidad

[[alternative HTML version deleted]]

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

Re: [R] Problem with <= (less than or equal): not giving the expected result

2016-04-06 Thread S Ellison
> Apparently, abs(1 - 0.95) is not equal to 0.05, which I find however quite
> disturbing.

It's normal.* See R FAQ 7.31 in the html help system.

S Ellison

*... and common to all computers that use binary. 



***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, 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-es] familia gamma / cero inflated

2016-04-06 Thread Francisco Rodriguez Sanchez

Hola Eliana,

El que tengas muchos ceros no implica que se deban usar zero-inflated 
models. A veces un simple glm de Poisson puede ajustarse mejor.


Este post está bastante bien sobre zero inflation en R: 
http://eco-stats.blogspot.com.es/2015/04/zero-inflation-in-ecology.html


Suerte

Paco

El 05/04/2016 a las 15:14, Eliana Eberle escribió:

Estimado,

Tengo dos consultas,

-Tengo datos que contienen ceros en datos con distribución Poisson, y quisiera 
utilizar una familia gamma para la realización de GLM.
Como puedo modificar los ceros para poder aplicar la familia?


- Tengo 98 datos y 20 son ceros, debería considerar zero inflated?

Saludos

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


--
Dr Francisco Rodriguez-Sanchez
Integrative Ecology Group
Estacion Biologica de Doñana - CSIC
Avda. Americo Vespucio s/n
41092 Sevilla (Spain)
http://bit.ly/frod_san

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


Re: [R] HTML help -- as a single document for the entire package

2016-04-06 Thread Duncan Murdoch

On 06/04/2016 4:17 AM, Holger Hoefling wrote:

Hi,

I was wondering if there was an equivalent to the pdf-manual for
R-packages, but rendered as a single html page? I am looking for this as it
would make reading easier as
- no restriction to the standard paper width, but flowing to the browser
window size
- no page breaks
- full text search across the entire manual.


No, there isn't.

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] Good pointers for understanding the R language implementation

2016-04-06 Thread Giorgio Garziano
Guessing that you may want to take a look at:

http://adv-r.had.co.nz/Expressions.html


https://www.opencpu.org/


Anyway, as David wrote, that it is too vague for specific hints.


--

Best,

GG



[[alternative HTML version deleted]]

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


[R-es] Fwd: Segunda llamada para el Envío de Comunicaciones. VIII Jornadas Usuarios de R, UCLM, Albacete, 17-18 noviembre 2016

2016-04-06 Thread Emilio L. Cano
La Asociación R-Hispano tiene el placer de anunciar la celebración de las
VIII Jornadas de Usuarios de R. En esta ocasión, será la Universidad de
Castilla-La Mancha, en su campus de Albacete, quien acoja las Jornadas los
días 17 y 18 de noviembre de 2016.

El objetivo de las Jornadas es proporcionar un punto de encuentro a la
diversidad de usuarios de R por lo que, independientemente de la filiación
o del área de trabajo o investigación, todo usuario de R es bienvenido.

Como en años anteriores, la presentación de trabajos en las Jornadas puede
ser en forma de *Presentación oral, *en distintas sesiones paralelas, que
reflejen el amplio abanico de análisis de datos mediante R, *Póster, en una
sesión específica,* o como un *Taller* que permita profundizar en aspectos
interesantes y menos conocidos de R.

El envío de trabajos ha de hacerse a través del formulario habilitado en la
web del congreso en http://r-es.org/8jornadasR . En esta edición de las
Jornadas también se otorgará un premio al mejor trabajo presentado por un
investigador joven (ver bases en la web de las Jornadas).

Finalmente, queremos agradecer la colaboración de nuestros patrocinadores,
sin los que las Jornadas no serían posible. Si tú o tu institución estáis
interesados en patrocinar las Jornadas puedes consultar cómo hacerlo en
http://r-es.org/8jornadasR .

Las fechas importantes son:

Envío de comunicaciones (presentación/póster/taller): del 15/02/2016 al
01/05/2016

Decisión sobre comunicaciones: 29/05/2016

Registro: del 15/04/2016 al 18/11/2016



-- 

*Emilio López Cano*
Mobile: +34 665 676 225
skype: emilopezcano
twitter: @emilopezcano
http://emilio.lcano.com

*Universidad de Castilla-La Mancha*
Tel: +34 902 204 100
Facultad de Farmacia (Albacete), despacho 2.25, +34 967 599 200 ext. 96240
Facultad de Derecho y Ciencias Sociales (Ciudad Real), Módulo E despacho
11, ext. 3595

[[alternative HTML version deleted]]

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


[R] HTML help -- as a single document for the entire package

2016-04-06 Thread Holger Hoefling
Hi,

I was wondering if there was an equivalent to the pdf-manual for
R-packages, but rendered as a single html page? I am looking for this as it
would make reading easier as
- no restriction to the standard paper width, but flowing to the browser
window size
- no page breaks
- full text search across the entire manual.

Thanks

Holger

[[alternative HTML version deleted]]

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


Re: [R-es] familia gamma / cero inflated

2016-04-06 Thread Olivier Nuñez
Si tus datos son enteros, una poisson debería ir bien.
En cuanto al segundo punto, un 20% de ceros no tiene porque ser mucho para una 
poisson.
Una poisson de media 1, tiene unos 37% de ceros ( dpois(0,1) ).
Depende emucho de como son los demás valores.
Un saludo. Olivier

- Mensaje original -
De: "Eliana Eberle" 
Para: R-help-es@r-project.org
Enviados: Martes, 5 de Abril 2016 15:14:01
Asunto: [R-es] familia gamma / cero inflated

Estimado,

Tengo dos consultas,

-Tengo datos que contienen ceros en datos con distribución Poisson, y quisiera 
utilizar una familia gamma para la realización de GLM. 
Como puedo modificar los ceros para poder aplicar la familia?


- Tengo 98 datos y 20 son ceros, debería considerar zero inflated?

Saludos

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

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


[R] Is this a bug in quantmod::OpCl?

2016-04-06 Thread James Hirschorn

OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug?

Example error:

x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1
set.seed(1)
x <- zoo(matrix(runif(20, 0, 1), nrow=5, ncol=4), x.Date)
q <- as.quantmod.OHLC(x,c("Open","High","Low","Close"))

# error
OpCl(q)
#> Error in `colnames<-`(`*tmp*`, value = "OpCl.q") : 
#>  attempt to set 'colnames' on an object with less than two dimensions

# OK
OpCl(as.xts(q))

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