[R] R web application development

2013-03-18 Thread John linux-user
Dear all,

I am wondering if what would be the simple way to develop a simple web 
application that runs R. That is, the web application allows any user upload a 
dataframe as a variable to my web server, a linux-based apache, and then run a 
R package (my package) on the variable that should ideally be handled  as a 
variable in memory instead of saving to the disk in my server , for security 
concern. After running, the result would be returned to the web.  Any 
suggestion will be appreciated. 

Best,

John  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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 web application development

2013-03-18 Thread John linux-user
Thanks for reply, but which archives? 

Thanks again.
 John



 From: Stephen Sefick 

Cc: "r-help@r-project.org"  
Sent: Monday, March 18, 2013 8:02 PM
Subject: Re: [R] R web application development

I can't offer any advice, but I feel like you could probably get a good start 
on this by looking through the archives.

On Mon 18 Mar 2013 06:55:33 PM CDT, John linux-user wrote:
> 
> Dear all,
> 
> I am wondering if what would be the simple way to develop a simple web 
> application that runs R. That is, the web application allows any user upload 
> a dataframe as a variable to my web server, a linux-based apache, and then 
> run a R package (my package) on the variable that should ideally be handled 
> as a variable in memory instead of saving to the disk in my server , for 
> security concern. After running, the result would be returned to the web. Any 
> suggestion will be appreciated.
> 
> Best,
> 
> John
> [[alternative HTML version deleted]]
> 
> 
> 
> __
> R-help@r-project.org mailing list
> 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
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to merge GRange object?

2013-10-16 Thread John linux-user
Hello everyone,

I am wondering how to simply merge two GRanges objects by range field and add 
the value by additional vector. For example, I have two objects below 
 
obj1 

seqnames           ranges strand |       Val
                       | 
  [1] chr1_random [272531, 272571]      + |        88
  [2] chr1_random [272871, 272911]      + |        45

obj2
 seqnames           ranges strand |       Val
                       | 
  [1] chr1_random [272531, 272581]      + |        800
  [2] chr1_random [272850, 272911]      + |        450

after merged, it should be an object as the following mergedObject and it would 
concern the differences in IRANGE data (e.g. 581 and 850 in obj2 above were 
different from those of obj1, which were 571 and 871 respectively)

mergedObject

 seqnames           ranges strand                 |         object2Val   
object1Val
                               |              

  [1] chr1_random [272531, 272581]      + |        800               88
  [2] chr1_random [272850, 272911]      + |        450               45





On Wednesday, October 16, 2013 8:31 AM, Terry Therneau  
wrote:
 


On 10/16/2013 05:00 AM, r-help-requ...@r-project.org wrote:
> Hello,
>
> I'm trying to use coxph() function to fit a very simple Cox proportional
> hazards regression model (only one covariate) but the parameter space is
> restricted to an open set (0, 1). Can I still obtain a valid estimate by
> using coxph function in this scenario? If yes, how? Any suggestion would be
> greatly appreciated. Thanks!!!

Easily:
    1.  Fit the unrestricted model.  If the solution is in 0-1 you are done.
    2.  If it is outside, fix the coefficient.  Say that the solution is 1.73, 
then the
optimal solution under contraint is 1.
        Redo the fit adding the paramters  "init=1, iter=0".  This forces the 
program to 
give the loglik and etc for the fixed coefficient of 1.0.

Terry Therneau

__
R-help@r-project.org mailing list
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
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] add vectors to multiple objects

2012-08-01 Thread John linux-user
Hi everyone,

I try to add many vectors (L1,L2,L3) to many list objects (a.list, 
b.list) in a workspace. Somethings like below, but it is not working. Any 
suggestions will be appreciated. Best, John



lf=ls(pattern=".lst")

 for (x in listfiles) {
    dat=read.delim(x,header=F)


    for (i in 1: lf) {
    assign(i$add,as.numeric(dat[,3]))
  #or i$add=as.numeric(dat[,3]
    names(i)[names(i)=="add"]=substr(x,1,5)

    print (i[1:3,])
 }
}
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] assign vectors to objects

