[R] Help to simulate data to model pump failure use case
Hi, I need help to simulate data to model pump's failure. Below is thought process to simulate the data: - For each Pump readings are captured via sensors each minute for period of 3 months. There are 10 pumps in total. - The failure rate or occurrences of event in 3 months for each Pump is defined. i.e Pump1 would fail 3 times in 3 months, Pump2 would fail 2 times in 3 months, etc. - The failure modes are defined based on the combination of below variables: Failure modes:: -- Bearing damage --> +ve_corr('temprature' + vibration) -- Cavitation --> -ve_corr( +ve_corr(discharge_pressure + flow) + temprature) -- worn shafts --> +ve_corr(discharge_pressure + flow) How should I be generate distributions for the variables listed in the "failure modes" maintaining the correlation stated above. Regards, Sunny [[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] Generate correlated expontial distribution -- lamda please guide
Hi, I need to generate correlated (positive as well as negative) bivariate exponential distribution with rate of 1/5 or any rate I need some guidance here. Please help. Regards, Sunny __ 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] (no subject)
> On Jun 15, 2017, at 3:05 PM, oussama bouldjedri> wrote: > > Hi every one I am working on shiny app using bnlearn for Bayesian networks > and using r studio I get a fatal error and when I use R GUI I get this error > > ** caught segfault *** > > address 0xfffc0fcd6248, cause 'memory not mapped' Traceback: 1: > .Call("mappred", node = node, fitted = fitted, data = data, n = > as.integer(n), from = from, prob = prob, debug = debug) 2: > map.prediction(node = node, fitted = object, data = data, n = > extra.args$n, from = extra.args$from, prob = prob, debug = debug) 3: > predict.bn.fit(values10$fitted, input$targetvariables, combn2, prob = > TRUE, method = "bayes-lw") 4: predict(values10$fitted, > input$targetvariables, combn2, prob = TRUE, method = "bayes-lw") 5: > t(attr(predict(values10$fitted, input$targetvariables, combn2, prob = > TRUE, method = "bayes-lw"), "prob")) 6: observeEventHandler(...) 7: > ..stacktraceon..(observeEventHandler(...)) 8: handlerFunc() 9: > ..stacktraceon..(expr) 10: contextFunc() 11: env$runWith(self, func) > 12: withReactiveDomain(.domain, { env <- .getReactiveEnvironment() > .graphEnterContext(id) on.exit(.graphExitContext(id), add = TRUE) > env$runWith(self, func)}). .. > > > I tried to get the latest version of R and rstudio but it still happens > > is it my computer memory that is small ?? or something else As I already told you on SO, you should send a reproducible example to the maintainer. > > thanks in advance > > > > best regards > > [[alternative HTML version deleted]] I did not suggest cross-posting to Rhelp, but if you are going to do so in the future, could you please read the posting guide and set up your email client to post in plain text? (I doubt this error is due to RStudio or R. Shiny ... perhaps. "bnlearn" ... most probably.) > > __ > 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.
[R] (no subject)
Hi every one I am working on shiny app using bnlearn for Bayesian networks and using r studio I get a fatal error and when I use R GUI I get this error ** caught segfault *** address 0xfffc0fcd6248, cause 'memory not mapped' Traceback: 1: .Call("mappred", node = node, fitted = fitted, data = data, n = as.integer(n), from = from, prob = prob, debug = debug) 2: map.prediction(node = node, fitted = object, data = data, n = extra.args$n, from = extra.args$from, prob = prob, debug = debug) 3: predict.bn.fit(values10$fitted, input$targetvariables, combn2, prob = TRUE, method = "bayes-lw") 4: predict(values10$fitted, input$targetvariables, combn2, prob = TRUE, method = "bayes-lw") 5: t(attr(predict(values10$fitted, input$targetvariables, combn2, prob = TRUE, method = "bayes-lw"), "prob")) 6: observeEventHandler(...) 7: ..stacktraceon..(observeEventHandler(...)) 8: handlerFunc() 9: ..stacktraceon..(expr) 10: contextFunc() 11: env$runWith(self, func) 12: withReactiveDomain(.domain, { env <- .getReactiveEnvironment() .graphEnterContext(id) on.exit(.graphExitContext(id), add = TRUE) env$runWith(self, func)}). .. I tried to get the latest version of R and rstudio but it still happens is it my computer memory that is small ?? or something else thanks in advance best regards [[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] about fitting a regression line
Did you perhaps accidentally include your response as a predictor? > On Jun 15, 2017, at 12:48 PM, lily liwrote: > > Thanks for your replies. I tried the regression, but then got a NA value > for the slope. And here is the error message: > Coefficients: (1 not defined because of singularities) > > > On Thu, Jun 15, 2017 at 12:20 AM, PIKAL Petr wrote: > >> Hi >> >> But X can be some function like - sin, cos, log, exp... >> >> Cheers >> Petr >> >>> -Original Message- >>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of lily li >>> Sent: Thursday, June 15, 2017 1:28 AM >>> To: MacQueen, Don >>> Cc: R mailing list >>> Subject: Re: [R] about fitting a regression line >>> >>> Thanks. I thought lm() function is for linear model, such as the >> correlation >>> below: >>> Y= aX + b >>> >>> On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don >>> wrote: >>> Start with the lm() function; i.e., see ?lm -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/14/17, 3:40 PM, "R-help on behalf of lily li" < r-help-boun...@r-project.org on behalf of chocol...@gmail.com> wrote: Hi R users, I have some data points (Xi, Yi), and they may follow such a pattern Yi = cCOS(Xi) + d, how to find the c and d in R? which function to use? Also, how to get the R2 and p value for this correlation? Thanks for any kind of help. [[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. >> >> >> 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
Re: [R] "reverse" quantile function
David, thanks for the response. In your response the quantile function (if I see correctly) runs on the columns versus I need to run it on the rows, which is an easy fix, but that is not exactly what I had in mind... essentially we can remove t() from my original code to make "res" look like this: res<-apply(z, 1, quantile, probs=c(0.3)) but after all maybe I did not explain myself clear enough so let me try again: the known variables to us in what I am trying to do are the data frame "z' : t<-seq(0,24,1) a<-10*exp(-0.05*t) b<-10*exp(-0.07*t) c<-10*exp(-0.1*t) d<-10*exp(-0.03*t) z<-data.frame(a,b,c,d) and the vector "res": res<-c(10.00, 9.296382, 8.642955, 8.036076 ,7.472374, 6.948723, 6.462233, 6.010223 ,5.590211 ,5.199896 ,4.837147, 4.499989 ,4.186589, 3.895250 ,3.624397, 3.372570, 3.138415, 2.920675 , 2.718185 ,2.529864 ,2.354708, 2.191786, 2.040233, 1.899247, 1.768084) and I need to find the probability (probs) , the unknown value, which would result in creating "res", ie: the probs=c(0.3), from: res<-apply(z, 1, quantile, probs=c(0.3))... a more simplified example assuming : k<-c(1:100) f<-30 ecdf(k)(f) would give us the value of 0.3... so same idea as this, but instead of "k" we have data frame "z", and instead of "f" we have "res", and need to find the value of 0.3... Does that make sense? much appreciate the help... Andras Farkas, On Thursday, June 15, 2017 6:46 PM, David Winsemiuswrote: > On Jun 15, 2017, at 12:37 PM, Andras Farkas via R-help > wrote: > > Dear All, > > we have: > > t<-seq(0,24,1) > a<-10*exp(-0.05*t) > b<-10*exp(-0.07*t) > c<-10*exp(-0.1*t) > d<-10*exp(-0.03*t) > z<-data.frame(a,b,c,d) > > res<-t(apply(z, 1, quantile, probs=c(0.3))) > > > > my goal is to do a 'reverse" of the function here that produces "res" on a > data frame, ie: to get the answer 0.3 back for the percentile location when I > have "res" available to me... For a single vector this would be done using > ecdf something like this: > > x <- rnorm(100) > #then I know this value: > quantile(x,0.33) > #so do this step > ecdf(x)(quantile(x,0.33)) > #to get 0.33 back... > > any suggestions on how I could to that for a data frame? Can't you just used ecdf and quantile ecdf? # See ?ecdf page for both functions > lapply( lapply(z, ecdf), quantile, 0.33) $a 33% 4.475758 $b 33% 3.245151 $c 33% 2.003595 $d 33% 6.173204 -- 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] "reverse" quantile function
> On Jun 15, 2017, at 12:37 PM, Andras Farkas via R-help> wrote: > > Dear All, > > we have: > > t<-seq(0,24,1) > a<-10*exp(-0.05*t) > b<-10*exp(-0.07*t) > c<-10*exp(-0.1*t) > d<-10*exp(-0.03*t) > z<-data.frame(a,b,c,d) > > res<-t(apply(z, 1, quantile, probs=c(0.3))) > > > > my goal is to do a 'reverse" of the function here that produces "res" on a > data frame, ie: to get the answer 0.3 back for the percentile location when I > have "res" available to me... For a single vector this would be done using > ecdf something like this: > > x <- rnorm(100) > #then I know this value: > quantile(x,0.33) > #so do this step > ecdf(x)(quantile(x,0.33)) > #to get 0.33 back... > > any suggestions on how I could to that for a data frame? Can't you just used ecdf and quantile ecdf? # See ?ecdf page for both functions > lapply( lapply(z, ecdf), quantile, 0.33) $a 33% 4.475758 $b 33% 3.245151 $c 33% 2.003595 $d 33% 6.173204 -- 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] Changing font of a certrain column in an excel file
Hi Persian, While this is not a forum for Excel: Right click on the alphabetic label at the top of the column Select "Format Cells" Select the "Font" tab Pick your font I will leave it to others to deliver sermons about the moral dangers of using Excel. Jim On Thu, Jun 15, 2017 at 10:33 PM, Persian Iraniwrote: > Hi all! > I need an example/reference to show me how to change the font of a > certain column in an existing .xlsx document. Thank you 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-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] glmmTMB
> On Jun 15, 2017, at 9:53 AM, Alice Domalikwrote: > > Hi List, > > I'm having some trouble finding documentation for the package glmmTMB. I had no trouble finding documentation with the search strategy copied from your sentence: "documentation for the package glmmTMB." Can you describe what search strategy you used and how the documents that did show up failed to meet your needs? There appears to be a truncated Poisson "hurdle model" in the examples for the main regression function and discussion of fitting issues at the end of the vignette: https://cran.r-project.org/web/packages/glmmTMB/vignettes/glmmTMB.pdf It's always possible that I misunderstood the issues here, but that does throw the responsibility back on you to do a better job of explaining your difficulties. Also, this is not really the right forum to post questions about mixed models. There's a SIG for that. > I would like to fit a zero-truncated poisson, what do I need to specify in > "family = " for this distribution? > > Thanks! Alice > > [[alternative HTML version deleted]] Please read the Posting Guide. > > __ > 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] about fitting a regression line
You really have to show what you did to get the result you showed. E.g., something like the following: > d <- data.frame(x=1:7, y=c(7,4,2,3,6,8,7)) > fit <- lm( y~cos(x), data=d) > coef(fit) (Intercept) cos(x) 5.0791903.022805 > sfit <- summary(fit) > sfit$r.squared [1] 0.9915548 > with(sfit, pf(fstatistic[1], fstatistic[2], fstatistic[3], lower=FALSE)) value 2.232099e-06 Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Jun 15, 2017 at 12:48 PM, lily liwrote: > Thanks for your replies. I tried the regression, but then got a NA value > for the slope. And here is the error message: > Coefficients: (1 not defined because of singularities) > > > On Thu, Jun 15, 2017 at 12:20 AM, PIKAL Petr > wrote: > > > Hi > > > > But X can be some function like - sin, cos, log, exp... > > > > Cheers > > Petr > > > > > -Original Message- > > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of lily > li > > > Sent: Thursday, June 15, 2017 1:28 AM > > > To: MacQueen, Don > > > Cc: R mailing list > > > Subject: Re: [R] about fitting a regression line > > > > > > Thanks. I thought lm() function is for linear model, such as the > > correlation > > > below: > > > Y= aX + b > > > > > > On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don > > > wrote: > > > > > > > Start with the lm() function; i.e., see > > > > > > > > ?lm > > > > > > > > -Don > > > > > > > > -- > > > > Don MacQueen > > > > > > > > Lawrence Livermore National Laboratory > > > > 7000 East Ave., L-627 > > > > Livermore, CA 94550 > > > > 925-423-1062 > > > > > > > > > > > > On 6/14/17, 3:40 PM, "R-help on behalf of lily li" < > > > > r-help-boun...@r-project.org on behalf of chocol...@gmail.com> > wrote: > > > > > > > > Hi R users, > > > > > > > > I have some data points (Xi, Yi), and they may follow such a > > > > pattern Yi = > > > > cCOS(Xi) + d, how to find the c and d in R? which function to > use? > > > > Also, > > > > how to get the R2 and p value for this correlation? Thanks for > any > > > > kind of > > > > help. > > > > > > > > [[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. > > > > > > 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
Re: [R] about fitting a regression line
Rather than just posting your error message, it helps immensely to post the code that produced the error--indeed with some small sample data that reproduces the problem. x <- rnorm(40) y <- 0.6 * x + rnorm(40, sd = 0.3) plot(y ~ x) model <- lm(y ~ cos(x)) summary(model) plot(y ~ cos(x)) abline(model, col = "red") ## obviously I am not claiming that this is a meaningful or sensible model ## It's just for illustrative purposes --Chris Ryan On Thu, Jun 15, 2017 at 3:48 PM, lily liwrote: > Thanks for your replies. I tried the regression, but then got a NA value > for the slope. And here is the error message: > Coefficients: (1 not defined because of singularities) > > > On Thu, Jun 15, 2017 at 12:20 AM, PIKAL Petr > wrote: > > > Hi > > > > But X can be some function like - sin, cos, log, exp... > > > > Cheers > > Petr > > > > > -Original Message- > > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of lily > li > > > Sent: Thursday, June 15, 2017 1:28 AM > > > To: MacQueen, Don > > > Cc: R mailing list > > > Subject: Re: [R] about fitting a regression line > > > > > > Thanks. I thought lm() function is for linear model, such as the > > correlation > > > below: > > > Y= aX + b > > > > > > On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don > > > wrote: > > > > > > > Start with the lm() function; i.e., see > > > > > > > > ?lm > > > > > > > > -Don > > > > > > > > -- > > > > Don MacQueen > > > > > > > > Lawrence Livermore National Laboratory > > > > 7000 East Ave., L-627 > > > > Livermore, CA 94550 > > > > 925-423-1062 > > > > > > > > > > > > On 6/14/17, 3:40 PM, "R-help on behalf of lily li" < > > > > r-help-boun...@r-project.org on behalf of chocol...@gmail.com> > wrote: > > > > > > > > Hi R users, > > > > > > > > I have some data points (Xi, Yi), and they may follow such a > > > > pattern Yi = > > > > cCOS(Xi) + d, how to find the c and d in R? which function to > use? > > > > Also, > > > > how to get the R2 and p value for this correlation? Thanks for > any > > > > kind of > > > > help. > > > > > > > > [[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. > > > > > > 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
Re: [R] about fitting a regression line
Thanks for your replies. I tried the regression, but then got a NA value for the slope. And here is the error message: Coefficients: (1 not defined because of singularities) On Thu, Jun 15, 2017 at 12:20 AM, PIKAL Petrwrote: > Hi > > But X can be some function like - sin, cos, log, exp... > > Cheers > Petr > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of lily li > > Sent: Thursday, June 15, 2017 1:28 AM > > To: MacQueen, Don > > Cc: R mailing list > > Subject: Re: [R] about fitting a regression line > > > > Thanks. I thought lm() function is for linear model, such as the > correlation > > below: > > Y= aX + b > > > > On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don > > wrote: > > > > > Start with the lm() function; i.e., see > > > > > > ?lm > > > > > > -Don > > > > > > -- > > > Don MacQueen > > > > > > Lawrence Livermore National Laboratory > > > 7000 East Ave., L-627 > > > Livermore, CA 94550 > > > 925-423-1062 > > > > > > > > > On 6/14/17, 3:40 PM, "R-help on behalf of lily li" < > > > r-help-boun...@r-project.org on behalf of chocol...@gmail.com> wrote: > > > > > > Hi R users, > > > > > > I have some data points (Xi, Yi), and they may follow such a > > > pattern Yi = > > > cCOS(Xi) + d, how to find the c and d in R? which function to use? > > > Also, > > > how to get the R2 and p value for this correlation? Thanks for any > > > kind of > > > help. > > > > > > [[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. > > > 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
[R] "reverse" quantile function
Dear All, we have: t<-seq(0,24,1) a<-10*exp(-0.05*t) b<-10*exp(-0.07*t) c<-10*exp(-0.1*t) d<-10*exp(-0.03*t) z<-data.frame(a,b,c,d) res<-t(apply(z, 1, quantile, probs=c(0.3))) my goal is to do a 'reverse" of the function here that produces "res" on a data frame, ie: to get the answer 0.3 back for the percentile location when I have "res" available to me... For a single vector this would be done using ecdf something like this: x <- rnorm(100) #then I know this value: quantile(x,0.33) #so do this step ecdf(x)(quantile(x,0.33)) #to get 0.33 back... any suggestions on how I could to that for a data frame? thank you,Andras Farkas __ 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] Estimating Unbiased Standard Deviation with Autocorrelation
Hello, I have a vector of values with significant autocorrelation, and I want to calculate an unbiased standard deviation that adjusts for the autocorrelation. The formula linked below purports to provide what I want: https://en.wikipedia.org/wiki/Unbiased_estimation_of_standard_deviation#Effect_of_autocorrelation_.28serial_correlation.29 However, rather than just implementing this equation in my own function, I figured there is likely already an R function that does this, and perhaps does a better job of handling the subtleties of the adjustment when the ACF itself is estimated from the same data that is used to estimate the sample standard deviation (if there are any). If such a function exists, can anyone point me to it? Thanks in advance, Robert __ 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] glmmTMB
Hi List, I'm having some trouble finding documentation for the package glmmTMB. I would like to fit a zero-truncated poisson, what do I need to specify in "family = " for this distribution? Thanks! Alice [[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] is.null(mylist[1]) and is.null(mylist$a) returns different values
I think look at the manual Is.null(mylist[[1]]) Will work -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ce Sent: 15 June 2017 16:33 To: r-help@r-project.org Subject: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values Hi I have a list : mylist <- list( a = NULL, b = 1, c = 2 ) > mylist[1] $a NULL > is.null(mylist[1]) [1] FALSE > is.null(mylist$a) [1] TRUE why? I need to use mylist[1] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values
Hello, You have to be aware that mylist[1] and mylist[[1]] are different things. class(mylist[1]) [1] "list" class(mylist[[1]]) [1] "NULL" Apparently you want/need the latter: is.null(mylist[[1]]) [1] TRUE Hope this helps, Rui Barradas Em 15-06-2017 16:33, ce escreveu: Hi I have a list : mylist <- list( a = NULL, b = 1, c = 2 ) mylist[1] $a NULL is.null(mylist[1]) [1] FALSE is.null(mylist$a) [1] TRUE why? I need to use mylist[1] __ 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] understanding I() in lmer formula
The suggestion to post on R-sig-ME was a good one. The problem turned out to be a bug in lmer parsing, which is now fixed. S Ellison writes: > > Is there a difference between I(x*y) and I(y*x) ? > > I have a call to lmer that results in this complaint: > > Error in is.alpha2.subordinate * ~z.min.co.res : > > A reproducible example would help ... __ 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] Changing font of a certrain column in an excel file
Hi all! I need an example/reference to show me how to change the font of a certain column in an existing .xlsx document. Thank you 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.
Re: [R] draw stripes in a circle in R
> On Jun 15, 2017, at 1:35 AM, jean-philippe >wrote: > > hi david > > Thank you very much for the hack of draw.circle that you proposed me. > I don't understand some part of the code, why do you pass radius as a vector > in the function (if I understand well the purpose of the for loop) ? Also > what is ymult? > > If I set the radius to the value 0.85 as I wanted (so as a scalar), I don't > see any difference in the result when I call this function draw.circle2, the > stripes are not drawn inside the circle. I don't know if it is normal. It certainly wasn't intended. I expected the radius argument to get used repeatedly just as it is in the original function, but remain a scalar. Did you just copy-paste my code or do your own alterations? And did you add the arguments to the new call? When I use: Your set-up surrounds this: draw.circle2(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=5, density=2, angle=45) I get the attached pdf: MWE.pdf Description: Adobe PDF document I don't think you are interpreting the code in the same manner as I do. When hacking someone else code it's probably a good idea to give all the arguments names. That way you uncover errors in the argument passing better because name collision get flagged and the error messages become more meaningful. Feel free to post annotations using the octothorpe method in between lines to explain how you understand the code. -- David. > > > Thanks, best > > > Jean-Philippe > > On 14/06/2017 19:29, David Winsemius wrote: >>> On Jun 14, 2017, at 10:18 AM, David Winsemius >>> wrote: >>> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller wrote: I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe wrote: > dear R users, > > I would like to fill a circle with yellow stripes instead of a uniform > yellow color. To draw the circle I used the following command after > having loaded the (very nice !) plotrix library : >> I finally understood the question and it needs a hack to the draw.circle >> function in plotrix since the angle and density arguments don't get passed >> in: >> >> First get code for draw.circle: >> >> -- >> >> draw.circle # then copy to console and edit >> >> draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, >> lty = 1, >>density=NA, angle=45, lwd = 1 ) >> { >> xylim <- par("usr") >> plotdim <- par("pin") >> ymult <- getYmult() >> angle.inc <- 2 * pi/nv >> angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) >> if (length(col) < length(radius)) >> col <- rep(col, length.out = length(radius)) >> for (circle in 1:length(radius)) { >> xv <- cos(angles) * radius[circle] + x >> yv <- sin(angles) * radius[circle] * ymult + y >> polygon(xv, yv, border = border, col = col, lty = lty, >> density=density, angle=angle, >> lwd = lwd) >> } >> invisible(list(x = xv, y = yv)) >> } >> >> Now run your call to pdf with draw.circle2 instead of draw.circle >> >> Best; >> David. > library(plotrix) > pdf("MWE.pdf",width=8, height=8) > plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) > par(new=T) > plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) > par(new=T) > polygon(c(seq(-12.5,-8.7,length.out=100), > rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), > > rev(seq(-11.7,-8.7,length.out=100))), > col = alpha("red",0.4), border = NA) > par(new=T) > draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) > dev.off() > >>> Agree that the coding question remains unclear, so not using the offered >>> example but responding to the natural language query. The `polygon` >>> function has 'density' and 'angle' argument that with 'col' and 'lwd' can >>> make slanted fill lines. This is a modification of hte first example on >>> `?polygon`? >>> >>> x <- c(1:9, 8:1) >>> y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) >>> op <- par(mfcol = c(3, 1)) >>> for(xpd in c(FALSE, TRUE, NA)) { >>>plot(1:10, main = paste("xpd =", xpd)) >>>box("figure", col = "pink", lwd = 3) >>>polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, >>> border = "red") >>> } >>> >>> The polygon function is _not_ in pkg::plotrix. >>> >>> >>> > It looks a bit ugly since they are not real data, but it is the > simplest > MWE example
Re: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values
By the way, NULL is not a "null list", it has class (and type and mode) "NULL" not "list". "NULL" is an odd class, in that it can have only one instance and hence can never have any attributes. "list" objects, like other vector objects, may have length zero, but such objects are not the same as NULL. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Jun 15, 2017 at 8:56 AM, Jeff Newmillerwrote: > I find that the str function is more helpful for understanding the > difference between a null list and a list containing a null list than the > implicit print function call that the interpreter invokes when you enter an > expression at the console. > > str( mylist[1] ) > > -- > Sent from my phone. Please excuse my brevity. > > On June 15, 2017 8:39:47 AM PDT, Huzefa Khalil > wrote: > >Hi, > > > >Try > > > >> is.null(mylist[[1]]) > >[1] TRUE > > > >Notice the double square brackets. > > > >From: ?`[` > >"The most important distinction between [, [[ and $ is that the [ can > >select more than one element whereas the other two select a single > >element." > > > >On Thu, Jun 15, 2017 at 11:33 AM, ce wrote: > >> Hi > >> > >> I have a list : > >> > >> mylist <- list( a = NULL, b = 1, c = 2 ) > >> > >>> mylist[1] > >> $a > >> NULL > >> > >>> is.null(mylist[1]) > >> [1] FALSE > >> > >>> is.null(mylist$a) > >> [1] TRUE > >> > >> why? I need to use mylist[1] > >> __ > >> 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. > [[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] is.null(mylist[1]) and is.null(mylist$a) returns different values
Thank you all , very informative, never thought of doing a str( mylist[1] ) -Original Message- From: "Jeff Newmiller" [jdnew...@dcn.davis.ca.us] Date: 06/15/2017 11:56 AM To: r-help@r-project.org, "Huzefa Khalil", "ce" Subject: Re: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values I find that the str function is more helpful for understanding the difference between a null list and a list containing a null list than the implicit print function call that the interpreter invokes when you enter an expression at the console. str( mylist[1] ) -- Sent from my phone. Please excuse my brevity. On June 15, 2017 8:39:47 AM PDT, Huzefa Khalil wrote: >Hi, > >Try > >> is.null(mylist[[1]]) >[1] TRUE > >Notice the double square brackets. > >From: ?`[` >"The most important distinction between [, [[ and $ is that the [ can >select more than one element whereas the other two select a single >element." > >On Thu, Jun 15, 2017 at 11:33 AM, ce wrote: >> Hi >> >> I have a list : >> >> mylist <- list( a = NULL, b = 1, c = 2 ) >> >>> mylist[1] >> $a >> NULL >> >>> is.null(mylist[1]) >> [1] FALSE >> >>> is.null(mylist$a) >> [1] TRUE >> >> why? I need to use mylist[1] >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values
I find that the str function is more helpful for understanding the difference between a null list and a list containing a null list than the implicit print function call that the interpreter invokes when you enter an expression at the console. str( mylist[1] ) -- Sent from my phone. Please excuse my brevity. On June 15, 2017 8:39:47 AM PDT, Huzefa Khalilwrote: >Hi, > >Try > >> is.null(mylist[[1]]) >[1] TRUE > >Notice the double square brackets. > >From: ?`[` >"The most important distinction between [, [[ and $ is that the [ can >select more than one element whereas the other two select a single >element." > >On Thu, Jun 15, 2017 at 11:33 AM, ce wrote: >> Hi >> >> I have a list : >> >> mylist <- list( a = NULL, b = 1, c = 2 ) >> >>> mylist[1] >> $a >> NULL >> >>> is.null(mylist[1]) >> [1] FALSE >> >>> is.null(mylist$a) >> [1] TRUE >> >> why? I need to use mylist[1] >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values
Hi, Try > is.null(mylist[[1]]) [1] TRUE Notice the double square brackets. From: ?`[` "The most important distinction between [, [[ and $ is that the [ can select more than one element whereas the other two select a single element." On Thu, Jun 15, 2017 at 11:33 AM, cewrote: > Hi > > I have a list : > > mylist <- list( a = NULL, b = 1, c = 2 ) > >> mylist[1] > $a > NULL > >> is.null(mylist[1]) > [1] FALSE > >> is.null(mylist$a) > [1] TRUE > > why? I need to use mylist[1] > __ > 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. -- Huzefa Khalil PhD Candidate, Department of Political Science, University of Michigan __ 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] is.null(mylist[1]) and is.null(mylist$a) returns different values
Hi I have a list : mylist <- list( a = NULL, b = 1, c = 2 ) > mylist[1] $a NULL > is.null(mylist[1]) [1] FALSE > is.null(mylist$a) [1] TRUE why? I need to use mylist[1] __ 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] understanding I() in lmer formula
> Is there a difference between I(x*y) and I(y*x) ? > I have a call to lmer that results in this complaint: > Error in is.alpha2.subordinate * ~z.min.co.res : A reproducible example would help ... In the absence of that, check the classes of the two variables in I() and, if you run the product on the command line, either inside I() or not, what's the class of the result? If that is order-dependent for the object types you're combining, while I don't know why that might be it would go some way to explaining the outcome. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] draw stripes in a circle in R
hi david Thank you very much for the hack of draw.circle that you proposed me. I don't understand some part of the code, why do you pass radius as a vector in the function (if I understand well the purpose of the for loop) ? Also what is ymult? If I set the radius to the value 0.85 as I wanted (so as a scalar), I don't see any difference in the result when I call this function draw.circle2, the stripes are not drawn inside the circle. I don't know if it is normal. Thanks, best Jean-Philippe On 14/06/2017 19:29, David Winsemius wrote: On Jun 14, 2017, at 10:18 AM, David Winsemiuswrote: On Jun 14, 2017, at 9:46 AM, Jeff Newmiller wrote: I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe wrote: dear R users, I would like to fill a circle with yellow stripes instead of a uniform yellow color. To draw the circle I used the following command after having loaded the (very nice !) plotrix library : I finally understood the question and it needs a hack to the draw.circle function in plotrix since the angle and density arguments don't get passed in: First get code for draw.circle: -- draw.circle # then copy to console and edit draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, lty = 1, density=NA, angle=45, lwd = 1 ) { xylim <- par("usr") plotdim <- par("pin") ymult <- getYmult() angle.inc <- 2 * pi/nv angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) if (length(col) < length(radius)) col <- rep(col, length.out = length(radius)) for (circle in 1:length(radius)) { xv <- cos(angles) * radius[circle] + x yv <- sin(angles) * radius[circle] * ymult + y polygon(xv, yv, border = border, col = col, lty = lty, density=density, angle=angle, lwd = lwd) } invisible(list(x = xv, y = yv)) } Now run your call to pdf with draw.circle2 instead of draw.circle Best; David. library(plotrix) pdf("MWE.pdf",width=8, height=8) plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) par(new=T) plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) par(new=T) polygon(c(seq(-12.5,-8.7,length.out=100), rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), rev(seq(-11.7,-8.7,length.out=100))), col = alpha("red",0.4), border = NA) par(new=T) draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) dev.off() Agree that the coding question remains unclear, so not using the offered example but responding to the natural language query. The `polygon` function has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted fill lines. This is a modification of hte first example on `?polygon`? x <- c(1:9, 8:1) y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) op <- par(mfcol = c(3, 1)) for(xpd in c(FALSE, TRUE, NA)) { plot(1:10, main = paste("xpd =", xpd)) box("figure", col = "pink", lwd = 3) polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, border = "red") } The polygon function is _not_ in pkg::plotrix. It looks a bit ugly since they are not real data, but it is the simplest MWE example that I found. Thanks, best Jean-Philippe __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. 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. 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. -- Jean-Philippe Fontaine PhD Student in Astroparticle Physics, Gran Sasso Science Institute (GSSI), Viale Francesco Crispi 7, 67100 L'Aquila, Italy Mobile: +393487128593, +33615653774 __ 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
Re: [R] about fitting a regression line
Hi But X can be some function like - sin, cos, log, exp... Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of lily li > Sent: Thursday, June 15, 2017 1:28 AM > To: MacQueen, Don> Cc: R mailing list > Subject: Re: [R] about fitting a regression line > > Thanks. I thought lm() function is for linear model, such as the correlation > below: > Y= aX + b > > On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don > wrote: > > > Start with the lm() function; i.e., see > > > > ?lm > > > > -Don > > > > -- > > Don MacQueen > > > > Lawrence Livermore National Laboratory > > 7000 East Ave., L-627 > > Livermore, CA 94550 > > 925-423-1062 > > > > > > On 6/14/17, 3:40 PM, "R-help on behalf of lily li" < > > r-help-boun...@r-project.org on behalf of chocol...@gmail.com> wrote: > > > > Hi R users, > > > > I have some data points (Xi, Yi), and they may follow such a > > pattern Yi = > > cCOS(Xi) + d, how to find the c and d in R? which function to use? > > Also, > > how to get the R2 and p value for this correlation? Thanks for any > > kind of > > help. > > > > [[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. 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