[R] John M. Chambers Statistical Software Award

2015-12-04 Thread Patrick Breheny

John M. Chambers Statistical Software Award 2016

This is a second announcement for the Chambers Award and reminder that 
all application materials must be submitted by December 15. The John M. 
Chambers Statistical Software Award is an annual award given by the 
Statistical Computing Section of the American Statistical Association to 
recognize student contributions to the development of statistical software.


Dr. John Chambers, developer of the S statistical computing language, 
generously donated to the Statistical Computing Section to endow an 
annual prize for statistical software written by, or in collaboration 
with, an undergraduate or graduate student. The prize carries with it a 
cash award of $1,000.


Teams of up to 3 people can participate in the competition. To be 
eligible, the team must have designed and implemented a piece of 
statistical software. At least one individual within the team must have 
begun the development while a student and must either currently be a 
student, or have completed all requirements for her/his last degree 
after January 1, 2015. The award will be given to the student, or split 
between student team members if the team consists of multiple students.


To apply for the award, teams must provide the following materials:

* Current CV's of all team members.

* A letter from a faculty mentor at the academic institution of the 
individual indicated to receive the travel award. The letter should 
confirm that the individual had substantial participation in the 
development of the software, certify her/his student status when the 
software began to be developed (and either the current student status or 
the date of degree completion), and briefly discuss the importance of 
the software to statistical practice.


* A brief, one to two page description of the software, summarizing what 
it does, how it does it, and why it is an important contribution. If any 
student team member has continued developing the software after 
finishing her/his studies, the description should indicate what was 
developed when the individual was a student and what has been added since.


* An installable software package with its source code for use by the 
award committee. It should be accompanied by enough information to allow 
the judges to effectively use and evaluate the software (including its 
design considerations). This information can be provided in a variety of 
ways, including but not limited to a user manual, a manuscript, a URL, 
and online help to the system.


All materials must be in English. We prefer that electronic text be 
submitted in Postscript or PDF. The entries will be judged on a variety 
of dimensions, including the importance and relevance for statistical 
practice of the tasks performed by the software, ease of use, clarity of 
description, elegance and availability for use by the statistical 
community. Preference will be given to those entries that are grounded 
in software design rather than calculation. The decision of the award 
committee is final.


All application materials must be received by Tuesday, December 15, 2015 
and should be sent to the e-mail address below.  The winner will be 
announced by January 15.  The award will be presented at the 2016 Joint 
Statistical Meetings, and the winner(s) will be given an opportunity to 
present their work in a topic-contributed session at the meetings.


Patrick Breheny
Department of Biostatistics
University of Iowa
patrick-breh...@uiowa.edu

--
Patrick Breheny
Assistant Professor
Department of Biostatistics
University of Iowa
N336 College of Public Health Building
319-384-1584

__
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] Keep only first date from consecutive dates

2015-12-04 Thread David Winsemius

> On Dec 4, 2015, at 1:10 PM, William Dunlap  wrote:
> 
> With a data.frame sorted by id, with ties broken by date, as in
> your example, you can select rows that are either the start
> of a new id group or the start of run of consecutive dates with:
> 
>> w <- c(TRUE, diff(uci$date)>1) | c(TRUE, diff(uci$id)!=0)
>> which(w)
> [1] 1 4 5 7
>> uci[w,]
>  id   date value
> 1  1 2005-10-28 1
> 4  1 2005-11-07 3
> 5  1 2007-03-19 1
> 7  2 2004-06-02 2
> 
> I'll leave it to you to translate that R syntax into data.table syntax -
> it just involves comparing the current row with the previous row.
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> 
> 
> On Fri, Dec 4, 2015 at 12:53 PM, Frank S.  wrote:
>> Dear R users,
>> 
>> I usually work with data.table package, but I'm sure that muy question can 
>> also be answered working with R data frame.
>> Working with grouped data (by "id"),  I wonder if it is possible to keep in 
>> a R data.frame (or R data.table):
>> a) Only the first row if there is a row which belongs to a a group of rows 
>> (from same "id") that have consecutive dates.
>> b) All the rows which do not belong to the above groups.
>> 
>> As an example, I have "uci" data.frame:
>> 
>> uci <- data.table(id=c(rep(1,6),2),
>>date = 
>> as.Date(c("2005-10-28","2005-10-29","2005-10-30","2005-11-07","2007-03-19","2007-03-20","2004-06-02")),
>>value = c(1, 2, 1, 3, 1, 2, 2))
>> 
>>   id  date   value
>>1  2005-10-281
>>1  2005-10-292
>>1  2005-10-301
>>1  2005-11-073
>>1  2007-03-191
>>1  2007-03-202
>>2  2004-06-022
>> 
>> And the desired output would be:
>> 
>>   id  date   value
>>1  2005-10-281
>>1  2005-11-073
>>1  2007-03-191
>>2  2004-06-022

The syntax of `[.data.table` is a bit odd; You can refer to columns by name; I 
never trust my intuition, though.

Selection is usually done with a logical vector in the ‘i’-position. The diff 
operator does succeed in the ‘i’ position with the obvious need to prepend with 
a starting value..

> uci[ c(0,diff(date))!=1, ]
   id   date value
1:  1 2005-10-28 1
2:  1 2005-11-07 3
3:  1 2007-03-19 1
4:  2 2004-06-02 2

The other cases are handle with the converse-expression

> uci[c(0,diff(date)) == 1, ]
   id   date value
1:  1 2005-10-29 2
2:  1 2005-10-30 1
3:  1 2007-03-20 2