2012-08-01 Thread John linux-user
Hi everyone,

I try to add many vectors (L1,L2,L3) to multiple list objects (a.list, 
b.list) in a workspace. Somethings like below, but it is not 
working. Any suggestions will be appreciated. Best, John



lf=ls(pattern=".lst")

 for (x in listfiles) {
    dat=read.delim(x,header=F)


    for (i in lf) {
    assign(i$add,as.numeric(dat[,3]))
  #or i$add=as.numeric(dat[,3]
    names(i)[names(i)=="add"]=substr(x,1,5)

    print (i[1:3,])
 }}







 From: "r-help-boun...@r-project.org" 

Sent: Wednesday, August 1, 2012 11:11 AM
Subject: Your message to R-help awaits moderator approval

Your mail to 'R-help' with the subject

    add vectors to multiple objects

Is being held until the list moderator can review it for approval.

The reason it is being held:

    Post to moderated list

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.  If you would like to cancel
this posting, please visit the following URL:

    
https://stat.ethz.ch/mailman/confirm/r-help/4bdc02c25f8cb618a623fce61b61fb51189c52ad
[[alternative HTML version deleted]]

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


Re: [R] add vectors to multiple objects

2012-08-03 Thread John linux-user
Hi David,

Thanks for response, but my key question still remains unsolved. That is, how 
to add many vectors (L1,L2,L3) to many list objects (a.list, 
b.list) in a workspace? 


listObjects=ls(pattern=".list") #for example,  a.list, b.list...



for (object in listObjects){

#how to sign vectors L1,L2,..Ln to each object (a.list, b.list...)



}


Any suggestions/comments/ideas will be appreciated.

John





 From: David Winsemius 

Cc: "r-help@r-project.org"  
Sent: Wednesday, August 1, 2012 7:21 PM
Subject: Re: [R] add vectors to multiple objects


On Aug 1, 2012, at 8:11 AM, John linux-user wrote:

