Re: [R] getOption() versus Sys.getenv

2017-08-25 Thread Henrik Bengtsson
There's also the alternative to use both, e.g. by having a system
environment variable set a corresponding R option, which then can be
overridden using options().  For instance, the R option mc.cores,
which is used by the parallel package, is set to the (integer) value
of system environment variable MC_CORES, iff set. Conceptually, when
the parallel package is loaded, the following takes place:

if (is.null(getOption("mc.cores")) {
  cores <- as.integer(Sys.getenv("MC_CORES"))
  if (!is.na(cores)) options(mc.cores = cores)
}

Example:

$ Rscript -e "library(parallel); getOption('mc.cores')"
NULL

$ MC_CORES=2 Rscript -e "library(parallel); getOption('mc.cores')"
[1] 2

$ MC_CORES=2 Rscript -e "options(mc.cores = 4); library(parallel);
getOption('mc.cores')"
[1] 4

/Henrik


On Fri, Aug 25, 2017 at 10:33 AM, Duncan Murdoch
 wrote:
> On 25/08/2017 1:19 PM, Sam Albers wrote:
>>
>> Hi there,
>>
>> I am trying to distinguish between getOption() and Sys.getenv(). My
>> understanding is that these are both used to set values for variables.
>> getOption is set something like this: option("var" = "A"). This can be
>> placed in an .Rprofile or at the top of script. They are called like this
>> getOption("var").
>>
>> Environmental variables are set in the .Renviron file like this: "var" =
>> "A" and called like this: Sys.getenv("var"). I've seen mention in the httr
>> package documentation that credentials for APIs should be stored in this
>> way.
>>
>> So my question is how does one decide which path is most appropriate? For
>> example I am working on a package that has to query a database in almost
>> every function call. I want to provide users an ability to skip having to
>> specify that path in every function call. So in this case should I
>> recommend users store the path as an option or as an environmental
>> variable? If I am storing credentials in an .Renviron file then maybe I
>> should store the path there as well?
>>
>> More generally the question is can anyone recommend some good
>> discussion/documentation on this topic?
>
>
>
> The environment is set outside of R; it's really part of the operating
> system that runs R.  So use Sys.getenv() if you want the user to be able to
> set something before starting R.  Use Sys.setenv() only if your R program is
> going to use system() (or related function) to run another process, and you
> want to communicate with it.
>
> The options live entirely within a given session.
>
> The .Renviron and .Rprofile files hide this difference, but they aren't the
> only ways to set these things, they're just convenient ways to set them at
> the start of a session.
>
> Duncan Murdoch
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] about multi-optimal points

2017-08-25 Thread lily li
Hi R users,

I have some sets of variables and put them into one dataframe, like in the
following. How to choose a specific set of pareto front, such as 10 from
the current datasets (which contains more than 100 sets)? And how to show
the 10 points on one figure with different colors? I can put all the points
on one figure though, and have the code below. I drew two ggplots to show
their correlations, but I want v1 and v3 to be as close as 1, v2 to be as
close as 0. Thanks very much.

DF

IDv1 v2 v3
10.8 0.10.7
20.85   0.30.6
30.9 0.21  0.7
40.95   0.22  0.8
50.9 0.30.7
60.8 0.40.76
70.9 0.30.77
...

fig1 = ggplot(data=DF, aes(x=v1,y=v2))+ geom_point()+ theme_bw()+
xlab('Variable 1')+ ylab('Variable 2')
print(fig1)