>> 
>> # From the following link, I have tried:
>> http://stackoverflow.com/questions/32308636/r-how-to-sum-values-from-rows-only-if-the-key-value-is-the-same-and-also-if-the
>> 
>> setDT(uci)[ ,list(date=date[1L], value = value[1L]),  by = 
>> .(ind=rleid(date), id)][, ind:=NULL][]
>> 
>> But I get the same data frame, and I do not know the reason.
>> 
>> Thank you very much for any help!!
>> 
>> Frank S.
>> 
>> 
>> 
>> 
>> 
>>[[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.

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] Keep only first date from consecutive dates

2015-12-04 Thread William Dunlap
With a data.frame sorted by id, with ties broken by date, as in
your example, you can select rows that are either the start
of a new id group or the start of run of consecutive dates with:

> w <- c(TRUE, diff(uci$date)>1) | c(TRUE, diff(uci$id)!=0)
> which(w)
[1] 1 4 5 7
> uci[w,]
  id   date value
1  1 2005-10-28 1
4  1 2005-11-07 3
5  1 2007-03-19 1
7  2 2004-06-02 2

I'll leave it to you to translate that R syntax into data.table syntax -
it just involves comparing the current row with the previous row.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Fri, Dec 4, 2015 at 12:53 PM, Frank S.  wrote:
> Dear R users,
>
> I usually work with data.table package, but I'm sure that muy question can 
> also be answered working with R data frame.
> Working with grouped data (by "id"),  I wonder if it is possible to keep in a 
> R data.frame (or R data.table):
> a) Only the first row if there is a row which belongs to a a group of rows 
> (from same "id") that have consecutive dates.
> b) All the rows which do not belong to the above groups.
>
> As an example, I have "uci" data.frame:
>
> uci <- data.table(id=c(rep(1,6),2),
> date = 
> as.Date(c("2005-10-28","2005-10-29","2005-10-30","2005-11-07","2007-03-19","2007-03-20","2004-06-02")),
> value = c(1, 2, 1, 3, 1, 2, 2))
>
>id  date   value
> 1  2005-10-281
> 1  2005-10-292
> 1  2005-10-301
> 1  2005-11-073
> 1  2007-03-191
> 1  2007-03-202
> 2  2004-06-022
>
> And the desired output would be:
>
>id  date   value
> 1  2005-10-281
> 1  2005-11-073
> 1  2007-03-191
> 2  2004-06-022
>
> # From the following link, I have tried:
> http://stackoverflow.com/questions/32308636/r-how-to-sum-values-from-rows-only-if-the-key-value-is-the-same-and-also-if-the
>
> setDT(uci)[ ,list(date=date[1L], value = value[1L]),  by = .(ind=rleid(date), 
> id)][, ind:=NULL][]
>
> But I get the same data frame, and I do not know the reason.
>
> Thank you very much for any help!!
>
> Frank S.
>
>
>
>
>
> [[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] Survival analysis: ERROR: Time and status are different lengths

2015-12-04 Thread Marleen Hamoen
Hi Terry,

I already suspected it had something to do with missing values in one of
the covariates. I couldn't get the na.action="na.exclude" to work (perhaps
this is because I am relatively unexperienced with R), but I managed to
solve the problem by using the following command with "complete.cases":

DF <- with(DF,DF[complete.cases(TimeDeath, event, age, sex, mutation,
ventilation, BM1, BM2), ])

Thank you very much for your help!


2015-12-04 15:02 GMT+01:00 Therneau, Terry M., Ph.D. :

> I expect that reading the result of print(fit.weib) will answer your
> question.  If there were any missing values in the data set, then the
> fit.weib$linear.predictors will be shorter than the original data set,
> and the printout will have a note about "...deleted due to missing".
>
> The simplest solution to this is to set
>   options(na.action="na.exclude")
> before doing the fit.  Then predict(fit) and resid(fit) will return
> vectors of the same length as the input data, containing NA in the
> appropriate positions.  The default na.action of "na.omit" leaves missing
> out of both the fit and the residuals.
>
> (Unfortunately, only a few modeling functions in R pay attention to the
> difference between these two na.action options.)
>
> Terry Therneau
>
>
>
> On 12/04/2015 05:00 AM, r-help-requ...@r-project.org wrote:
>
>> Hi,
>>
>> I am fitting an AFT model assuming a Weibull distribution and I would like
>> to check the residuals compared to the Kaplan Meier residuals, but when I
>> try to create the Kaplan Meier residuals I get an error: Time and status
>> are different lengths.
>>
>> I am using the following script:
>>
>> # Fitting the AFT model
>> fit.weib <- survreg(Surv(TimeDeath, event) ~ age + sex + mutation +
>> ventilation + BM1 + BM2, data = DF, dist = "weibull")
>> fits <- fit.weib$linear.predictors
>> resids <- (fit.weib$y[, 1] - fits)/fit.weib$scale
>> resKM <- survfit(Surv(resids, event) ~ 1, data = DF)
>>
>> I get the error from the last line of the script.
>>
>> I tried some things that didn't work and I was wondering if anyone could
>> help me.
>> If you need more information please let me know.
>>
>> Thanks in advance,
>>
>

[[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] system.file(...) self-referencing the containing package

2015-12-04 Thread Duncan Murdoch

On 04/12/2015 11:28 AM, Murat Tasan wrote:

Perfect, thanks!

(Any idea if/where this is documented? I checked through the "Writing
R Extensions" doc and couldn't find any mention of it.)


It is mentioned in ?getPackageName:

" (Currently, the name is stored as the object |.packageName| but don't 
trust this for the future.)"


The more trustworthy approach is to use packageName() or getPackageName().

Duncan Murdoch


Thanks much again,

-Murat


On Thu, Dec 3, 2015 at 6:42 PM, William Dunlap  wrote:
> Every package has in it, after it is installed, a character object
> called ".packageName" containing its name.  It is not exported from
> the package.  Functions in your package can refer to it as just
> .packageName.
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Thu, Dec 3, 2015 at 5:28 PM, Murat Tasan  wrote:
>> In a package I'm writing, I'm placing all SQL code here:
>> /inst/sql/
>>
>> And so when referring to these blocks of code from the package's R
>> code, I do something like so:
>>
>> system.file("sql", "my_example_file.sql", package = "ThisPackage",
>> mustWork = TRUE)
>>
>> But, referring to the package itself with the string "ThisPackage" is
>> annoying and somewhat brittle... if the package were ever to change
>> names (e.g. during development), I'll have to replace all such calls
>> with the new package name.
>> And generally referring to the package containing the code itself by
>> name seems inelegant.
>>
>> Anyone know of a safe way to reference additional files in a package,
>> from within that package's code, that doesn't require specifying the
>> name of the package as a string?
>>
>> Cheers,
>>
>> -Murat
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

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


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


Re: [R] Can we use all the functions of R in visual studio? The Rmath.dll and R.dll seems only contain a part of R functions

2015-12-04 Thread Erich Neuwirth
There is statconnDCOM, whoch gives full R as a COM server which can be used 
from all he Visual languages.
It is not free. There are cost free licenses for student and home use, but 
essentially it is a commercial product.

Mor information can be found at
www.statconn.com 



> On 04 Dec 2015, at 13:38, 李琥 <081024...@fudan.edu.cn> wrote:
> 
> Can we use all the functions of R in visual studio? The Rmath.dll and R.dll 
> seems only contain a part of R functions



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
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] RPostgreSQL (or even ANSI DBI) parameterized query with IN (...)