> Hi everyone,
> 
> I try to add many vectors (L1,L2,L3) to many list objects (a.list, 
> b.list) in a workspace. Somethings like below, but it is not working. Any 
> suggestions will be appreciated. Best, John
> 
> lf=ls(pattern=".lst")
> 
>  for (x in listfiles) {
>     dat=read.delim(x,header=F)

Presumably that would fail since 'listfiles' has not been defined. did you mean 
'lf'? If you did,then wouldn't the second line overwrite all the early values 
of "dat" leaving only the last one?

Perhaps:
  datfils <- list()
  for (x in listfiles) {
    datfils[x] <- read.delim(x,header=F)


> 
>     for (i in 1: lf) {

And that would fail because 'lf' is a character vector, and it's not meaningful 
to specify such a range. Try instead:

     for (i in names(datfils[x]) ) {
#
# which will then iterate over the names of the files which are now also the 
names of the list elements

>     assign(i$add,as.numeric(dat[,3]))

But since 'i' is a length-1 character vector, the expression `i$add` will be 
meaningless. The "$" operator does not do function calling in R unless you do 
fancy things with environments, and you cannot "sub-assign" in that manner, at 
least not with the assign() function.

Try instead:

    assign(i, as.numeric(datfils[x][,3]))
    names(i)[length(i)] <- "add"

Or:
     i <- transform(i, add=datfils[x][,3] )



>   #or i$add=as.numeric(dat[,3]
>     names(i)[names(i)=="add"]=substr(x,1,5)

I'm not sure these would be doing the same thing. What was your goal here?

> 
>     print (i[1:3,])
>  }
> }


David Winsemius, MD
Alameda, CA, USA
[[alternative HTML version deleted]]

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


Re: [R] add vectors to multiple objects

2012-08-03 Thread John linux-user
Maybe what I previously posted was not clear enough or something else. All 
vectors L1,L2.. and objects (e.g. a.list, b.list, c.list) already exit or 
easily to be created in a workspace. Do not worry about those. The key question 
is how to systematically append/assign these vectors to many objects (hundreds) 
in a loop without explicitly typing these object names one by one. Please refer 
to my code posted below to detail my question.  I really appreciate your 
ideas/suggestions. John 



> listObjects=ls(pattern=".list")   #for example,  a.list, b.list...
> 
> 
> for (object in listObjects){
> 
> #how to sign vectors L1,L2,..Ln to each object (a.list, b.list...)
> 
> 
> }



>lf=ls(pattern=".lst")
>
>  for (x in listfiles) {
>     dat=read.delim(x,header=F)
>
>
>     for (i in lf) {
>     assign(i$add,as.numeric(dat[,3]))
>   #or i$add=as.numeric(dat[,3]
>     names(i)[names(i)=="add"]=substr(x,1,5)
>
>     print (i[1:3,])
>  }}



 From: David Winsemius 

Cc: "r-help@r-project.org"  
Sent: Friday, August 3, 2012 2:58 PM
Subject: Re: [R] add vectors to multiple objects


On Aug 3, 2012, at 8:19 AM, John linux-user wrote:

> Hi David,
> 
> Thanks for response, but my key question still remains unsolved. That is, how 
> to add many vectors (L1,L2,L3) to many list objects (a.list, b.list) 
> in a workspace?
> 
> listObjects=ls(pattern=".list") #for example,  a.list, b.list...
> 
> 
> for (object in listObjects){
> 
> #how to sign vectors L1,L2,..Ln to each object (a.list, b.list...)
> 
> 
> }
> 
> Any suggestions/comments/ideas will be appreciated.

Can we have code that creates these entities in the workspace? (That is what is 
meant as a reproducible example.)  I cannot tell whether there are already 
objects named "L1", "L2",... to which you wish to append the value of the 
objects found,  or  that you want to assign values to names that only exist as 
character vectors.

--David.

> 
> John
> 
> 
> From: David Winsemius 

> Cc: "r-help@r-project.org" 
> Sent: Wednesday, August 1, 2012 7:21 PM
> Subject: Re: [R] add vectors to multiple objects
> 
> 
> On Aug 1, 2012, at 8:11 AM, John linux-user wrote:
> 
> > Hi everyone,
> >
> > I try to add many vectors (L1,L2,L3) to many list objects (a.list, 
> > b.list) in a workspace. Somethings like below, but it is not working. 
> > Any suggestions will be appreciated. Best, John
> >
> > lf=ls(pattern=".lst")
> >
> >  for (x in listfiles) {
> >    dat=read.delim(x,header=F)
> 
> Presumably that would fail since 'listfiles' has not been defined. did you 
> mean 'lf'? If you did,then wouldn't the second line overwrite all the early 
> values of "dat" leaving only the last one?
> 
> Perhaps:
>   datfils <- list()
>   for (x in listfiles) {
>     datfils[x] <- read.delim(x,header=F)
> 
> 
> >
> >    for (i in 1: lf) {
> 
> And that would fail because 'lf' is a character vector, and it's not 
> meaningful to specify such a range. Try instead:
> 
>     for (i in names(datfils[x]) ) {
> #
> # which will then iterate over the names of the files which are now also the 
> names of the list elements
> 
> >    assign(i$add,as.numeric(dat[,3]))
> 
> But since 'i' is a length-1 character vector, the expression `i$add` will be 
> meaningless. The "$" operator does not do function calling in R unless you do 
> fancy things with environments, and you cannot "sub-assign" in that manner, 
> at least not with the assign() function.
> 
> Try instead:
> 
>     assign(i, as.numeric(datfils[x][,3]))
>     names(i)[length(i)] <- "add"
> 
> Or:
>     i <- transform(i, add=datfils[x][,3] )
> 
> 
> 
> >  #or i$add=as.numeric(dat[,3]
> >    names(i)[names(i)=="add"]=substr(x,1,5)
> 
> I'm not sure these would be doing the same thing. What was your goal here?
> 
> >
> >    print (i[1:3,])
> >  }
> > }
> 
> 
> David Winsemius, MD
> Alameda, CA, USA
> 
> 
> 

David Winsemius, MD
Alameda, CA, USA
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.