Ragia Ibrahim | 22 Nov 15:29 2014

Generate random numbers under constrain

Dear all,
I use R 3.1.1 for Windows.
kindly how can I generate n number of random numbers with probability from [0,1]
and their sum must not be more than one
thanks in advance

	[[alternative HTML version deleted]]

Yunqi Zhang | 22 Nov 05:56 2014

Interpreting ANOVA / quantile regression results

Hi all,

I think this is probably a very simple question related to ANOVA or
quantile regression.

Let's say if I'm doing ANOVA on 2 factors (f_a and f_b) and trying to
figure out whether they have an impact on the output. The result shows me
that f_a has a significant impact while f_b does not as following, where
the std. error (confidence interval) is

         estimate    std. error      p-value
f_a    10              0.2               0.001
f_b    0.5             2                  0.56

If I take this result, and I want to make my best guess for the output of a
pair of f_a and f_b values. Should I calculate the output using both f_a
and f_b or only the f_a because f_b is statistically insignificant? And
what the std. error (confidence interval) would be?

Specifically, should I do

guessed output = 10 * f_a + 0.5 * f_b and the std. error is 0.2 + 2 = 2.2


guessed output = 10 * f_a and the std.err is 0.2

Thank you very much!

(Continue reading)

Andrew Z | 22 Nov 00:26 2014

memory usage with party::cforest

Is there a way to shrink the size of RandomForest-class (an S4
object), so that it requires less memory during run-time and less disk
space for serialization?

On my system the data slot is about 2GB, which is causing problems,
and I'd like to see whether predict() works without it.

# example with a much smaller data set (i.e., less than 2GB)
cf <- cforest(Species ~ ., data=iris)
str(cf, max.level=2)
cf <at> data <- NULL # this fails


philippe massicotte | 21 Nov 14:23 2014

Formula with dynamic number of variables

Hi everyone.

I have a non-linear model specified as this (6 variables, a0, S, K, p0, p1, p2):

fit <- nlsLM(formula = dat ~ a0 * exp(-S*(x - 250)) + K + ( C ) )

where C = (p0*exp(-0.5*((x-p1)/p2)^2))

The problem is that I do not know in advance how many component (C) I will have in the model. That means It could be:

nlsLM(formula = dat ~ a0 * exp(-S*(x - 250)) + K + ( (p0*exp(-0.5*((x-p1)/p2)^2)) ) )


nlsLM(formula = dat ~ a0 * exp(-S*(x - 250)) + K + ( (p0*exp(-0.5*((x-p1)/p2)^2)) ) +   (
(p0b*exp(-0.5*((x-p1b)/p2b)^2)) ))