2015-12-04 Thread Murat Tasan
Using PostgreSQL's parameterized query form, this works:

R> dbSendQuery(CONN, "SELECT * FROM foo WHERE val = $1 OR val = $2",
list("bar", "baz"))

... and becomes: SELECT * FROM foo WHERE val = 'bar' OR val = 'baz';

I cannot figure out, however, if something like this is possible with
RPostgreSQL:

R> dbSendQuery(CONN, "SELECT * FROM foo WHERE val IN ($1)",
list(c("bar", "baz")))

... which becomes: SELECT * FROM foo WHERE val IN ('bar', 'baz');

(To be clear, the dbSendQuery attempt above does _not_ work.)

Anyone know if this is doable with RPostgreSQL?
I can construct the statement with sprintf/paste, but I'd prefer to
use properly-parameterized queries if possible (relying on PostgreSQL
to do the type conversions safely).

I've also, BTW, tried using DBI's basic ANSI functionality, like so:

R> sqlInterpolate(ANSI(), "SELECT * FROM foo WHERE name IN (?names)",
names = c("foo", "bar"))

... but this also doesn't work :-/

-Murat

__
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] system.file(...) self-referencing the containing package

2015-12-04 Thread Murat Tasan
Perfect, thanks!

(Any idea if/where this is documented? I checked through the "Writing
R Extensions" doc and couldn't find any mention of it.)

Thanks much again,

-Murat


On Thu, Dec 3, 2015 at 6:42 PM, William Dunlap  wrote:
> Every package has in it, after it is installed, a character object
> called ".packageName" containing its name.  It is not exported from
> the package.  Functions in your package can refer to it as just
> .packageName.
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Thu, Dec 3, 2015 at 5:28 PM, Murat Tasan  wrote:
>> In a package I'm writing, I'm placing all SQL code here:
>> /inst/sql/
>>
>> And so when referring to these blocks of code from the package's R
>> code, I do something like so:
>>
>> system.file("sql", "my_example_file.sql", package = "ThisPackage",
>> mustWork = TRUE)
>>
>> But, referring to the package itself with the string "ThisPackage" is
>> annoying and somewhat brittle... if the package were ever to change
>> names (e.g. during development), I'll have to replace all such calls
>> with the new package name.
>> And generally referring to the package containing the code itself by
>> name seems inelegant.
>>
>> Anyone know of a safe way to reference additional files in a package,
>> from within that package's code, that doesn't require specifying the
>> name of the package as a string?
>>
>> Cheers,
>>
>> -Murat
>>
>> __
>> 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] Ordering Filenames stored in list or vector

2015-12-04 Thread Mark Sharp
Mario,

I am certain there are more elegant solutions. This is an effort to make the 
process clear by dividing out each transformation used into separate lines.

## Start of code
library(stringi) # This is written in C and C++ (ICU library), is fast, and is 
well documented.
filenames <- c("Q_Read_prist#1...@1.xls", "Q_Read_prist#1...@10.xls", 
   "Q_Read_prist#1...@11.xls", "Q_Read_prist#1...@12.xls", 
   "Q_Read_prist#1...@13.xls", "Q_Read_prist#1...@14.xls", 
   "Q_Read_prist#1...@15.xls", "Q_Read_prist#1...@16.xls", 
   "Q_Read_prist#1...@17.xls", "Q_Read_prist#1...@18.xls", 
   "Q_Read_prist#1...@19.xls", "Q_Read_prist#1...@2.xls", 
   "Q_Read_prist#1...@3.xls", "Q_Read_prist#1...@4.xls", 
   "Q_Read_prist#1...@5.xls", "Q_Read_prist#1...@6.xls", 
   "Q_Read_prist#1...@7.xls", "Q_Read_prist#1...@8.xls", 
   "Q_Read_prist#1...@9.xls")
indx_list <- stri_split_regex(filenames, pattern = "[@.]")
indx <- sapply(indx_list, function(x) {x[[2]]})
filenames_df <- data.frame(file_name = filenames, indx = indx, 
stringsAsFactors = FALSE)
filenames_ordered <- filenames_df[order(as.numeric(filenames_df$indx)), 
"file_name"]
filenames_ordered
## end of code
Mark


R. Mark Sharp, Ph.D.
Director of Primate Records Database
Southwest National Primate Research Center
Texas Biomedical Research Institute
P.O. Box 760549
San Antonio, TX 78245-0549
Telephone: (210)258-9476
e-mail: msh...@txbiomed.org