fig2 = ggplot(data=DF, aes(x=v1,y=v3)+ geom_point()+ theme_bw()+
xlab('Variable 1')+ ylab('Variable 3')
print(fig2)

[[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] splitting a dataframe in R based on multiple gene names in a specific column

2017-08-25 Thread Jeff Newmiller
If row numbers can be dispensed with, then tidyr makes this easy with 
the unnest function:


#
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(purrr)
library(tidyr)

df.sample.gene<-read.table(
 text="Chr Start   End Ref Alt Func.refGene  Gene.refGene
 284 chr2  16080996  16080996   C   T ncRNA_exonic  GACAT3
 448 chr2 113979920 113979920   C   T ncRNA_exonic  LINC01191,LOC100499194
 465 chr2 131279347 131279347   C   G ncRNA_exonic  LOC440910
 525 chr2 22358 22358   T   A   exonic  AP1S3
 626 chr3  99794575  99794575   G   A   exonic  COL8A1
 643 chr3 132601066 132601066   A   G   exonic  ACKR4
 655 chr3 132601999 132601999   A   G   exonic  BCDF5,CDFG6",
 header=TRUE,stringsAsFactors=FALSE)

df.sample.out <- (   df.sample.gene
 %>% mutate( Gene.refGene = strsplit( Gene.refGene
, ","
)
   )
 %>% unnest( Gene.refGene )
 )
df.sample.out
#>Chr Start   End Ref Alt Func.refGene Gene.refGene
#> 1 chr2  16080996  16080996   C   T ncRNA_exonic   GACAT3
#> 2 chr2 113979920 113979920   C   T ncRNA_exonicLINC01191
#> 3 chr2 113979920 113979920   C   T ncRNA_exonic LOC100499194
#> 4 chr2 131279347 131279347   C   G ncRNA_exonicLOC440910
#> 5 chr2 22358 22358   T   A   exonicAP1S3
#> 6 chr3  99794575  99794575   G   A   exonic   COL8A1
#> 7 chr3 132601066 132601066   A   G   exonicACKR4
#> 8 chr3 132601999 132601999   A   G   exonicBCDF5
#> 9 chr3 132601999 132601999   A   G   exonicCDFG6
#


On Wed, 23 Aug 2017, Jim Lemon wrote:


Hi Bogdan,
Messy, and very specific to your problem:

df.sample.gene<-read.table(
text="Chr Start   End Ref Alt Func.refGene  Gene.refGene
284 chr2  16080996  16080996   C   T ncRNA_exonic  GACAT3
448 chr2 113979920 113979920   C   T ncRNA_exonic  LINC01191,LOC100499194
465 chr2 131279347 131279347   C   G ncRNA_exonic  LOC440910
525 chr2 22358 22358   T   A   exonic  AP1S3
626 chr3  99794575  99794575   G   A   exonic  COL8A1
643 chr3 132601066 132601066   A   G   exonic  ACKR4
655 chr3 132601999 132601999   A   G   exonic  BCDF5,CDFG6",
header=TRUE,stringsAsFactors=FALSE)

multgenes<-grep(",",df.sample.gene$Gene.refGene)
rep_genes<-strsplit(df.sample.gene$Gene.refGene[multgenes],",")
ngenes<-unlist(lapply(rep_genes,length))
dup_row<-function(x) {
newrows<-x
lastcol<-dim(x)[2]
rep_genes<-unlist(strsplit(x[,lastcol],","))
for(i in 2:length(rep_genes)) newrows<-rbind(newrows,x)
newrows$Gene.refGene<-rep_genes
return(newrows)
}
for(multgene in multgenes)
df.sample.gene<-rbind(df.sample.gene,dup_row(df.sample.gene[multgene,]))
df.sample.gene<-df.sample.gene[-multgenes,]
df.sample.gene

I added a second line with multiple genes to make sure that it would
work with more than one line.

Jim


On Wed, Aug 23, 2017 at 9:57 AM, Bogdan Tanasa  wrote:

I would appreciate please a suggestion on how to do the following :

i'm working with a dataframe in R that contains in a specific column
multiple gene names, eg :


df.sample.gene[15:20,2:8]

 Chr Start   End Ref Alt Func.refGene
Gene.refGene284 chr2  16080996  16080996   C   T ncRNA_exonic
   GACAT3448 chr2 113979920 113979920   C   T ncRNA_exonic
LINC01191,LOC100499194465 chr2 131279347 131279347   C   G
ncRNA_exonic  LOC440910525 chr2 22358 22358   T
A   exonic  AP1S3626 chr3  99794575  99794575   G
 A   exonic COL8A1643 chr3 132601066 132601066   A
  G   exonic  ACKR4

How could I obtain a dataframe where each line that has multiple gene names
(in the field Gene.refGene) is replicated with only one gene name ? i.e.

for the second row :

  448 chr2 113979920 113979920   C   T ncRNA_exonic LINC01191,LOC100499194

we shall get in the final output (that contains all the rows) :

  448 chr2 113979920 113979920   C   T ncRNA_exonic LINC01191
  448 chr2 113979920 113979920   C   T ncRNA_exonic LOC100499194

thanks a lot !

-- bogdan

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

Re: [R] getOption() versus Sys.getenv

2017-08-25 Thread Duncan Murdoch

On 25/08/2017 1:19 PM, Sam Albers wrote:

Hi there,

I am trying to distinguish between getOption() and Sys.getenv(). My
understanding is that these are both used to set values for variables.
getOption is set something like this: option("var" = "A"). This can be
placed in an .Rprofile or at the top of script. They are called like this
getOption("var").

Environmental variables are set in the .Renviron file like this: "var" =
"A" and called like this: Sys.getenv("var"). I've seen mention in the httr
package documentation that credentials for APIs should be stored in this
way.

So my question is how does one decide which path is most appropriate? For
example I am working on a package that has to query a database in almost
every function call. I want to provide users an ability to skip having to
specify that path in every function call. So in this case should I
recommend users store the path as an option or as an environmental
variable? If I am storing credentials in an .Renviron file then maybe I
should store the path there as well?

More generally the question is can anyone recommend some good
discussion/documentation on this topic?



The environment is set outside of R; it's really part of the operating 
system that runs R.  So use Sys.getenv() if you want the user to be able 
to set something before starting R.  Use Sys.setenv() only if your R 
program is going to use system() (or related function) to run another 
process, and you want to communicate with it.


The options live entirely within a given session.

The .Renviron and .Rprofile files hide this difference, but they aren't 
the only ways to set these things, they're just convenient ways to set 
them at the start of a session.


Duncan Murdoch

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


[R] getOption() versus Sys.getenv

2017-08-25 Thread Sam Albers
Hi there,

I am trying to distinguish between getOption() and Sys.getenv(). My
understanding is that these are both used to set values for variables.
getOption is set something like this: option("var" = "A"). This can be
placed in an .Rprofile or at the top of script. They are called like this
getOption("var").

Environmental variables are set in the .Renviron file like this: "var" =
"A" and called like this: Sys.getenv("var"). I've seen mention in the httr
package documentation that credentials for APIs should be stored in this
way.

So my question is how does one decide which path is most appropriate? For
example I am working on a package that has to query a database in almost
every function call. I want to provide users an ability to skip having to
specify that path in every function call. So in this case should I
recommend users store the path as an option or as an environmental
variable? If I am storing credentials in an .Renviron file then maybe I
should store the path there as well?

More generally the question is can anyone recommend some good
discussion/documentation on this topic?

Thanks in advance,

Sam

[[alternative HTML version deleted]]

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


Re: [R] Problem in optimization of Gaussian Mixture model

2017-08-25 Thread Jeff Newmiller
You are doing yourself no favors by posting HTML format email... the code 
shown below has extra characters in it that you probably did not put 
there. This is a plain text mailing list, so you need to send plain text 
email. Read the Posting Guide mentioned in the footer of this and every 
R-help posting.


On top of that, your code is not presented as a stand-alone reproducible 
example. Read [1], [2], and in particular [3]. Failing to make it 
reproducible means most readers will just ignore it and move on.


I cannot figure out why you have "seg" as an optimized parameter... in 
particular, you are trying to index one-dimensional vectors with two 
indexes, one of which is the floating point variable "seg".


Anyway, despite the above, here is my take on your problem.


myfunc <- function( x ) {
   meanval <- c( 506.8644, 672.8448, 829.902 )
   sigmaval <- c( 61.02859, 9.149168, 74.84682 )
   coeffval <- c( 0.1241933, 0.6329082, 0.2428986 )
   sapply( x
 , function( xi )
 sum( coeffval * dnorm( xi
  , meanval
  , sigmaval
  )
)
 )
}

plot( 400:1000, myfunc( 400:1000 ) )

#' ![](http://i.imgur.com/65fhqrL.png)


# fooled by local maximum
val1 <- optim( par = c( x = 800 )
 , fn = myfunc
 , method = "BFGS"
 , control = list( fnscale= -1
 , parscale = 1/0.025
 )
 )
val1
#> $par
#>x
#> 829.5249
#>
#> $value
#> [1] 0.001294662
#>
#> $counts
#> function gradient
#>54
#>
#> $convergence
#> [1] 0
#>
#> $message
#> NULL

val2 <- optim( par = c( x = 1000 )
 , fn = myfunc
 , method = "SANN"
 , control = list( fnscale= -1
 , parscale = 1/0.025
 )
 )
val2
#> $par
#>x
#> 672.8166
#>
#> $value
#> [1] 0.02776057
#>
#> $counts
#> function gradient
#>1   NA
#>
#> $convergence
#> [1] 0
#>
#> $message
#> NULL


[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)


On Thu, 24 Aug 2017, niharika singhal wrote:


Hello,


I am facing a problem with optimization in R from 2-3 weeks.



I have some Gaussian mixtures parameters and I want to find the maximum in
that



*Parameters are in the form *

mean1mean2mean3   sigma1   sigma2   sigma3   c1c2c3

506.8644 672.8448 829.902 61.02859 9.149168 74.84682 0.1241933
0.6329082 0.2428986





I have used optima and optimx to find the maxima, but it gives me value
near by the highest mean as an output, for example 830 in the above
parameters. The code for my optim function is

val1=*optim*(par=c(X=1000, *seg=1*),fn=xnorm,  opt=c(NA,seg=1),
method="BFGS",lower=-Inf,upper=+Inf, control=list(fnscale=-1))

*I am running the optim function in a loop and for different initial value
and taking the val1$par[1] as the best value.*

*I am taking this parameter since I want to run it on n number of segments
latter*

and xnorm is simply calculating the dnorm

*xnorm*=function(param, opt = rep(NA, 2)){

 if (any(!sapply(opt, is.na))) {

   i = !sapply(opt, is.na)

   # Fix non-NA values

   param[i] <- opt[i]

 }

 xval= param[1]

   seg <- param[2]

 sum_prob=0

 val=0

l=3

meanval=c(506.8644, 672.8448, 829.902)

sigmaval=c(61.02859, 9.149168, 74.84682)

coeffval(0.1241933, 0.6329082, 0.2428986)

 for(n in 1 :l)

 {

   mu=meanval[seg,n]

   sg=sigmaval[seg,n]

   cval=coeffval[seg,n]

   val=cval*(dnorm(xval,mu,sg))

   #print(paste0("The dnorm value for x is.: ", val))

   sum_prob=sum_prob+val

 }

 sum_prob

}


The output is not correct. Since I check my data using*
UnivarMixingDistribution* from distr package and according to this the max
should lie somewhere between 600-800

Code I used to check

mc0=c( 0.6329082,0.6329082,0.2428986)

rv
<-UnivarMixingDistribution(Norm(506.8644,61.02859),Norm(672.8448,9.149168),Norm(
829.902,74.84682), mixCoeff=mc0/sum(mc0))

plot(rv, to.draw.arg="d")



Can someone please help how I can solve this problem?


Thanks & Regards

Niharika Singhal

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: 

Re: [R] Pull data from Tally 9.1 to R studio

2017-08-25 Thread jagan krishnan via R-help
Hi,
Really appreciate your guidance...I tried google searches before posting here, 
but may be I am wrong...that's why I thought of getting this forum's guidance...
Going through the links shared here..I think I can take up my first task in R 
with some confidence...
Really this is not a sarcastic mail without comic scan font and smileys..
Could not believe you guys will be this much tough in your words when somebody 
is just starting something in R...
With Regards,Jagannathan Krishnan

Sent from Yahoo Mail on Android 
 
  On Thu, Aug 24, 2017 at 10:36 PM, Marc Schwartz wrote:  
 Hi,
Inline below.


On Aug 24, 2017, at 5:22 AM, John Kane via R-help  wrote:

IIt might help to read the material at one or both of these links 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example




In this case, had Jagan spent about 30 seconds Googling for the application 
developer's site, he would have found that Tally software has a support page 
here:
  https://tallysolutions.com/support/
and that using the online help that they provide, searching for "export data":
  
https://help.tallysolutions.com/tallyweb/modules/pss/crm/kb/search/CKBTallyHelpSearchWIC.php#searchPage=1=export%20data
he would find the following article in the initial set of returned hits that 
appears to describe the export file formats that Tally supports:
  
https://help.tallysolutions.com/article/te9rel60/Data_Management/Export_of_Data_Intro.htm
One of which is CSV files, which can then be imported into R, using ?read.csv.
He might have also been able to quickly obtain similar guidance from his own IT 
support folks who presumably support the Tally ERP installation or from Tally 
directly. The initial step is less about R specifically and more about how to 
get data out of Tally's database in an industry standard format.
If Tally supports any kind of direct API or other interface (e.g. ODBC or 
similar), Jagan would need to pursue that conversation with his IT folks and/or 
Tally and to see if there would be a way for R to interface with that path. 
Also, importantly, whether or not under any restricted IT access policies, that 
would even be allowed. Many companies restrict such access for security reasons.
Another Google search would suggest that Tally uses a proprietary database 
engine and language, but that some interfaces (e.g. ODBC) may exist, if enabled 
locally.
  
http://www.tallysolutions.com/website/html/tallydeveloper/architecture-series-a.php

On the R side, there is the R Data Import/Export Manual here:
  https://cran.r-project.org/manuals.html
which provides additional general insight into R's import/export capabilities.

The R Posting Guide, as has been mentioned, is a good resource, as is the 
Getting Help With R page, linked on the main R Project page:
  https://www.r-project.org/help.html

Regards,
Marc Schwartz





On Thursday, August 24, 2017, 6:19:25 AM EDT, John Kane  
wrote:




On Thursday, August 24, 2017, 1:50:13 AM EDT, David Winsemius 
 wrote:



On Aug 22, 2017, at 11:31 PM, jagan krishnan via R-help  
wrote:

Hi all,
This is Jagan.i have been provided a task of analyzing sales data of a company 
in R programming...Just wanted to know,how can I pull Tally 9.1 software data 
into R programming dataframe.
Waiting eagerly for your inputs.
With Regards,Jagannathan Krishnan
Sent from Yahoo Mail on Android 

  On Tue, Aug 22, 2017 at 10:47 AM, jagan krishnan 
wrote:  Hi all,
This is Jagan.i have been provided a task of analyzing sales data of a company 
in R programming...Just wanted to know,how can I pull Tally 9.1 software data 
into R programming dataframe.
Waiting eagerly for your inputs.


Are we supposed to know what "Tally 9.1 software data" might look like?
Of course. Just download Tally 9.1, stick in some data  and you're away.
A quick google shows it is accounting software.



With Regards,Jagannathan Krishnan

Sent from Yahoo Mail on Android  

    [[alternative HTML version deleted]]


A Posting Guide was prepared for you. I suggest that you should read it.



__
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

'Any technology distinguishable from magic is insufficiently advanced.'  
-Gehm's Corollary to Clarke's Third Law


  

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

Re: [R] strange nlme augpred behaviour

2017-08-25 Thread PIKAL Petr
Hi David

No as it is rather big and I just thought somebody who has better insight into 
how augPred works could point me why such behaviour could happen.

I **think** that augPred somehow looks into original groupedData object and 
some column in full mar.g triggers error. It seems to me, that when the first 
column is character augPred results in error.

See below.

This works
> mar.g<-groupedData(rutilizace~doba|int, data=mar)
> mar.g<-mar.g[,c(2, 3,4, 6,7, 21)]
> plot(augPred(fit1, level=0:1))

and this not
> mar.g<-groupedData(rutilizace~doba|int, data=mar)
> mar.g<-mar.g[,c(1,2, 3,4, 6,7, 21)]
> plot(augPred(fit1, level=0:1))
Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(6L, 6L, 6L, 6L, 8L,  :
  replacement has 60 rows, data has 12

> dim(mar.g)
[1] 60  7

> str(mar.g)
Classes ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and 'data.frame':  
60 obs. of  7 variables:
 $ vzor  : chr  "RP140" "RP141" "RP142" "RP143" ...
 $ tepl  : num  940 940 940 940 970 970 970 970 1000 1000 ...
 $ doba  : num  15 60 120 240 15 60 120 240 15 60 ...
 $ rutilizace: num  91.2 96.5 96.6 99.6 96.3 98 99.6 99.9 99.8 99.8 ...
 $ k2oteor   : num  0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 ...
 $ k2omer: num  0.155 0.198 0.207 0.212 0.238 0.22 0.203 0.204 0.22 0.222 
...
 $ int   : Ord.factor w/ 12 levels "0.4/940"<"0.33/940"<..: 6 6 6 6 8 8 8 8 
10 10 ...
 - attr(*, "formula")=Class 'formula'  language rutilizace ~ doba | int
  .. ..- attr(*, ".Environment")=
 - attr(*, "FUN")=function (x)
 - attr(*, "order.groups")= logi TRUE

After changing column 1 to factor it works.
mar.g[,1]<-factor(mar.g[,1])
plot(augPred(fit1, level=0:1))

As I said, I can live with it, but if anybody wants to dig further, I could try 
to prepare a working example.

Cheers
Petr

> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net]
> Sent: Thursday, August 24, 2017 6:20 PM
> To: PIKAL Petr 
> Cc: Bert Gunter ; r-help mailing list  project.org>
> Subject: Re: [R] strange nlme augpred behaviour
>
>
> > On Aug 23, 2017, at 8:08 AM, PIKAL Petr  wrote:
> >
> > Hi
> >
> > Well, yes I tried it about two weeks ago but my post did not get through as 
> > it
> still awaits moderator approval.
>
> It got through just fine. It appeared on Aug 15. It just didn't get any 
> replies.
>
> As I read your original question in this thread, it was not clear to me that 
> you
> had provided the data-object named "mar".
>
> -- David.
>
>
> > I could check which column is offending but actually it is only minor 
> > nuisance,
> I can live with selection of columns before fitting a model. What seems to me
> strange is that both full dataset and only selected colums gave me identical 
> fit
> results but only one works within augPred.
> >
> > Cheers
> > Petr
> >
> >> -Original Message-
> >> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
> >> Sent: Wednesday, August 23, 2017 4:50 PM
> >> To: PIKAL Petr 
> >> Cc: r-help mailing list 
> >> Subject: Re: [R] strange nlme augpred behaviour
> >>
> >> Better posted on r-sig-mixed-models , no?
> >>
> >> Cheers,
> >> Bert
> >>
> >>
> >> Bert Gunter
> >>
> >> "The trouble with having an open mind is that people keep coming
> >> along and sticking things into it."
> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >>
> >>
> >> On Wed, Aug 23, 2017 at 5:17 AM, PIKAL Petr 
> wrote:
> >>> Dear all
> >>>
> >>> I encountered strange behaviour of augPred with virtually the same
> >>> data
> >>>
> >>> First I made groupedData object.
>  mar.g<-groupedData(rutilizace~doba|int, data=mar)
> >>>
> >>> When I perform nlme on complete dataset I get an error with augPred
>  fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
> >>> Warning message:
> >>> c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x),
> >>> exp(-exp(lrc) * x)), data
> >> = xy, : singular gradient", "1 error caught in start = list(lrc = 
> >> lrc), algorithm
> =
> >> \"plinear\"): singular gradient")
>  fit1<-nlme(fit)
>  plot(augPred(fit1, level=0:1))
> >>> Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(6L, 6L, 6L, 6L, 8L,  :
> >>>  replacement has 60 rows, data has 12
> >>>
> >>> However when I make subset of my data to keep only affected collumns.
> 
>  mar.g<-mar.g[,c(3,4, 21)]
> >>>
>  fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0,  lrc), data=mar.g)
> >>> Warning message:
> >>> c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x),
> >>> exp(-exp(lrc) * x)), data
> >> = xy, : singular gradient", "1 error caught in start = list(lrc = 
> >> lrc), algorithm
> =
> >> \"plinear\"): singular gradient")
>  fit2<-nlme(fit)
>  plot(augPred(fit2, level=0:1))
> 
> >>> augPred works as a charm.
> >>>
> >>> When I compare fit1 and fit2 they are equal
>