Re: [R] The "--slave" option
> Personally I much prefer backwards compatibility to political correctness. I agree with Rolf, here. And as someone that's planning to write a Linux Terminal Emulator, in the medium-term future, I *strongly* defend this approach. And to the original poster. Haven't you seen The Matrix? (Second best movie ever, after the Shawshank Redemption). I would prefer the technology to be my slave, than I be a prisoner/slave to the technology. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The "--slave" option
On 18/09/19 6:00 PM, Benjamin Lang wrote: Dear R project, I have a very simple question: How, in late 2019, is there an option called "--slave" to "make R run as quietly as possible"? Let me reiterate that it is 2019, i.e. "The Future", rather than 1970 when R was presumably developed, based on its atrocious syntax, documentation and usability (I think I only need to say "NaN", "NULL", and "NA"). This is a disgrace and it should have been addressed one or two decades ago. Why not just "--quiet"? Please do not mention "backwards compatibility". Personally I much prefer backwards compatibility to political correctness. For the historically inclined, it does not make much of a difference whether the term evokes the Roman, Greek, American or modern kind of slavery for you: it is as disgusting as it gets. IMHO this is a precious PC quibble, taking offence where no offence is intended. If you are really concerned about literal slavery --- as everyone should be --- then join/contribute to an appropriate activist organisation (e.g. Amnesty International, which is my personal choice). cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The "--slave" option
I think there is no confusion except in the minds of those with nothing better to do. I agree with Antirez, quoted in [1], which nevertheless indicates that perspective lost the debate. Any accurate alternative notation will have similar connotations because in fact the "slave" side of that relationship is completely subordinate to the "master" side... there is no escaping that fact. It requires a very different and more complicated architecture to achieve a "peer" relationship, which often is not worth the effort or even appropriate. So while Dr Lang may be mollified by a change in notation, someone else is going to find the new words offensive and make the same PC argument since the implications of the architecture have not changed. In fact there should never have been a parallel drawn between the morality of human slavery and computing architectures to begin with. [1] https://www.vice.com/en_us/article/8x7akv/masterslave-terminology-was-removed-from-python-programming-language On September 18, 2019 11:57:32 AM PDT, "Patrick (Malone Quantitative)" wrote: >For what it's worth, this is an ongoing conversation in computer >science and engineering. And has been so for decades. > >Not R, but related to this it's only in the past few months that a >fork of the photo-manipulation software GIMP (slur for handicapped) >renames it (GLIMPSE). > >Note, I am not saying this isn't a battle worth fighting. > >On Wed, Sep 18, 2019 at 1:52 PM Benjamin Lang >wrote: >> >> Dear R project, >> >> I have a very simple question: >> >> How, in late 2019, is there an option called "--slave" to "make R run >as >> quietly as possible"? >> >> Let me reiterate that it is 2019, i.e. "The Future", rather than 1970 >when >> R was presumably developed, based on its atrocious syntax, >documentation >> and usability (I think I only need to say "NaN", "NULL", and "NA"). >> >> This is a disgrace and it should have been addressed one or two >decades >> ago. Why not just "--quiet"? >> >> Please do not mention "backwards compatibility". For the historically >> inclined, it does not make much of a difference whether the term >evokes the >> Roman, Greek, American or modern kind of slavery for you: it is as >> disgusting as it gets. >> >> Thank you, >> Ben >> >> -- >> Benjamin Lang, PhD >> http://orcid.org/-0001-6358-8380 >> >> Marie Sklodowska-Curie Postdoctoral Fellow (MSCA-IF) >> Gene Function and Evolution (Dr. Gian Tartaglia) >> Centre for Genomic Regulation (CRG), Barcelona, Spain >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data conversion
Hi Edward, Say your "data frame" is named "epdat". This may do it: epmat<-matrix(epdat[10:289],nrow=28) colnames(epmat)<-sub("1","",names(epdat[10:289])[seq(1,270,by=28)]) This one looks like the Sorceror's Apprentice tangled with one of those experimental schedule scripting programs. Jim On Thu, Sep 19, 2019 at 7:04 AM Patzelt, Edward wrote: > > Hi R Help, > > How would I convert the data below so that I have it formatted with trials > along the rows and then each type of measure separately? e.g., > Subject RT OnOff Feedback > Trial_1 > Trial_2 > Trial_3 > Trial_4 > > Thanks! > > Edward > > > > > > structure(list(TAP_ID = "967372 ", TAP_Date = NA_real_, TAP_Time = 29700, > TAP_Study = " ", SexOfTarget = "M", > SexOfSubj = "M", OperatorName = "", LowThresh = 220, > HighThresh = 1320, Trial1 = 1, Trial2 = 2, Trial3 = 3, Trial4 = 4, > Trial5 = 5, Trial6 = 6, Trial7 = 7, Trial8 = 8, Trial9 = 9, > Trial10 = 10, Trial11 = 11, Trial12 = 12, Trial13 = 13, Trial14 = 14, > Trial15 = 15, Trial16 = 16, Trial17 = 17, Trial18 = 18, Trial19 = 19, > Trial20 = 20, Trial21 = 21, Trial22 = 22, Trial23 = 23, Trial24 = 24, > Trial25 = 25, Trial26 = 26, Trial27 = 27, Trial28 = 28, ITI1 = 5, > ITI2 = 5, ITI3 = 5, ITI4 = 5, ITI5 = 5, ITI6 = 5, ITI7 = 5, > ITI8 = 5, ITI9 = 5, ITI10 = 5, ITI11 = 5, ITI12 = 5, ITI13 = 5, > ITI14 = 5, ITI15 = 5, ITI16 = 5, ITI17 = 5, ITI18 = 5, ITI19 = 5, > ITI20 = 5, ITI21 = 5, ITI22 = 5, ITI23 = 5, ITI24 = 5, ITI25 = 5, > ITI26 = 5, ITI27 = 5, ITI28 = 5, Shock1 = 0, Shock2 = 0, > Shock3 = 0, Shock4 = 0, Shock5 = 0, Shock6 = 0, Shock7 = 0, > Shock8 = 0, Shock9 = 0, Shock10 = 0, Shock11 = 0, Shock12 = 0, > Shock13 = 0, Shock14 = 0, Shock15 = 0, Shock16 = 0, Shock17 = 0, > Shock18 = 0, Shock19 = 0, Shock20 = 0, Shock21 = 0, Shock22 = 0, > Shock23 = 0, Shock24 = 0, Shock25 = 0, Shock26 = 0, Shock27 = 0, > Shock28 = 0, Delay1 = 1102, Delay2 = 993, Delay3 = 446, Delay4 = 613, > Delay5 = 649, Delay6 = 333, Delay7 = 342, Delay8 = 366, Delay9 = 360, > Delay10 = 307, Delay11 = 372, Delay12 = 335, Delay13 = 328, > Delay14 = 296, Delay15 = 521, Delay16 = 393, Delay17 = 491, > Delay18 = 467, Delay19 = 401, Delay20 = 483, Delay21 = 312, > Delay22 = 311, Delay23 = 274, Delay24 = 348, Delay25 = 422, > Delay26 = 305, Delay27 = 637, Delay28 = 429, Hold1 = 1203, > Hold2 = 598, Hold3 = 1209, Hold4 = 1373, Hold5 = 1170, Hold6 = 1442, > Hold7 = 2192, Hold8 = 1802, Hold9 = 1891, Hold10 = 1880, > Hold11 = 1204, Hold12 = 1597, Hold13 = 809, Hold14 = 848, > Hold15 = 1328, Hold16 = 767, Hold17 = 1053, Hold18 = 1648, > Hold19 = 1365, Hold20 = 1889, Hold21 = 1452, Hold22 = 1468, > Hold23 = 1595, Hold24 = 2060, Hold25 = 1213, Hold26 = 1060, > Hold27 = 745, Hold28 = 1110, RTdelay1 = 800, RTdelay2 = 251, > RTdelay3 = 422, RTdelay4 = 264, RTdelay5 = 397, RTdelay6 = 472, > RTdelay7 = 225, RTdelay8 = 228, RTdelay9 = 430, RTdelay10 = 527, > RTdelay11 = 244, RTdelay12 = 747, RTdelay13 = 269, RTdelay14 = 330, > RTdelay15 = 400, RTdelay16 = 401, RTdelay17 = 394, RTdelay18 = 364, > RTdelay19 = 210, RTdelay20 = 415, RTdelay21 = 267, RTdelay22 = 248, > RTdelay23 = 209, RTdelay24 = 277, RTdelay25 = 498, RTdelay26 = 663, > RTdelay27 = 331, RTdelay28 = 494, RTheld1 = 2318, RTheld2 = 2039, > RTheld3 = 2594, RTheld4 = 2061, RTheld5 = 1501, RTheld6 = 1070, > RTheld7 = 2492, RTheld8 = 1532, RTheld9 = 2034, RTheld10 = 2338, > RTheld11 = 1095, RTheld12 = 2227, RTheld13 = 2402, RTheld14 = 1057, > RTheld15 = 1718, RTheld16 = 1789, RTheld17 = 1611, RTheld18 = 1824, > RTheld19 = 1582, RTheld20 = 2749, RTheld21 = 1407, RTheld22 = 1780, > RTheld23 = 1103, RTheld24 = 1513, RTheld25 = 1562, RTheld26 = 2283, > RTheld27 = 2722, RTheld28 = 2703, RT1 = 284, RT2 = 228, RT3 = 226, > RT4 = 186, RT5 = 208, RT6 = 223, RT7 = 206, RT8 = 189, RT9 = 229, > RT10 = 198, RT11 = 224, RT12 = 203, RT13 = 199, RT14 = 224, > RT15 = 220, RT16 = 208, RT17 = 270, RT18 = 188, RT19 = 205, > RT20 = 191, RT21 = 190, RT22 = 183, RT23 = 193, RT24 = 176, > RT25 = 195, RT26 = 196, RT27 = 185, RT28 = 160, Feedback1 = 2, > Feedback2 = 2, Feedback3 = 3, Feedback4 = 3, Feedback5 = 2, > Feedback6 = 3, Feedback7 = 4, Feedback8 = 5, Feedback9 = 5, > Feedback10 = 6, Feedback11 = 5, Feedback12 = 6, Feedback13 = 6, > Feedback14 = 7, Feedback15 = 9, Feedback16 = 8, Feedback17 = 9, > Feedback18 = 8, Feedback19 = 8, Feedback20 = 9, Feedback21 = 20, > Feedback22 = 9, Feedback23 = 8, Feedback24 = 9, Feedback25 = 8, > Feedback26 = 8, Feedback27 = 9, Feedback28 = 8, OnOff1 = 1, > OnOff2 = 0, OnOff3 = 0, OnOff4 = 1, OnOff5 = 0, OnOff6 = 1, > OnOff7 = 0, OnOff8 = 0, OnOff9 = 1, OnOff10 = 1, OnOff11 = 0, > OnOff12 = 1, OnOff13 = 0, OnOff14 = 1, OnOff15 = 1, OnOff16 = 0, > OnOff17 = 1, OnOff18 = 0, OnOff19 =
[R] Data conversion
Hi R Help, How would I convert the data below so that I have it formatted with trials along the rows and then each type of measure separately? e.g., Subject RT OnOff Feedback Trial_1 Trial_2 Trial_3 Trial_4 Thanks! Edward structure(list(TAP_ID = "967372 ", TAP_Date = NA_real_, TAP_Time = 29700, TAP_Study = " ", SexOfTarget = "M", SexOfSubj = "M", OperatorName = "", LowThresh = 220, HighThresh = 1320, Trial1 = 1, Trial2 = 2, Trial3 = 3, Trial4 = 4, Trial5 = 5, Trial6 = 6, Trial7 = 7, Trial8 = 8, Trial9 = 9, Trial10 = 10, Trial11 = 11, Trial12 = 12, Trial13 = 13, Trial14 = 14, Trial15 = 15, Trial16 = 16, Trial17 = 17, Trial18 = 18, Trial19 = 19, Trial20 = 20, Trial21 = 21, Trial22 = 22, Trial23 = 23, Trial24 = 24, Trial25 = 25, Trial26 = 26, Trial27 = 27, Trial28 = 28, ITI1 = 5, ITI2 = 5, ITI3 = 5, ITI4 = 5, ITI5 = 5, ITI6 = 5, ITI7 = 5, ITI8 = 5, ITI9 = 5, ITI10 = 5, ITI11 = 5, ITI12 = 5, ITI13 = 5, ITI14 = 5, ITI15 = 5, ITI16 = 5, ITI17 = 5, ITI18 = 5, ITI19 = 5, ITI20 = 5, ITI21 = 5, ITI22 = 5, ITI23 = 5, ITI24 = 5, ITI25 = 5, ITI26 = 5, ITI27 = 5, ITI28 = 5, Shock1 = 0, Shock2 = 0, Shock3 = 0, Shock4 = 0, Shock5 = 0, Shock6 = 0, Shock7 = 0, Shock8 = 0, Shock9 = 0, Shock10 = 0, Shock11 = 0, Shock12 = 0, Shock13 = 0, Shock14 = 0, Shock15 = 0, Shock16 = 0, Shock17 = 0, Shock18 = 0, Shock19 = 0, Shock20 = 0, Shock21 = 0, Shock22 = 0, Shock23 = 0, Shock24 = 0, Shock25 = 0, Shock26 = 0, Shock27 = 0, Shock28 = 0, Delay1 = 1102, Delay2 = 993, Delay3 = 446, Delay4 = 613, Delay5 = 649, Delay6 = 333, Delay7 = 342, Delay8 = 366, Delay9 = 360, Delay10 = 307, Delay11 = 372, Delay12 = 335, Delay13 = 328, Delay14 = 296, Delay15 = 521, Delay16 = 393, Delay17 = 491, Delay18 = 467, Delay19 = 401, Delay20 = 483, Delay21 = 312, Delay22 = 311, Delay23 = 274, Delay24 = 348, Delay25 = 422, Delay26 = 305, Delay27 = 637, Delay28 = 429, Hold1 = 1203, Hold2 = 598, Hold3 = 1209, Hold4 = 1373, Hold5 = 1170, Hold6 = 1442, Hold7 = 2192, Hold8 = 1802, Hold9 = 1891, Hold10 = 1880, Hold11 = 1204, Hold12 = 1597, Hold13 = 809, Hold14 = 848, Hold15 = 1328, Hold16 = 767, Hold17 = 1053, Hold18 = 1648, Hold19 = 1365, Hold20 = 1889, Hold21 = 1452, Hold22 = 1468, Hold23 = 1595, Hold24 = 2060, Hold25 = 1213, Hold26 = 1060, Hold27 = 745, Hold28 = 1110, RTdelay1 = 800, RTdelay2 = 251, RTdelay3 = 422, RTdelay4 = 264, RTdelay5 = 397, RTdelay6 = 472, RTdelay7 = 225, RTdelay8 = 228, RTdelay9 = 430, RTdelay10 = 527, RTdelay11 = 244, RTdelay12 = 747, RTdelay13 = 269, RTdelay14 = 330, RTdelay15 = 400, RTdelay16 = 401, RTdelay17 = 394, RTdelay18 = 364, RTdelay19 = 210, RTdelay20 = 415, RTdelay21 = 267, RTdelay22 = 248, RTdelay23 = 209, RTdelay24 = 277, RTdelay25 = 498, RTdelay26 = 663, RTdelay27 = 331, RTdelay28 = 494, RTheld1 = 2318, RTheld2 = 2039, RTheld3 = 2594, RTheld4 = 2061, RTheld5 = 1501, RTheld6 = 1070, RTheld7 = 2492, RTheld8 = 1532, RTheld9 = 2034, RTheld10 = 2338, RTheld11 = 1095, RTheld12 = 2227, RTheld13 = 2402, RTheld14 = 1057, RTheld15 = 1718, RTheld16 = 1789, RTheld17 = 1611, RTheld18 = 1824, RTheld19 = 1582, RTheld20 = 2749, RTheld21 = 1407, RTheld22 = 1780, RTheld23 = 1103, RTheld24 = 1513, RTheld25 = 1562, RTheld26 = 2283, RTheld27 = 2722, RTheld28 = 2703, RT1 = 284, RT2 = 228, RT3 = 226, RT4 = 186, RT5 = 208, RT6 = 223, RT7 = 206, RT8 = 189, RT9 = 229, RT10 = 198, RT11 = 224, RT12 = 203, RT13 = 199, RT14 = 224, RT15 = 220, RT16 = 208, RT17 = 270, RT18 = 188, RT19 = 205, RT20 = 191, RT21 = 190, RT22 = 183, RT23 = 193, RT24 = 176, RT25 = 195, RT26 = 196, RT27 = 185, RT28 = 160, Feedback1 = 2, Feedback2 = 2, Feedback3 = 3, Feedback4 = 3, Feedback5 = 2, Feedback6 = 3, Feedback7 = 4, Feedback8 = 5, Feedback9 = 5, Feedback10 = 6, Feedback11 = 5, Feedback12 = 6, Feedback13 = 6, Feedback14 = 7, Feedback15 = 9, Feedback16 = 8, Feedback17 = 9, Feedback18 = 8, Feedback19 = 8, Feedback20 = 9, Feedback21 = 20, Feedback22 = 9, Feedback23 = 8, Feedback24 = 9, Feedback25 = 8, Feedback26 = 8, Feedback27 = 9, Feedback28 = 8, OnOff1 = 1, OnOff2 = 0, OnOff3 = 0, OnOff4 = 1, OnOff5 = 0, OnOff6 = 1, OnOff7 = 0, OnOff8 = 0, OnOff9 = 1, OnOff10 = 1, OnOff11 = 0, OnOff12 = 1, OnOff13 = 0, OnOff14 = 1, OnOff15 = 1, OnOff16 = 0, OnOff17 = 1, OnOff18 = 0, OnOff19 = 1, OnOff20 = 0, OnOff21 = 0, OnOff22 = 1, OnOff23 = 0, OnOff24 = 1, OnOff25 = 0, OnOff26 = 1, OnOff27 = 0, OnOff28 = 1), class = "data.frame", row.names = c(NA, -1L), variable.labels = c(TAP_ID = "", TAP_Date = "", TAP_Time = "", TAP_Study = "", SexOfTarget = "", SexOfSubj = "", OperatorName = "", LowThresh = "", HighThresh = "", Trial1 = "Trial number 1", Trial2 = "Trial number 2", Trial3 = "Trial number 3", Trial4 = "Trial number 4", Trial5 = "Trial number 5", Trial6 = "Trial number 6",
[R] Problem loading packages in R 3.6.1
I have recently installed R 3.6.1 on my MacBook running Mac OS Mojave 10.14.5 in order to run a custom package called MH1823 (probability of detection). This package requires me to load the following packages from CRAN, tcltk, tcltk2, survival and xlsx. I have installed survival, xlsx and tlctk2 (i believe tcltk is embedded). When I look at Package Manager i see that although the above packages are installed they are not loaded. I can load survival but when I try to load “xlsx” i get the following error message is: Error: package or namespace load failed for ‘xlsx’: .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so': dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so Reason: image not found starting httpd help server … done there may be a couple of hints in here. .onLoad failed in loadNamespace() for 'rJava', details suggests the problem starts with calling rJava. the next line in the error: error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so': I have checked this path and see no problems, everything seems to stack up and I find jJava.so where it is supposed to be. However in the next line: dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib I don’t know what the number , 6 after Java.so means but have presumed version number and may be why Java8 is not working. I also note the path …. /JavaVirtualMachines/jdk-11.0.1.jdk/ appears as . /JavaVirtualMachines/1.6.0.jdk/ suggesting a different build the same occurs when I try to load the local source package MH1823 When I try to load HM1823 I get the error message: * installing *source* package ‘mh1823’ ... ** using staged installation ** R ** data ** inst ** byte-compile and prepare package for lazy loading Error: package or namespace load failed for ‘xlsx’: .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so': dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so Reason: image not found Error: package ‘xlsx’ could not be loaded Execution halted ERROR: lazy loading failed for package ‘mh1823’ * removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/mh1823’ > I find that the error message is substantially the same suggesting rJava and/or the version of Java. I have tried removing Java 8 from my machine and installing Java 6 but don’t see any difference. It is easy to see that Java 8 has been removed but not easy to see that 6 is installed properly as the path names are still the same. When I try to load either tcltk or tcltk2, my instance of R stops responding entirely. I have also installed Xquartz as I believe this is needed for Mac OS X Can anyone provide some advice on what the issue might be? I have tried reading through the FAQ’s but not found anything to point me in the right direction. Regards, Tom Knox [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Not the same length
Ar ! What a pity, I have not seen it ! Many thanks ! Le mercredi 18 septembre 2019 à 19:07:42 UTC+2, peter dalgaard a écrit : Redefining n is probably not a good idea... [...snip...] > m <-runif(n, 0, 5) > n <-rnorm(n, 2, 3) Oops! n is now a vector of length 2000. [...snip...] > y_obs <- y_model +c( rnorm(n*0.97, 0, 0.1), rnorm(n*0.03, 0, 0.5) ) now length(n*0.97) == 2000 > 1, so rnorm(n*0.97, ...) gets you a length 2000 vector (check ?rnorm), and c() of 2 of those is a vector of length 4000. [...etc...] > -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The "--slave" option
For what it's worth, this is an ongoing conversation in computer science and engineering. And has been so for decades. Not R, but related to this it's only in the past few months that a fork of the photo-manipulation software GIMP (slur for handicapped) renames it (GLIMPSE). Note, I am not saying this isn't a battle worth fighting. On Wed, Sep 18, 2019 at 1:52 PM Benjamin Lang wrote: > > Dear R project, > > I have a very simple question: > > How, in late 2019, is there an option called "--slave" to "make R run as > quietly as possible"? > > Let me reiterate that it is 2019, i.e. "The Future", rather than 1970 when > R was presumably developed, based on its atrocious syntax, documentation > and usability (I think I only need to say "NaN", "NULL", and "NA"). > > This is a disgrace and it should have been addressed one or two decades > ago. Why not just "--quiet"? > > Please do not mention "backwards compatibility". For the historically > inclined, it does not make much of a difference whether the term evokes the > Roman, Greek, American or modern kind of slavery for you: it is as > disgusting as it gets. > > Thank you, > Ben > > -- > Benjamin Lang, PhD > http://orcid.org/-0001-6358-8380 > > Marie Sklodowska-Curie Postdoctoral Fellow (MSCA-IF) > Gene Function and Evolution (Dr. Gian Tartaglia) > Centre for Genomic Regulation (CRG), Barcelona, Spain > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The "--slave" option
Dear R project, I have a very simple question: How, in late 2019, is there an option called "--slave" to "make R run as quietly as possible"? Let me reiterate that it is 2019, i.e. "The Future", rather than 1970 when R was presumably developed, based on its atrocious syntax, documentation and usability (I think I only need to say "NaN", "NULL", and "NA"). This is a disgrace and it should have been addressed one or two decades ago. Why not just "--quiet"? Please do not mention "backwards compatibility". For the historically inclined, it does not make much of a difference whether the term evokes the Roman, Greek, American or modern kind of slavery for you: it is as disgusting as it gets. Thank you, Ben -- Benjamin Lang, PhD http://orcid.org/-0001-6358-8380 Marie Sklodowska-Curie Postdoctoral Fellow (MSCA-IF) Gene Function and Evolution (Dr. Gian Tartaglia) Centre for Genomic Regulation (CRG), Barcelona, Spain [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Not the same length
Dear Varin Sacha, My guess to try to help you is the following: I think you may want to change this: y_obs <- rnorm(n*0.9, y_model, 0.1) + rnorm(n*0.1, y_model, 0.5) for: y_obs <- c( rnorm(n*0.9, y_model, 0.1), rnorm(n*0.1, y_model, 0.5) ) then y_obs: > length(y_obs) [1] 2000 De: varin sacha via R-help Enviado: martes, 17 de septiembre de 2019 21:49 Para: R-help Mailing List Asunto: [R] Not the same length Dear R-helpers, Doing dput(x) and dput(y_obs), the 2 vectors are not the same length (1800 for y_obs and 2000 for x) How can I solve the problem ? Here is the reproducible R code # # # # # # # # # # library(mgcv) library(earth) n<-2000 x<-runif(n, 0, 5) y_model<- 0.1*x^3 - 0.5 * x^2 - x + 10 y_obs<-rnorm(n*0.9, y_model, 0.1)+rnorm(n*0.1, y_model, 0.5) gam_model<- gam(y_obs~s(x)) mars_model<- earth(y_obs~x) MSE_GAM<-mean((gam_model$fitted.values - y_model)^2) MSE_MARS<-mean((mars_model$fitted.values - y_model)^2) MSE_GAM MSE_MARS # # # # # # # # # # # # # # # # __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Not the same length
Redefining n is probably not a good idea... [...snip...] > m <-runif(n, 0, 5) > n <-rnorm(n, 2, 3) Oops! n is now a vector of length 2000. [...snip...] > y_obs <- y_model +c( rnorm(n*0.97, 0, 0.1), rnorm(n*0.03, 0, 0.5) ) now length(n*0.97) == 2000 > 1, so rnorm(n*0.97, ...) gets you a length 2000 vector (check ?rnorm), and c() of 2 of those is a vector of length 4000. [...etc...] > -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Not the same length
Dear Peter Dalgaard, Really appreciated, but my code does not work. There is still a problem ! Here below the reproducible example with 20 variables library(mgcv) library(earth) n<-2000 x<-runif(n, 0, 5) z <- rnorm(n, 2, 3) a <- runif(n, 0, 5) b <- rnorm(n, 2, 3) c <- runif(n, 0, 5) d <- rnorm(n, 2, 3) e <- runif(n, 0, 5) f <- rnorm(n, 2, 3) g <- runif(n, 0, 5) h <- rnorm(n, 2, 3) i <-runif(n, 0, 5) j <-rnorm(n, 2, 3) k <-runif(n, 0, 5) l <-rnorm(n, 2, 3) m <-runif(n, 0, 5) n <-rnorm(n, 2, 3) o <-runif(n, 0, 5) p <-rnorm(n, 2, 3) q <-runif(n, 0, 5) r <-rnorm(n, 2, 3) y_model<- 0.1*x^3 - 0.5 * z^2 - a^2 + b^2 + 2*c + 3*d - 4*e + 3.5*f - 4.5*g+ 2.5*h + 5.5*i^2 -1.5*j - 6*k + l + 2*m + n + 3*o - 4.5*p + q - r + 10 y_obs <- y_model +c( rnorm(n*0.97, 0, 0.1), rnorm(n*0.03, 0, 0.5) ) gam_model<- gam(y_obs~s(x)+s(z)+s(a)+s(b)+s(c)+s(d)+s(e)+s(f)+s(g)+s(h)+s(i)+s(j)+s(k)+s(l)+s(m)+s(n)+s(o)+s(p)+s(q)+s(r)) mars_model<-earth(y_obs~x+z+a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r) MSE_GAM<-mean((gam_model$fitted.values - y_model)^2) MSE_MARS<-mean((mars_model$fitted.values - y_model)^2) MSE_GAM MSE_MARS Le mercredi 18 septembre 2019 à 11:04:26 UTC+2, peter dalgaard a écrit : Um, I think not... The mean of the last 200 observation won't line up with the x and z. Possibly, if what you want is the last 200 obs to have a different variance, y_obs <- y_model + c(rnorm(0.9 * n, 0, 0.1), rnorm(0.1 * n, 0, 0.5)) or y_obs <- rnorm(n, y_model, rep(c(0.1, 0.5), c(.9 * n, .1 * n))) -pd > On 17 Sep 2019, at 22:27 , David Winsemius wrote: > > > On 9/17/19 12:48 PM, varin sacha via R-help wrote: >> Dear R-helpers, >> >> Doing dput(x) and dput(y_obs), the 2 vectors are not the same length (1800 >> for y_obs and 2000 for x) >> How can I solve the problem ? >> >> Here is the reproducible R code >> >> # # # # # # # # # # >> library(mgcv) >> library(earth) >> >> n<-2000 >> x<-runif(n, 0, 5) >> y_model<- 0.1*x^3 - 0.5 * x^2 - x + 10 >> # y_obs<-rnorm(n*0.9, y_model, 0.1)+rnorm(n*0.1, y_model, 0.5) # maybe not >> exactly your goal? > > > You didn't lay out any goals for analysis, so let me guess what was intended: > > > I suspect that you were hoping to model a mixture composed of 90% from one > distribution and 10% from another. If I'm right about that guess then you > would instead wat to join the samples from each distribution: > > y_obs<-c( rnorm(n*0.9, y_model, 0.1), rnorm(n*0.1, y_model, 0.5) ) > > -- > > David > > >> gam_model<- gam(y_obs~s(x)) >> mars_model<- earth(y_obs~x) >> MSE_GAM<-mean((gam_model$fitted.values - y_model)^2) >> MSE_MARS<-mean((mars_model$fitted.values - y_model)^2) >> MSE_GAM >> MSE_MARS >> # # # # # # # # # # # # # # # # >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help needed with eval parse
That worked! Thanks for the explanation. On Wed, Sep 18, 2019 at 10:06 AM Duncan Murdoch wrote: > > On 18/09/2019 8:43 a.m., Huzefa Khalil wrote: > > Hello R-users, > > > > I have been running a script which produces objects based on the > > column names of a data.frame. The column names are of the form CB_1-1, > > CB_1-2, etc. Now this calculation was rather long and memory > > intensive, so I would rather not have to do it again after fixing the > > column names using "make.names". As a consequence, I am left with a > > bunch of R objects with `-` in the name. > > Accessing them is proving challenging and any help would be appreciated. > > > > Reproducible example: > > `cb_1-2` <- "hello world" > > t <- "cb_1-2" > > t <- as.name(t) > > t <- eval(parse(text = t)) > > > > Error in eval(parse(text = t)) : object 'cb_1' not found > > After t <- as.name(t), you already have language: no need to parse it > again. So > >eval(t) > > works. If you have more complicated expressions, use call() to set them > ụp. For example, call("paste0", t, "!") evaluates to > >paste0(`cb_1-2`, "!") > > and evaluating that expression via > >eval(call("paste0", t, "!")) > > gives > > [1] "hello world!" > > Don't go back and forth between language objects and text > representations of them, because it's hard to do that without > introducing changes. In other words, don't use eval(parse()). > > Duncan Murdoch __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help needed with eval parse
On 18/09/2019 8:43 a.m., Huzefa Khalil wrote: Hello R-users, I have been running a script which produces objects based on the column names of a data.frame. The column names are of the form CB_1-1, CB_1-2, etc. Now this calculation was rather long and memory intensive, so I would rather not have to do it again after fixing the column names using "make.names". As a consequence, I am left with a bunch of R objects with `-` in the name. Accessing them is proving challenging and any help would be appreciated. Reproducible example: `cb_1-2` <- "hello world" t <- "cb_1-2" t <- as.name(t) t <- eval(parse(text = t)) Error in eval(parse(text = t)) : object 'cb_1' not found After t <- as.name(t), you already have language: no need to parse it again. So eval(t) works. If you have more complicated expressions, use call() to set them ụp. For example, call("paste0", t, "!") evaluates to paste0(`cb_1-2`, "!") and evaluating that expression via eval(call("paste0", t, "!")) gives [1] "hello world!" Don't go back and forth between language objects and text representations of them, because it's hard to do that without introducing changes. In other words, don't use eval(parse()). Duncan Murdoch __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help needed with eval parse
Hello R-users, I have been running a script which produces objects based on the column names of a data.frame. The column names are of the form CB_1-1, CB_1-2, etc. Now this calculation was rather long and memory intensive, so I would rather not have to do it again after fixing the column names using "make.names". As a consequence, I am left with a bunch of R objects with `-` in the name. Accessing them is proving challenging and any help would be appreciated. Reproducible example: `cb_1-2` <- "hello world" t <- "cb_1-2" t <- as.name(t) t <- eval(parse(text = t)) Error in eval(parse(text = t)) : object 'cb_1' not found Thanks. huzefa __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] regex
A little note on quoting in regular expressions. I find writing \\. when I want a quoted . somewhat confusing, so I would use the pattern "_w_.*[.]csv$". Better still, if you want to match file names, there is a function glob2rx that converts shell ("glob") patterns into regular expression patterns. Thus > grep(glob2rx("*_w_*.csv"), myfiles, value=TRUE) [1] "BU-072_1_E1_RE_SEC-01_local_w_0.2_0.2.csv" [2] "BU-072_1_E1_RE_SEC-01_local_w_0.2_0.6.csv" [3] "BU-072_1_E1_RE_SEC-01_local_w_0.4_1.0.csv" [4] "BU-072_1_E1_RE_SEC-01_local_w_1.0_0.2.csv" [5] "BU-072_1_E1_RE_SEC-01_local_w_1.0_0.6.csv" [6] "BU-072_1_E1_RE_SEC-01_local_w_1.0_1.0.csv" So the simplest way to get what you want is CSVs <- list.files(path=..., pattern=glob2rx("*_w_*.csv")) In fact ?list.files mentions glob2rx. On Tue, 17 Sep 2019 at 18:49, Ivan Calandra wrote: > Dear useRs, > > I still have problems using regular expressions. I have two problems for > which I have found workarounds, but I'm sure there are better ways of > doing it. > > 1) list CSV files with "_w_" in the name > > Here is a sample of the files in the folder: > myfiles <- c("BU-072_1_E1_RE_SEC-01_local_a_0.2_0.2.csv", > "BU-072_1_E1_RE_SEC-01_local_a_0.2_0.6.csv","BU-072_1_E1_RE_SEC-01_local_a_0.4_1.0.csv", > > "BU-072_1_E1_RE_SEC-01_local_a_1.0_0.2.csv","BU-072_1_E1_RE_SEC-01_local_a_1.0_0.6.csv", > > "BU-072_1_E1_RE_SEC-01_local_w_0.2_0.2.csv","BU-072_1_E1_RE_SEC-01_local_w_0.2_0.6.csv", > > "BU-072_1_E1_RE_SEC-01_local_w_0.4_1.0.csv","BU-072_1_E1_RE_SEC-01_local_w_1.0_0.2.csv", > > "BU-072_1_E1_RE_SEC-01_local_w_1.0_0.6.csv","BU-072_1_E1_RE_SEC-01_local_w_1.0_1.0.csv", > > "BU-072_1_E1_RE_SEC-01_local_a_0.2_0.2.xls","BU-072_1_E1_RE_SEC-01_local_a_0.2_0.6.xls", > > "BU-072_1_E1_RE_SEC-01_local_a_0.4_1.0.xls","BU-072_1_E1_RE_SEC-01_local_a_1.0_0.2.xls", > > "BU-072_1_E1_RE_SEC-01_local_a_1.0_0.6.xls","BU-072_1_E1_RE_SEC-01_local_w_0.2_0.2.xls", > > "BU-072_1_E1_RE_SEC-01_local_w_0.2_0.6.xls","BU-072_1_E1_RE_SEC-01_local_w_0.4_1.0.xls", > > "BU-072_1_E1_RE_SEC-01_local_w_1.0_0.2.xls","BU-072_1_E1_RE_SEC-01_local_w_1.0_0.6.xls", > > "BU-072_1_E1_RE_SEC-01_local_w_1.0_1.0.xls") > > Here is what I did: CSVs <- list.files(path=..., pattern="\\.csv$") > w.files <- CSVs[grep(pattern="_w_", CSVs)] > > Of course, what I would like to do is list only the interesting files > from the beginning, rather than subsetting the whole list of files. In > other words, having a pattern that includes both "\\.csv$" and "_w_" in > the list.files() call. I tried "_w_&\\.csv$" but it returns an empty > vector. > > 2) The units of the variables are given in the original headers. I would > like to extract the units. This is what I did: headers <- c("dist to > origin on curve [mm]","segment on section [mm]", "angle 1 [degree]", > "angle 2 [degree]","angle 3 [degree]") units.var <- > gsub(pattern="^.*\\[|\\]$", "", headers) > > It seems to be to overly complicated using gsub(). Isn't there a way to > extract what is interesting rather than deleting what is not? > > Thank you for your help! Best, Ivan > > -- > Dr. Ivan Calandra > TraCEr, laboratory for Traceology and Controlled Experiments > MONREPOS Archaeological Research Centre and > Museum for Human Behavioural Evolution > Schloss Monrepos > 56567 Neuwied, Germany > +49 (0) 2631 9772-243 > https://www.researchgate.net/profile/Ivan_Calandra > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use breaks argument in hist() function correctly?
> When I had breaks = 18, I get total number of cells as 16, which is > same when I put breaks = 20 > > In the 2nd case I was expecting total number of cells (i.e. bars) as > 20 i.e. if I understand the documentation correctly I should expect > total number of cells (bars) should be same as breaks argument in > hist() function. You do not _quite_ understand the documentation correctly. ?hist says "In the last three cases the number is a suggestion only; as the breakpoints will be set to 'pretty' values" That includes specification of a single number of breaks. > How to make that happen? Specify a vector of breaks with 20 intervals (21 values). For example, breaks=seq(-450, 350, length.out=21) This gives a bin width of 4e5. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use breaks argument in hist() function correctly?
Hi Cristofer, If you just ask for a number of breaks, you will get what "hist" thinks you should. Try this or something similar: hist(x,breaks=seq(min(x),max(x),length.out=21)) Jim On Wed, Sep 18, 2019 at 8:55 PM Christofer Bogaso wrote: > > Hi, > > I have a numerical vector as below > > x = c(92958.2014593977, -379826.025677203, 881937.411562002, 25761.5278163719, > -11837.158273897, 48450.8089746788, -415505.62910869, -168462.98512054, > 328504.255373387, -298966.051027528, 237133.794811816, -49610.1148173768, > -92459.1170329526, -261611.557495123, -314388.27876, -432257.362693919, > -1031328.04402229, 79654.3696754137, 107072.114744956, -43384.1420067487, > 410881.767122128, 1107540.47690119, -187319.627164858, -363126.966946238, > 264885.548330589, -127020.002396109, 150315.10537545, 609502.016523236, > 218679.801620448, 901573.599806465, 8289.59210428538, -860908.637977889, > 39680.5921457494, -70270.7462533897, 1135442.61429015, 133964.991179536, > 1603815.51357657, 2509929.42959337, 193680.587201446, -167020.153065672, > -55258.5415736386, -121185.161514792, -1003115.2769274, 1345368.12703686, > 91665.388397883, 137350.320344812, 29866.332965572, 558999.444304371, > 523687.79187, -867194.523170726, -271190.308507375, -423629.796389981, > 96407.0505512169, 193397.770743584, -1231855.39144784, 324272.89909045, > -1586859.60653751, 252986.272621096, -1008329.14877038, -24090.2255466315, > 159815.745712707, 969037.929787668, -586905.922684562, 573133.370665267, > -285493.361916026, -368392.707593945, -199242.654709143, 151002.480443041, > -678758.615800119, 467477.65504, -267683.37512503, -1541813.6353232, > -6723.49019530666, 373.233886695949, 59116.2440402955, -1369030.26511923, > 1527024.1822942, 63951.299612343, -535128.407281035, 304507.377244809, > 141771.552178838, 98963.774668207, 10810.9015935012, 1022008.90830883, > 276804.330003406, -304607.247552493, -15767.6578367545, -204454.923166458, > 722866.275157944, 137685.886832198, 590201.29119819, 904805.824902981, > -47417.8588758472, 55097.1936075327, 144426.170076371, 1020559.38779514, > -7019.11334737329, 488224.043025845, -28272.5766026849, -295384.449673914, > -93475.8799719289, -367939.725072447, -1244135.36327203, -863835.124327735, > -1399240.55792133, 241146.794430078, -96612.1109580967, -9159.41140641969, > -240291.731366074, -7482.02181888149, 71427.8225121907, -228401.89341468, > 948738.649629141, -327368.940001115, -53374.866091836, 126448.573738739, > 344962.4459403, 270571.141270723, 746988.197131718, -253220.465177424, > -362652.833437272, -4385.56796251462, -114398.64639441, 454240.63525686, > -1239567.92855698, -389939.987378005, -364083.196493484, 24693.1882238397, > 4635.22406457209, 57992.688805147, -67934.5184434773, 123034.937557127, > 483909.751375248, -167441.867070132, -382537.019103907, 267584.10264059, > -188944.743935369, -47062.5409102427, -860201.712919788, -203096.090898701, > 44317.9727734545, 375924.206160012, 67000.7086638517, 137607.783105903, > -306430.502044082, -669552.84790218, -72629.0354820569, 251145.827045551, > -230557.16727732, -112594.52630222, 74052.4425890159, -105774.458850881, > -241185.430318678, -296663.488112722, 156807.699193046, -520102.742784345, > -56451.5201730288, -23171.0259034268, -107945.719878344, -158480.929620835, > -769507.414580615, -83077.050717928, 477248.698330914, 27706.3803488034, > 70485.7144565997, 302213.341425514, -322119.331851626, -476228.406727923, > -99453.524756431, -673693.791106482, 38765.0473434452, 63302.3087165867, > 116619.019966859, -167803.424492692, 82982.1864557734, -262627.809345438, > 643538.235642472, -90724.2065826313, -435531.286293254, -371820.753318447, > -224713.223837607, -538987.838068522, -195841.454277966, 13924.6120356087, > -415252.7309228, 209424.879456433, 485624.048364534, 74317.8482029741, > 19994.939065553, -460452.302259829, -141374.457424938, -77310.8968822459, > 56112.3979095014, -150891.122921784, -679395.088755517, -523803.739201696, > -69888.2239139985, -4463.34352237508, -63616.8025699607, 906704.585396864, > 1096575.89875834, -382869.397851591, -624324.630106468, -468837.009485095, > -49963.2943695135, 17038.2753380311, 756286.614911188, -995536.510249994, > 308899.601761641, -375123.707808525, -113921.428586057, -61573.6957341075, > 55239.3511454715, -46731.8391379398, 697843.754042485, 265162.29364751, > 1133747.94683337, -355974.319924194, 30699.0482856455, -19680.791041683, > -624454.313911307, 94983.7375389124, 744849.080038272, 172732.610815633, > -120546.157860821, 62579.2205127864, -621204.554941904, 293869.359181081, > -108505.317455271, 646163.583792489, -502636.630380265, 502413.155645464, > -49238.362688755, 108812.985894042, -139113.621347874, 1120034.73283877, > -296008.55142246, -845627.626734492, 116082.364002893, 85096.4224949463, > -84149.6401610159, 611729.398657364, -783642.839894851, -9788.4825023263, > -58734.3009729933, -110950.384570162, -53258.3833170316, -20519.0858192393, >
[R] How to use breaks argument in hist() function correctly?
Hi, I have a numerical vector as below x = c(92958.2014593977, -379826.025677203, 881937.411562002, 25761.5278163719, -11837.158273897, 48450.8089746788, -415505.62910869, -168462.98512054, 328504.255373387, -298966.051027528, 237133.794811816, -49610.1148173768, -92459.1170329526, -261611.557495123, -314388.27876, -432257.362693919, -1031328.04402229, 79654.3696754137, 107072.114744956, -43384.1420067487, 410881.767122128, 1107540.47690119, -187319.627164858, -363126.966946238, 264885.548330589, -127020.002396109, 150315.10537545, 609502.016523236, 218679.801620448, 901573.599806465, 8289.59210428538, -860908.637977889, 39680.5921457494, -70270.7462533897, 1135442.61429015, 133964.991179536, 1603815.51357657, 2509929.42959337, 193680.587201446, -167020.153065672, -55258.5415736386, -121185.161514792, -1003115.2769274, 1345368.12703686, 91665.388397883, 137350.320344812, 29866.332965572, 558999.444304371, 523687.79187, -867194.523170726, -271190.308507375, -423629.796389981, 96407.0505512169, 193397.770743584, -1231855.39144784, 324272.89909045, -1586859.60653751, 252986.272621096, -1008329.14877038, -24090.2255466315, 159815.745712707, 969037.929787668, -586905.922684562, 573133.370665267, -285493.361916026, -368392.707593945, -199242.654709143, 151002.480443041, -678758.615800119, 467477.65504, -267683.37512503, -1541813.6353232, -6723.49019530666, 373.233886695949, 59116.2440402955, -1369030.26511923, 1527024.1822942, 63951.299612343, -535128.407281035, 304507.377244809, 141771.552178838, 98963.774668207, 10810.9015935012, 1022008.90830883, 276804.330003406, -304607.247552493, -15767.6578367545, -204454.923166458, 722866.275157944, 137685.886832198, 590201.29119819, 904805.824902981, -47417.8588758472, 55097.1936075327, 144426.170076371, 1020559.38779514, -7019.11334737329, 488224.043025845, -28272.5766026849, -295384.449673914, -93475.8799719289, -367939.725072447, -1244135.36327203, -863835.124327735, -1399240.55792133, 241146.794430078, -96612.1109580967, -9159.41140641969, -240291.731366074, -7482.02181888149, 71427.8225121907, -228401.89341468, 948738.649629141, -327368.940001115, -53374.866091836, 126448.573738739, 344962.4459403, 270571.141270723, 746988.197131718, -253220.465177424, -362652.833437272, -4385.56796251462, -114398.64639441, 454240.63525686, -1239567.92855698, -389939.987378005, -364083.196493484, 24693.1882238397, 4635.22406457209, 57992.688805147, -67934.5184434773, 123034.937557127, 483909.751375248, -167441.867070132, -382537.019103907, 267584.10264059, -188944.743935369, -47062.5409102427, -860201.712919788, -203096.090898701, 44317.9727734545, 375924.206160012, 67000.7086638517, 137607.783105903, -306430.502044082, -669552.84790218, -72629.0354820569, 251145.827045551, -230557.16727732, -112594.52630222, 74052.4425890159, -105774.458850881, -241185.430318678, -296663.488112722, 156807.699193046, -520102.742784345, -56451.5201730288, -23171.0259034268, -107945.719878344, -158480.929620835, -769507.414580615, -83077.050717928, 477248.698330914, 27706.3803488034, 70485.7144565997, 302213.341425514, -322119.331851626, -476228.406727923, -99453.524756431, -673693.791106482, 38765.0473434452, 63302.3087165867, 116619.019966859, -167803.424492692, 82982.1864557734, -262627.809345438, 643538.235642472, -90724.2065826313, -435531.286293254, -371820.753318447, -224713.223837607, -538987.838068522, -195841.454277966, 13924.6120356087, -415252.7309228, 209424.879456433, 485624.048364534, 74317.8482029741, 19994.939065553, -460452.302259829, -141374.457424938, -77310.8968822459, 56112.3979095014, -150891.122921784, -679395.088755517, -523803.739201696, -69888.2239139985, -4463.34352237508, -63616.8025699607, 906704.585396864, 1096575.89875834, -382869.397851591, -624324.630106468, -468837.009485095, -49963.2943695135, 17038.2753380311, 756286.614911188, -995536.510249994, 308899.601761641, -375123.707808525, -113921.428586057, -61573.6957341075, 55239.3511454715, -46731.8391379398, 697843.754042485, 265162.29364751, 1133747.94683337, -355974.319924194, 30699.0482856455, -19680.791041683, -624454.313911307, 94983.7375389124, 744849.080038272, 172732.610815633, -120546.157860821, 62579.2205127864, -621204.554941904, 293869.359181081, -108505.317455271, 646163.583792489, -502636.630380265, 502413.155645464, -49238.362688755, 108812.985894042, -139113.621347874, 1120034.73283877, -296008.55142246, -845627.626734492, 116082.364002893, 85096.4224949463, -84149.6401610159, 611729.398657364, -783642.839894851, -9788.4825023263, -58734.3009729933, -110950.384570162, -53258.3833170316, -20519.0858192393, 456910.655858686, 48830.1071552214, -358333.95721609, 80046.3518406906, -224193.119044228, 45897.0722281932, -4895.48804178487, 735710.318540904, 183571.602770915, -103173.288434665, 554285.106452708, 536724.819749035, -38962.2828892764, 26730.2338615816, -267784.282389664, 659763.691652086, 331635.73797362, -305496.497141735, 337703.432388682, 26793.2725583163, -214055.61511956,
Re: [R] Not the same length
Um, I think not... The mean of the last 200 observation won't line up with the x and z. Possibly, if what you want is the last 200 obs to have a different variance, y_obs <- y_model + c(rnorm(0.9 * n, 0, 0.1), rnorm(0.1 * n, 0, 0.5)) or y_obs <- rnorm(n, y_model, rep(c(0.1, 0.5), c(.9 * n, .1 * n))) -pd > On 17 Sep 2019, at 22:27 , David Winsemius wrote: > > > On 9/17/19 12:48 PM, varin sacha via R-help wrote: >> Dear R-helpers, >> >> Doing dput(x) and dput(y_obs), the 2 vectors are not the same length (1800 >> for y_obs and 2000 for x) >> How can I solve the problem ? >> >> Here is the reproducible R code >> >> # # # # # # # # # # >> library(mgcv) >> library(earth) >> >> n<-2000 >> x<-runif(n, 0, 5) >> y_model<- 0.1*x^3 - 0.5 * x^2 - x + 10 >> # y_obs<-rnorm(n*0.9, y_model, 0.1)+rnorm(n*0.1, y_model, 0.5) # maybe not >> exactly your goal? > > > You didn't lay out any goals for analysis, so let me guess what was intended: > > > I suspect that you were hoping to model a mixture composed of 90% from one > distribution and 10% from another. If I'm right about that guess then you > would instead wat to join the samples from each distribution: > > y_obs<-c( rnorm(n*0.9, y_model, 0.1), rnorm(n*0.1, y_model, 0.5) ) > > -- > > David > > >> gam_model<- gam(y_obs~s(x)) >> mars_model<- earth(y_obs~x) >> MSE_GAM<-mean((gam_model$fitted.values - y_model)^2) >> MSE_MARS<-mean((mars_model$fitted.values - y_model)^2) >> MSE_GAM >> MSE_MARS >> # # # # # # # # # # # # # # # # >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R wrong, Python rigth in calcution
Here's a tip for the original poster. > ?numeric and then follow the link it suggests > ?double which says amongst other things All R platforms are required to work with values conforming to the IEC 60559 (also known as IEEE 754) standard. This basically works with a precision of 53 bits, and represents to that precision a range of absolute values from about 2e-308 to 2e+308. and reminds us that > .Machine will give you the parameters of the 'double' type. On Wed, 18 Sep 2019 at 12:03, Abby Spurdle wrote: > > R by default uses floating-point arithmetic, which > > is subject to problems described in [*]. > > Yes. > > I want to note that both graphics and modern statistics, require > efficient floating point arithmetic. > So, R does what it's designed to do... > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.