nlsLM(formula = dat ~ a0 * exp(-S*(x - 250)) + K + ( (p0*exp(-0.5*((x-p1)/p2)^2)) ) +   (
(p0b*exp(-0.5*((x-p1b)/p2b)^2)) +   ( (p0c*exp(-0.5*((x-p1c)/p2c)^2))))

So I was wondering if it was possible to dynamically build the formula that I will use in my model? The first
part of my model will always be "a0 * exp(-S*(x - 250)) + K", I just want to add a certain number of
"components" dynamically.

I guess it will be related with "reformulate()" but I can't not find how to make it works.

Thank you for your help,
(Continue reading)

Diogo André Alagador | 21 Nov 21:02 2014

C project within R function

Hi all,

I need some assistance regarding the use of C project (set of programming
files)  as R functions in Windows OS.

By now I really would like to avoid package-building.

What are the steps to undergo or where can I check to perform that

Thanks in advance,

My best regards,

Diogo Alagador


CIBIO/UE - Research Center in Biodiversity and Genetic Resources, University
of …vora, Portugal

	[[alternative HTML version deleted]]

Hi all,

I need some assistance regarding the use of C project (set of programming
files)  as R functions in Windows OS.
(Continue reading)

Raghuraman Ramachandran | 21 Nov 23:52 2014

Help with Time

Dear guRus

How can I round of time in R to the nearest 30th minute please?

For example suppose if
[1] "2014-11-21 22:49:05.59042 GMT"
then I would like a function that outputs 22:30:00.

if Sys.time is 12:13:22 then I would like to get 12:00:00 etc.

Any help would be appreciated.

Many thanks and regards,

John Posner | 21 Nov 18:10 2014

dplyr/summarize does not create a true data frame

I got an error when trying to extract a 1-column subset of a data frame (called "my.output") created by
dplyr/summarize. The ncol() function says that my.output has 4 columns, but "my.output[4]" fails. Note
that converting my.output using as.data.frame() makes for a happy ending.

Is this the intended behavior of dplyr?


> library(dplyr)

> # set up data frame
> rows = 100
> repcnt = 50
> sexes = c("Female", "Male")
> heights = c("Med", "Short", "Tall")

> frm = data.frame(
+   Id = paste("P", sprintf("%04d", 1:rows), sep=""),
+   Sex = sample(rep(sexes, repcnt), rows, replace=T),
+   Height = sample(rep(heights, repcnt), rows, replace=T),
+   V1 = round(runif(rows)*25, 2) + 50,
+   V2 = round(runif(rows)*1000, 2) + 50,
+   V3 = round(runif(rows)*350, 2) - 175
+ )
> # use dplyr/summarize to create data frame
> my.output = frm %>%
+   group_by(Sex, Height) %>%
+   summarize(V1sum=sum(V1), V2sum=sum(V2))
(Continue reading)

Amit Thombre | 21 Nov 07:07 2014

Optimization function


I want to optimize the root mean square error objective function using the optim function. Thus the
function will look like sqrt(sum((yi - f(xi))^2)/n). Now the f(xi) is the Arima function.  I am not clear
how do I get the f(xi) because the call to arima function in C gives the value of the arima function which
takes in the entire vector x, or do I restrict the value of x  to the arima function in C. That is for getting he
f(x1) value give only x1 as the input to arima, for getting f(x2) give only x1 and x2 as input to arima
function in C.

Any help on this will be highly appreciated.


Disclaimer:  This message and the information contained herein is proprietary and confidential and
subject to the Tech Mahindra policy statement, you may review the policy at
http://www.techmahindra.com/Disclaimer.html externally
http://tim.techmahindra.com/tim/disclaimer.html internally within TechMahindra.

	[[alternative HTML version deleted]]

Matt Considine | 21 Nov 02:42 2014

Parsing Google Finance page data?

I'm wondering if anyone can point me to code to parse data on Google 
Finance pages, i.e. parse the results of a URL request such as this

I know how to return the contents of the page; it's figuring out the 
best tools to parse it that I'm interested in and hopefully someone has 
already done this.

(For what it is worth, the only info I am looking for are the ticker, 
exchange, currency and "Mkt Cap" datapoint)

Thanks in advance for any help - scraping is not my strong suit.

This email is free from viruses and malware because avast! Antivirus protection is active.

Mark Miller | 21 Nov 01:16 2014

see rcurl contents before they're sent?

I am trying to use the R / solr integration from

I have the query function working, but I'm having trouble with the post
functions, which uses rcurl.

Is it possible to see the string that rcurl is going to send to a webserver
(instead of, or in addition to send it to the server?)


	[[alternative HTML version deleted]]

Jennifer Sabatier | 21 Nov 00:44 2014

Saving Google worksheets with common prefix

Hi R-Help,

So, I will try to provide a reproducible example...I basically made a dummy
spreadsheet that contains the same number of tabs as the spreadsheet I am
really interested in.  The data on that spreadsheet is really sensitive so
I couldn't use it.

Anyway, here are the various sheets in the spreadsheet:
> names(ts)
[1] "Operations"    "Financing"     "Income"        "Balance sheet" "Cash
[6] "Cash Flows210" "Cash Flows29"  "Cash Flows28"  "Cash Flows27"

I am only interested in these sheets:
> names(ts2)
[1] "Cash Flows211" "Cash Flows210" "Cash Flows29"  "Cash Flows28"  "Cash

I want to save them to csv files that contain the same name or similar as
the sheet name.

Here's the error I'm getting (using traceback i ran it twice to get the
[1] "Cash Flows211"
[1] "Cash Flows211 - 2014-11-20.csv"
6: stop(err)
5: stop.if.HTTP.error(http.header)
4: getURLContent(uri, .opts = .opts, .encoding = .encoding, binary =
       curl = curl)
(Continue reading)