> On Dec 4, 2015, at 4:51 AM, BARLAS Marios 247554  wrote:
> 
> Hello everyone,
> 
> I am an R rookie and I'm learning as I program.
> 
> I am working on a script to process a large amount of data: I read a pattern 
> of filenames in the folder I want and import their data
> 
> filenames = list.files(path, pattern="*Q_Read_prist*")
> 
> myfiles = lapply(filenames, function(x) read.xlsx2(file=x, sheetName="Data", 
> header=TRUE, FILENAMEVAR=x))
> 
> The problem is that R recognizes the files in a 'non human' order.
> 
> Q_Read_prist#1...@1.xls   Q_Read_prist#1...@1.xls
> Q_Read_prist#1...@10.xls Q_Read_prist#1...@10.xls
> Q_Read_prist#1...@11.xls Q_Read_prist#1...@11.xls
> Q_Read_prist#1...@12.xls Q_Read_prist#1...@12.xls
> Q_Read_prist#1...@13.xls Q_Read_prist#1...@13.xls
> Q_Read_prist#1...@14.xls Q_Read_prist#1...@14.xls
> Q_Read_prist#1...@15.xls Q_Read_prist#1...@15.xls
> Q_Read_prist#1...@16.xls Q_Read_prist#1...@16.xls
> Q_Read_prist#1...@17.xls Q_Read_prist#1...@17.xls
> Q_Read_prist#1...@18.xls Q_Read_prist#1...@18.xls
> Q_Read_prist#1...@19.xls Q_Read_prist#1...@19.xls
> Q_Read_prist#1...@2.xls   Q_Read_prist#1...@2.xls
> Q_Read_prist#1...@3.xls   Q_Read_prist#1...@3.xls
> Q_Read_prist#1...@4.xls   Q_Read_prist#1...@4.xls
> Q_Read_prist#1...@5.xls   Q_Read_prist#1...@5.xls
> Q_Read_prist#1...@6.xls   Q_Read_prist#1...@6.xls
> Q_Read_prist#1...@7.xls   Q_Read_prist#1...@7.xls
> Q_Read_prist#1...@8.xls   Q_Read_prist#1...@8.xls
> Q_Read_prist#1...@9.xls   Q_Read_prist#1...@9.xls
> 
> I tried to order them using order or sort but it doesn' seem to work. I have 
> had the same issue in matlab but there I have a function to re-define the 
> order in a "correct" way.
> 
> Anyone knows of a smart way to sort these guys from 1 to 19 ascending or 
> descending?
> 
> Thanks in advance,
> Mario
> 
>   [[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] Question Regarding a nested for loop in R

2015-12-04 Thread MacQueen, Don
I'll hope this isn't homework (R-help has a "don't do people's homework
for them" convention), and make a few suggestions.

The inner loop is not needed. For example, you can replace

for (i in 1:15 ) {


Inv1Outcome[i] = if (random[i] <= .25){Inv1Returns[1]}
  else if (random[i] > .25 & random[i] <= .50){Inv1Returns[2]}
  else if (random[i] > .50 & random[i] <= .75){Inv1Returns[3]}
  else {Inv1Returns[4]}

}


with

 
Inv1Outcome <- rep(Inv1Returns[1],15]

Inv1Outcome[random > 0.25 & random <= 0.50] <- Inv1Returns[2]
Inv1Outcome[random > 0.50 & random <= 0.75] <- Inv1Returns[3]
Inv1Outcome[random > 0.75]  <- Inv1Returns[4]

And similarly for the other two outcomes.

For that matter, if I interpret correctly what's going on, this might do
it:

Inv1Outcome <- sample(Inv1Returns, 15, replace=TRUE, prob=c(0.25, 0.25,
0.25, 0.25)



I don't think I understand what you're trying to do with the outer loop,
but it does occur to me that with 'random' defined outside both loops, the
inner loop will have exactly the same results all four times, and does
that make any sense? Try putting
  random = runif(15, 0, 1)
inside the outer loop but outside the inner loop.

-- 
Don MacQueen

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





On 12/3/15, 2:42 PM, "R-help on behalf of Vermilio, Ryan"

wrote:

>Hello there,
>
>I'm an R novice and am trying to figure out how to create an external for
>loop.  My current loop iterates 15 times and stores the resulting values
>in 3 separate vectors.  What I need is to create an outside loop that
>will run internal loop 4 times, sum the resulting vectors for each, and
>then store the sum of each in a vector of length 4 for each investment.
>
>Right now, the target vector has the same value in each position, which
>is what I'm trying to fix.
>
>Here's what I have at this point:
>
>Inv1Returns <- c(0, 1000, -500, 500)
>Inv2Returns <- c(0, -9000, 3, 1)
>Inv3Returns <- c(0, 4000, -1000, -2000)
>
>random = runif(15, 0, 1)
>
>Inv1Outcome = NULL
>Inv2Outcome = NULL
>Inv3Outcome = NULL
>
>Inv1Total = NULL
>Inv2Total = NULL
>Inv3Total = NULL
>
>for (j in 1:4)
>
>{
>
>for (i in 1:15 )
>
>{
>
>  Inv1Outcome[i] = if (random[i] <= .25){Inv1Returns[1]}
>  else if (random[i] > .25 & random[i] <= .50){Inv1Returns[2]}
>  else if (random[i] > .50 & random[i] <= .75){Inv1Returns[3]}
>  else {Inv1Returns[4]}
>
>  Inv2Outcome[i] = if (random[i] <= .20){Inv2Returns[1]}
>  else if (random[i] > .20 & random[i] <= .30){Inv2Returns[2]}
>  else if (random[i] > .30 & random[i] <= .70){Inv2Returns[3]}
>  else {Inv2Returns[4]}
>
>  Inv3Outcome[i] = if (random[i] <= .50){Inv3Returns[1]}
>  else if (random[i] > .50 & random[i] <= .70){Inv3Returns[2]}
>  else if (random[i] > .70 & random[i] <= .90){Inv3Returns[3]}
>  else {Inv3Returns[4]}
>
>}
>
>Inv1Total = append(Inv1Total, sum(Inv1Outcome))
>Inv2Total = append(Inv2Total, sum(Inv2Outcome))
>Inv3Total = append(Inv3Total, sum(Inv3Outcome))
>
>}
>
>Inv1Total
>Inv2Total
>Inv3Total
>
>
>Sincerely,
>
>Ryan
>
>   [[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] Ordering Filenames stored in list or vector

2015-12-04 Thread Henrik Bengtsson
> filenames <- c("Q_Read_prist#1...@1.xls", "Q_Read_prist#1...@10.xls", 
> "Q_Read_prist#1...@2.xls")
> filenames <- gtools::mixedsort(filenames, numeric.type="decimal")
> filenames
[1] "Q_Read_prist#1...@1.xls"  "Q_Read_prist#1...@2.xls"  
"Q_Read_prist#1...@10.xls"

/Henrik

On Fri, Dec 4, 2015 at 7:53 AM, Boris Steipe  wrote:
> The thread below has a number of solutions. I personally like the one with 
> sprintf().
>https://stat.ethz.ch/pipermail/r-help/2010-July/246059.html
>
>
> B.
>
> On Dec 4, 2015, at 5:51 AM, BARLAS Marios 247554  wrote:
>
>> Hello everyone,
>>
>> I am an R rookie and I'm learning as I program.
>>
>> I am working on a script to process a large amount of data: I read a pattern 
>> of filenames in the folder I want and import their data
>>
>> filenames = list.files(path, pattern="*Q_Read_prist*")
>>
>> myfiles = lapply(filenames, function(x) read.xlsx2(file=x, sheetName="Data", 
>> header=TRUE, FILENAMEVAR=x))
>>
>> The problem is that R recognizes the files in a 'non human' order.
>>
>> Q_Read_prist#1...@1.xls   Q_Read_prist#1...@1.xls
>> Q_Read_prist#1...@10.xls Q_Read_prist#1...@10.xls
>> Q_Read_prist#1...@11.xls Q_Read_prist#1...@11.xls
>> Q_Read_prist#1...@12.xls Q_Read_prist#1...@12.xls
>> Q_Read_prist#1...@13.xls Q_Read_prist#1...@13.xls
>> Q_Read_prist#1...@14.xls Q_Read_prist#1...@14.xls
>> Q_Read_prist#1...@15.xls Q_Read_prist#1...@15.xls
>> Q_Read_prist#1...@16.xls Q_Read_prist#1...@16.xls
>> Q_Read_prist#1...@17.xls Q_Read_prist#1...@17.xls
>> Q_Read_prist#1...@18.xls Q_Read_prist#1...@18.xls
>> Q_Read_prist#1...@19.xls Q_Read_prist#1...@19.xls
>> Q_Read_prist#1...@2.xls   Q_Read_prist#1...@2.xls
>> Q_Read_prist#1...@3.xls   Q_Read_prist#1...@3.xls
>> Q_Read_prist#1...@4.xls   Q_Read_prist#1...@4.xls
>> Q_Read_prist#1...@5.xls   Q_Read_prist#1...@5.xls
>> Q_Read_prist#1...@6.xls   Q_Read_prist#1...@6.xls
>> Q_Read_prist#1...@7.xls   Q_Read_prist#1...@7.xls
>> Q_Read_prist#1...@8.xls   Q_Read_prist#1...@8.xls
>> Q_Read_prist#1...@9.xls   Q_Read_prist#1...@9.xls
>>
>> I tried to order them using order or sort but it doesn' seem to work. I have 
>> had the same issue in matlab but there I have a function to re-define the 
>> order in a "correct" way.
>>
>> Anyone knows of a smart way to sort these guys from 1 to 19 ascending or 
>> descending?
>>
>> Thanks in advance,
>> Mario
>>
>>   [[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-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] dataframe rbind

2015-12-04 Thread Troels Ring

Thanks a lot - I should have seen that
Best wishes
Troels

Den 04-12-2015 kl. 17:09 skrev PIKAL Petr:

Hi

Maybe little bit of studying how functions work can be useful

rbind uses to bind two objects together, however you give it only one.

Use

DF <- rbind(DF, data.frame(a=rnorm(10),b=runif(10),ID=i))

instead.

Cheers
Petr



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Troels
Ring
Sent: Friday, December 04, 2015 5:03 PM
To: r-help@r-project.org
Subject: [R] dataframe rbind

Dear friends - I have a very simple question - I generate a number of
dataframes with identical names and want to combine them into one large
dataframe with the same names - here is an example

DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
for (i in 1:10){
DF <- DF+rbind(data.frame(a=rnorm(10),b=runif(10),ID=i))}

- the dataframe do not grow as I thought it would.

How would I do this?

All best wishes
Troels Ring
Nephrology
Aalborg
Denmark

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


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
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] dataframe rbind

2015-12-04 Thread peter dalgaard

On 04 Dec 2015, at 17:03 , Troels Ring  wrote:

> Dear friends - I have a very simple question -
> I generate a number of dataframes with identical names and want to combine 
> them into one large dataframe with the same names -
> here is an example
> 
> DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
> for (i in 1:10){
> DF <- DF+rbind(data.frame(a=rnorm(10),b=runif(10),ID=i))}
> 
> - the dataframe do not grow as I thought it would.
> 

Don't you mean DF <- rbind(DF, data.frame(.. ?

(Or, but a different discussion, do.call("rbind", lapply(1:10, function(i) 
data.frame(.,ID=i)))

-pd


> How would I do this?
> 
> All best wishes
> Troels Ring
> Nephrology
> Aalborg
> Denmark
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] dataframe rbind

2015-12-04 Thread Bert Gunter
Try reading and following the Help file, ?rbind.data.frame.

You are inventing your own syntax, not using R's.

Incidentally, growing the frames as you do is generally a bad idea.
Search r-help archives for why.

Cheers,
Bert

Bert Gunter

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


On Fri, Dec 4, 2015 at 8:03 AM, Troels Ring  wrote:
> Dear friends - I have a very simple question -
> I generate a number of dataframes with identical names and want to combine
> them into one large dataframe with the same names -
> here is an example
>
> DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
> for (i in 1:10){
> DF <- DF+rbind(data.frame(a=rnorm(10),b=runif(10),ID=i))}
>
> - the dataframe do not grow as I thought it would.
>
> How would I do this?
>
> All best wishes
> Troels Ring
> Nephrology
> Aalborg
> Denmark
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] For loop coding

2015-12-04 Thread PIKAL Petr
Hi

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Saba
> Sehrish via R-help
> Sent: Friday, December 04, 2015 11:21 AM
> To: r-help@r-project.org
> Subject: [R] For loop coding
>
> Hi
>
> I will be grateful if someone please tell me the programming to run
> regression on time series data through "For Loop".

for ( i in seq) {

lll[[i]] <- lm(whatever)

}

Cheers
Petr

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


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] dataframe rbind

2015-12-04 Thread David L Carlson
This will work, although depending on what you are trying to do, there may be a 
better way:

> DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
> for (i in 1:10){
+ DF <- rbind(DF, data.frame(a=rnorm(10),b=runif(10),ID=i))}
> str(DF)
'data.frame':   110 obs. of  3 variables:
 $ a : num  0.792 0.141 -1.091 -0.918 1.265 ...
 $ b : num  0.5935 0.695 0.075 0.0827 0.852 ...
 $ ID: num  0 0 0 0 0 0 0 0 0 0 ...

For example:

> DF <- data.frame(a=rnorm(110), b=rnorm(110), ID=rep(0:10, each=10))
> str(DF)
'data.frame':   110 obs. of  3 variables:
 $ a : num  -1.91926 0.00791 0.65523 0.95019 1.23822 ...
 $ b : num  0.344 1.281 2.057 -1.69 -0.268 ...
 $ ID: int  0 0 0 0 0 0 0 0 0 0 ...

-
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 Troels Ring
Sent: Friday, December 4, 2015 10:03 AM
To: r-help@r-project.org
Subject: [R] dataframe rbind

Dear friends - I have a very simple question -
I generate a number of dataframes with identical names and want to 
combine them into one large dataframe with the same names -
here is an example

DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
for (i in 1:10){
DF <- DF+rbind(data.frame(a=rnorm(10),b=runif(10),ID=i))}

- the dataframe do not grow as I thought it would.

How would I do this?

All best wishes
Troels Ring
Nephrology
Aalborg
Denmark

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

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


Re: [R] dataframe rbind

2015-12-04 Thread PIKAL Petr
Hi

Maybe little bit of studying how functions work can be useful

rbind uses to bind two objects together, however you give it only one.

Use

DF <- rbind(DF, data.frame(a=rnorm(10),b=runif(10),ID=i))

instead.

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Troels
> Ring
> Sent: Friday, December 04, 2015 5:03 PM
> To: r-help@r-project.org
> Subject: [R] dataframe rbind
>
> Dear friends - I have a very simple question - I generate a number of
> dataframes with identical names and want to combine them into one large
> dataframe with the same names - here is an example
>
> DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
> for (i in 1:10){
> DF <- DF+rbind(data.frame(a=rnorm(10),b=runif(10),ID=i))}
>
> - the dataframe do not grow as I thought it would.
>
> How would I do this?
>
> All best wishes
> Troels Ring
> Nephrology
> Aalborg
> Denmark
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Random forest regression: feedback on general approach and possible issues

2015-12-04 Thread Bert Gunter
I would suggest that you post instead on stats.stackexchange.com  .
This forum is mostly about R programming issues, not statistics
(admittedly, the intersection is nonempty, but ...) That stackexchange
forum is more about statistics.

You might also consider a bioconductor forum, as this appears to be a
bioinformatics type of issue.

Cheers,

Bert

P.S. Both of these could be found with suitable internet searches.
Don't neglect search engines for these types of queries. I have found
them to be very helpful.
Bert Gunter

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


On Fri, Dec 4, 2015 at 1:15 AM, Johannes Klene  wrote:
> Hi all,
> I'd like to use random forest regression to say something about the
> importance of a set of genes (binary) for schizophrenia-related behavior
> (continuous measure). I am still reading up on this technique, but would
> already really appreciate any feedback on whether my approach is valid.
> So...using the randomForest package, is it a good approach to enter a few
> dozen binary predictors to assess their importance (as a set, and
> individually) for a continuous measure with a sample size of ~1000 people?
> More specific questions:
> - I have an additional interest in interactions (though perhaps not the
> best word in this context), does it make any sense to say something about
> the influence one predictor has over others by looking at the change in
> estimated importance of the others when that predictor is removed from the
> model?
> - I have a few siblings in the data, i.e. non-independence, is this a
> problem and if so, is there anything I can do about it?
> - The few papers I have seen so far on using this technique in a similar
> situation do not include any 'standard' covariates such as age and gender,
> should I?
> Any and all feedback is greatly appreciated!! Kind regards, Johannes
>
> p.s. Hope I've come to the right place despite this being a more general
> question, if not please let me know of a forum where this is more suited
> for.
>
> [[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] dataframe rbind

2015-12-04 Thread Troels Ring

Dear friends - I have a very simple question -
I generate a number of dataframes with identical names and want to 
combine them into one large dataframe with the same names -

here is an example

DF <- data.frame(a=rnorm(10),b=runif(10),ID=0)
for (i in 1:10){
DF <- DF+rbind(data.frame(a=rnorm(10),b=runif(10),ID=i))}

- the dataframe do not grow as I thought it would.

How would I do this?

All best wishes
Troels Ring
Nephrology
Aalborg
Denmark

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


Re: [R] Ordering Filenames stored in list or vector

2015-12-04 Thread Boris Steipe
The thread below has a number of solutions. I personally like the one with 
sprintf().
   https://stat.ethz.ch/pipermail/r-help/2010-July/246059.html


B.

On Dec 4, 2015, at 5:51 AM, BARLAS Marios 247554  wrote:

> Hello everyone,
> 
> I am an R rookie and I'm learning as I program.
> 
> I am working on a script to process a large amount of data: I read a pattern 
> of filenames in the folder I want and import their data
> 
> filenames = list.files(path, pattern="*Q_Read_prist*")
> 
> myfiles = lapply(filenames, function(x) read.xlsx2(file=x, sheetName="Data", 
> header=TRUE, FILENAMEVAR=x))
> 
> The problem is that R recognizes the files in a 'non human' order.
> 
> Q_Read_prist#1...@1.xls   Q_Read_prist#1...@1.xls
> Q_Read_prist#1...@10.xls Q_Read_prist#1...@10.xls
> Q_Read_prist#1...@11.xls Q_Read_prist#1...@11.xls
> Q_Read_prist#1...@12.xls Q_Read_prist#1...@12.xls
> Q_Read_prist#1...@13.xls Q_Read_prist#1...@13.xls
> Q_Read_prist#1...@14.xls Q_Read_prist#1...@14.xls
> Q_Read_prist#1...@15.xls Q_Read_prist#1...@15.xls
> Q_Read_prist#1...@16.xls Q_Read_prist#1...@16.xls
> Q_Read_prist#1...@17.xls Q_Read_prist#1...@17.xls
> Q_Read_prist#1...@18.xls Q_Read_prist#1...@18.xls
> Q_Read_prist#1...@19.xls Q_Read_prist#1...@19.xls
> Q_Read_prist#1...@2.xls   Q_Read_prist#1...@2.xls
> Q_Read_prist#1...@3.xls   Q_Read_prist#1...@3.xls
> Q_Read_prist#1...@4.xls   Q_Read_prist#1...@4.xls
> Q_Read_prist#1...@5.xls   Q_Read_prist#1...@5.xls
> Q_Read_prist#1...@6.xls   Q_Read_prist#1...@6.xls
> Q_Read_prist#1...@7.xls   Q_Read_prist#1...@7.xls
> Q_Read_prist#1...@8.xls   Q_Read_prist#1...@8.xls
> Q_Read_prist#1...@9.xls   Q_Read_prist#1...@9.xls
> 
> I tried to order them using order or sort but it doesn' seem to work. I have 
> had the same issue in matlab but there I have a function to re-define the 
> order in a "correct" way.
> 
> Anyone knows of a smart way to sort these guys from 1 to 19 ascending or 
> descending?
> 
> Thanks in advance,
> Mario
> 
>   [[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] For loop coding

2015-12-04 Thread Saba Sehrish via R-help
Hi

I will be grateful if someone please tell me the programming to run regression 
on time series data through "For Loop".

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


Re: [R] Strange error

2015-12-04 Thread Nicolae Doban
Hi again,

i found the error:
the problem was that I have created a template of rmarkdown myself inspired
from Tufte one and I guess I didn't build it correctly..when i tried
running it in a regular rmarkdown template it worked.

sorry for inconvenience
nick

Nicolae (Nick) Doban | Masters student
EIT KIC Energy for Smart Cities Master of Science Programme
Tel.: +32 489 11 81 73
LinkedIn: https://be.linkedin.com/in/nicolaedoban
Skype ID: doban.nicolae
Twitter: https://twitter.com/NicolaeDoban
GitHub: https://github.com/nickdoban


On Fri, Dec 4, 2015 at 7:34 AM, Jim Lemon  wrote:

> Hi Nick,
> I think that Jeff may be correct in that the code was cut and pasted from
> a non-text application. In particular, the error message about "*" is
> suspicious. What may be happening is that when you select a single line, it
> only picks up the text, but when you select multiple lines, the garbage
> bytes come along for the ride. Since you seem to be using Windows, try
> Notepad (text editor) for an external editor as it is usually better
> behaved. The final error is the result of not having read the data into GWS.
>
> Jim
>
> On Thu, Dec 3, 2015 at 10:59 PM, Nicolae Doban 
> wrote:
>
>> Hi,
>>
>> recently I received a strange error after running my code in chunks. But,
>> I
>> don't get any errors when I run it line by line.
>>
>> Also, what is strange is that the  error message is misspelled
>>
>> This is the error messages I get
>>
>> *> setwd("H:/XX/XXX")*
>> *"rror: unexpected input in "setwd("H:/XX/XXX")*
>> *> *
>> *"rror: unexpected input in "*
>> *> GWS <- read.csv("X.csv", header = TRUE, sep = ",", stringsAsFactors =
>> FALSE, na.strings=c("","","NA"))*
>> *"rror: unexpected input in "GWS <- read.csv("X.csv", header = TRUE, sep =
>> ",", stringsAsFactors = FALSE, na.strings=c("","","NA"))*
>> *> GWS <- GWS[with(GWS, order(d)), ]; row.names(GWS) <- NULL*
>> *Error: object 'GWS' not found*
>>
>> As you can see even changing the directory results in an error message
>> but,
>> it changes the directory to the correct folder.
>>
>> What is interesting is that I was not getting this error yesterday (Dec.,
>> 2nd 2015)
>>
>> Could you please shed some light on this issue? Is it something related to
>> R or Rstudio or the packages?
>>
>> Thank you in advance very much,
>> nick
>>
>> [[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] Random forest regression: feedback on general approach and possible issues

2015-12-04 Thread Johannes Klene
Hi all,
I'd like to use random forest regression to say something about the
importance of a set of genes (binary) for schizophrenia-related behavior
(continuous measure). I am still reading up on this technique, but would
already really appreciate any feedback on whether my approach is valid.
So...using the randomForest package, is it a good approach to enter a few
dozen binary predictors to assess their importance (as a set, and
individually) for a continuous measure with a sample size of ~1000 people?
More specific questions:
- I have an additional interest in interactions (though perhaps not the
best word in this context), does it make any sense to say something about
the influence one predictor has over others by looking at the change in
estimated importance of the others when that predictor is removed from the
model?
- I have a few siblings in the data, i.e. non-independence, is this a
problem and if so, is there anything I can do about it?
- The few papers I have seen so far on using this technique in a similar
situation do not include any 'standard' covariates such as age and gender,
should I?
Any and all feedback is greatly appreciated!! Kind regards, Johannes

p.s. Hope I've come to the right place despite this being a more general
question, if not please let me know of a forum where this is more suited
for.

[[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 Regarding a nested for loop in R

2015-12-04 Thread MCGUIRE, Rhydwyn
Hi Ryan, 

I don't think you need the outer loop, loops are worth avoiding if you can 
possibly can because they are inefficient, have a look at this dplyr tutorial 
(https://cran.rstudio.com/web/packages/dplyr/vignettes/introduction.html) which 
should be able to achieve what your outer loop is currently doing. 
Vectorisation (applying a calculation to a whole array) should be able to 
process your innerloop. 

Good luck

Rhydwyn 


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Vermilio, Ryan
Sent: Friday, 4 December 2015 9:43 AM
To: r-help@r-project.org
Subject: [R] Question Regarding a nested for loop in R


Hello there,

I'm an R novice and am trying to figure out how to create an external for loop. 
 My current loop iterates 15 times and stores the resulting values in 3 
separate vectors.  What I need is to create an outside loop that will run 
internal loop 4 times, sum the resulting vectors for each, and then store the 
sum of each in a vector of length 4 for each investment.

Right now, the target vector has the same value in each position, which is what 
I'm trying to fix.

Here's what I have at this point:

Inv1Returns <- c(0, 1000, -500, 500)
Inv2Returns <- c(0, -9000, 3, 1) Inv3Returns <- c(0, 4000, -1000, -2000)

random = runif(15, 0, 1)

Inv1Outcome = NULL
Inv2Outcome = NULL
Inv3Outcome = NULL

Inv1Total = NULL
Inv2Total = NULL
Inv3Total = NULL

for (j in 1:4)

{

for (i in 1:15 )

{

  Inv1Outcome[i] = if (random[i] <= .25){Inv1Returns[1]}
  else if (random[i] > .25 & random[i] <= .50){Inv1Returns[2]}
  else if (random[i] > .50 & random[i] <= .75){Inv1Returns[3]}
  else {Inv1Returns[4]}

  Inv2Outcome[i] = if (random[i] <= .20){Inv2Returns[1]}
  else if (random[i] > .20 & random[i] <= .30){Inv2Returns[2]}
  else if (random[i] > .30 & random[i] <= .70){Inv2Returns[3]}
  else {Inv2Returns[4]}

  Inv3Outcome[i] = if (random[i] <= .50){Inv3Returns[1]}
  else if (random[i] > .50 & random[i] <= .70){Inv3Returns[2]}
  else if (random[i] > .70 & random[i] <= .90){Inv3Returns[3]}
  else {Inv3Returns[4]}

}

Inv1Total = append(Inv1Total, sum(Inv1Outcome)) Inv2Total = append(Inv2Total, 
sum(Inv2Outcome)) Inv3Total = append(Inv3Total, sum(Inv3Outcome))

}

Inv1Total
Inv2Total
Inv3Total


Sincerely,

Ryan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
This email has been scanned for the NSW Ministry of Health by the Websense 
Hosted Email Security System.
Emails and attachments are monitored to ensure compliance with the NSW Ministry 
of health's Electronic Messaging Policy.
__
___
Disclaimer: This message is intended for the addressee named and may contain 
confidential information.
If you are not the intended recipient, please delete it and notify the sender.
Views expressed in this message are those of the individual sender, and are not 
necessarily the views of the NSW Ministry of Health.
___
This email has been scanned for the NSW Ministry of Health by the Websense 
Hosted Email Security System.
Emails and attachments are monitored to ensure compliance with the NSW Ministry 
of Health's Electronic Messaging Policy.

__
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] Ordering Filenames stored in list or vector

2015-12-04 Thread BARLAS Marios 247554
Hello everyone,

I am an R rookie and I'm learning as I program.

I am working on a script to process a large amount of data: I read a pattern of 
filenames in the folder I want and import their data

filenames = list.files(path, pattern="*Q_Read_prist*")

myfiles = lapply(filenames, function(x) read.xlsx2(file=x, sheetName="Data", 
header=TRUE, FILENAMEVAR=x))

The problem is that R recognizes the files in a 'non human' order.

Q_Read_prist#1...@1.xls   Q_Read_prist#1...@1.xls
Q_Read_prist#1...@10.xls Q_Read_prist#1...@10.xls
Q_Read_prist#1...@11.xls Q_Read_prist#1...@11.xls
Q_Read_prist#1...@12.xls Q_Read_prist#1...@12.xls
Q_Read_prist#1...@13.xls Q_Read_prist#1...@13.xls
Q_Read_prist#1...@14.xls Q_Read_prist#1...@14.xls
Q_Read_prist#1...@15.xls Q_Read_prist#1...@15.xls
Q_Read_prist#1...@16.xls Q_Read_prist#1...@16.xls
Q_Read_prist#1...@17.xls Q_Read_prist#1...@17.xls
Q_Read_prist#1...@18.xls Q_Read_prist#1...@18.xls
Q_Read_prist#1...@19.xls Q_Read_prist#1...@19.xls
Q_Read_prist#1...@2.xls   Q_Read_prist#1...@2.xls
Q_Read_prist#1...@3.xls   Q_Read_prist#1...@3.xls
Q_Read_prist#1...@4.xls   Q_Read_prist#1...@4.xls
Q_Read_prist#1...@5.xls   Q_Read_prist#1...@5.xls
Q_Read_prist#1...@6.xls   Q_Read_prist#1...@6.xls
Q_Read_prist#1...@7.xls   Q_Read_prist#1...@7.xls
Q_Read_prist#1...@8.xls   Q_Read_prist#1...@8.xls
Q_Read_prist#1...@9.xls   Q_Read_prist#1...@9.xls

I tried to order them using order or sort but it doesn' seem to work. I have 
had the same issue in matlab but there I have a function to re-define the order 
in a "correct" way.

Anyone knows of a smart way to sort these guys from 1 to 19 ascending or 
descending?

Thanks in advance,
Mario

[[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] Can we use all the functions of R in visual studio? The Rmath.dll and R.dll seems only contain a part of R functions

2015-12-04 Thread 李琥
Can we use all the functions of R in visual studio? The Rmath.dll and R.dll 
seems only contain a part of R functions

Hi, I 'm going to use R functions in visual studio. I have investigated 
this problem for several days. There're guide about
using R in embedded way,which use R.dll. But it seems a lot of functions are 
not included in the dll, such as t.test().

So, is there a way that we can use all the R functions in visual studio? Or 
is there a way we can use all the R functions in other 
compilers with c++? Or can we integrate R into c++ in linux platform?
Thanks a lot.
   
 Best Regards.
  Eric.Li
   2015.12.4

__
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] Survival analysis: ERROR: Time and status are different lengths

2015-12-04 Thread Therneau, Terry M., Ph.D.
I expect that reading the result of print(fit.weib) will answer your question.  If there 
were any missing values in the data set, then the fit.weib$linear.predictors will be 
shorter than the original data set,

and the printout will have a note about "...deleted due to missing".

The simplest solution to this is to set
  options(na.action="na.exclude")
before doing the fit.  Then predict(fit) and resid(fit) will return vectors of the same 
length as the input data, containing NA in the appropriate positions.  The default 
na.action of "na.omit" leaves missing out of both the fit and the residuals.


(Unfortunately, only a few modeling functions in R pay attention to the difference between 
these two na.action options.)


Terry Therneau


On 12/04/2015 05:00 AM, r-help-requ...@r-project.org wrote:

Hi,

I am fitting an AFT model assuming a Weibull distribution and I would like
to check the residuals compared to the Kaplan Meier residuals, but when I
try to create the Kaplan Meier residuals I get an error: Time and status
are different lengths.

I am using the following script:

# Fitting the AFT model
fit.weib <- survreg(Surv(TimeDeath, event) ~ age + sex + mutation +
ventilation + BM1 + BM2, data = DF, dist = "weibull")
fits <- fit.weib$linear.predictors
resids <- (fit.weib$y[, 1] - fits)/fit.weib$scale
resKM <- survfit(Surv(resids, event) ~ 1, data = DF)

I get the error from the last line of the script.

I tried some things that didn't work and I was wondering if anyone could
help me.
If you need more information please let me know.

Thanks in advance,


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


[R] queries return different output when sourced

2015-12-04 Thread Thierry Onkelinx
Dear all,

We need to run several queries in an R Markdown file. The queries have quit
elaborate sql statements. We try to recude the amount of code in the
markdown file by moving the query functions in a seperate R script which is
sourced by the markdown file.

The queries work fine if we place the code directly in the markdown file
but fail when sourced. They return an empty data.frame with the correct
colnames. We have attached a minimal example.

Can someone tell us why the sourced functions give the a different output?

Best regards,

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

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


QueriesTest.pdf
Description: Adobe PDF document
__
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.