Further to my email below, I have just realised that I forgot to include the specification of L and R.
Hence, the code needs to include the following additional lines at the start;- L<-7.5e6 R<-2.5e6 Apologies for any confusion caused! Best regards, Tony > On 12 Jul 2017, at 10:03 AM, HUL-Anthony Egerton <[hidden email]> wrote: > > I am trying to code a basic Monte Carlo Simulation in R where a Poisson distribution generates a frequency output that is then input into a Lognormal distribution, which produces a different, independent severity for each incidence. The individual incidences are then summed to produce an aggregate amount per period/iteration. > > Here is the code;- > > scale<-15.08707 > shape<-0.8592507 > lambda.risk<-1.75 > L<-7.5e5 > R<-2.5e6 > iterations<-replicate(10000,{ > claims1<-0 > claims2<-0 > claims3<-0 > claims4<-0 > claims5<-0 > claims6<-0 > claims7<-0 > claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7) > freq<-(qpois(runif(1),lambda.risk)) > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if(freq>=1){claims1<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if(freq>=2){claims2<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=3) {claims3<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=4) {claims4<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=5) {claims5<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=6) {claims6<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=7) {claims7<-sev} > claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7) > min(22.5e6,sum(claims)) > }) > > I am new to R, but am sure that there must be a simpler way to code this process. > > Furthermore, as the Poisson lambda increases, there is a need to include provision for potentially more incidences, which will require a manual expansion of the code to claims8, claims9 etc. > > Can you assist, please? > > Best regards, > > Anthony A H Egerton MA MBA ACII > ����� > HUNTINGTON UNDERWRITING LIMITED > Labuan FT, Malaysia > > > > CONFIDENTIALITY NOTE: > > The information contained in this email message may be legally privileged and contain confidential information and is intended only for the use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copy of this message is strictly prohibited. If you have received this email in error, please immediately delete this message. > > Begin forwarded message: > >> From: [hidden email] >> Date: 8 July 2017 at 6:00:02 PM SGT >> To: [hidden email] >> Subject: R-help Digest, Vol 173, Issue 8 >> Reply-To: [hidden email] >> >> Send R-help mailing list submissions to >> [hidden email] >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://stat.ethz.ch/mailman/listinfo/r-help >> or, via email, send a message with subject or body 'help' to >> [hidden email] >> >> You can reach the person managing the list at >> [hidden email] >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of R-help digest..." >> >> >> Today's Topics: >> >> 1. R loop function in Tableau (Dai, Shengyu) >> 2. Factor vs character in a data.frame vs vector (John Kane) >> 3. Re: Factor vs character in a data.frame vs vector (Marc Schwartz) >> 4. Re: Scoring and Ranking Methods (David Winsemius) >> 5. Re: R loop function in Tableau (David Winsemius) >> 6. Re: [Rd] italic font on cairo devices in R 3.4 ([hidden email]) >> 7. Re: [Rd] italic font on cairo devices in R 3.4 ([hidden email]) >> 8. Beginner s quwry about cfa in lavaan (Martina Hule?ov?) >> 9. Re: [Rd] italic font on cairo devices in R 3.4 (Ilia Kats) >> 10. Re: Beginner s quwry about cfa in lavaan (Bert Gunter) >> 11. Re: Factor vs character in a data.frame vs vector (Marc Schwartz) >> 12. Re: Factor vs character in a data.frame vs vector (John Kane) >> 13. Re: [Rd] italic font on cairo devices in R 3.4 (Yixuan Qiu) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Thu, 06 Jul 2017 17:19:47 -0400 >> From: "Dai, Shengyu" <[hidden email]> >> To: <[hidden email]> >> Subject: [R] R loop function in Tableau >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Hi R helpers, >> >> >> >> I hope this email finds you well. >> >> >> >> I am having trouble with R loop function in Tableau. Please see the attachment of a simple dataset. The problem is to test whether the value of columns is match. >> >> >> >> Because Tableau do not have iteration function, I coded ?if statement? in Tableau to realize the function, which is slow if having huge amount of data. I wonder to integrate Tableau with R studio to realize this functionality. >> >> >> >> I did not find too much useful information online and I am asking helps for any examples of related low-level data calculation. >> >> >> >> Thank you very much. Your helps and supports are really appreciated! >> >> >> >> Best, >> >> >> >> -- >> >> >> >> Shengyu (Freddy) Dai >> >> Master of Science in Business Analytics >> >> Lally School of Management >> >> Rensselaer Polytechnic Institute >> >> Mobile: (513)328-5659 >> >> >> >> >> >> ------------------------------ >> >> Message: 2 >> Date: Fri, 7 Jul 2017 11:03:51 +0000 >> From: John Kane <[hidden email]> >> To: R R-help <[hidden email]> >> Subject: [R] Factor vs character in a data.frame vs vector >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> This is not? serious problem but I just wonder if someone can explain what is happening. >> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character.? It's probably something simple that I have read and forgotten but I thought I'd ask. >> Thanks >> >> #================================================ >> dat1 <- data.frame(aa = letters[1:10]) >> str(dat1) >> data.frame':????10 obs. of??1 variable: >> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >> bb = letters[1:10] >> str(bb) >> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >> #============================================================== >> >> >> [[alternative HTML version deleted]] >> >> >> >> ------------------------------ >> >> Message: 3 >> Date: Fri, 7 Jul 2017 09:37:12 -0500 >> From: Marc Schwartz <[hidden email]> >> To: John Kane <[hidden email]> >> Cc: R R-help <[hidden email]> >> Subject: Re: [R] Factor vs character in a data.frame vs vector >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset="us-ascii" >> >> >>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <[hidden email]> wrote: >>> >>> This is not serious problem but I just wonder if someone can explain what is happening. >>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask. >>> Thanks >>> >>> #================================================ >>> dat1 <- data.frame(aa = letters[1:10]) >>> str(dat1) >>> data.frame': 10 obs. of 1 variable: >>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>> bb = letters[1:10] >>> str(bb) >>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>> #============================================================== >>> >> >> >> See the 'stringsAsFactors' argument in ?data.frame. >> >> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >> >>> str(dat1) >> 'data.frame': 10 obs. of 1 variable: >> $ aa: chr "a" "b" "c" "d" ... >> >> >> Regards, >> >> Marc Schwartz >> >> >> >> ------------------------------ >> >> Message: 4 >> Date: Fri, 7 Jul 2017 08:47:57 -0700 >> From: David Winsemius <[hidden email]> >> To: Dhivya Narayanasamy <[hidden email]> >> Cc: r-help mailing list <[hidden email]> >> Subject: Re: [R] Scoring and Ranking Methods >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset=us-ascii >> >> >>> On Jul 7, 2017, at 2:29 AM, Dhivya Narayanasamy <[hidden email]> wrote: >>> >>> Hi, >>> >>> I am doing predictive modelling of Multivariate Time series Data of a Motor >>> in R using various models such as Arima, H2O.Randomforest, glmnet, lm and >>> few other models. >>> >>> I created a function to select a model of our choice and do prediction. >>> >>> Model1 <- function(){ >>> .. >>> return() >>> } >> >> That looks like a prescription for serious disappointment. I seriously doubt that you have done any testing using similar code. You would have created a function that returns NULL. I get the sense that you need to study and work through the examples in the "Introduction to R" document. >> >> >> >>> Model2 <- function(){ >>> ... >>> return() >>> } >>> Model3 <- function(){ >>> ... >>> return() >>> } >>> main <- function(n){ >>> if(n == 1) { >>> Model1() >>> } >>> else if(n == 2){ >>> Model2() >>> } >>> else if(n == 3){ >>> Model3() >>> }} >>> Now I am supposed to automate these models which gives RMSE and MAPE of >>> each model. I would like to provide scores (eg. out of 5) for each model >>> based on the performance. For example, if Arima gives a low RMSE than other >>> models, it will be scored high and the second lowest RMSE model will score >>> a less than Arima and so on. >>> >>> And every time i run those models with different input Data [motor2, motor3 >>> ..], it must give the mean score of a model. what I mean to say is, >>> >>> 1. for motor1 it will give scores of each model, let's say *s1*. >>> 2. for motor2 run it give scores of each model, and let's call it *s2*. >>> And i want a mean score of that model every time i run it with different >>> input. It is more like scoring and ranking method. >>> >>> Are there any methods or packages in R that can give a glimpse of how it is >>> done? or any examples? Any suggestions would be very helpful. >> >> The 'switch'-function can dispatch to different functions on the basis of the value of an indicator variable. >> >> >>> >>> Thank you. >>> Dhivya >>> >>> [[alternative HTML version deleted]] >> >> Please read the Posting Guide. Rhelp is a plain text mailing list. >>> >>> ______________________________________________ >>> [hidden email] 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 >> >> >> >> ------------------------------ >> >> Message: 5 >> Date: Fri, 7 Jul 2017 08:57:50 -0700 >> From: David Winsemius <[hidden email]> >> To: "Dai, Shengyu" <[hidden email]> >> Cc: [hidden email] >> Subject: Re: [R] R loop function in Tableau >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset=utf-8 >> >> >>> On Jul 6, 2017, at 2:19 PM, Dai, Shengyu <[hidden email]> wrote: >>> >>> Hi R helpers, >>> >>> >>> >>> I hope this email finds you well. >>> >>> >>> >>> I am having trouble with R loop function in Tableau. >>> >> >> There is no "R loop function". (There is an R `for`-function.) If you are having trouble with code then it should be provided. If the problem is with the Tableau code then this is the wrong place. Tableau is not either free or open source. You would in that case need to contact Tableau or get assistance from your academic institution. >> >>> Please see the attachment of a simple dataset. >> >> No data attached. Probably scrubbed by the mail server. Any data needs to be a .txt file. >> >>> The problem is to test whether the value of columns is match. >> >> There is a `match` function. It's vectorized, so may not need to be wrapped with a function that would provide looping. >> >>> >>> Because Tableau do not have iteration function, I coded ?if statement? in Tableau to realize the function, which is slow if having huge amount of data. I wonder to integrate Tableau with R studio to realize this functionality. >>> >>> >>> >>> I did not find too much useful information online and I am asking helps for any examples of related low-level data calculation. >> >> That is then the fault of Tableau (if true), since there is a huge amount of online documentation for R. The Rhelp Archives and StackOverflow have thousands of worked examples of "low-level data calculation". I suspect with estimated probability approaching unity that StackOverflow will have questions tagged jointly with [r] and [tableau]. >> >> >>> >>> Thank you very much. Your helps and supports are really appreciated! >>> >>> >>> >>> Best, >>> >>> >>> >>> -- >>> >>> >>> >>> Shengyu (Freddy) Dai >>> >>> Master of Science in Business Analytics >>> >>> Lally School of Management >>> >>> Rensselaer Polytechnic Institute >>> >>> Mobile: (513)328-5659 >>> >>> >>> >>> ______________________________________________ >>> [hidden email] 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 >> >> >> >> ------------------------------ >> >> Message: 6 >> Date: Fri, 7 Jul 2017 09:17:34 -0700 >> From: [hidden email] >> To: Ilia Kats <[hidden email]> >> Cc: [hidden email], [hidden email] >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset=us-ascii >> >> Hi Ilia, >> >> I'm running Arch Linux, R 3.4.0. >> >> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >> >> It doesn't look pixelated to me... >> >> Here's a post that I wrote when I solved my last font problem in R, >> almost 2 years ago: >> >> https://stackoverflow.com/a/40940331/5087283 >> >> I had to install some Microsoft font packages, which is sad, because >> there are some perfectly good free fonts that R could be using >> instead. It could be considered a bug that R requires Microsoft fonts, >> at least by default. However, does this even fix your problem? I.e. if >> you install the corresponding Debian Microsoft font packages, does the >> text appear anti-aliased? >> >> Frederick >> >>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>> [cross-post from R-help] >>> >>> Hi all, >>> >>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>> devices appear pixelated. Here's a minimal example: >>> cairo_pdf('test.pdf') >>> plot(1:10, ylab=expression(italic(test))) >>> dev.off() >>> >>> The same problem occurs with bolditalic, but not bold. I am using Debian >>> Stretch. Several friends tried the same on their machines, another Debian >>> machine has the same problem. On MacOSX the output was not pixelated, but it >>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>> that R somehow can't find the proper font to use and falls back to something >>> weird. Ideas? >>> >>> Note that I'm not subscribed to the list, so please CC me in replies. >>> >>> Cheers, Ilia >>> >>> ______________________________________________ >>> [hidden email] mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>> >> >> >> >> ------------------------------ >> >> Message: 7 >> Date: Fri, 7 Jul 2017 10:28:44 -0700 >> From: [hidden email] >> To: Ilia Kats <[hidden email]> >> Cc: [hidden email], [hidden email] >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset=us-ascii >> >>> On Fri, Jul 07, 2017 at 07:08:52PM +0200, Ilia Kats wrote: >>> Interesting. I did not have the package installed, but I did at some point >>> extract Helvetica from some MacOSX font files and R was using that just fine >>> until 3.3. This is how the plot looks in 3.4 (still using Helvetica): >>> https://ptpb.pw/HikX.pdf . After removing Helvetica, installing the >>> ttf-mscorefonts-installer package, and running fc-cache --force the plot >>> looks like this: https://ptpb.pw/CM8A.pdf >> >> The second plot looks worse, in other words, and the Microsoft fonts >> didn't help. >> >> Maybe the Cairo device should be giving better warning messages. >> >> Anyway it sounds like you are describing a regression so maybe someone >> can track down the commit that created this problem. >> >> Thanks, >> >> Frederick >> >> >>> Also note that the standard pdf device works fine: https://ptpb.pw/3Ml1.pdf >>> , it's just the cairo devices (both pdf and svg) that have the issue. >>> Unfortunately I need to use cairo_pdf due to unicode characters in axis >>> labels. >>> >>> Cheers, Ilia >>> >>> >>> -------- Original Message -------- >>> Subject: Re: [Rd] italic font on cairo devices in R 3.4 >>> Date: 2017-07-07 18:17:34 +0200 >>> From: frederik >>> To: Ilia Kats >>> CC: r-devel, r-help >>>> Hi Ilia, >>>> >>>> I'm running Arch Linux, R 3.4.0. >>>> >>>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>>> >>>> It doesn't look pixelated to me... >>>> >>>> Here's a post that I wrote when I solved my last font problem in R, >>>> almost 2 years ago: >>>> >>>> https://stackoverflow.com/a/40940331/5087283 >>>> >>>> I had to install some Microsoft font packages, which is sad, because >>>> there are some perfectly good free fonts that R could be using >>>> instead. It could be considered a bug that R requires Microsoft fonts, >>>> at least by default. However, does this even fix your problem? I.e. if >>>> you install the corresponding Debian Microsoft font packages, does the >>>> text appear anti-aliased? >>>> >>>> Frederick >>>> >>>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>>> [cross-post from R-help] >>>>> >>>>> Hi all, >>>>> >>>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>>> devices appear pixelated. Here's a minimal example: >>>>> cairo_pdf('test.pdf') >>>>> plot(1:10, ylab=expression(italic(test))) >>>>> dev.off() >>>>> >>>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>>> Stretch. Several friends tried the same on their machines, another Debian >>>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>>> that R somehow can't find the proper font to use and falls back to something >>>>> weird. Ideas? >>>>> >>>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>>> >>>>> Cheers, Ilia >>>>> >>>>> ______________________________________________ >>>>> [hidden email] mailing list >>>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>>> >>> >>> -- >>> The first is to ensure your partner understands that nature has root >>> privileges - nature doesn't have to make sense. >>> -- Telsa Gwynne >>> >> >> >> >> ------------------------------ >> >> Message: 8 >> Date: Fri, 7 Jul 2017 16:52:34 +0000 >> From: Martina Hule?ov? <[hidden email]> >> To: "[hidden email]" <[hidden email]> >> Subject: [R] Beginner s quwry about cfa in lavaan >> Message-ID: >> <[hidden email]> >> >> Content-Type: text/plain; charset="UTF-8" >> >> Dear all, >> I am trying to learn about R. As a Phd student, I would like to use R for Krippendorff s alpha and later for a series of CFA. Is there any good introduction to these kind of analyses, or could you recommend me some tutorials on youtube, for example? I am new to R, so I need something basic , starting from opening the R environment?. >> Thank you . >> Martina Hulesova >> >> Odesl?no z m?ho Windows Phone >> >> [[alternative HTML version deleted]] >> >> >> ------------------------------ >> >> Message: 9 >> Date: Fri, 7 Jul 2017 19:08:52 +0200 >> From: Ilia Kats <[hidden email]> >> To: [hidden email] >> Cc: [hidden email], [hidden email] >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset=utf-8; format=flowed >> >> Interesting. I did not have the package installed, but I did at some >> point extract Helvetica from some MacOSX font files and R was using that >> just fine until 3.3. This is how the plot looks in 3.4 (still using >> Helvetica): https://ptpb.pw/HikX.pdf . After removing Helvetica, >> installing the ttf-mscorefonts-installer package, and running fc-cache >> --force the plot looks like this: https://ptpb.pw/CM8A.pdf >> >> Also note that the standard pdf device works fine: >> https://ptpb.pw/3Ml1.pdf , it's just the cairo devices (both pdf and >> svg) that have the issue. Unfortunately I need to use cairo_pdf due to >> unicode characters in axis labels. >> >> Cheers, Ilia >> >> >> -------- Original Message -------- >> Subject: Re: [Rd] italic font on cairo devices in R 3.4 >> Date: 2017-07-07 18:17:34 +0200 >> From: frederik >> To: Ilia Kats >> CC: r-devel, r-help >>> Hi Ilia, >>> >>> I'm running Arch Linux, R 3.4.0. >>> >>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>> >>> It doesn't look pixelated to me... >>> >>> Here's a post that I wrote when I solved my last font problem in R, >>> almost 2 years ago: >>> >>> https://stackoverflow.com/a/40940331/5087283 >>> >>> I had to install some Microsoft font packages, which is sad, because >>> there are some perfectly good free fonts that R could be using >>> instead. It could be considered a bug that R requires Microsoft fonts, >>> at least by default. However, does this even fix your problem? I.e. if >>> you install the corresponding Debian Microsoft font packages, does the >>> text appear anti-aliased? >>> >>> Frederick >>> >>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>> [cross-post from R-help] >>>> >>>> Hi all, >>>> >>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>> devices appear pixelated. Here's a minimal example: >>>> cairo_pdf('test.pdf') >>>> plot(1:10, ylab=expression(italic(test))) >>>> dev.off() >>>> >>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>> Stretch. Several friends tried the same on their machines, another Debian >>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>> that R somehow can't find the proper font to use and falls back to something >>>> weird. Ideas? >>>> >>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>> >>>> Cheers, Ilia >>>> >>>> ______________________________________________ >>>> [hidden email] mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>> >> >> -- >> The first is to ensure your partner understands that nature has root >> privileges - nature doesn't have to make sense. >> -- Telsa Gwynne >> >> >> >> ------------------------------ >> >> Message: 10 >> Date: Fri, 7 Jul 2017 16:43:12 -0700 >> From: Bert Gunter <[hidden email]> >> To: Martina Hule?ov? <[hidden email]> >> Cc: [hidden email] >> Subject: Re: [R] Beginner s quwry about cfa in lavaan >> Message-ID: >> <CAGxFJbQ3CgCFXLBGsz9e8y=VLw=9gQKTw7CsoDjy6Feu4=[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Google is your friend. >> >> Also rseek.org >> >> Bert >> >> >> >>> On Jul 7, 2017 3:48 PM, "Martina Hule?ov?" <[hidden email]> wrote: >>> >>> Dear all, >>> I am trying to learn about R. As a Phd student, I would like to use R for >>> Krippendorff s alpha and later for a series of CFA. Is there any good >>> introduction to these kind of analyses, or could you recommend me some >>> tutorials on youtube, for example? I am new to R, so I need something basic >>> , starting from opening the R environment?. >>> Thank you . >>> Martina Hulesova >>> >>> Odesl?no z m?ho Windows Phone >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> [hidden email] 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]] >> >> >> >> ------------------------------ >> >> Message: 11 >> Date: Fri, 7 Jul 2017 21:25:42 -0500 >> From: Marc Schwartz <[hidden email]> >> To: John Kane <[hidden email]> >> Cc: R R-help <[hidden email]> >> Subject: Re: [R] Factor vs character in a data.frame vs vector >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset="us-ascii" >> >> >>> On Jul 7, 2017, at 7:03 PM, John Kane <[hidden email]> wrote: >>> >>> Thanks Marc. >>> It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame. I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. >> >> >> Welcome John. >> >> Going back to the old NEWS files, the 'stringsAsFactors' argument for data.frame() appears in version 2.4.0, which was released on 2006-10-03. >> >> It is possible that somewhere along the way, you set options(stringsAsFactors = FALSE) in your .Rprofile, which would change the default behavior. I know that some folks do that, as they do not like the default coercion to factors, both for data.frame() and for the read.table() family. >> >> Other alternatives would be to use the 'colClasses' argument to explicitly set such vectors to character, or to use I(...) to create AsIs class columns. >> >> Regards, >> >> Marc >> >> >>> >>> >>> >>> On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <[hidden email]> wrote: >>> >>> >>> >>>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <[hidden email]> wrote: >>>> >>>> This is not serious problem but I just wonder if someone can explain what is happening. >>>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask. >>>> Thanks >>>> >>>> #================================================ >>>> dat1 <- data.frame(aa = letters[1:10]) >>>> str(dat1) >>>> data.frame': 10 obs. of 1 variable: >>>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>>> bb = letters[1:10] >>>> str(bb) >>>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>>> #============================================================== >>>> >>> >>> >>> See the 'stringsAsFactors' argument in ?data.frame. >>> >>> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >>> >>> >>>> str(dat1) >>> 'data.frame': 10 obs. of 1 variable: >>> >>> $ aa: chr "a" "b" "c" "d" ... >>> >>> >>> Regards, >>> >>> Marc Schwartz >>> >> >> >> >> ------------------------------ >> >> Message: 12 >> Date: Sat, 8 Jul 2017 00:03:19 +0000 >> From: John Kane <[hidden email]> >> To: Marc Schwartz <[hidden email]> >> Cc: R R-help <[hidden email]> >> Subject: Re: [R] Factor vs character in a data.frame vs vector >> Message-ID: <[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Thanks Marc. It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame.? I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. >> >> >> On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <[hidden email]> wrote: >> >> >>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <[hidden email]> wrote: >>> >>> This is not? serious problem but I just wonder if someone can explain what is happening. >>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character.? It's probably something simple that I have read and forgotten but I thought I'd ask. >>> Thanks >>> >>> #================================================ >>> dat1 <- data.frame(aa = letters[1:10]) >>> str(dat1) >>> data.frame':? ? 10 obs. of? 1 variable: >>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>> bb = letters[1:10] >>> str(bb) >>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>> #============================================================== >>> >> >> >> See the 'stringsAsFactors' argument in ?data.frame. >> >> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >> >>> str(dat1) >> 'data.frame':??? 10 obs. of? 1 variable: >> $ aa: chr? "a" "b" "c" "d" ... >> >> >> Regards, >> >> Marc Schwartz >> >> [[alternative HTML version deleted]] >> >> >> >> ------------------------------ >> >> Message: 13 >> Date: Sat, 8 Jul 2017 01:11:10 -0400 >> From: Yixuan Qiu <[hidden email]> >> To: [hidden email] >> Cc: [hidden email], r-help <[hidden email]> >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: >> <CAFr_7yFTMPers4D9P_vaPW5=[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Hi Ilia, >> >> You may want to have a try of the showtext package >> (https://github.com/yixuan/showtext). Below is a quick example: >> >> library(showtext) >> showtext.auto() >> >> pdf("test.pdf") >> ## Use the "sans" font family provided by the showtext package >> ## font == 3 means italic font face >> plot(1, xlab = "Unicode characters: \u00C0 \u00C6 \u00D8", >> family = "sans", font.lab = 3) >> dev.off() >> >> ## Same for SVG >> svg("test.svg") >> plot(1, xlab = "Unicode characters: \u00C0 \u00C6 \u00D8", >> family = "sans", font.lab = 3) >> dev.off() >> >> >> Best, >> Yixuan >> >> >> 2017-07-07 13:08 GMT-04:00 Ilia Kats <[hidden email]>: >>> Interesting. I did not have the package installed, but I did at some point >>> extract Helvetica from some MacOSX font files and R was using that just fine >>> until 3.3. This is how the plot looks in 3.4 (still using Helvetica): >>> https://ptpb.pw/HikX.pdf . After removing Helvetica, installing the >>> ttf-mscorefonts-installer package, and running fc-cache --force the plot >>> looks like this: https://ptpb.pw/CM8A.pdf >>> >>> Also note that the standard pdf device works fine: https://ptpb.pw/3Ml1.pdf >>> , it's just the cairo devices (both pdf and svg) that have the issue. >>> Unfortunately I need to use cairo_pdf due to unicode characters in axis >>> labels. >>> >>> Cheers, Ilia >>> >> >> >> >> >> -- >> Yixuan Qiu <[hidden email]> >> Department of Statistics, >> Purdue University >> >> >> >> ------------------------------ >> >> Subject: Digest Footer >> >> _______________________________________________ >> [hidden email] 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. >> >> ------------------------------ >> >> End of R-help Digest, Vol 173, Issue 8 >> ************************************** ______________________________________________ [hidden email] 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. |
Tony,
I’m not sure what exactly you’re trying to do, but you're not really taking advantage of vectorization in your R code. I've tried to clean it up a little. The clamped lognormal is almost always 0 or L? That seems a little odd. You seem to be using the inverse cdf method of drawing samples. That's not necessary in R for standard probability distributions. You may want to do a little more investigating of basic programming tasks in R before you dig into a complex simulation. scale <- 15.08707 shape <- 0.8592507 lambda.risk <- 1.75 L <- 7.5e5 R <- 2.5e6 # Generate n random poisson with rate = lambda.risk frequency <- function(n) rpois(n,lambda.risk) # clamp a numeric to 0, L clamp <- function(x, min, max) pmin(max, pmax(min, x)) # Generate lognormal shifted by R severity <- function(n) rlnorm(n,scale,shape)-R clamp(severity(100), 0, L) # Lognormal shifted left by R, and then clamped between 0 and L? Almost always equal to 0 or L sim <- function(breaks = 7){ freq <- frequency(1) i <- freq > 1:7 sev <- clamp(severity(sum(i)), 0, L) claims <- rep(0, 7) claims[i] <- sev min(22.5e6,sum(claims)) } hist(iterations <- replicate(10000, sim()), breaks = 20) From: R-help [mailto:[hidden email]] On Behalf Of HUL-Anthony Egerton Sent: Friday, July 14, 2017 7:45 PM To: [hidden email] Subject: Re: [R] One Dimensional Monte Carlo Simulation Further to my email below, I have just realised that I forgot to include the specification of L and R. Hence, the code needs to include the following additional lines at the start;- L<-7.5e6 R<-2.5e6 Apologies for any confusion caused! Best regards, Tony > On 12 Jul 2017, at 10:03 AM, HUL-Anthony Egerton <mailto:[hidden email]> wrote: > > I am trying to code a basic Monte Carlo Simulation in R where a Poisson distribution generates a frequency output that is then input into a Lognormal distribution, which produces a different, independent severity for each incidence. The individual incidences are then summed to produce an aggregate amount per period/iteration. > > Here is the code;- > > scale<-15.08707 > shape<-0.8592507 > lambda.risk<-1.75 > L<-7.5e5 > R<-2.5e6 > iterations<-replicate(10000,{ > claims1<-0 > claims2<-0 > claims3<-0 > claims4<-0 > claims5<-0 > claims6<-0 > claims7<-0 > claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7) > freq<-(qpois(runif(1),lambda.risk)) > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if(freq>=1){claims1<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if(freq>=2){claims2<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=3) {claims3<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=4) {claims4<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=5) {claims5<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=6) {claims6<-sev} > sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) > if (freq>=7) {claims7<-sev} > claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7) > min(22.5e6,sum(claims)) > }) > > I am new to R, but am sure that there must be a simpler way to code this process. > > Furthermore, as the Poisson lambda increases, there is a need to include provision for potentially more incidences, which will require a manual expansion of the code to claims8, claims9 etc. > > Can you assist, please? > > Best regards, > > Anthony A H Egerton MA MBA ACII > ����� > HUNTINGTON UNDERWRITING LIMITED > Labuan FT, Malaysia > > > > CONFIDENTIALITY NOTE: > > The information contained in this email message may be legally privileged and contain confidential information and is intended only for the use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copy of this message is strictly prohibited. If you have received this email in error, please immediately delete this message. > > Begin forwarded message: > >> From: mailto:[hidden email] >> Date: 8 July 2017 at 6:00:02 PM SGT >> To: mailto:[hidden email] >> Subject: R-help Digest, Vol 173, Issue 8 >> Reply-To: mailto:[hidden email] >> >> Send R-help mailing list submissions to >> mailto:[hidden email] >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://stat.ethz.ch/mailman/listinfo/r-help >> or, via email, send a message with subject or body 'help' to >> mailto:[hidden email] >> >> You can reach the person managing the list at >> mailto:[hidden email] >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of R-help digest..." >> >> >> Today's Topics: >> >> 1. R loop function in Tableau (Dai, Shengyu) >> 2. Factor vs character in a data.frame vs vector (John Kane) >> 3. Re: Factor vs character in a data.frame vs vector (Marc Schwartz) >> 4. Re: Scoring and Ranking Methods (David Winsemius) >> 5. Re: R loop function in Tableau (David Winsemius) >> 6. Re: [Rd] italic font on cairo devices in R 3.4 (mailto:[hidden email]) >> 7. Re: [Rd] italic font on cairo devices in R 3.4 (mailto:[hidden email]) >> 8. Beginner s quwry about cfa in lavaan (Martina Hule?ov?) >> 9. Re: [Rd] italic font on cairo devices in R 3.4 (Ilia Kats) >> 10. Re: Beginner s quwry about cfa in lavaan (Bert Gunter) >> 11. Re: Factor vs character in a data.frame vs vector (Marc Schwartz) >> 12. Re: Factor vs character in a data.frame vs vector (John Kane) >> 13. Re: [Rd] italic font on cairo devices in R 3.4 (Yixuan Qiu) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Thu, 06 Jul 2017 17:19:47 -0400 >> From: "Dai, Shengyu" <mailto:[hidden email]> >> To: <mailto:[hidden email]> >> Subject: [R] R loop function in Tableau >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Hi R helpers, >> >> >> >> I hope this email finds you well. >> >> >> >> I am having trouble with R loop function in Tableau. Please see the attachment of a simple dataset. The problem is to test whether the value of columns is match. >> >> >> >> Because Tableau do not have iteration function, I coded ?if statement? in Tableau to realize the function, which is slow if having huge amount of data. I wonder to integrate Tableau with R studio to realize this functionality. >> >> >> >> I did not find too much useful information online and I am asking helps for any examples of related low-level data calculation. >> >> >> >> Thank you very much. Your helps and supports are really appreciated! >> >> >> >> Best, >> >> >> >> -- >> >> >> >> Shengyu (Freddy) Dai >> >> Master of Science in Business Analytics >> >> Lally School of Management >> >> Rensselaer Polytechnic Institute >> >> Mobile: (513)328-5659 >> >> >> >> >> >> ------------------------------ >> >> Message: 2 >> Date: Fri, 7 Jul 2017 11:03:51 +0000 >> From: John Kane <mailto:[hidden email]> >> To: R R-help <mailto:[hidden email]> >> Subject: [R] Factor vs character in a data.frame vs vector >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> This is not? serious problem but I just wonder if someone can explain what is happening. >> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character.? It's probably something simple that I have read and forgotten but I thought I'd ask. >> Thanks >> >> #================================================ >> dat1 <- data.frame(aa = letters[1:10]) >> str(dat1) >> data.frame':????10 obs. of??1 variable: >> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >> bb = letters[1:10] >> str(bb) >> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >> #============================================================== >> >> >> [[alternative HTML version deleted]] >> >> >> >> ------------------------------ >> >> Message: 3 >> Date: Fri, 7 Jul 2017 09:37:12 -0500 >> From: Marc Schwartz <mailto:[hidden email]> >> To: John Kane <mailto:[hidden email]> >> Cc: R R-help <mailto:[hidden email]> >> Subject: Re: [R] Factor vs character in a data.frame vs vector >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset="us-ascii" >> >> >>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <mailto:[hidden email]> wrote: >>> >>> This is not serious problem but I just wonder if someone can explain what is happening. >>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask. >>> Thanks >>> >>> #================================================ >>> dat1 <- data.frame(aa = letters[1:10]) >>> str(dat1) >>> data.frame': 10 obs. of 1 variable: >>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>> bb = letters[1:10] >>> str(bb) >>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>> #============================================================== >>> >> >> >> See the 'stringsAsFactors' argument in ?data.frame. >> >> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >> >>> str(dat1) >> 'data.frame': 10 obs. of 1 variable: >> $ aa: chr "a" "b" "c" "d" ... >> >> >> Regards, >> >> Marc Schwartz >> >> >> >> ------------------------------ >> >> Message: 4 >> Date: Fri, 7 Jul 2017 08:47:57 -0700 >> From: David Winsemius <mailto:[hidden email]> >> To: Dhivya Narayanasamy <mailto:[hidden email]> >> Cc: r-help mailing list <mailto:[hidden email]> >> Subject: Re: [R] Scoring and Ranking Methods >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset=us-ascii >> >> >>> On Jul 7, 2017, at 2:29 AM, Dhivya Narayanasamy <mailto:[hidden email]> wrote: >>> >>> Hi, >>> >>> I am doing predictive modelling of Multivariate Time series Data of a Motor >>> in R using various models such as Arima, H2O.Randomforest, glmnet, lm and >>> few other models. >>> >>> I created a function to select a model of our choice and do prediction. >>> >>> Model1 <- function(){ >>> .. >>> return() >>> } >> >> That looks like a prescription for serious disappointment. I seriously doubt that you have done any testing using similar code. You would have created a function that returns NULL. I get the sense that you need to study and work through the examples in the "Introduction to R" document. >> >> >> >>> Model2 <- function(){ >>> ... >>> return() >>> } >>> Model3 <- function(){ >>> ... >>> return() >>> } >>> main <- function(n){ >>> if(n == 1) { >>> Model1() >>> } >>> else if(n == 2){ >>> Model2() >>> } >>> else if(n == 3){ >>> Model3() >>> }} >>> Now I am supposed to automate these models which gives RMSE and MAPE of >>> each model. I would like to provide scores (eg. out of 5) for each model >>> based on the performance. For example, if Arima gives a low RMSE than other >>> models, it will be scored high and the second lowest RMSE model will score >>> a less than Arima and so on. >>> >>> And every time i run those models with different input Data [motor2, motor3 >>> ..], it must give the mean score of a model. what I mean to say is, >>> >>> 1. for motor1 it will give scores of each model, let's say *s1*. >>> 2. for motor2 run it give scores of each model, and let's call it *s2*. >>> And i want a mean score of that model every time i run it with different >>> input. It is more like scoring and ranking method. >>> >>> Are there any methods or packages in R that can give a glimpse of how it is >>> done? or any examples? Any suggestions would be very helpful. >> >> The 'switch'-function can dispatch to different functions on the basis of the value of an indicator variable. >> >> >>> >>> Thank you. >>> Dhivya >>> >>> [[alternative HTML version deleted]] >> >> Please read the Posting Guide. Rhelp is a plain text mailing list. >>> >>> ______________________________________________ >>> mailto:[hidden email] 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 >> >> >> >> ------------------------------ >> >> Message: 5 >> Date: Fri, 7 Jul 2017 08:57:50 -0700 >> From: David Winsemius <mailto:[hidden email]> >> To: "Dai, Shengyu" <mailto:[hidden email]> >> Cc: mailto:[hidden email] >> Subject: Re: [R] R loop function in Tableau >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset=utf-8 >> >> >>> On Jul 6, 2017, at 2:19 PM, Dai, Shengyu <mailto:[hidden email]> wrote: >>> >>> Hi R helpers, >>> >>> >>> >>> I hope this email finds you well. >>> >>> >>> >>> I am having trouble with R loop function in Tableau. >>> >> >> There is no "R loop function". (There is an R `for`-function.) If you are having trouble with code then it should be provided. If the problem is with the Tableau code then this is the wrong place. Tableau is not either free or open source. You would in that case need to contact Tableau or get assistance from your academic institution. >> >>> Please see the attachment of a simple dataset. >> >> No data attached. Probably scrubbed by the mail server. Any data needs to be a .txt file. >> >>> The problem is to test whether the value of columns is match. >> >> There is a `match` function. It's vectorized, so may not need to be wrapped with a function that would provide looping. >> >>> >>> Because Tableau do not have iteration function, I coded ?if statement? in Tableau to realize the function, which is slow if having huge amount of data. I wonder to integrate Tableau with R studio to realize this functionality. >>> >>> >>> >>> I did not find too much useful information online and I am asking helps for any examples of related low-level data calculation. >> >> That is then the fault of Tableau (if true), since there is a huge amount of online documentation for R. The Rhelp Archives and StackOverflow have thousands of worked examples of "low-level data calculation". I suspect with estimated probability approaching unity that StackOverflow will have questions tagged jointly with [r] and [tableau]. >> >> >>> >>> Thank you very much. Your helps and supports are really appreciated! >>> >>> >>> >>> Best, >>> >>> >>> >>> -- >>> >>> >>> >>> Shengyu (Freddy) Dai >>> >>> Master of Science in Business Analytics >>> >>> Lally School of Management >>> >>> Rensselaer Polytechnic Institute >>> >>> Mobile: (513)328-5659 >>> >>> >>> >>> ______________________________________________ >>> mailto:[hidden email] 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 >> >> >> >> ------------------------------ >> >> Message: 6 >> Date: Fri, 7 Jul 2017 09:17:34 -0700 >> From: mailto:[hidden email] >> To: Ilia Kats <mailto:[hidden email]> >> Cc: mailto:[hidden email], mailto:[hidden email] >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset=us-ascii >> >> Hi Ilia, >> >> I'm running Arch Linux, R 3.4.0. >> >> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >> >> It doesn't look pixelated to me... >> >> Here's a post that I wrote when I solved my last font problem in R, >> almost 2 years ago: >> >> https://stackoverflow.com/a/40940331/5087283 >> >> I had to install some Microsoft font packages, which is sad, because >> there are some perfectly good free fonts that R could be using >> instead. It could be considered a bug that R requires Microsoft fonts, >> at least by default. However, does this even fix your problem? I.e. if >> you install the corresponding Debian Microsoft font packages, does the >> text appear anti-aliased? >> >> Frederick >> >>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>> [cross-post from R-help] >>> >>> Hi all, >>> >>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>> devices appear pixelated. Here's a minimal example: >>> cairo_pdf('test.pdf') >>> plot(1:10, ylab=expression(italic(test))) >>> dev.off() >>> >>> The same problem occurs with bolditalic, but not bold. I am using Debian >>> Stretch. Several friends tried the same on their machines, another Debian >>> machine has the same problem. On MacOSX the output was not pixelated, but it >>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>> that R somehow can't find the proper font to use and falls back to something >>> weird. Ideas? >>> >>> Note that I'm not subscribed to the list, so please CC me in replies. >>> >>> Cheers, Ilia >>> >>> ______________________________________________ >>> mailto:[hidden email] mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>> >> >> >> >> ------------------------------ >> >> Message: 7 >> Date: Fri, 7 Jul 2017 10:28:44 -0700 >> From: mailto:[hidden email] >> To: Ilia Kats <mailto:[hidden email]> >> Cc: mailto:[hidden email], mailto:[hidden email] >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset=us-ascii >> >>> On Fri, Jul 07, 2017 at 07:08:52PM +0200, Ilia Kats wrote: >>> Interesting. I did not have the package installed, but I did at some point >>> extract Helvetica from some MacOSX font files and R was using that just fine >>> until 3.3. This is how the plot looks in 3.4 (still using Helvetica): >>> https://ptpb.pw/HikX.pdf . After removing Helvetica, installing the >>> ttf-mscorefonts-installer package, and running fc-cache --force the plot >>> looks like this: https://ptpb.pw/CM8A.pdf >> >> The second plot looks worse, in other words, and the Microsoft fonts >> didn't help. >> >> Maybe the Cairo device should be giving better warning messages. >> >> Anyway it sounds like you are describing a regression so maybe someone >> can track down the commit that created this problem. >> >> Thanks, >> >> Frederick >> >> >>> Also note that the standard pdf device works fine: https://ptpb.pw/3Ml1.pdf >>> , it's just the cairo devices (both pdf and svg) that have the issue. >>> Unfortunately I need to use cairo_pdf due to unicode characters in axis >>> labels. >>> >>> Cheers, Ilia >>> >>> >>> -------- Original Message -------- >>> Subject: Re: [Rd] italic font on cairo devices in R 3.4 >>> Date: 2017-07-07 18:17:34 +0200 >>> From: frederik >>> To: Ilia Kats >>> CC: r-devel, r-help >>>> Hi Ilia, >>>> >>>> I'm running Arch Linux, R 3.4.0. >>>> >>>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>>> >>>> It doesn't look pixelated to me... >>>> >>>> Here's a post that I wrote when I solved my last font problem in R, >>>> almost 2 years ago: >>>> >>>> https://stackoverflow.com/a/40940331/5087283 >>>> >>>> I had to install some Microsoft font packages, which is sad, because >>>> there are some perfectly good free fonts that R could be using >>>> instead. It could be considered a bug that R requires Microsoft fonts, >>>> at least by default. However, does this even fix your problem? I.e. if >>>> you install the corresponding Debian Microsoft font packages, does the >>>> text appear anti-aliased? >>>> >>>> Frederick >>>> >>>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>>> [cross-post from R-help] >>>>> >>>>> Hi all, >>>>> >>>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>>> devices appear pixelated. Here's a minimal example: >>>>> cairo_pdf('test.pdf') >>>>> plot(1:10, ylab=expression(italic(test))) >>>>> dev.off() >>>>> >>>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>>> Stretch. Several friends tried the same on their machines, another Debian >>>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>>> that R somehow can't find the proper font to use and falls back to something >>>>> weird. Ideas? >>>>> >>>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>>> >>>>> Cheers, Ilia >>>>> >>>>> ______________________________________________ >>>>> mailto:[hidden email] mailing list >>>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>>> >>> >>> -- >>> The first is to ensure your partner understands that nature has root >>> privileges - nature doesn't have to make sense. >>> -- Telsa Gwynne >>> >> >> >> >> ------------------------------ >> >> Message: 8 >> Date: Fri, 7 Jul 2017 16:52:34 +0000 >> From: Martina Hule?ov? <mailto:[hidden email]> >> To: "mailto:[hidden email]" <mailto:[hidden email]> >> Subject: [R] Beginner s quwry about cfa in lavaan >> Message-ID: >> <mailto:[hidden email]> >> >> Content-Type: text/plain; charset="UTF-8" >> >> Dear all, >> I am trying to learn about R. As a Phd student, I would like to use R for Krippendorff s alpha and later for a series of CFA. Is there any good introduction to these kind of analyses, or could you recommend me some tutorials on youtube, for example? I am new to R, so I need something basic , starting from opening the R environment?. >> Thank you . >> Martina Hulesova >> >> Odesl?no z m?ho Windows Phone >> >> [[alternative HTML version deleted]] >> >> >> ------------------------------ >> >> Message: 9 >> Date: Fri, 7 Jul 2017 19:08:52 +0200 >> From: Ilia Kats <mailto:[hidden email]> >> To: mailto:[hidden email] >> Cc: mailto:[hidden email], mailto:[hidden email] >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset=utf-8; format=flowed >> >> Interesting. I did not have the package installed, but I did at some >> point extract Helvetica from some MacOSX font files and R was using that >> just fine until 3.3. This is how the plot looks in 3.4 (still using >> Helvetica): https://ptpb.pw/HikX.pdf . After removing Helvetica, >> installing the ttf-mscorefonts-installer package, and running fc-cache >> --force the plot looks like this: https://ptpb.pw/CM8A.pdf >> >> Also note that the standard pdf device works fine: >> https://ptpb.pw/3Ml1.pdf , it's just the cairo devices (both pdf and >> svg) that have the issue. Unfortunately I need to use cairo_pdf due to >> unicode characters in axis labels. >> >> Cheers, Ilia >> >> >> -------- Original Message -------- >> Subject: Re: [Rd] italic font on cairo devices in R 3.4 >> Date: 2017-07-07 18:17:34 +0200 >> From: frederik >> To: Ilia Kats >> CC: r-devel, r-help >>> Hi Ilia, >>> >>> I'm running Arch Linux, R 3.4.0. >>> >>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>> >>> It doesn't look pixelated to me... >>> >>> Here's a post that I wrote when I solved my last font problem in R, >>> almost 2 years ago: >>> >>> https://stackoverflow.com/a/40940331/5087283 >>> >>> I had to install some Microsoft font packages, which is sad, because >>> there are some perfectly good free fonts that R could be using >>> instead. It could be considered a bug that R requires Microsoft fonts, >>> at least by default. However, does this even fix your problem? I.e. if >>> you install the corresponding Debian Microsoft font packages, does the >>> text appear anti-aliased? >>> >>> Frederick >>> >>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>> [cross-post from R-help] >>>> >>>> Hi all, >>>> >>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>> devices appear pixelated. Here's a minimal example: >>>> cairo_pdf('test.pdf') >>>> plot(1:10, ylab=expression(italic(test))) >>>> dev.off() >>>> >>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>> Stretch. Several friends tried the same on their machines, another Debian >>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>> that R somehow can't find the proper font to use and falls back to something >>>> weird. Ideas? >>>> >>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>> >>>> Cheers, Ilia >>>> >>>> ______________________________________________ >>>> mailto:[hidden email] mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>> >> >> -- >> The first is to ensure your partner understands that nature has root >> privileges - nature doesn't have to make sense. >> -- Telsa Gwynne >> >> >> >> ------------------------------ >> >> Message: 10 >> Date: Fri, 7 Jul 2017 16:43:12 -0700 >> From: Bert Gunter <mailto:[hidden email]> >> To: Martina Hule?ov? <mailto:[hidden email]> >> Cc: mailto:[hidden email] >> Subject: Re: [R] Beginner s quwry about cfa in lavaan >> Message-ID: >> <mailto:CAGxFJbQ3CgCFXLBGsz9e8y=VLw=9gQKTw7CsoDjy6Feu4=[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Google is your friend. >> >> Also rseek.org >> >> Bert >> >> >> >>> On Jul 7, 2017 3:48 PM, "Martina Hule?ov?" <mailto:[hidden email]> wrote: >>> >>> Dear all, >>> I am trying to learn about R. As a Phd student, I would like to use R for >>> Krippendorff s alpha and later for a series of CFA. Is there any good >>> introduction to these kind of analyses, or could you recommend me some >>> tutorials on youtube, for example? I am new to R, so I need something basic >>> , starting from opening the R environment?. >>> Thank you . >>> Martina Hulesova >>> >>> Odesl?no z m?ho Windows Phone >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> mailto:[hidden email] 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]] >> >> >> >> ------------------------------ >> >> Message: 11 >> Date: Fri, 7 Jul 2017 21:25:42 -0500 >> From: Marc Schwartz <mailto:[hidden email]> >> To: John Kane <mailto:[hidden email]> >> Cc: R R-help <mailto:[hidden email]> >> Subject: Re: [R] Factor vs character in a data.frame vs vector >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset="us-ascii" >> >> >>> On Jul 7, 2017, at 7:03 PM, John Kane <mailto:[hidden email]> wrote: >>> >>> Thanks Marc. >>> It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame. I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. >> >> >> Welcome John. >> >> Going back to the old NEWS files, the 'stringsAsFactors' argument for data.frame() appears in version 2.4.0, which was released on 2006-10-03. >> >> It is possible that somewhere along the way, you set options(stringsAsFactors = FALSE) in your .Rprofile, which would change the default behavior. I know that some folks do that, as they do not like the default coercion to factors, both for data.frame() and for the read.table() family. >> >> Other alternatives would be to use the 'colClasses' argument to explicitly set such vectors to character, or to use I(...) to create AsIs class columns. >> >> Regards, >> >> Marc >> >> >>> >>> >>> >>> On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <mailto:[hidden email]> wrote: >>> >>> >>> >>>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <mailto:[hidden email]> wrote: >>>> >>>> This is not serious problem but I just wonder if someone can explain what is happening. >>>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask. >>>> Thanks >>>> >>>> #================================================ >>>> dat1 <- data.frame(aa = letters[1:10]) >>>> str(dat1) >>>> data.frame': 10 obs. of 1 variable: >>>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>>> bb = letters[1:10] >>>> str(bb) >>>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>>> #============================================================== >>>> >>> >>> >>> See the 'stringsAsFactors' argument in ?data.frame. >>> >>> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >>> >>> >>>> str(dat1) >>> 'data.frame': 10 obs. of 1 variable: >>> >>> $ aa: chr "a" "b" "c" "d" ... >>> >>> >>> Regards, >>> >>> Marc Schwartz >>> >> >> >> >> ------------------------------ >> >> Message: 12 >> Date: Sat, 8 Jul 2017 00:03:19 +0000 >> From: John Kane <mailto:[hidden email]> >> To: Marc Schwartz <mailto:[hidden email]> >> Cc: R R-help <mailto:[hidden email]> >> Subject: Re: [R] Factor vs character in a data.frame vs vector >> Message-ID: <mailto:[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Thanks Marc. It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame.? I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. >> >> >> On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <mailto:[hidden email]> wrote: >> >> >>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <mailto:[hidden email]> wrote: >>> >>> This is not? serious problem but I just wonder if someone can explain what is happening. >>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character.? It's probably something simple that I have read and forgotten but I thought I'd ask. >>> Thanks >>> >>> #================================================ >>> dat1 <- data.frame(aa = letters[1:10]) >>> str(dat1) >>> data.frame':? ? 10 obs. of? 1 variable: >>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>> bb = letters[1:10] >>> str(bb) >>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>> #============================================================== >>> >> >> >> See the 'stringsAsFactors' argument in ?data.frame. >> >> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >> >>> str(dat1) >> 'data.frame':??? 10 obs. of? 1 variable: >> $ aa: chr? "a" "b" "c" "d" ... >> >> >> Regards, >> >> Marc Schwartz >> >> [[alternative HTML version deleted]] >> >> >> >> ------------------------------ >> >> Message: 13 >> Date: Sat, 8 Jul 2017 01:11:10 -0400 >> From: Yixuan Qiu <mailto:[hidden email]> >> To: mailto:[hidden email] >> Cc: mailto:[hidden email], r-help <mailto:[hidden email]> >> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >> Message-ID: >> <mailto:CAFr_7yFTMPers4D9P_vaPW5=[hidden email]> >> Content-Type: text/plain; charset="UTF-8" >> >> Hi Ilia, >> >> You may want to have a try of the showtext package >> (https://github.com/yixuan/showtext). Below is a quick example: >> >> library(showtext) >> showtext.auto() >> >> pdf("test.pdf") >> ## Use the "sans" font family provided by the showtext package >> ## font == 3 means italic font face >> plot(1, xlab = "Unicode characters: \u00C0 \u00C6 \u00D8", >> family = "sans", font.lab = 3) >> dev.off() >> >> ## Same for SVG >> svg("test.svg") >> plot(1, xlab = "Unicode characters: \u00C0 \u00C6 \u00D8", >> family = "sans", font.lab = 3) >> dev.off() >> >> >> Best, >> Yixuan >> >> >> 2017-07-07 13:08 GMT-04:00 Ilia Kats <mailto:[hidden email]>: >>> Interesting. I did not have the package installed, but I did at some point >>> extract Helvetica from some MacOSX font files and R was using that just fine >>> until 3.3. This is how the plot looks in 3.4 (still using Helvetica): >>> https://ptpb.pw/HikX.pdf . After removing Helvetica, installing the >>> ttf-mscorefonts-installer package, and running fc-cache --force the plot >>> looks like this: https://ptpb.pw/CM8A.pdf >>> >>> Also note that the standard pdf device works fine: https://ptpb.pw/3Ml1.pdf >>> , it's just the cairo devices (both pdf and svg) that have the issue. >>> Unfortunately I need to use cairo_pdf due to unicode characters in axis >>> labels. >>> >>> Cheers, Ilia >>> >> >> >> >> >> -- >> Yixuan Qiu <mailto:[hidden email]> >> Department of Statistics, >> Purdue University >> >> >> >> ------------------------------ >> >> Subject: Digest Footer >> >> _______________________________________________ >> mailto:[hidden email] 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. >> >> ------------------------------ >> >> End of R-help Digest, Vol 173, Issue 8 >> ************************************** [[alternative HTML version deleted]] ______________________________________________ mailto:[hidden email] 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. ______________________________________________ [hidden email] 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. |
Jason,
Many thanks for your email and the kind assistance provided. This is very beautiful code that it is a joy to work through, especially so for a beginner like me. I have a couple of quick comments/questions as follows;- - I made a mistake in specifying L, it should be 7.5e6, which makes far more sense - do you use 7 in the sim function as it is a more than adequate limit given the level of lambda.risk here, please? - shouldn't the i<-freq>1:7 line actually be i<-freq>=1:7? - excuse my ignorance, but how does the breaks=7 argument impact the sim function? I had made some progress with my own version, which now incorporates a second Poisson distribution for catastrophe losses, as follows;- L<-c(2.5e6,7.5e6,22.5e6) ln<-c(15.08707, 0.8592507) lambda<-c(2,0.4) iterations<-replicate(10000,{ freq<-(qpois(runif(2),lambda)) i<-1 temp<-0 while (i<=freq[1]){ sev<-pmin(L[2],pmax(0,(qlnorm(runif(1),ln[1],ln[2])-L[1]))) temp<-temp+sev i<-i+1} min(L[3],(temp+(freq[2]*L[2])))}) However, your approach is much simpler and more elegant. Thank you again for the insights. Best regards, Tony Anthony A H Egerton MA MBA ACII 李晋唐 HUNTINGTON UNDERWRITING LIMITED Labuan FT, Malaysia CONFIDENTIALITY NOTE: The information contained in this email message may be legally privileged and contain confidential information and is intended only for the use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copy of this message is strictly prohibited. If you have received this email in error, please immediately delete this message. > On 2 Aug 2017, at 5:13 AM, Law, Jason <[hidden email]> wrote: > > Tony, > > I’m not sure what exactly you’re trying to do, but you're not really taking advantage of vectorization in your R code. I've tried to clean it up a little. The clamped lognormal is almost always 0 or L? That seems a little odd. You seem to be using the inverse cdf method of drawing samples. That's not necessary in R for standard probability distributions. You may want to do a little more investigating of basic programming tasks in R before you dig into a complex simulation. > > scale <- 15.08707 > shape <- 0.8592507 > lambda.risk <- 1.75 > L <- 7.5e5 > R <- 2.5e6 > > # Generate n random poisson with rate = lambda.risk > frequency <- function(n) rpois(n,lambda.risk) > > # clamp a numeric to 0, L > clamp <- function(x, min, max) pmin(max, pmax(min, x)) > > # Generate lognormal shifted by R > severity <- function(n) rlnorm(n,scale,shape)-R > > clamp(severity(100), 0, L) # Lognormal shifted left by R, and then clamped between 0 and L? Almost always equal to 0 or L > > sim <- function(breaks = 7){ > freq <- frequency(1) > i <- freq > 1:7 > sev <- clamp(severity(sum(i)), 0, L) > claims <- rep(0, 7) > claims[i] <- sev > min(22.5e6,sum(claims)) > } > > hist(iterations <- replicate(10000, sim()), breaks = 20) > > > > From: R-help [mailto:[hidden email]] On Behalf Of HUL-Anthony Egerton > Sent: Friday, July 14, 2017 7:45 PM > To: [hidden email] > Subject: Re: [R] One Dimensional Monte Carlo Simulation > > Further to my email below, I have just realised that I forgot to include the specification of L and R. > > Hence, the code needs to include the following additional lines at the start;- > > L<-7.5e6 > R<-2.5e6 > > Apologies for any confusion caused! > > Best regards, > > Tony > > >> On 12 Jul 2017, at 10:03 AM, HUL-Anthony Egerton <mailto:[hidden email]> wrote: >> >> I am trying to code a basic Monte Carlo Simulation in R where a Poisson distribution generates a frequency output that is then input into a Lognormal distribution, which produces a different, independent severity for each incidence. The individual incidences are then summed to produce an aggregate amount per period/iteration. >> >> Here is the code;- >> >> scale<-15.08707 >> shape<-0.8592507 >> lambda.risk<-1.75 >> L<-7.5e5 >> R<-2.5e6 >> iterations<-replicate(10000,{ >> claims1<-0 >> claims2<-0 >> claims3<-0 >> claims4<-0 >> claims5<-0 >> claims6<-0 >> claims7<-0 >> claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7) >> freq<-(qpois(runif(1),lambda.risk)) >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if(freq>=1){claims1<-sev} >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if(freq>=2){claims2<-sev} >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if (freq>=3) {claims3<-sev} >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if (freq>=4) {claims4<-sev} >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if (freq>=5) {claims5<-sev} >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if (freq>=6) {claims6<-sev} >> sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) >> if (freq>=7) {claims7<-sev} >> claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7) >> min(22.5e6,sum(claims)) >> }) >> >> I am new to R, but am sure that there must be a simpler way to code this process. >> >> Furthermore, as the Poisson lambda increases, there is a need to include provision for potentially more incidences, which will require a manual expansion of the code to claims8, claims9 etc. >> >> Can you assist, please? >> >> Best regards, >> >> Anthony A H Egerton MA MBA ACII >> ����� >> HUNTINGTON UNDERWRITING LIMITED >> Labuan FT, Malaysia >> >> >> >> CONFIDENTIALITY NOTE: >> >> The information contained in this email message may be legally privileged and contain confidential information and is intended only for the use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copy of this message is strictly prohibited. If you have received this email in error, please immediately delete this message. >> >> Begin forwarded message: >> >>> From: mailto:[hidden email] >>> Date: 8 July 2017 at 6:00:02 PM SGT >>> To: mailto:[hidden email] >>> Subject: R-help Digest, Vol 173, Issue 8 >>> Reply-To: mailto:[hidden email] >>> >>> Send R-help mailing list submissions to >>> mailto:[hidden email] >>> >>> To subscribe or unsubscribe via the World Wide Web, visit >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> or, via email, send a message with subject or body 'help' to >>> mailto:[hidden email] >>> >>> You can reach the person managing the list at >>> mailto:[hidden email] >>> >>> When replying, please edit your Subject line so it is more specific >>> than "Re: Contents of R-help digest..." >>> >>> >>> Today's Topics: >>> >>> 1. R loop function in Tableau (Dai, Shengyu) >>> 2. Factor vs character in a data.frame vs vector (John Kane) >>> 3. Re: Factor vs character in a data.frame vs vector (Marc Schwartz) >>> 4. Re: Scoring and Ranking Methods (David Winsemius) >>> 5. Re: R loop function in Tableau (David Winsemius) >>> 6. Re: [Rd] italic font on cairo devices in R 3.4 (mailto:[hidden email]) >>> 7. Re: [Rd] italic font on cairo devices in R 3.4 (mailto:[hidden email]) >>> 8. Beginner s quwry about cfa in lavaan (Martina Hule?ov?) >>> 9. Re: [Rd] italic font on cairo devices in R 3.4 (Ilia Kats) >>> 10. Re: Beginner s quwry about cfa in lavaan (Bert Gunter) >>> 11. Re: Factor vs character in a data.frame vs vector (Marc Schwartz) >>> 12. Re: Factor vs character in a data.frame vs vector (John Kane) >>> 13. Re: [Rd] italic font on cairo devices in R 3.4 (Yixuan Qiu) >>> >>> >>> ---------------------------------------------------------------------- >>> >>> Message: 1 >>> Date: Thu, 06 Jul 2017 17:19:47 -0400 >>> From: "Dai, Shengyu" <mailto:[hidden email]> >>> To: <mailto:[hidden email]> >>> Subject: [R] R loop function in Tableau >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset="UTF-8" >>> >>> Hi R helpers, >>> >>> >>> >>> I hope this email finds you well. >>> >>> >>> >>> I am having trouble with R loop function in Tableau. Please see the attachment of a simple dataset. The problem is to test whether the value of columns is match. >>> >>> >>> >>> Because Tableau do not have iteration function, I coded ?if statement? in Tableau to realize the function, which is slow if having huge amount of data. I wonder to integrate Tableau with R studio to realize this functionality. >>> >>> >>> >>> I did not find too much useful information online and I am asking helps for any examples of related low-level data calculation. >>> >>> >>> >>> Thank you very much. Your helps and supports are really appreciated! >>> >>> >>> >>> Best, >>> >>> >>> >>> -- >>> >>> >>> >>> Shengyu (Freddy) Dai >>> >>> Master of Science in Business Analytics >>> >>> Lally School of Management >>> >>> Rensselaer Polytechnic Institute >>> >>> Mobile: (513)328-5659 >>> >>> >>> >>> >>> >>> ------------------------------ >>> >>> Message: 2 >>> Date: Fri, 7 Jul 2017 11:03:51 +0000 >>> From: John Kane <mailto:[hidden email]> >>> To: R R-help <mailto:[hidden email]> >>> Subject: [R] Factor vs character in a data.frame vs vector >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset="UTF-8" >>> >>> This is not? serious problem but I just wonder if someone can explain what is happening. >>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character.? It's probably something simple that I have read and forgotten but I thought I'd ask. >>> Thanks >>> >>> #================================================ >>> dat1 <- data.frame(aa = letters[1:10]) >>> str(dat1) >>> data.frame':????10 obs. of??1 variable: >>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>> bb = letters[1:10] >>> str(bb) >>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>> #============================================================== >>> >>> >>> [[alternative HTML version deleted]] >>> >>> >>> >>> ------------------------------ >>> >>> Message: 3 >>> Date: Fri, 7 Jul 2017 09:37:12 -0500 >>> From: Marc Schwartz <mailto:[hidden email]> >>> To: John Kane <mailto:[hidden email]> >>> Cc: R R-help <mailto:[hidden email]> >>> Subject: Re: [R] Factor vs character in a data.frame vs vector >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset="us-ascii" >>> >>> >>>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <mailto:[hidden email]> wrote: >>>> >>>> This is not serious problem but I just wonder if someone can explain what is happening. >>>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask. >>>> Thanks >>>> >>>> #================================================ >>>> dat1 <- data.frame(aa = letters[1:10]) >>>> str(dat1) >>>> data.frame': 10 obs. of 1 variable: >>>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>>> bb = letters[1:10] >>>> str(bb) >>>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>>> #============================================================== >>>> >>> >>> >>> See the 'stringsAsFactors' argument in ?data.frame. >>> >>> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >>> >>>> str(dat1) >>> 'data.frame': 10 obs. of 1 variable: >>> $ aa: chr "a" "b" "c" "d" ... >>> >>> >>> Regards, >>> >>> Marc Schwartz >>> >>> >>> >>> ------------------------------ >>> >>> Message: 4 >>> Date: Fri, 7 Jul 2017 08:47:57 -0700 >>> From: David Winsemius <mailto:[hidden email]> >>> To: Dhivya Narayanasamy <mailto:[hidden email]> >>> Cc: r-help mailing list <mailto:[hidden email]> >>> Subject: Re: [R] Scoring and Ranking Methods >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset=us-ascii >>> >>> >>>> On Jul 7, 2017, at 2:29 AM, Dhivya Narayanasamy <mailto:[hidden email]> wrote: >>>> >>>> Hi, >>>> >>>> I am doing predictive modelling of Multivariate Time series Data of a Motor >>>> in R using various models such as Arima, H2O.Randomforest, glmnet, lm and >>>> few other models. >>>> >>>> I created a function to select a model of our choice and do prediction. >>>> >>>> Model1 <- function(){ >>>> .. >>>> return() >>>> } >>> >>> That looks like a prescription for serious disappointment. I seriously doubt that you have done any testing using similar code. You would have created a function that returns NULL. I get the sense that you need to study and work through the examples in the "Introduction to R" document. >>> >>> >>> >>>> Model2 <- function(){ >>>> ... >>>> return() >>>> } >>>> Model3 <- function(){ >>>> ... >>>> return() >>>> } >>>> main <- function(n){ >>>> if(n == 1) { >>>> Model1() >>>> } >>>> else if(n == 2){ >>>> Model2() >>>> } >>>> else if(n == 3){ >>>> Model3() >>>> }} >>>> Now I am supposed to automate these models which gives RMSE and MAPE of >>>> each model. I would like to provide scores (eg. out of 5) for each model >>>> based on the performance. For example, if Arima gives a low RMSE than other >>>> models, it will be scored high and the second lowest RMSE model will score >>>> a less than Arima and so on. >>>> >>>> And every time i run those models with different input Data [motor2, motor3 >>>> ..], it must give the mean score of a model. what I mean to say is, >>>> >>>> 1. for motor1 it will give scores of each model, let's say *s1*. >>>> 2. for motor2 run it give scores of each model, and let's call it *s2*. >>>> And i want a mean score of that model every time i run it with different >>>> input. It is more like scoring and ranking method. >>>> >>>> Are there any methods or packages in R that can give a glimpse of how it is >>>> done? or any examples? Any suggestions would be very helpful. >>> >>> The 'switch'-function can dispatch to different functions on the basis of the value of an indicator variable. >>> >>> >>>> >>>> Thank you. >>>> Dhivya >>>> >>>> [[alternative HTML version deleted]] >>> >>> Please read the Posting Guide. Rhelp is a plain text mailing list. >>>> >>>> ______________________________________________ >>>> mailto:[hidden email] 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 >>> >>> >>> >>> ------------------------------ >>> >>> Message: 5 >>> Date: Fri, 7 Jul 2017 08:57:50 -0700 >>> From: David Winsemius <mailto:[hidden email]> >>> To: "Dai, Shengyu" <mailto:[hidden email]> >>> Cc: mailto:[hidden email] >>> Subject: Re: [R] R loop function in Tableau >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset=utf-8 >>> >>> >>>> On Jul 6, 2017, at 2:19 PM, Dai, Shengyu <mailto:[hidden email]> wrote: >>>> >>>> Hi R helpers, >>>> >>>> >>>> >>>> I hope this email finds you well. >>>> >>>> >>>> >>>> I am having trouble with R loop function in Tableau. >>>> >>> >>> There is no "R loop function". (There is an R `for`-function.) If you are having trouble with code then it should be provided. If the problem is with the Tableau code then this is the wrong place. Tableau is not either free or open source. You would in that case need to contact Tableau or get assistance from your academic institution. >>> >>>> Please see the attachment of a simple dataset. >>> >>> No data attached. Probably scrubbed by the mail server. Any data needs to be a .txt file. >>> >>>> The problem is to test whether the value of columns is match. >>> >>> There is a `match` function. It's vectorized, so may not need to be wrapped with a function that would provide looping. >>> >>>> >>>> Because Tableau do not have iteration function, I coded ?if statement? in Tableau to realize the function, which is slow if having huge amount of data. I wonder to integrate Tableau with R studio to realize this functionality. >>>> >>>> >>>> >>>> I did not find too much useful information online and I am asking helps for any examples of related low-level data calculation. >>> >>> That is then the fault of Tableau (if true), since there is a huge amount of online documentation for R. The Rhelp Archives and StackOverflow have thousands of worked examples of "low-level data calculation". I suspect with estimated probability approaching unity that StackOverflow will have questions tagged jointly with [r] and [tableau]. >>> >>> >>>> >>>> Thank you very much. Your helps and supports are really appreciated! >>>> >>>> >>>> >>>> Best, >>>> >>>> >>>> >>>> -- >>>> >>>> >>>> >>>> Shengyu (Freddy) Dai >>>> >>>> Master of Science in Business Analytics >>>> >>>> Lally School of Management >>>> >>>> Rensselaer Polytechnic Institute >>>> >>>> Mobile: (513)328-5659 >>>> >>>> >>>> >>>> ______________________________________________ >>>> mailto:[hidden email] 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 >>> >>> >>> >>> ------------------------------ >>> >>> Message: 6 >>> Date: Fri, 7 Jul 2017 09:17:34 -0700 >>> From: mailto:[hidden email] >>> To: Ilia Kats <mailto:[hidden email]> >>> Cc: mailto:[hidden email], mailto:[hidden email] >>> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset=us-ascii >>> >>> Hi Ilia, >>> >>> I'm running Arch Linux, R 3.4.0. >>> >>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>> >>> It doesn't look pixelated to me... >>> >>> Here's a post that I wrote when I solved my last font problem in R, >>> almost 2 years ago: >>> >>> https://stackoverflow.com/a/40940331/5087283 >>> >>> I had to install some Microsoft font packages, which is sad, because >>> there are some perfectly good free fonts that R could be using >>> instead. It could be considered a bug that R requires Microsoft fonts, >>> at least by default. However, does this even fix your problem? I.e. if >>> you install the corresponding Debian Microsoft font packages, does the >>> text appear anti-aliased? >>> >>> Frederick >>> >>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>> [cross-post from R-help] >>>> >>>> Hi all, >>>> >>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>> devices appear pixelated. Here's a minimal example: >>>> cairo_pdf('test.pdf') >>>> plot(1:10, ylab=expression(italic(test))) >>>> dev.off() >>>> >>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>> Stretch. Several friends tried the same on their machines, another Debian >>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>> that R somehow can't find the proper font to use and falls back to something >>>> weird. Ideas? >>>> >>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>> >>>> Cheers, Ilia >>>> >>>> ______________________________________________ >>>> mailto:[hidden email] mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>> >>> >>> >>> >>> ------------------------------ >>> >>> Message: 7 >>> Date: Fri, 7 Jul 2017 10:28:44 -0700 >>> From: mailto:[hidden email] >>> To: Ilia Kats <mailto:[hidden email]> >>> Cc: mailto:[hidden email], mailto:[hidden email] >>> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset=us-ascii >>> >>>> On Fri, Jul 07, 2017 at 07:08:52PM +0200, Ilia Kats wrote: >>>> Interesting. I did not have the package installed, but I did at some point >>>> extract Helvetica from some MacOSX font files and R was using that just fine >>>> until 3.3. This is how the plot looks in 3.4 (still using Helvetica): >>>> https://ptpb.pw/HikX.pdf . After removing Helvetica, installing the >>>> ttf-mscorefonts-installer package, and running fc-cache --force the plot >>>> looks like this: https://ptpb.pw/CM8A.pdf >>> >>> The second plot looks worse, in other words, and the Microsoft fonts >>> didn't help. >>> >>> Maybe the Cairo device should be giving better warning messages. >>> >>> Anyway it sounds like you are describing a regression so maybe someone >>> can track down the commit that created this problem. >>> >>> Thanks, >>> >>> Frederick >>> >>> >>>> Also note that the standard pdf device works fine: https://ptpb.pw/3Ml1.pdf >>>> , it's just the cairo devices (both pdf and svg) that have the issue. >>>> Unfortunately I need to use cairo_pdf due to unicode characters in axis >>>> labels. >>>> >>>> Cheers, Ilia >>>> >>>> >>>> -------- Original Message -------- >>>> Subject: Re: [Rd] italic font on cairo devices in R 3.4 >>>> Date: 2017-07-07 18:17:34 +0200 >>>> From: frederik >>>> To: Ilia Kats >>>> CC: r-devel, r-help >>>>> Hi Ilia, >>>>> >>>>> I'm running Arch Linux, R 3.4.0. >>>>> >>>>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>>>> >>>>> It doesn't look pixelated to me... >>>>> >>>>> Here's a post that I wrote when I solved my last font problem in R, >>>>> almost 2 years ago: >>>>> >>>>> https://stackoverflow.com/a/40940331/5087283 >>>>> >>>>> I had to install some Microsoft font packages, which is sad, because >>>>> there are some perfectly good free fonts that R could be using >>>>> instead. It could be considered a bug that R requires Microsoft fonts, >>>>> at least by default. However, does this even fix your problem? I.e. if >>>>> you install the corresponding Debian Microsoft font packages, does the >>>>> text appear anti-aliased? >>>>> >>>>> Frederick >>>>> >>>>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>>>> [cross-post from R-help] >>>>>> >>>>>> Hi all, >>>>>> >>>>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>>>> devices appear pixelated. Here's a minimal example: >>>>>> cairo_pdf('test.pdf') >>>>>> plot(1:10, ylab=expression(italic(test))) >>>>>> dev.off() >>>>>> >>>>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>>>> Stretch. Several friends tried the same on their machines, another Debian >>>>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>>>> that R somehow can't find the proper font to use and falls back to something >>>>>> weird. Ideas? >>>>>> >>>>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>>>> >>>>>> Cheers, Ilia >>>>>> >>>>>> ______________________________________________ >>>>>> mailto:[hidden email] mailing list >>>>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>>>> >>>> >>>> -- >>>> The first is to ensure your partner understands that nature has root >>>> privileges - nature doesn't have to make sense. >>>> -- Telsa Gwynne >>>> >>> >>> >>> >>> ------------------------------ >>> >>> Message: 8 >>> Date: Fri, 7 Jul 2017 16:52:34 +0000 >>> From: Martina Hule?ov? <mailto:[hidden email]> >>> To: "mailto:[hidden email]" <mailto:[hidden email]> >>> Subject: [R] Beginner s quwry about cfa in lavaan >>> Message-ID: >>> <mailto:[hidden email]> >>> >>> Content-Type: text/plain; charset="UTF-8" >>> >>> Dear all, >>> I am trying to learn about R. As a Phd student, I would like to use R for Krippendorff s alpha and later for a series of CFA. Is there any good introduction to these kind of analyses, or could you recommend me some tutorials on youtube, for example? I am new to R, so I need something basic , starting from opening the R environment?. >>> Thank you . >>> Martina Hulesova >>> >>> Odesl?no z m?ho Windows Phone >>> >>> [[alternative HTML version deleted]] >>> >>> >>> ------------------------------ >>> >>> Message: 9 >>> Date: Fri, 7 Jul 2017 19:08:52 +0200 >>> From: Ilia Kats <mailto:[hidden email]> >>> To: mailto:[hidden email] >>> Cc: mailto:[hidden email], mailto:[hidden email] >>> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset=utf-8; format=flowed >>> >>> Interesting. I did not have the package installed, but I did at some >>> point extract Helvetica from some MacOSX font files and R was using that >>> just fine until 3.3. This is how the plot looks in 3.4 (still using >>> Helvetica): https://ptpb.pw/HikX.pdf . After removing Helvetica, >>> installing the ttf-mscorefonts-installer package, and running fc-cache >>> --force the plot looks like this: https://ptpb.pw/CM8A.pdf >>> >>> Also note that the standard pdf device works fine: >>> https://ptpb.pw/3Ml1.pdf , it's just the cairo devices (both pdf and >>> svg) that have the issue. Unfortunately I need to use cairo_pdf due to >>> unicode characters in axis labels. >>> >>> Cheers, Ilia >>> >>> >>> -------- Original Message -------- >>> Subject: Re: [Rd] italic font on cairo devices in R 3.4 >>> Date: 2017-07-07 18:17:34 +0200 >>> From: frederik >>> To: Ilia Kats >>> CC: r-devel, r-help >>>> Hi Ilia, >>>> >>>> I'm running Arch Linux, R 3.4.0. >>>> >>>> Here's my test.pdf from your minimal example: https://ptpb.pw/HxsA.pdf >>>> >>>> It doesn't look pixelated to me... >>>> >>>> Here's a post that I wrote when I solved my last font problem in R, >>>> almost 2 years ago: >>>> >>>> https://stackoverflow.com/a/40940331/5087283 >>>> >>>> I had to install some Microsoft font packages, which is sad, because >>>> there are some perfectly good free fonts that R could be using >>>> instead. It could be considered a bug that R requires Microsoft fonts, >>>> at least by default. However, does this even fix your problem? I.e. if >>>> you install the corresponding Debian Microsoft font packages, does the >>>> text appear anti-aliased? >>>> >>>> Frederick >>>> >>>>> On Fri, Jul 07, 2017 at 10:30:46AM +0200, Ilia Kats wrote: >>>>> [cross-post from R-help] >>>>> >>>>> Hi all, >>>>> >>>>> I have the following problem: Since R 3.4.0, italic fonts rendered on Cairo >>>>> devices appear pixelated. Here's a minimal example: >>>>> cairo_pdf('test.pdf') >>>>> plot(1:10, ylab=expression(italic(test))) >>>>> dev.off() >>>>> >>>>> The same problem occurs with bolditalic, but not bold. I am using Debian >>>>> Stretch. Several friends tried the same on their machines, another Debian >>>>> machine has the same problem. On MacOSX the output was not pixelated, but it >>>>> wasn't italic either. Ubuntu 16.04.2 xenial works fine. My impression is >>>>> that R somehow can't find the proper font to use and falls back to something >>>>> weird. Ideas? >>>>> >>>>> Note that I'm not subscribed to the list, so please CC me in replies. >>>>> >>>>> Cheers, Ilia >>>>> >>>>> ______________________________________________ >>>>> mailto:[hidden email] mailing list >>>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>>> >>> >>> -- >>> The first is to ensure your partner understands that nature has root >>> privileges - nature doesn't have to make sense. >>> -- Telsa Gwynne >>> >>> >>> >>> ------------------------------ >>> >>> Message: 10 >>> Date: Fri, 7 Jul 2017 16:43:12 -0700 >>> From: Bert Gunter <mailto:[hidden email]> >>> To: Martina Hule?ov? <mailto:[hidden email]> >>> Cc: mailto:[hidden email] >>> Subject: Re: [R] Beginner s quwry about cfa in lavaan >>> Message-ID: >>> <mailto:CAGxFJbQ3CgCFXLBGsz9e8y=VLw=9gQKTw7CsoDjy6Feu4=[hidden email]> >>> Content-Type: text/plain; charset="UTF-8" >>> >>> Google is your friend. >>> >>> Also rseek.org >>> >>> Bert >>> >>> >>> >>>> On Jul 7, 2017 3:48 PM, "Martina Hule?ov?" <mailto:[hidden email]> wrote: >>>> >>>> Dear all, >>>> I am trying to learn about R. As a Phd student, I would like to use R for >>>> Krippendorff s alpha and later for a series of CFA. Is there any good >>>> introduction to these kind of analyses, or could you recommend me some >>>> tutorials on youtube, for example? I am new to R, so I need something basic >>>> , starting from opening the R environment?. >>>> Thank you . >>>> Martina Hulesova >>>> >>>> Odesl?no z m?ho Windows Phone >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> mailto:[hidden email] 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]] >>> >>> >>> >>> ------------------------------ >>> >>> Message: 11 >>> Date: Fri, 7 Jul 2017 21:25:42 -0500 >>> From: Marc Schwartz <mailto:[hidden email]> >>> To: John Kane <mailto:[hidden email]> >>> Cc: R R-help <mailto:[hidden email]> >>> Subject: Re: [R] Factor vs character in a data.frame vs vector >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset="us-ascii" >>> >>> >>>> On Jul 7, 2017, at 7:03 PM, John Kane <mailto:[hidden email]> wrote: >>>> >>>> Thanks Marc. >>>> It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame. I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. >>> >>> >>> Welcome John. >>> >>> Going back to the old NEWS files, the 'stringsAsFactors' argument for data.frame() appears in version 2.4.0, which was released on 2006-10-03. >>> >>> It is possible that somewhere along the way, you set options(stringsAsFactors = FALSE) in your .Rprofile, which would change the default behavior. I know that some folks do that, as they do not like the default coercion to factors, both for data.frame() and for the read.table() family. >>> >>> Other alternatives would be to use the 'colClasses' argument to explicitly set such vectors to character, or to use I(...) to create AsIs class columns. >>> >>> Regards, >>> >>> Marc >>> >>> >>>> >>>> >>>> >>>> On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <mailto:[hidden email]> wrote: >>>> >>>> >>>> >>>>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <mailto:[hidden email]> wrote: >>>>> >>>>> This is not serious problem but I just wonder if someone can explain what is happening. >>>>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask. >>>>> Thanks >>>>> >>>>> #================================================ >>>>> dat1 <- data.frame(aa = letters[1:10]) >>>>> str(dat1) >>>>> data.frame': 10 obs. of 1 variable: >>>>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>>>> bb = letters[1:10] >>>>> str(bb) >>>>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>>>> #============================================================== >>>>> >>>> >>>> >>>> See the 'stringsAsFactors' argument in ?data.frame. >>>> >>>> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >>>> >>>> >>>>> str(dat1) >>>> 'data.frame': 10 obs. of 1 variable: >>>> >>>> $ aa: chr "a" "b" "c" "d" ... >>>> >>>> >>>> Regards, >>>> >>>> Marc Schwartz >>>> >>> >>> >>> >>> ------------------------------ >>> >>> Message: 12 >>> Date: Sat, 8 Jul 2017 00:03:19 +0000 >>> From: John Kane <mailto:[hidden email]> >>> To: Marc Schwartz <mailto:[hidden email]> >>> Cc: R R-help <mailto:[hidden email]> >>> Subject: Re: [R] Factor vs character in a data.frame vs vector >>> Message-ID: <mailto:[hidden email]> >>> Content-Type: text/plain; charset="UTF-8" >>> >>> Thanks Marc. It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame.? I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. >>> >>> >>> On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <mailto:[hidden email]> wrote: >>> >>> >>>> On Jul 7, 2017, at 6:03 AM, John Kane via R-help <mailto:[hidden email]> wrote: >>>> >>>> This is not? serious problem but I just wonder if someone can explain what is happening. >>>> The same command within a dataframe is giving me a factor and as a plain vector is giving me a character.? It's probably something simple that I have read and forgotten but I thought I'd ask. >>>> Thanks >>>> >>>> #================================================ >>>> dat1 <- data.frame(aa = letters[1:10]) >>>> str(dat1) >>>> data.frame':? ? 10 obs. of? 1 variable: >>>> $ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#============================================================= >>>> bb = letters[1:10] >>>> str(bb) >>>> chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" >>>> #============================================================== >>>> >>> >>> >>> See the 'stringsAsFactors' argument in ?data.frame. >>> >>> dat1 <- data.frame(aa = letters[1:10], stringsAsFactors = FALSE) >>> >>>> str(dat1) >>> 'data.frame':??? 10 obs. of? 1 variable: >>> $ aa: chr? "a" "b" "c" "d" ... >>> >>> >>> Regards, >>> >>> Marc Schwartz >>> >>> [[alternative HTML version deleted]] >>> >>> >>> >>> ------------------------------ >>> >>> Message: 13 >>> Date: Sat, 8 Jul 2017 01:11:10 -0400 >>> From: Yixuan Qiu <mailto:[hidden email]> >>> To: mailto:[hidden email] >>> Cc: mailto:[hidden email], r-help <mailto:[hidden email]> >>> Subject: Re: [R] [Rd] italic font on cairo devices in R 3.4 >>> Message-ID: >>> <mailto:CAFr_7yFTMPers4D9P_vaPW5=[hidden email]> >>> Content-Type: text/plain; charset="UTF-8" >>> >>> Hi Ilia, >>> >>> You may want to have a try of the showtext package >>> (https://github.com/yixuan/showtext). Below is a quick example: >>> >>> library(showtext) >>> showtext.auto() >>> >>> pdf("test.pdf") >>> ## Use the "sans" font family provided by the showtext package >>> ## font == 3 means italic font face >>> plot(1, xlab = "Unicode characters: \u00C0 \u00C6 \u00D8", >>> family = "sans", font.lab = 3) >>> dev.off() >>> >>> ## Same for SVG >>> svg("test.svg") >>> plot(1, xlab = "Unicode characters: \u00C0 \u00C6 \u00D8", >>> family = "sans", font.lab = 3) >>> dev.off() >>> >>> >>> Best, >>> Yixuan >>> >>> >>> 2017-07-07 13:08 GMT-04:00 Ilia Kats <mailto:[hidden email]>: >>>> Interesting. I did not have the package installed, but I did at some point >>>> extract Helvetica from some MacOSX font files and R was using that just fine >>>> until 3.3. This is how the plot looks in 3.4 (still using Helvetica): >>>> https://ptpb.pw/HikX.pdf . After removing Helvetica, installing the >>>> ttf-mscorefonts-installer package, and running fc-cache --force the plot >>>> looks like this: https://ptpb.pw/CM8A.pdf >>>> >>>> Also note that the standard pdf device works fine: https://ptpb.pw/3Ml1.pdf >>>> , it's just the cairo devices (both pdf and svg) that have the issue. >>>> Unfortunately I need to use cairo_pdf due to unicode characters in axis >>>> labels. >>>> >>>> Cheers, Ilia >>>> >>> >>> >>> >>> >>> -- >>> Yixuan Qiu <mailto:[hidden email]> >>> Department of Statistics, >>> Purdue University >>> >>> >>> >>> ------------------------------ >>> >>> Subject: Digest Footer >>> >>> _______________________________________________ >>> mailto:[hidden email] 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. >>> >>> ------------------------------ >>> >>> End of R-help Digest, Vol 173, Issue 8 >>> ************************************** > > [[alternative HTML version deleted]] > ______________________________________________ > mailto:[hidden email] 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]] ______________________________________________ [hidden email] 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. |
Free forum by Nabble | Edit this page |