Re: [R] Text showing when R is launched
Hi, Thankyou for your response <https://1drv.ms/i/s!AkfoLX--ikbqkweYckSQiXYKXJuR> [https://9c11xq.db.files.1drv.com/y4m7xqt5yVu7b5IG1jFuopunwB7Oa9Eij0WeZ7p1lSSmBECcSIB3XjcKjXIUhdMrJwaJdjZnBRhMeAxY0_Kko06Nq1fm5IhqaHlT6aFeI3R7gicXCteRPkzqNwmCdVxZu5DhNq66IrpwDyQ1lr8E5OFdm_xL86pMgNSLAx5HRRKLPOmFdUFWdv1ID-D1PC6LvNvAB-rT87JiQonSHRJIHouLg?width=200&height=150&cropmode=center] [https://res-h3.public.cdn.office.net/assets/mail/file-icon/png/cloud_blue_16x16.png]Screenshot 2023-10-11 at 19.19.48.png ? However this is all that exists in Users/Admin There were a couple of R files in there which I have since deleted but I am still getting the same issue Thankyou, George From: Rui Barradas Sent: 10 October 2023 12:06 To: George Loftus ; r-help@r-project.org Subject: Re: [R] Text showing when R is launched �s 23:56 de 09/10/2023, George Loftus escreveu: > Good Evening, > > I was wondering if you were able to help, I am running R on MacOS, it is the > 2020 model mac so have install the Intel arm of R which I believe is correct > > However when I launch R or resume the R window after going on a different > programme the following text is running > > I have also copied and pasted for ease > > 1 HIToolbox 0x7ff82142e0c2 > _ZN15MenuBarInstance22RemoveAutoShowObserverEv + 30 > 2 HIToolbox 0x7ff82146a638 > _ZL17BroadcastInternaljPvh + 167 > 3 SkyLight0x7ff81c70f23d > _ZN12_GLOBAL__N_123notify_datagram_handlerEj15CGSDatagramTypePvmS1_ + 1030 > 4 SkyLight0x7ff81ca2205a > _ZN21CGSDatagramReadStream26dispatchMainQueueDatagramsEv + 202 > 5 SkyLight0x7ff81ca21f81 > ___ZN21CGSDatagramReadStream15mainQueueWakeupEv_block_invoke + 18 > 6 libdispatch.dylib 0x7ff8178867fb > _dispatch_call_block_and_release + 12 > 7 libdispatch.dylib 0x7ff817887a44 > _dispatch_client_callout + 8 > 8 libdispatch.dylib 0x7ff8178947b9 > _dispatch_main_queue_drain + 952 > 9 libdispatch.dylib 0x7ff8178943f3 > _dispatch_main_queue_callback_4CF + 31 > 10 CoreFoundation 0x7ff817b215f0 > __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 > 11 CoreFoundation 0x7ff817ae1b70 __CFRunLoopRun + > 2454 > 12 CoreFoundation 0x7ff817ae0b60 > CFRunLoopRunSpecific + 560 > 13 HIToolbox 0x7ff82142e766 > RunCurrentEventLoopInMode + 292 > 14 HIToolbox 0x7ff82142e576 > ReceiveNextEventCommon + 679 > 15 HIToolbox 0x7ff82142e2b3 > _BlockUntilNextEventMatchingListInModeWithFilter + 70 > 16 AppKit 0x7ff81ac31293 _DPSNextEvent + 909 > 17 AppKit 0x7ff81ac30114 > -[NSApplication(NSEvent) > _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219 > 18 R 0x000103d60c76 -[RController > doProcessEvents:] + 166 > 19 R 0x000103d5b295 -[RController > handleReadConsole:] + 149 > 20 R 0x000103d6466f Re_ReadConsole + > 175 > 21 libR.dylib 0x000104442154 R_ReplDLLdo1 + 148 > 22 R 0x000103d71c47 > run_REngineRmainloop + 263 > 23 R 0x000103d66d5f -[REngine runREPL] > + 143 > 24 R 0x000103d56718 main + 792 > 25 dyld0x7ff8176d4310 start + 2432 > 1 HIToolbox 0x7ff8214a1726 > _ZN15MenuBarInstance22EnsureAutoShowObserverEv + 102 > 2 HIToolbox 0x7ff82146a638 > _ZL17BroadcastInternaljPvh + 167 > 3 SkyLight0x7ff81c70f23d > _ZN12_GLOBAL__N_123notify_datagram_handlerEj15CGSDatagramTypePvmS1_ + 1030 > 4 SkyLight0x7ff81ca2205a > _ZN21CGSDatagramReadStream26dispatchMainQueueDatagramsEv + 202 > 5 SkyLight0x7ff81ca21f81 > ___ZN21CGSDatagramReadStream15mainQueueWakeupEv_block_invoke + 18 > 6 libdispatch.dylib 0x7ff8178867fb > _dispatch_call_block_and_release + 12 > 7 libdispatch.dylib 0x7ff817887a44 > _dispatch_client_callout + 8 > 8 libdispatch.dylib 0x7ff8178947b9 > _dispatch_main_queue_drain + 952 > 9 libdispatch.dylib 0x7ff8178943f3 > _dispatch
[R] Shaded area
Dear R users, I have an xlsx file (attached to this mail) that shows the values of a "der" series observed on a daily basis from January 1, 2017 to January 25, 2017. This series is strictly positive during two periods: from January 8, 2017 to January 11, 2017 and from January 16, 2017 to January 20, 2017. I would like to plot the series with two shaded areas corresponding to the positivity of the series. Specifically, I would like to draw 4 vertical lines intersecting the x-axis in the 4 dates mentioned above and shade the two areas of positivity. Thanks for your help. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Logistic regression for large data
Dear R users, I have a database called Base.csv (attached to this email) which contains 13 columns and 8257 rows and whose the first 8 columns are dummy variables which take 1 or 0. The problem is when I wrote the following instructions to do a logistic regression , R runs for hours and hours without giving an output: Base=read.csv("C:\\Users\\HP\\Desktop\\New\\Base.csv",header=FALSE,sep=";") fit_1=glm(Base[,2]~Base[,1]+Base[,10]+Base[,11]+Base[,12]+Base[,13],family=binomial(link="logit")) Apparently, there is not enough memory to have the requested output. Is there any other function for logistic regression that handle large data and return output in reasonable time. Many thanks Kind regards George __ 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] Mapping of groups of countries
Thanks a lot Jim. I really appreciate your help. Happy new year 2022. George On Wed, Dec 29, 2021 at 10:10 PM Jim Lemon wrote: > Hi George, > This example is obviously a mess, but it shows the basic elements. The > labels may be placed manually using something like boxed.labels > (plotrix) with lines connecting the labels to the smaller countries. > If you want the labels within the countries you will have to use a big > graphics device. > > library(maps) > map("world") > countries=c("China","Bangladesh","Egypt","Indonesia","South > Korea","Nigeria", > "Brazil","Pakistan","Philippines","Vietnam","South Africa", > "India","Mexico","Turkey") > countrycol<-c(rep("red",6),rep("blue",4),"green",rep("orange",3)) > for(i in 1:length(countries)) { > mapinf<-map(region=countries[i],col=countrycol[i],add=TRUE) > xpos<-sum(mapinf$range[1:2])/2 > ypos<-sum(mapinf$range[3:4])/2 > text(xpos,ypos,countries[i]) > } > > > Jim > > On Thu, Dec 30, 2021 at 7:34 AM george brida > wrote: > > > > Dear R users, > > > > I would like to map with R the following countries (with their names on > the > > map) as follows: the first group in red composed by China, Bangladesh, > > Eypt, Indonesia, South Korea, Nigeria. The second group in blue composed > by > > Brazil, Pakistan, Philippines, Vietnam. > > > > The third group in green solely composed by South Africa. > > > > Finally, the fourth group in orange composed by India, Mexico and Turkey. > > > > I'd also like a legend that assigns the different colors to the various > > group. > > I tried several times with library maps but it seems that I failed to > find > > the real setting of xlim and ylim. Can you please help me, I will be very > > grateful. > > > > Best regards > > George > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Mapping of groups of countries
Dear R users, I would like to map with R the following countries (with their names on the map) as follows: the first group in red composed by China, Bangladesh, Eypt, Indonesia, South Korea, Nigeria. The second group in blue composed by Brazil, Pakistan, Philippines, Vietnam. The third group in green solely composed by South Africa. Finally, the fourth group in orange composed by India, Mexico and Turkey. I'd also like a legend that assigns the different colors to the various group. I tried several times with library maps but it seems that I failed to find the real setting of xlim and ylim. Can you please help me, I will be very grateful. Best regards George [[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] Cars2
Thanks Ivan, I was a fool. That�s the one I am looking for. Best, George From: Ivan Krylov Sent: Thursday, August 19, 2021 5:32:43 PM To: George Bellas Cc: r-help@r-project.org Subject: Re: [R] Cars2 On Thu, 19 Aug 2021 00:12:51 + George Bellas wrote: > I'm still looking for it, it had car prices and car models in it. I > couldn't find it through the r search link. Could it be the third search result for a query of 'cars2'? https://search.r-project.org/?P=cars2&SORT=&HITSPERPAGE=10&DB=r-manuals&DB=r-help&DB=cran-views&DB=cran-info&DB=cran-help&DB=cran-news&DB=cran-readme&DB=cran-vignettes&DEFAULTOP=and&FMT=query&xDB=cran-help&xFILTERS=.%7E%7E -> https://search.r-project.org/CRAN/refmans/fBasics/html/data-examples.html >> cars2 contains the price, country, reliability, mileage, type, >> weight, engine displacement and net horsepower of various car >> models. -- Best regards, Ivan [[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] Cars2
Hi R Core team, I was looking at this link for data sets, https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/00Index.html and wanted to use cars2. I found cars2 earlier this week, but now when I look at the list, it's not there! Can you tell me what happened to cars2? I have tried calling it on my version of R4.0.5 (backdated so Shiny works), but I can't find it anymore. Thanks, George [[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] Mapping of countries
Thanks a lot Jim.. Thank you Ani and Rasmus. Best On Wed, Apr 1, 2020 at 2:54 AM ani jaya wrote: > Maybe simply add: > > > points(station$Lon, station$Lat, col="red", pch=16, label="Your Country") > text(station$Lon, station$Lat,"Your Country", > col="black", pos=3, cex=1) > > station$Lon and Lat in your coordinate position. > > Regards, > Ani > > > On Tue, Mar 31, 2020 at 10:58 PM george brida > wrote: > > > > Dear Jim, > > > > Is it possible to add also a title to this map? > > > > Many thanks > > > > > > > > On Tue, Mar 31, 2020 at 2:29 PM george brida > wrote: > > > > > Dear Jim, > > > > > > Thank you very much. I obtained now the required map. I would like to > know > > > how to add the names of the countries. > > > > > > Best > > > George > > > > > > On Tue, Mar 31, 2020 at 10:10 AM Jim Lemon > wrote: > > > > > >> Hi George, > > >> Try this: > > >> > > >> library(maps) > > >> map("world",xlim=c(34.353,60.369),ylim=c(16.7,32.193), > > >> regions="Saudi Arabia",col="yellow",fill=TRUE) > > >> map("world",regions="Bahrain",col="yellow",fill=TRUE,add=TRUE) > > >> map("world",regions="Kuwait",col="lightblue",fill=TRUE,add=TRUE) > > >> map("world",regions="Qatar",col="yellow",fill=TRUE,add=TRUE) > > >> map("world",regions="United Arab > > >> Emirates",col="lightblue",fill=TRUE,add=TRUE) > > >> map("world",regions="Oman",col="lightgreen",fill=TRUE,add=TRUE) > > >> > > >> Jim > > >> > > >> On Tue, Mar 31, 2020 at 12:39 PM george brida > > > >> wrote: > > >> > > > >> > Dear R users, > > >> > > > >> > i would like to plot the maps of the Gulf Cooperation Council (GCC) > > >> > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > > >> > constraints: i/ KSA , Qatar and Bahrain have the same face color , > ii/ > > >> > Kuweit and UAE with the same face color and iii/Oman with another > face > > >> > color. Is there any code in R doing this task. > > >> > > > >> > Many thanks. > > >> > > > >> > [[alternative HTML version deleted]] > > >> > > > >> > __ > > >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > >> > https://stat.ethz.ch/mailman/listinfo/r-help > > >> > PLEASE do read the posting guide > > >> http://www.R-project.org/posting-guide.html > > >> > and provide commented, minimal, self-contained, reproducible code. > > >> > > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[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] Mapping of countries
Dear Jim, Is it possible to add also a title to this map? Many thanks On Tue, Mar 31, 2020 at 2:29 PM george brida wrote: > Dear Jim, > > Thank you very much. I obtained now the required map. I would like to know > how to add the names of the countries. > > Best > George > > On Tue, Mar 31, 2020 at 10:10 AM Jim Lemon wrote: > >> Hi George, >> Try this: >> >> library(maps) >> map("world",xlim=c(34.353,60.369),ylim=c(16.7,32.193), >> regions="Saudi Arabia",col="yellow",fill=TRUE) >> map("world",regions="Bahrain",col="yellow",fill=TRUE,add=TRUE) >> map("world",regions="Kuwait",col="lightblue",fill=TRUE,add=TRUE) >> map("world",regions="Qatar",col="yellow",fill=TRUE,add=TRUE) >> map("world",regions="United Arab >> Emirates",col="lightblue",fill=TRUE,add=TRUE) >> map("world",regions="Oman",col="lightgreen",fill=TRUE,add=TRUE) >> >> Jim >> >> On Tue, Mar 31, 2020 at 12:39 PM george brida >> wrote: >> > >> > Dear R users, >> > >> > i would like to plot the maps of the Gulf Cooperation Council (GCC) >> > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these >> > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ >> > Kuweit and UAE with the same face color and iii/Oman with another face >> > color. Is there any code in R doing this task. >> > >> > Many thanks. >> > >> > [[alternative HTML version deleted]] >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Mapping of countries
Dear Gunter, It is noted. Thanks Best On Tue, Mar 31, 2020 at 6:04 AM Bert Gunter wrote: > Probably better posted to the r-sig-geo list, where you are more > likely to find the relevant expertise. > > Perhaps see also https://cran.r-project.org/web/views/Spatial.html, > depending on what you plan to do with your maps. > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > On Mon, Mar 30, 2020 at 8:03 PM Erin Hodgess > wrote: > > > > Hello George! > > > > Do you mean to have a map of the world with these countries filled in, or > > to have just those countries on the map, please? > > > > Thanks, > > Erin > > > > Erin Hodgess, PhD > > mailto: erinm.hodg...@gmail.com > > > > > > On Mon, Mar 30, 2020 at 7:38 PM george brida > wrote: > > > > > Dear R users, > > > > > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > > > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > > > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > > > Kuweit and UAE with the same face color and iii/Oman with another face > > > color. Is there any code in R doing this task. > > > > > > Many thanks. > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[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] Mapping of countries
Dear Jim, Thank you very much. I obtained now the required map. I would like to know how to add the names of the countries. Best George On Tue, Mar 31, 2020 at 10:10 AM Jim Lemon wrote: > Hi George, > Try this: > > library(maps) > map("world",xlim=c(34.353,60.369),ylim=c(16.7,32.193), > regions="Saudi Arabia",col="yellow",fill=TRUE) > map("world",regions="Bahrain",col="yellow",fill=TRUE,add=TRUE) > map("world",regions="Kuwait",col="lightblue",fill=TRUE,add=TRUE) > map("world",regions="Qatar",col="yellow",fill=TRUE,add=TRUE) > map("world",regions="United Arab > Emirates",col="lightblue",fill=TRUE,add=TRUE) > map("world",regions="Oman",col="lightgreen",fill=TRUE,add=TRUE) > > Jim > > On Tue, Mar 31, 2020 at 12:39 PM george brida > wrote: > > > > Dear R users, > > > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > > Kuweit and UAE with the same face color and iii/Oman with another face > > color. Is there any code in R doing this task. > > > > Many thanks. > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Mapping of countries
Hi Erin, Thanks for the reply. I would like to have just those countries on the map. Best George On Tue, Mar 31, 2020 at 5:02 AM Erin Hodgess wrote: > Hello George! > > Do you mean to have a map of the world with these countries filled in, or > to have just those countries on the map, please? > > Thanks, > Erin > > Erin Hodgess, PhD > mailto: erinm.hodg...@gmail.com > > > On Mon, Mar 30, 2020 at 7:38 PM george brida > wrote: > >> Dear R users, >> >> i would like to plot the maps of the Gulf Cooperation Council (GCC) >> countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these >> constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ >> Kuweit and UAE with the same face color and iii/Oman with another face >> color. Is there any code in R doing this task. >> >> Many thanks. >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Mapping of countries
Dear R users, i would like to plot the maps of the Gulf Cooperation Council (GCC) countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ Kuweit and UAE with the same face color and iii/Oman with another face color. Is there any code in R doing this task. Many thanks. [[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] power analysis for Friedman's test
Hello, I am running a non parametric repeated measures experiment with Friedman’s test: Friedman rank sum test data: glikozi and week and subject Friedman chi-squared = 18.538, df = 3, p-value = 0.0003405 How could I run a power analysis for this test in R? Thank you! -- George Karavasilis Department of Business Administration & Serres, Greece --- Αυτό το e-mail ελέγχθηκε για ιούς από το πρόγραμμα Avast antivirus. https://www.avast.com/antivirus __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with r project in ubuntu xenial
For anyone who sees this conversation. There is a bug in installation of igraph in R language in Ubuntu. There is a solution in stackoverflow. We have to use the devtools. Write this code: install.packages("devtools") library(devtools) install_github("igraph/rigraph") If there are errors installing devtools just install any package that comments. On Nov 5, 2017 00:07, "George Balas" wrote: > -Well it seems that it is getting "el_GR.UTF-8" but still I am not able > to read files written in greek, there are only "" instead of letters. > -Also, I forgot to mention that I do load igraph library when I try > "graph_from_adjacency_matrix". > When I check igraph in packages dialog I can not see functions with > underscores between words, only dots. > > 2017-11-04 2:22 GMT+02:00 David Winsemius : > >> >> > On Nov 3, 2017, at 5:09 PM, peter dalgaard wrote: >> > >> > >> >> On 3 Nov 2017, at 23:39 , George Balas wrote: >> >> >> >> I have a problem with R in Ubuntu 16.04. I do not know if it is mine >> pc or >> >> general problem but I was not able to find solution on Internet. >> >> First of all I can not change locale to greek by getting this message: >> >> "In Sys.setlocale("LC_CTYPE", "Greek") : >> >> OS reports request to set locale to "Greek" cannot be honored" >> > >> > The Greek locale is likely not called "Greek" outside of Windows. More >> likely "el_GR.UTF-8" or thereabouts (check your locale database, I'm on a >> Mac). These things are not standardized across platforms. >> > >> >> Also >> >> From help(locales): Attempts to change the character set by >> Sys.setlocale("LC_CTYPE") that implies a different character set during a >> session may not work and are likely to lead to some confusion because it >> may not affect the native encoding. >> >> >> >> Second and more serious is that I can not use some functions like >> >> graph_from_adjacency_matrix or print_all I get these messeges: >> >> "could not find function "graph_from_adjacency_matrix"" >> >> "could not find function "print_all"". >> > >> > Missing library(igraph)? >> > >> > -pd >> > >> >> I am using R version 3.4.2 (2017-09-28) -- "Short Summer" either on >> rstudio >> >> or ubuntu terminal. >> >> On my pc I also run win 10 with the same installs and I do not have the >> >> above problems, but I work on ubuntu and can not change Os all the >> time. >> >> Please help me. >> >> >> >> Thank you for your time, >> >> George >> >> gbala...@gmail.com >> >> >> >> [[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/posti >> ng-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/posti >> ng-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> >> David Winsemius >> Alameda, CA, USA >> >> 'Any technology distinguishable from magic is insufficiently advanced.' >> -Gehm's Corollary to Clarke's Third Law >> >> >> >> >> >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with r project in ubuntu xenial
-Well it seems that it is getting "el_GR.UTF-8" but still I am not able to read files written in greek, there are only "" instead of letters. -Also, I forgot to mention that I do load igraph library when I try "graph_from_adjacency_matrix". When I check igraph in packages dialog I can not see functions with underscores between words, only dots. 2017-11-04 2:22 GMT+02:00 David Winsemius : > > > On Nov 3, 2017, at 5:09 PM, peter dalgaard wrote: > > > > > >> On 3 Nov 2017, at 23:39 , George Balas wrote: > >> > >> I have a problem with R in Ubuntu 16.04. I do not know if it is mine pc > or > >> general problem but I was not able to find solution on Internet. > >> First of all I can not change locale to greek by getting this message: > >> "In Sys.setlocale("LC_CTYPE", "Greek") : > >> OS reports request to set locale to "Greek" cannot be honored" > > > > The Greek locale is likely not called "Greek" outside of Windows. More > likely "el_GR.UTF-8" or thereabouts (check your locale database, I'm on a > Mac). These things are not standardized across platforms. > > > > Also > > From help(locales): Attempts to change the character set by > Sys.setlocale("LC_CTYPE") that implies a different character set during a > session may not work and are likely to lead to some confusion because it > may not affect the native encoding. > > > >> Second and more serious is that I can not use some functions like > >> graph_from_adjacency_matrix or print_all I get these messeges: > >> "could not find function "graph_from_adjacency_matrix"" > >> "could not find function "print_all"". > > > > Missing library(igraph)? > > > > -pd > > > >> I am using R version 3.4.2 (2017-09-28) -- "Short Summer" either on > rstudio > >> or ubuntu terminal. > >> On my pc I also run win 10 with the same installs and I do not have the > >> above problems, but I work on ubuntu and can not change Os all the time. > >> Please help me. > >> > >> Thank you for your time, > >> George > >> gbala...@gmail.com > >> > >> [[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. > > > > -- > > 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. > > David Winsemius > Alameda, CA, USA > > 'Any technology distinguishable from magic is insufficiently advanced.' > -Gehm's Corollary to Clarke's Third Law > > > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with r project in ubuntu xenial
I have a problem with R in Ubuntu 16.04. I do not know if it is mine pc or general problem but I was not able to find solution on Internet. First of all I can not change locale to greek by getting this message: "In Sys.setlocale("LC_CTYPE", "Greek") : OS reports request to set locale to "Greek" cannot be honored" Second and more serious is that I can not use some functions like graph_from_adjacency_matrix or print_all I get these messeges: "could not find function "graph_from_adjacency_matrix"" "could not find function "print_all"". I am using R version 3.4.2 (2017-09-28) -- "Short Summer" either on rstudio or ubuntu terminal. On my pc I also run win 10 with the same installs and I do not have the above problems, but I work on ubuntu and can not change Os all the time. Please help me. Thank you for your time, George gbala...@gmail.com [[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] Wireframe plot inside a function
But it works ;-). According to print.trellis help, 'plot' is an alias for 'print'. IMO, this is an abuse of overloading: same method name does totally different things. On 21 April 2017 at 21:58, Jeff Newmiller wrote: > No... it is > > print(plot(cop1, main = "cop1 function")) > > -- > Sent from my phone. Please excuse my brevity. > > On April 21, 2017 1:56:00 PM PDT, George Trojan - NOAA Federal > wrote: >>I see. So, if I don't care about the plot object itself, the proper >>incantation is >> >>plot(plot(cop1, main = "cop1 function")) >> >>Thanks again. >> >>On 21 April 2017 at 20:32, Jeff Newmiller >>wrote: >>> Your original function created the cop1 plot object but did nothing >>with it. It then created the cop2 plot and returned it from the >>function. Since you had invoked the cplot function from the interactive >>console, R printed that returned object automatically, which displayed >>the plot. >>> >>> FYI: when you want to start presenting multiple plots and/or tables >>together you will find that something like knitr and RMarkdown are very >>helpful. >>> -- >>> Sent from my phone. Please excuse my brevity. >>> >>> On April 21, 2017 11:59:28 AM PDT, George Trojan - NOAA Federal >> wrote: >>>>Thanks. After changing the function to >>>> >>>>cplot <- function(cop1, cop2) { >>>> x11() >>>> o <- plot(cop1, main = "cop1 function") >>>> print(o) >>>> x11() >>>> o <- plot(cop2, main = "cop2 function") >>>> print(o) >>>>} >>>> >>>>I see both plots. But, since "cop2 function" was plotted before, does >>>>it mean it is plotted twice now? Looks as a strange design. >>>> >>>>I did check the "Plain text mode" in Chrome, you should see only the >>>>text part. >>>> >>>>George >>>> >>>>On 21 April 2017 at 16:27, Jeff Newmiller >>>>wrote: >>>>> FAQ 7.22 >>>>> And don't send HTML email... you are the one making it difficult >>for >>>>us to read your question. >>>>> >>>>> -- >>>>> Sent from my phone. Please excuse my brevity. >>>>> >>>>> On April 21, 2017 8:27:20 AM PDT, George Trojan - NOAA Federal >>>> wrote: >>>>>>Consider the following example: >>>>>> >>>>>>library("kdecopula") >>>>>>library("mvtnorm") >>>>>> >>>>>>pobs <- function(x) rank(x) / (length(x) + 1) >>>>>> >>>>>>n <- 1000 >>>>>> >>>>>>sigma1 <- diag(x = 1, 2, 2) >>>>>>x1 <- rmvnorm(n, sigma = sigma1) >>>>>>xx1 <- apply(x1, 2, pobs) >>>>>>cop1 <- kdecop(xx1) >>>>>> >>>>>>eps <- 0.8 >>>>>>sigma2 <- matrix(c(1, eps, eps, 1), ncol = 2) >>>>>>x2 <- rmvnorm(n, sigma = sigma2) >>>>>>xx2 <- apply(x2, 2, pobs) >>>>>>cop2 <- kdecop(xx2) >>>>>> >>>>>>x11() >>>>>>plot(cop1, main = "cop1 main") >>>>>>x11() >>>>>>plot(cop2, main = "cop2 main") >>>>>> >>>>>>cplot <- function(cop1, cop2) { >>>>>> x11() >>>>>> plot(cop1, main = "cop1 function") >>>>>> x11() >>>>>> plot(cop2, main = "cop2 function") >>>>>>} >>>>>> >>>>>>cplot(cop1, cop2) >>>>>> >>>>>>cat("Press to quit") >>>>>>readLines(file("stdin"), n >>>>>> >>>>>>= >>>>>> >>>>>>1) >>>>>>quit() >>>>>> >>>>>>When I run it with Rscript all four x11 windows pop up, however the >>>>one >>>>>>that should display "cop1 function" is blank, the wireframe is not >>>>>>plotted. >>>>>>This is R 3.3.1, on Fedora 20. >>>>>>I see similar behaviour on Fedora 24, R 3.3.3 when I run the code >>>>from >>>>>>RStudio (the most recent one). >>>>>> >>>>>>George >>>>>> >>>>>> [[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.
Re: [R] Wireframe plot inside a function
I see. So, if I don't care about the plot object itself, the proper incantation is plot(plot(cop1, main = "cop1 function")) Thanks again. On 21 April 2017 at 20:32, Jeff Newmiller wrote: > Your original function created the cop1 plot object but did nothing with it. > It then created the cop2 plot and returned it from the function. Since you > had invoked the cplot function from the interactive console, R printed that > returned object automatically, which displayed the plot. > > FYI: when you want to start presenting multiple plots and/or tables together > you will find that something like knitr and RMarkdown are very helpful. > -- > Sent from my phone. Please excuse my brevity. > > On April 21, 2017 11:59:28 AM PDT, George Trojan - NOAA Federal > wrote: >>Thanks. After changing the function to >> >>cplot <- function(cop1, cop2) { >> x11() >> o <- plot(cop1, main = "cop1 function") >> print(o) >> x11() >> o <- plot(cop2, main = "cop2 function") >> print(o) >>} >> >>I see both plots. But, since "cop2 function" was plotted before, does >>it mean it is plotted twice now? Looks as a strange design. >> >>I did check the "Plain text mode" in Chrome, you should see only the >>text part. >> >>George >> >>On 21 April 2017 at 16:27, Jeff Newmiller >>wrote: >>> FAQ 7.22 >>> And don't send HTML email... you are the one making it difficult for >>us to read your question. >>> >>> -- >>> Sent from my phone. Please excuse my brevity. >>> >>> On April 21, 2017 8:27:20 AM PDT, George Trojan - NOAA Federal >> wrote: >>>>Consider the following example: >>>> >>>>library("kdecopula") >>>>library("mvtnorm") >>>> >>>>pobs <- function(x) rank(x) / (length(x) + 1) >>>> >>>>n <- 1000 >>>> >>>>sigma1 <- diag(x = 1, 2, 2) >>>>x1 <- rmvnorm(n, sigma = sigma1) >>>>xx1 <- apply(x1, 2, pobs) >>>>cop1 <- kdecop(xx1) >>>> >>>>eps <- 0.8 >>>>sigma2 <- matrix(c(1, eps, eps, 1), ncol = 2) >>>>x2 <- rmvnorm(n, sigma = sigma2) >>>>xx2 <- apply(x2, 2, pobs) >>>>cop2 <- kdecop(xx2) >>>> >>>>x11() >>>>plot(cop1, main = "cop1 main") >>>>x11() >>>>plot(cop2, main = "cop2 main") >>>> >>>>cplot <- function(cop1, cop2) { >>>> x11() >>>> plot(cop1, main = "cop1 function") >>>> x11() >>>> plot(cop2, main = "cop2 function") >>>>} >>>> >>>>cplot(cop1, cop2) >>>> >>>>cat("Press to quit") >>>>readLines(file("stdin"), n >>>> >>>>= >>>> >>>>1) >>>>quit() >>>> >>>>When I run it with Rscript all four x11 windows pop up, however the >>one >>>>that should display "cop1 function" is blank, the wireframe is not >>>>plotted. >>>>This is R 3.3.1, on Fedora 20. >>>>I see similar behaviour on Fedora 24, R 3.3.3 when I run the code >>from >>>>RStudio (the most recent one). >>>> >>>>George >>>> >>>> [[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.
Re: [R] Wireframe plot inside a function
Thanks. After changing the function to cplot <- function(cop1, cop2) { x11() o <- plot(cop1, main = "cop1 function") print(o) x11() o <- plot(cop2, main = "cop2 function") print(o) } I see both plots. But, since "cop2 function" was plotted before, does it mean it is plotted twice now? Looks as a strange design. I did check the "Plain text mode" in Chrome, you should see only the text part. George On 21 April 2017 at 16:27, Jeff Newmiller wrote: > FAQ 7.22 > And don't send HTML email... you are the one making it difficult for us to > read your question. > > -- > Sent from my phone. Please excuse my brevity. > > On April 21, 2017 8:27:20 AM PDT, George Trojan - NOAA Federal > wrote: >>Consider the following example: >> >>library("kdecopula") >>library("mvtnorm") >> >>pobs <- function(x) rank(x) / (length(x) + 1) >> >>n <- 1000 >> >>sigma1 <- diag(x = 1, 2, 2) >>x1 <- rmvnorm(n, sigma = sigma1) >>xx1 <- apply(x1, 2, pobs) >>cop1 <- kdecop(xx1) >> >>eps <- 0.8 >>sigma2 <- matrix(c(1, eps, eps, 1), ncol = 2) >>x2 <- rmvnorm(n, sigma = sigma2) >>xx2 <- apply(x2, 2, pobs) >>cop2 <- kdecop(xx2) >> >>x11() >>plot(cop1, main = "cop1 main") >>x11() >>plot(cop2, main = "cop2 main") >> >>cplot <- function(cop1, cop2) { >> x11() >> plot(cop1, main = "cop1 function") >> x11() >> plot(cop2, main = "cop2 function") >>} >> >>cplot(cop1, cop2) >> >>cat("Press to quit") >>readLines(file("stdin"), n >> >>= >> >>1) >>quit() >> >>When I run it with Rscript all four x11 windows pop up, however the one >>that should display "cop1 function" is blank, the wireframe is not >>plotted. >>This is R 3.3.1, on Fedora 20. >>I see similar behaviour on Fedora 24, R 3.3.3 when I run the code from >>RStudio (the most recent one). >> >>George >> >> [[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.
Re: [R] Interesting quirk with fractions and rounding
The subject is messy. I vaguely remember learning this stuff on my first numerical analysis course over 40 years ago. The classic reference material (much newer, only 25 years old) is: What Every Computer Scientist Should Know About Floating-Point Arithmetic, David Goldberg, ACM Computing Surveys, Vol 23, No 1, 1991. Available here: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 George I suggest you read some basic books on numerical analysis and/or talk > with a numerical analyst. You are (like most of us) an amateur at this > sort of thing trying to reinvent wheels. If you are concerned with > details, talk with experts. Don't assume what you don't know. This > list is *not* a reliable source of such expertise, although there > *are* individuals in the R universe with considerable knowledge who > may or may not choose to respond. > Cheers, > Bert > Bert Gunter > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Apr 21, 2017 at 5:19 AM, Paul Johnson https://stat.ethz.ch/mailman/listinfo/r-help>> wrote: >* We all agree it is a problem with digital computing, not unique to R. I *>* don't think that is the right place to stop. *>>* What to do? The round example arose in a real funded project where 2 R *>* programs differed in results and cause was that one person got 57 and *>* another got 58. The explanation was found, but its less clear how to *>* prevent similar in future. Guidelines, anyone? *>>* So far, these are my guidelines. *>>* 1. Insert L on numbers to signal that you really mean INTEGER. In R, *>* forgetting the L in a single number will usually promote whole calculation *>* to floats. *>* 2. S3 variables are called 'numeric' if they are integer or double storage. *>* So avoid "is.numeric" and prefer "is.double". *>* 3. == is a total fail on floats *>* 4. Run print with digits=20 so we can see the less rounded number. Perhaps *>* start sessions with "options(digits=20)" *>* 5. all.equal does what it promises, but one must be cautious. *>>* Are there math habits we should follow? *>>* For example, Is it generally true in R that (100*x)/y is more accurate than *>* 100*(x/y), if x > y? (If that is generally true, couldn't the R *>* interpreter do it for the user?) *>>* I've seen this problem before. In later editions of the game theory program *>* Gambit, extraordinary effort was taken to keep values symbolically as *>* integers as long as possible. Avoid division until the last steps. Same in *>* Swarm simulations. Gary Polhill wrote an essay about the Ghost in the *>* Machine along those lines, showing accidents from trusting floats. *>>* I wonder now if all uses of > or < with numeric variables are suspect. *>>* Oh well. If everybody posts their advice, I will write a summary. *>>* Paul Johnson *>* University of Kansas *>>* On Apr 21, 2017 12:02 AM, "PIKAL Petr" https://stat.ethz.ch/mailman/listinfo/r-help>> wrote: *>>>* Hi *>>>>* The problem is that people using Excel or probably other such spreadsheets *>>* do not encounter this behaviour as Excel silently rounds all your *>>* calculations and makes approximate comparison without telling it does so. *>>* Therefore most people usually do not have any knowledge of floating point *>>* numbers representation. *>>>>* Cheers *>>* Petr *>>>>* -Original Message- *>>* From: R-help [mailto:r-help-bounces at r-project.org <https://stat.ethz.ch/mailman/listinfo/r-help>] On Behalf Of Paul *>>* Johnson *>>* Sent: Thursday, April 20, 2017 11:56 PM *>>* To: R-help https://stat.ethz.ch/mailman/listinfo/r-help>> *>>* Subject: [R] Interesting quirk with fractions and rounding *>>>>* Hello, R friends *>>>>* My student unearthed this quirk that might interest you. *>>>>* I wondered if this might be a bug in the R interpreter. If not a bug, it *>>* certainly stands as a good example of the dangers of floating point numbers *>>* in computing. *>>>>* What do you think? *>>>>* > 100*(23/40) *>>* [1] 57.5 *>>* > (100*23)/40 *>>* [1] 57.5 *>>* > round(100*(23/40)) *>>* [1] 57 *>>* > round((100*23)/40) *>>* [1] 58 *>>>>* The result in the 2 rounds should be the same, I think. Clearly some *>>* digital number devil is at work. I *guess* that when you put in whole *>>* numbers and group them like this (100*23), the interpreter does integer *>>* math, but if you group (23
[R] Wireframe plot inside a function
Consider the following example: library("kdecopula") library("mvtnorm") pobs <- function(x) rank(x) / (length(x) + 1) n <- 1000 sigma1 <- diag(x = 1, 2, 2) x1 <- rmvnorm(n, sigma = sigma1) xx1 <- apply(x1, 2, pobs) cop1 <- kdecop(xx1) eps <- 0.8 sigma2 <- matrix(c(1, eps, eps, 1), ncol = 2) x2 <- rmvnorm(n, sigma = sigma2) xx2 <- apply(x2, 2, pobs) cop2 <- kdecop(xx2) x11() plot(cop1, main = "cop1 main") x11() plot(cop2, main = "cop2 main") cplot <- function(cop1, cop2) { x11() plot(cop1, main = "cop1 function") x11() plot(cop2, main = "cop2 function") } cplot(cop1, cop2) cat("Press to quit") readLines(file("stdin"), n = 1) quit() When I run it with Rscript all four x11 windows pop up, however the one that should display "cop1 function" is blank, the wireframe is not plotted. This is R 3.3.1, on Fedora 20. I see similar behaviour on Fedora 24, R 3.3.3 when I run the code from RStudio (the most recent one). George [[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] Question about logspline
I have a dataset with values of limited precision. I am trying to plot its density using package logspline. The logspline() call with default parameters causes oscillations in the density plot. My solution was to fuzzify the input values, using function: > fuzz <- function(x, prec) x + runif(length(x), -prec / 2, prec /2) Is there a better idea, perhaps setting mind? Example: > x <- seq(-1, 1, by = 0.01) > ds <- rnorm(1000, sd = 0.2) > hist(ds, breaks = 40, freq = FALSE) > s <- logspline(ds) > lines(x, dlogspline(x, s), col = "red") > ds2 <- as.numeric(sapply(ds, function(x) sprintf("%.1f", x))) > s2 <- logspline(ds2) > lines(x, dlogspline(x, s2), col = "blue") > ds3 <- fuzz(ds2, 0.1) > s3 <- logspline(ds3) > lines(x, dlogspline(x, s3), col = "green") > George [[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] Help with saving user defined functions
I want to split my computation into parts. The first script processes the data, the second does the graphics. I want to save results of time-consuming calculations. My example tried to simulate this by terminate the session without saving it, so the environment was lost on purpose. What confuses me that ecdf can be saved and restored, but not my own derived function. Of course I can save parameters and redefine the function in the second script. Reading Chapter 8 of Advanced R, hopefully the book will clear my mind. On Mon, Feb 13, 2017 at 12:05 AM, Bert Gunter wrote: > It worked fine for me: > > > t <- rnorm(100) > > cdf <- ecdf(t) > > > > trans <- function(x) qnorm(cdf(x) * 0.99) > > saveRDS(trans, "/tmp/foo") > > trans(1.2) > [1] 1.042457 > > trans1 <- readRDS("/tmp/foo") > > trans1(0) > [1] 0.1117773 > > > Of course, if I remove cdf() from the global environment, it will fail: > > > rm(cdf) > > trans1(0) > Error in qnorm(cdf(x) * 0.99) : could not find function "cdf" > > So it looks like you're clearing you global workspace in between > saving and loading? > > You may need to read up on function closures/lexical scoping : A > user-defined function in R includes not only code but also a pointer > to the environment in which it was defined, in your case, the global > environment from which you apparently removed cdf(). Note that > functions are not evauated until called, so free variables in the > functions that do not or will not exist in the function's lexical > scope when called will not trigger any errors until the function *is* > called. > > Same comments for your second version -- if tmp is removed the > function will fail. > > > > Cheers, > Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sun, Feb 12, 2017 at 2:11 PM, George Trojan - NOAA Federal > wrote: > > I can't figure out how to save functions to RDS file. Here is an example > > what I am trying to achieve: > > > >> t <- rnorm(100) > >> cdf <- ecdf(t) > >> cdf(0) > > [1] 0.59 > >> saveRDS(cdf, "/tmp/foo") > >> > > Save workspace image? [y/n/c]: n > > [gtrojan@asok petproject]$ R > >> cdf <- readRDS("/tmp/foo") > >> cdf > > Empirical CDF > > Call: ecdf(t) > > x[1:100] = -2.8881, -2.2054, -2.0026, ..., 2.0367, 2.0414 > > > > This works. However when instead of saving cdf() I try to save function > > > >> trans <- function(x) qnorm(cdf(x) * 0.99) > > > > after restoring object from file I get an error: > > > >> trans <- readRDS("/tmp/foo") > >> trans(0) > > Error in qnorm(cdf(x) * 0.99) : could not find function "cdf" > > > > I tried to define and call cdf within the definition of trans, without > > success: > > > >> tmp <- rnorm(100) > >> trans <- function(x) { cdf <- ecdf(tmp); cdf(0); qnorm(cdf(x)) * 0.99 } > >> saveRDS(trans, "/tmp/foo") > > Save workspace image? [y/n/c]: n > > > >> trans <- readRDS("/tmp/foo") > >> trans > > function(x) { cdf <- ecdf(tmp); cdf(0); qnorm(cdf(x)) * 0.99 } > >> trans(0) > > Error in sort(x) : object 'tmp' not found > > > > So, here the call cdf(0) did not force evaluation of my random sample. > What > > am I missing? > > > > George > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with saving user defined functions
I can't figure out how to save functions to RDS file. Here is an example what I am trying to achieve: > t <- rnorm(100) > cdf <- ecdf(t) > cdf(0) [1] 0.59 > saveRDS(cdf, "/tmp/foo") > Save workspace image? [y/n/c]: n [gtrojan@asok petproject]$ R > cdf <- readRDS("/tmp/foo") > cdf Empirical CDF Call: ecdf(t) x[1:100] = -2.8881, -2.2054, -2.0026, ..., 2.0367, 2.0414 This works. However when instead of saving cdf() I try to save function > trans <- function(x) qnorm(cdf(x) * 0.99) after restoring object from file I get an error: > trans <- readRDS("/tmp/foo") > trans(0) Error in qnorm(cdf(x) * 0.99) : could not find function "cdf" I tried to define and call cdf within the definition of trans, without success: > tmp <- rnorm(100) > trans <- function(x) { cdf <- ecdf(tmp); cdf(0); qnorm(cdf(x)) * 0.99 } > saveRDS(trans, "/tmp/foo") Save workspace image? [y/n/c]: n > trans <- readRDS("/tmp/foo") > trans function(x) { cdf <- ecdf(tmp); cdf(0); qnorm(cdf(x)) * 0.99 } > trans(0) Error in sort(x) : object 'tmp' not found So, here the call cdf(0) did not force evaluation of my random sample. What am I missing? George [[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] diff doesnot work
Dear R users, I have a txt file entitled coc composed by one column of numeric values without header and having 50 rows. This file is under the following path: C:\\Users\\intel\\Documents\\TR I have written the following lines: xcx=read.table("C:\\Users\\intel\\Documents\\TR\\coc.txt",header=F) xc=log(xcx) I have obtained the series xc but when I wrote x=diff(xc) I obtained the following message: data frame with 0 columns and 50 rows I don't know where is the problem. Can you help me please [[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] R2Cube integration errors
Why this happens? > library("R2Cuba") > f <- function(x) 0 > cuhre(ndim=1, ncomp=1, f) Iteration 1: 11 integrand evaluations so far [1] 0 +- 0 chisq 0 (0 df) Iteration 2: 33 integrand evaluations so far [1] 0 +- 0 chisq 0 (1 df) integral: 0 (+-0) nregions: 2; number of evaluations: 33; probability: 0 > vegas(ndim=1, ncomp=1, f) Iteration 1: 1000 integrand evaluations so far [1] 0 +- 7.02518e-18chisq 0 (0 df) . . . Iteration 13: 52000 integrand evaluations so far [1] 0 +- 2.65413e-18chisq 0 (12 df) integral: 0 (+-2.7e-18) number of evaluations: 52000; probability: 0 failed with message ‘Dimension out of range’ > suave(ndim=1, ncomp=1, f) . . . [1] 0 +- 7.02462e-17chisq 0 (411 df) integral: 0 (+-7e-17) nregions: 50; number of evaluations: 5; probability: 0 failed with message ‘Dimension out of range’ Is this a bug? George [[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] rgl does not plot
I have installed package rgl without any problems. I can load the library, issue commands from console without any errors showing up, however I can't get anything plotted. Example session: > library(rgl) > plot3d(rnorm(100), rnorm(100), rnorm(100)) > rgl.quit() > library(rgl) > .check3d() glX 1 > plot3d(rnorm(100), rnorm(100), rnorm(100)) > > open3d() glX 2 > plot3d(rnorm(100), rnorm(100), rnorm(100)) > rgl.quit() .check3d() and open3d() open a small window ~8x8 cm, copying desktop background under it, which stays there when the window is moved. plot3d() does not do anything. rgl.quit() closes the windows, as expected. I am running Fedora 24 Scientific, NVIDIA video card with NVIDIA proprietory driver that supports GLX. Any idea where to look for a solution? George [[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] gamlss question
What is the recommended way of accessing distribution parameters (mu, sigma, ...) from the model fit? The indention is to use those values in d/p/q/r calls. I came out with a wrapper gamlss_fit <- function(x, family) { fit <- gamlssML(x, family = family) mu <- fitted(fit, "mu")[1] sigma <- fitted(fit, "sigma")[1] nu <- ifelse("nu" %in% fit$parameters, fitted(fit, "nu")[1], NA) tau <- ifelse("tau" %in% fit$parameters, fitted(fit, "tau")[1], NA) list(mu = mu, sigma = sigma, nu = nu, tau = tau) } Alternatively, I could write functions to emulate logspline calls to density estimation. I suspect I must be missing something obvious. I am relatively new to R. George [[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] Matrix multiplications
Thank you very much Peter. On Sat, May 21, 2016 at 9:18 PM, peter dalgaard wrote: > > > On 21 May 2016, at 21:00 , george brida wrote: > > > > Dear R users: > > > > I have written the following lines : > > > >> x=c(10,11,12,13,14,17,15,16,10,11,41,25,26,14,12,14,15,20,14,22) > >> x=matrix(x,ncol=2) > >> a=matrix(1,nrow(x),1) > >> X=cbind(a,x) > >> y=c(12.00, 11.00, 13.00, 12.50, 14.00, 18.50, 15.00, 12.50, 13.75, > 15.00) > > > >> b=solve(t(X)%*% X)%*% t(X)%*% y > > > > when I wrote the following line > >> (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))*solve(t(X)%*% X) > > I have obtained an error message, I don't know why namely (t(y-X %*% > > b)%*%(y-X %*% b)/(length(y)-ncol(X))) is a scalar: > >> (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X))) > > [,1] > > [1,] 3.620354 > > > > > > Can you please help me. > > Mistake is that (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X))) is NOT a > scalar, but a 1 x 1 matrix. > > This works: > > as.vector((t(y-X %*% b)%*%(y-X %*% b))/(length(y)-ncol(X)))*solve(t(X)%*% > X) > > as does recognizing the first term as a sum of squares: > > sum((y-X %*% b)^2)/(length(y)-ncol(X))*solve(t(X)%*% X) > > (And, for the Illuminati, a Kronecker product works too: > > (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X))) %x% solve(t(X)%*% X) > > This could be useful for multivariate y.) > > > > > Thank you > > > > George > > > > [[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. > > -- > 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 > > > > > > > > > > [[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] Matrix multiplications
Roy, Yes, t(y-X %*% b) is the transpose of y-X %*% b. In principle the product of t(y-X %*% b) *(y-X %*% b) is a scalar, I don't know why I have an error message after the following line: (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))*solve(t(X)%*% X) Thanks On Sat, May 21, 2016 at 9:10 PM, Roy Mendelssohn - NOAA Federal < roy.mendelss...@noaa.gov> wrote: > > str(t(y-X %*% b)) > num [1, 1:10] 0.595 -1.7538 -0.0498 -1.651 -0.6328 ... > > str((y-X %*% b)) > num [1:10, 1] 0.595 -1.7538 -0.0498 -1.651 -0.6328 … > > -Roy > > > > On May 21, 2016, at 12:00 PM, george brida > wrote: > > > > Dear R users: > > > > I have written the following lines : > > > >> x=c(10,11,12,13,14,17,15,16,10,11,41,25,26,14,12,14,15,20,14,22) > >> x=matrix(x,ncol=2) > >> a=matrix(1,nrow(x),1) > >> X=cbind(a,x) > >> y=c(12.00, 11.00, 13.00, 12.50, 14.00, 18.50, 15.00, 12.50, 13.75, > 15.00) > > > >> b=solve(t(X)%*% X)%*% t(X)%*% y > > > > when I wrote the following line > >> (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))*solve(t(X)%*% X) > > I have obtained an error message, I don't know why namely (t(y-X %*% > > b)%*%(y-X %*% b)/(length(y)-ncol(X))) is a scalar: > >> (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X))) > > [,1] > > [1,] 3.620354 > > > > > > Can you please help me. > > > > Thank you > > > > George > > > > [[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. > > ** > "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > ** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new address and phone*** > 110 Shaffer Road > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK > Jr. > > [[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] Matrix multiplications
Dear R users: I have written the following lines : >x=c(10,11,12,13,14,17,15,16,10,11,41,25,26,14,12,14,15,20,14,22) > x=matrix(x,ncol=2) > a=matrix(1,nrow(x),1) > X=cbind(a,x) >y=c(12.00, 11.00, 13.00, 12.50, 14.00, 18.50, 15.00, 12.50, 13.75, 15.00) >b=solve(t(X)%*% X)%*% t(X)%*% y when I wrote the following line >(t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))*solve(t(X)%*% X) I have obtained an error message, I don't know why namely (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X))) is a scalar: > (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X))) [,1] [1,] 3.620354 Can you please help me. Thank you George [[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] R cannot allocate a vector of size 5.4mb
Hi, I am trying to do mixed integer programming using R & Java. My input is a list of flight legs which is proportional to the number of times the loop is executed. The input is fed from java to R. I cannot avoid the for loops as it is part of the logic. I am running into a "cannot allocate a vector of size 5.4mb" error. The system memory available 16Gb and nearly 11Gb of it is used. I checked on the memory.limit() in R and it is showing as 16Gb. Can someone guide me with this. package used to connect r and java - Rserve I checked with Rserve developers to reduce the execution time of my loop but after doing that i ran into the above mentioned error Thanks & Regards Jijo Sunny DISCLAIMER: "The information in this e-mail and any atta...{{dropped:12}} __ 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] [R-pkgs] New package 'netdiffuseR: Network Analysis for Diffusion of Innovations'
Dear useRs, We are happy to announce that the R package 'netdiffuseR: Network Analysis for Diffusion of Innovations' is now on CRAN (https://cran.r-project.org/web/packages/netdiffuseR/). From the package's description: "Empirical statistical analysis, visualization and simulation of network models of the diffusion of innovations. The package implements algorithms for calculating network diffusion statistics such as transmission rate, hazard rates, exposure models, network threshold levels, infectiousness (contagion), and susceptibility. The package is inspired by work published in Valente, et al., (2015) ; Valente (1995) , Myers (2000) , Iyengar and others (2011) , Burt (1987) ; among others." Some other relevant features: - Allows working with relative large graphs via sparse matrices (easily handles tenths of thousands vertices), and - Includes three classical network diffusion of innovations datasets: Brazilian Farmers, Korean Family Planning and Medical Innovation The package should be available to be installed via R's install.packages function in the following hours as CRAN builds binaries for Windows/OSX and mirrors have them available to be installed. For those of you who are interested on taking a deep look on this new tool, we will be offering a workshop at the 2016 SUNBELT Conference (http://insna.org/sunbelt2016/) , so we encourage you to sign in! Best, George G. Vega Yon +1 (626) 381 8171 http://www.its.caltech.edu/~gvegayon/ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] SEM specify RAM model
Dear all, I am trying to create multiple SEM models in a loop - so that if I change the data they can easily be re-created rather than re-creating each RAM model line by line - therein lies my problem. I have a dataframe set out as follows1 Duration -> RC1 cov1 -0.2563002 MMSE -> RC1 cov2 -0.0309003 RC1 -> Aggression npi1 0.2310004RC1 -> Apathy npi2 0.1043005 RC1 -> Disinhibition npi3 0.279800 ... the specifyModel() and specifyEquations() methods need you to manually input each line individually. Can I simply supply the SEM method with a matrix like the one I have above? Thanks,George [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] New to R
I successfully downloaded and loaded the stockPortfolio and quadprog packages, but when I entered the following command I got an error: returns <- getReturns(names(stocks), freq="week") Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open: HTTP status was '404 Not Found' When I tried discovering the source of this error, it appears that the file has been temporarily moved to a new URL address. Iâm currently running Windows 8.1. Is there a fix for this? Sent from Windows Mail [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with plm package
Ah ok. the problem is somewhat great, I can't rewrite it in txt file. On Wed, Jan 29, 2014 at 10:48 PM, george brida wrote: > Ah ok. the problem is somewhat great, I can't rewrite it in txt file. > > > On Wed, Jan 29, 2014 at 9:52 PM, arun wrote: > >> HI George, >> >> Some of the attachments get stripped off by the mailing list. Check this >> link: >> http://www.r-project.org/mail.html >> >> >> May be .txt files will be okay. >> Arun >> >> >> >> >> On Wednesday, January 29, 2014 3:43 PM, george brida < >> george.br...@gmail.com> wrote: >> Hi Arun >> you can't open the file? >> >> >> On Wed, Jan 29, 2014 at 9:23 PM, arun wrote: >> >> > Hi, >> > Your attachment didn't came through. >> > A.K. >> > >> > >> > >> > >> > >> > On Wednesday, January 29, 2014 12:03 PM, george brida < >> > george.br...@gmail.com> wrote: >> > Dear friends, >> > I have a csv data entitled GFS in the following path: >> > c:\TEG >> > This data is attached with this mail. >> > When I wrote the following lines: >> > >> > y=read.csv("c:\\TEG\\GFS.csv", header=FALSE, sep=";") >> > purtest(y, pmax = 4, exo = "intercept", test = "hadri") >> > >> > I obtained the following message: >> > >> > Error in Math.factor(x) : cumsum not meaningful for factors >> > In addition: There were 50 or more warnings (use warnings() to see the >> > first 50) >> > >> > where's the problem? can you please help me >> > Thank you in advance >> > George >> > >> > __ >> > R-help@r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > >> > >> >> [[alternative HTML version deleted]] >> >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with plm package
Hi Arun you can't open the file? On Wed, Jan 29, 2014 at 9:23 PM, arun wrote: > Hi, > Your attachment didn't came through. > A.K. > > > > > > On Wednesday, January 29, 2014 12:03 PM, george brida < > george.br...@gmail.com> wrote: > Dear friends, > I have a csv data entitled GFS in the following path: > c:\TEG > This data is attached with this mail. > When I wrote the following lines: > > y=read.csv("c:\\TEG\\GFS.csv", header=FALSE, sep=";") > purtest(y, pmax = 4, exo = "intercept", test = "hadri") > > I obtained the following message: > > Error in Math.factor(x) : cumsum not meaningful for factors > In addition: There were 50 or more warnings (use warnings() to see the > first 50) > > where's the problem? can you please help me > Thank you in advance > George > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with plm package
Dear friends, I have a csv data entitled GFS in the following path: c:\TEG This data is attached with this mail. When I wrote the following lines: y=read.csv("c:\\TEG\\GFS.csv", header=FALSE, sep=";") purtest(y, pmax = 4, exo = "intercept", test = "hadri") I obtained the following message: Error in Math.factor(x) : cumsum not meaningful for factors In addition: There were 50 or more warnings (use warnings() to see the first 50) where's the problem? can you please help me Thank you in advance George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How can I cluster a set of formulae?
I am working on a problem in which I have derived a set of D formulae relating a different dependent variable to a grouping of independent variables. D1 = intercept + ax1 + bx2 + bx3 + bx4 D2 = intercept + ex2 + fx7 + gx8 D3= intercept + hx1 + ix3 + jx7 etc to ... D8. I have 3 categorical variables P, Q and A [which are actually hierarchical with A within Q with P, each containing a different number of classes] – I want to look at each of the categorical variables as a separate issue clustering each of the D formulae into classes, so I can say something about how the D's vary / interact across classes. Intuitively this seems to be a discriminant function problem because the classes are already known. However, a PCA or FA might be necessary – and then do a DFA on the clusters. Either way I am not sure how to set it up or even if I can interpret it to make sense. Alternatively, I might be climbing up/down the wrong tree [pun intended]. Other methods might be better. Help! George F. Hart I'm sending this to a number of statistics groups so apologize if you get this note more than once. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unable to carry through object in a nested function
Hi, This is a resend of a previous message reproduced below but with sample data to run. Thanks. George Chen Hi There, I am having trouble carrying through an object listed in the outer function into the inner function of a nested pair. sample data below - library(plyr) SUBJECT<-c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) STIM<-c("No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No") CELL<-c("CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4","CD4") SIGNAL<-c("ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC") DAY<-c(7,7,7,7,7,7,7,7,7,7,1,1,1,1,1,1,1,1,1,1) SIMSCORE<-c(2,3,4,5,2,3,4,5,2,3,4,5,2,3,4,5,2,3,4,5) PrePropData<-data.frame(SUBJECT, STIM, CELL, SIGNAL, DAY, SIMSCORE) This is my code: FindGreaterThanProportion<- function (y, SSThreshold) { DenomCells<-length(y) NumerCells<-subset(y,y>SSThreshold) PropCells<-length(NumerCells)/DenomCells return (PropCells) } GetPropPlot<- function (PrePropData, direction, SSThreshold, cell, stim) { # Split up the dataframe with ddply and apply the function print(direction) print (SSThreshold) if (direction==">") { PropData<-ddply(PrePropData,.(SUBJECT, STIM, CELL, SIGNAL, DAY), summarise, PROP=FindGreaterThanProportion(SIMSCORE, SSThreshold)) } PlotSubset <- subset(PropData, PropData$STIM==stim & PropData$CELL == cell) PropPlot<-ggplot(data=PlotSubset, aes(x=DAY, y=PROP)) + geom_line() + geom_point() + facet_grid(SIGNAL~SUBJECT) return(FinalPropPlot) } GetPropPlot(PrePropData, direction=">", SSThreshold=3, "CD4", "No") When I run the code, I get this error: [1] ">" [1] 3 Error in subset.default(y, y > SSThreshold) : object 'SSThreshold' not found It seems as if SSThreshold is not being passed into FindGreaterThanProportion. Any help would be appreciated to determine what I am doing incorrectly. Thanks in advance. George Chen This email message may contain legally privileged and/or confidential information. If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited. If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] unable to carry through object in a nested function
Hi There, I am having trouble carrying through an object listed in the outer function into the inner function of a nested pair. This is my code: FindGreaterThanProportion<- function (y, SSThreshold) { DenomCells<-length(y) NumerCells<-subset(y,y>SSThreshold) PropCells<-length(NumerCells)/DenomCells return (PropCells) } GetPropPlot<- function (PrePropData, direction, SSThreshold, cell, stim) { # Split up the dataframe with ddply and apply the function print(direction) print (SSThreshold) if (direction==">") { PropData<-ddply(PrePropData,.(SUBJECT, STIM, CELL, SIGNAL, DAY), summarise, PROP=FindGreaterThanProportion(SIMSCORE, SSThreshold)) } PlotSubset <- subset(PropData, PropData$STIM==stim & PropData$CELL == cell) PropPlot<-ggplot(data=PlotSubset, aes(x=DAY, y=PROP)) + geom_line() + geom_point() + facet_grid(SIGNAL~SUBJECT) return(FinalPropPlot) } When I run the code, I get this error: [1] ">" [1] 2 Error in subset.default(y, y > SSThreshold) : object 'SSThreshold' not found It seems as if SSThreshold is not being passed into FindGreaterThanProportion. Any help would be appreciated to determine what I am doing incorrectly. Thanks in advance. George Chen This email message may contain legally privileged and/or confidential information. If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited. If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I perform conditional annotation of lattice panel plots?
My apologies for asking this question that may have been asked before. I am trying to plot activity dependent on time conditioned by the subject. Code for sample data below. So I have something like this xyplot(Activity~Time|Subject). This works fine, but now I want to show where on these activity curves Event A occurs. This is to explore the relationship between A and activity. I tried this: xyplot(EventA+Activity~Time|Subject) but then the numerical ordering gets out of order. Ideally Event A could be denoted by a vertical line cutting through the curve at the day Event A occurred, but some other way to denote it would be great! Here is my sample data as R code: Subject<-c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4) Day<-c(1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6) Activity<-c(2,3,4,3,7,4,5,8,2,8,4,6,2,5,3,8,9,5,6,3,4,5,6,7) EventA<-c("Yes",NA,"Yes",NA,NA,NA,"Yes",NA,NA,NA,NA,NA, "Yes",NA,NA,NA,NA,NA,NA,NA,"Yes",NA,NA,NA) Data<-data.frame(cbind(Subject,Day,Activity,EventA)) Subject Day Activity EventA 11 12Yes 21 23 31 34Yes 41 43 51 57 61 64 72 15Yes 82 28 92 32 10 2 48 11 2 54 12 2 66 13 3 12Yes 14 3 25 15 3 33 16 3 48 17 3 59 18 3 65 19 4 16 20 4 23 21 4 34Yes 22 4 45 23 4 56 24 4 67 Any ideas on how to do this would be appreciated! Thanks very much in advance! This email message may contain legally privileged and/or confidential information. If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited. If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Difference between arima(1, 1, 1) of y and arima(1, 0, 1) of diff(y)
Hi Mark, This is very helpful!! Much appreciated Sent from my iPad On Jul 19, 2013, at 3:51 AM, Mark Leeds wrote: > Hi George: Assuming it's still relevant, the link below will explain why. > > http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm > > > > On Thu, Jul 18, 2013 at 2:14 PM, George Milunovich > wrote: >> Dear all, >> When I run an arima(1,1,1) on an I(1) variable, y, I get different estimates >> to when I first difference the variable myself, e.g y2<-diff(y), and then >> run arima(1,0,1) on y2. Shouldn't these two approaches give the same output? >> Any help will be much appreciated. >> george >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Difference between arima(1, 1, 1) for y and arima(1, 0, 1) for diff(y)
Dear all, When I run an arima(1,1,1) on an I(1) variable, e.g. y, I get different estimates to when I first difference the variable myself, e.g y2<-diff(y), and then run arima(1,0,1) on y2. Shouldn't these two approaches give the same output? Any help will be much appreciated. george -- View this message in context: http://r.789695.n4.nabble.com/Difference-between-arima-1-1-1-for-y-and-arima-1-0-1-for-diff-y-tp4671873.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] restrected arima models
Thanks Sent from my iPhone On 19/07/2013, at 1:43 AM, "Prof Brian Ripley [via R]" wrote: > On 18/07/2013 16:14, george wrote: > > Dear all, > > Does anyone know if it is possible to estimate restricted arima models > > using > > the arima command in R? For instance lets say I want arima(6,0,0) but where > > the first three ar parameters are restricted to zero, ie. ar(1)=ar(2)=ar(3) > > = 0, and only the last three are actually estimated. > > Yes. > > > Any help will be much appreciated. > > Have you read the help page? Someone helped you by writing it (and > indeed, by providing the facility, which few ARIMA-fitting programs have). > > fixed: optional numeric vector of the same length as the total >number of parameters. If supplied, only âNAâ entries in >âfixedâ will be varied. âtransform.pars = TRUEâ will be >overridden (with a warning) if any AR parameters are fixed. > > E.g. > > x <- rnorm(100) > arima(x, order=c(6,0,0), fixed = c(0,0,0,NA,NA,NA,NA)) > > Coefficients: >ar1 ar2 ar3 ar4 ar5 ar6 intercept > 0 00 0.0423 0.0977 0.1299-0.1462 > s.e.000 0.1065 0.1075 0.1059 0.1323 > > > > george > > > > -- > Brian D. Ripley, [hidden email] > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > > __ > [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. > > > If you reply to this email, your message will be added to the discussion > below: > http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847p4671862.html > To unsubscribe from restrected arima models, click here. > NAML -- View this message in context: http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847p4671867.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Difference between arima(1, 1, 1) of y and arima(1, 0, 1) of diff(y)
Dear all, When I run an arima(1,1,1) on an I(1) variable, y, I get different estimates to when I first difference the variable myself, e.g y2<-diff(y), and then run arima(1,0,1) on y2. Shouldn't these two approaches give the same output? Any help will be much appreciated. george __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] restrected arima models
Dear all, Does anyone know if it is possible to estimate restricted arima models using the arima command in R? For instance lets say I want arima(6,0,0) but where the first three ar parameters are restricted to zero, ie. ar(1)=ar(2)=ar(3) = 0, and only the last three are actually estimated. Any help will be much appreciated. george -- View this message in context: http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fonts not rendering during plot
I apologize for not going in to too much detail-I didn't want to confuse people with the gory details of what I'm trying to do (trying to make a portable R installation bundled in to a mac app, among other things). I am on a mac, Mountain Lion. Anyhow, I figured out the problem was with the paths pango looks uses to search for font configuration files. I solved it by writing a script that sets these paths at run-time. George On Apr 24, 2013, at 7:45 PM, David Winsemius wrote: > > On Apr 24, 2013, at 7:29 AM, George Dietz wrote: > >> Hi, >> >> I am having a problem where sometimes fonts for text in plots don't get >> rendered-the text just shows up as boxes. If I call R from a certain >> directory the problem goes away, otherwise the fonts don't render (but plots >> get made). In both cases, my PANGO_RC and FONTCONFIG_FILE do not change… > > Offering the OS details is more courteous than omitting them. (And there are > several other courtesies expected of you listed in the Fine Posting Guide.) > If this happens to be on a Mac, it may mean your screen fonts are corrupt. > You can see their names with: names(quartzFonts()). Using Fontbook.app will > sometimes reveal that there are two copies of one of the screen graphics > fonts and that one of them displays as blanks. These should be deleted with > Fontbook.app. > > -- > > David Winsemius > Alameda, CA, USA > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fonts not rendering during plot
Hi, I am having a problem where sometimes fonts for text in plots don't get rendered-the text just shows up as boxes. If I call R from a certain directory the problem goes away, otherwise the fonts don't render (but plots get made). In both cases, my PANGO_RC and FONTCONFIG_FILE do not change… Thank you, -George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nomogram after Cox Random Effect (frailty) model
Dear R-users, I am a novice R-user with some experience in using the RMS package for taking nomograms after various survival models. This time, I am trying to plot a nomogram after a Random Effects Cox, implemented by the "coxme" package. My questions are: 1. Is it possible to take a nomogram directly after the coxme survival function? 2. If not is there a way to take the linear predictor results and plug them into the RMS cox model and get the nomogram I want? Any instructions/suggestions would be highly appreciable? Thank you in advance George Dr. George Bouliotis Research Fellow in BiostatisticsMRC-MHTMR (Midland Hub for Trials Methodology Research) University of BirminghamPublic Health BuildingBirmingham B115 2TTUnited Kingdom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to drop unused factors in faceted R ggplot boxplot?
Hi and thanks. This unfortunately doesn't work because: "ggplot2 does not currently support free scales with a non-cartesian coord or coord_flip." -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: January-24-13 1:49 PM To: Gorczynski, George Cc: R help Subject: Re: [R] How to drop unused factors in faceted R ggplot boxplot? HI, You can get the plot in the same window, but the width seems to be a problem. stest<- read.table(text=" site year conc south 2001 5.3 south 2001 4.67 south 2001 4.98 south 2002 5.76 south 2002 5.93 north 2001 4.64 north 2001 6.32 north 2003 11.5 north 2003 6.3 north 2004 9.6 north 2004 56.11 north 2004 63.55 north 2004 61.35 north 2005 67.11 north 2006 39.17 north 2006 43.51 north 2006 76.21 north 2006 158.89 north 2006 122.27 ",sep="",header=T,stringsAsFactors=T) stest1<-stest stest1<- within(stest1,{year<- factor(year)}) ggplot(stest1, aes(x=year, y=conc)) + geom_boxplot(horizontal=TRUE)+ facet_wrap(~ site, ncol = 1, scales="free_x") + coord_flip()+scale_y_log10()+ theme_bw() + opts(strip.text.x = theme_text()) A.K. - Original Message - From: Niec To: r-help@r-project.org Cc: Sent: Thursday, January 24, 2013 1:13 PM Subject: Re: [R] How to drop unused factors in faceted R ggplot boxplot? Thank you, Jeff. I think I should have been more clear. I don't want to modify my data. I need to create a series of box plots for different sites (north and south in my example but there are many more) but I don't want empty rows in my plot - for years when data was not collected. I tried to make separate plots and join them with grid.arrange and it plots the layout I want but I can't get the boxes in all plots have uniform look (width), see the screenshot: <http://r.789695.n4.nabble.com/file/n4656535/2013-01-24_0949.png> And thank you for pointing out the shortcomings of my posted data sample. I'll be better prepared next time. -- View this message in context: http://r.789695.n4.nabble.com/How-to-drop-unused-factors-in-faceted-R-ggplot-boxplot-tp4656480p4656535.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fwd: Simulation of spatial Log-Gaussian Cox process in Spatstat
Hello, I have fitted a Log-Gaussian Cox Process on my data but when I try to use "simulate.kppm" of the spatstat package I get this error: Error in rLGCP(model = model, mu = mu, param = param, ..., win = win) : The spatial domain of the pixel image ‘mu’ does not cover the simulation window ‘win’ I've used covariates as im, changed the npixel value of the spatstat options to match the dimensions of the covariates images, but the problem keeps showing up. Maybe it has something to do with the irregular owin used as window of the ppp object? I'd appreciate any help! Regards, George -- === George Limitsios MSc. "Geography and Applied Geoinformatics" Dep. of Geography University of the Aegean __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] parApply computing
I'm using /parApply/() function in "snow" package for parallel computing (boostrapping repeating calculation), as the follows: MyBoostrapping <- function( i ){ . } cl <- makeCluster( ncluster, type = "SOCK") i.circle <- as.matrix( 1:128, , 1) parApply( cl, i.circle, 1, FUN = MyBoostrapping) It works. However, I want to set more than one arguments to function MyBoostrapping, e.g., MyBoostrapping <- function( i , A, B) Would you please help me on it? Thank you very much. -- View this message in context: http://r.789695.n4.nabble.com/parApply-computing-tp4650201.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Write to MS SQL Database
I want to update a column of a database table (in MS SQL) using sqlUpdate( ) or sqlSave( ) function in "RODBC" package. E.g. SQLchannel is the database connection; SQLtable is the destination table in the database, including at least two columns, ID and Value; Xdata is a data frame in R environment, including two columns: ID and Value. What I wanna do is to update the Value in SQLtable using Xdata, with ID as the primary key. Which is the fast way to do it? Thank you very much. -- View this message in context: http://r.789695.n4.nabble.com/Write-to-MS-SQL-Database-tp4649522.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I exactly align the right hand side of "mtext" relative to a plot device? Beyond "adj".
Hi, I have a problem with aligning text which I'm adding to a plot using "mtext". I would like to specify the position of the right hand end of the text string, relative to the device (in the left-right direction). I've been looking at the use of the argument "adj". But this can't be used to specify the rightmost point of the text. Neither does it specify exactly the centre of the text, so I'm not sure exactly how it works. I could hack it and change "adj" accordingly but this is part of a function which I need to generalise. So it needs to be the same regardless of the length of the added text, or the values on the x-axis. Here's a simple example with two versions (the first three lines of each version are identical). I would like the right end of the added text to be the same distance from the legend in both versions. ### v1 dev.new() plot(c(0,1),c(0,1),ylim=c(0,2)) legend("topright",c("data1","data2"),col=c(1,2),lty=1,bty="n") mtext("text",side=3,line=-2,adj=0.8) ### v2 dev.new() plot(c(0,1),c(0,1),ylim=c(0,2)) legend("topright",c("data1","data2"),col=c(1,2),lty=1,bty="n") mtext("really long text",side=3,line=-2,adj=0.8) Thank you for your help, George [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cp2tform equivalent
I'm a new R user and am looking for an R equivalent to the Matlab 'cp2tform' function (see: http://www.mathworks.com/help/toolbox/images/ref/cp2tform.html). cp2tform accepts pairs of 2D control points and produces a least-squares optimized spatial transformation from one set of points to the other. Specifically, I'm looking to produce the coefficients of a 3rd order polynomial transformation. I'm familiar with the mathematics involved, but am very new to R. If this functionality isn't implemented in R directly, a brief outline of the R functions that I'd use to implement it myself would be helpful. Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] no non-missing arguments to max; returning -Inf
Hi, I just wanted to object of class xts, zoo and I got the error no non-missing arguments to max; returning -Inf After all the values were printed. Tried searching on this forum, but no luck. Anyone has any idea ? Thanks. George -- View this message in context: http://r.789695.n4.nabble.com/no-non-missing-arguments-to-max-returning-Inf-tp4182296p4182296.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bruno's Panel LSDVC
I'm repeating the post. Has anyone written a routine for this R? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Re-Bruno-s-Panel-LSDVC-tp3680824p3726719.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bruno's Panel LSDVC
*Is there an implementation of this in R? Thanks. * [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about linear regression and leverage
Dear David, Thanks for your answer. Yes now that you mentioned these points are in the beginning of a variable range. From the plot of the residuals seems to have non constant variance which is solved by a transformation. I checked also for interactions by using the symbol : between two variables and the change on the result was not so important. I am working on computer science field but I wanted to do an analysis from scratch because some previous results that I have seen are not good for such cases. Moreover the data are not the same of course. Thanks, George On 06/21/2011 01:08 PM, David Winsemius wrote: > > On Jun 21, 2011, at 3:49 AM, George Markomanolis wrote: > >> Dear all, >> >> I am new to this field and I have a question about a linear regression. >> I have a dataset of around to 31000 points and I want to apply a linear >> regression. The R-squared is 0.9 however when I check the diagnostic >> plots I can see that there are around to 250 points with big leverage >> value. As I know the points with big leverage influence a lot the fit. >> If I remove these points in order to check their influence, the >> R-squared of the rest points is 0.71. So I removed less than 1% of my >> data and the fit is not so good. Could you please give me any advice >> about this? Is it right to let these 250 points in my dataset or not? >> Could I do something else? The data are measured through an experiment >> so even these 250 points are real values. > > You could be looking at the descriptive statistics on the points. > Perhaps they are at one end of a variable range, or you perhaps have > some other feature that is scientifically interesting. So far you have > only been examining one set of simple linear hypotheses and have not > (presumably) been looking at any non-linear possibilities or the > potential that interactions are affecting the outcome. The prior > science of your (so far undescribed) domain should be carefully > considered, but in your message we see no evidence of such. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about linear regression and leverage
Dear all, I am new to this field and I have a question about a linear regression. I have a dataset of around to 31000 points and I want to apply a linear regression. The R-squared is 0.9 however when I check the diagnostic plots I can see that there are around to 250 points with big leverage value. As I know the points with big leverage influence a lot the fit. If I remove these points in order to check their influence, the R-squared of the rest points is 0.71. So I removed less than 1% of my data and the fit is not so good. Could you please give me any advice about this? Is it right to let these 250 points in my dataset or not? Could I do something else? The data are measured through an experiment so even these 250 points are real values. Thanks a lot, George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rcspline.plot query
The actual dataframe that I have imported on R is Death adp 1 0 58.00 2 1 18.70 3 0 21.75 4 1 25.35 5 0 20.55 6 1 28.05 7 0 50.15 8 1 31.25 9 1 32.75 10 1 28.95 11 1 15.10 12 0 45.05 13 1 19.95 14 0 32.95 15 0 22.60 16 0 10.75 17 0 41.80 18 0 27.05 19 1 26.25 20 0 34.40 21 1 24.65 22 1 42.30 23 0 19.80 24 0 47.20 25 1 25.90 26 1 30.70 27 1 28.60 28 1 25.80 29 0 27.05 30 0 14.40 31 0 28.40 32 0 48.45 33 0 17.85 34 1 30.85 35 1 24.75 36 0 16.20 37 0 34.10 38 0 12.00 39 0 24.40 40 0 69.50 41 1 36.45 42 0 41.55 43 1 17.80 44 0 40.10 45 1 21.35 46 1 22.90 47 0 63.80 48 1 45.80 49 0 70.65 50 0 54.00 51 0 26.90 52 0 50.75 53 0 28.20 54 1 23.25 55 1 18.10 56 0 29.20 57 1 52.80 58 0 46.60 59 1 32.55 60 0 74.50 The R command that I actually use is > rcspline.plot ("adp", "Death", model="logistic", nk=3, knots=NULL) and the >rcspline.eval ("adp", nk=3, inclx=FALSE, knots.only=FALSE, type="ordinary") For both the commands I receive the same message : " fewer than 6 non missing observations". George -- View this message in context: http://r.789695.n4.nabble.com/rcspline-plot-query-tp3590233p3591679.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mtext text size (cex) doesn't match plot
thanks for reading the manual for me :X 2011/5/12 Prof Brian Ripley : > On Wed, 11 May 2011, George Locke wrote: > >> Hi, >> >> I am using mtext instead of the ylab argument in some plots because i >> want to move it away from the numbers in the axis. However, the text >> in the X axis, >> >> for example: >> par(mar=c(5, 5.5, 4, 2)); >> plot(data, main="plot name", xlab= 'X axis', ylab="", >> font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); >> mtext('Y axis', side=2, cex=1.5, line=4, font=2); >> >> This works fine, but if I then set >> >> par(mfrow=c(3,2)); >> >> the text produced by mtext becomes much larger than the text "X axis" >> produced by plot, despite their having identical cex specifications. >> In this case, the words "Y axis" become much larger than "plot name". >> Note that without par(mfrow) the size of "X axis" and "Y axis" match >> iff their cex(.lab) arguments match. >> >> How can I make mtext produce text that exactly matches the xlab? In >> my limited experience fiddling around with this problem, the size of >> the mtext does not depend on par(mfrow), whereas the size of the xlab >> does, so if there were a formula that relates the actual size of text, > > Please do read the help! ?mtext says > > cex: character expansion factor. ‘NULL’ and ‘NA’ are equivalent > to ‘1.0’. This is an absolute measure, not scaled by > ‘par("cex")’ or by setting ‘par("mfrow")’ or ‘par("mfcol")’. > > so no 'limited experience fiddling around with this problem' was needed. > And see ?par: > > ‘cex’ A numerical value giving the amount by which plotting text > and symbols should be magnified relative to the default. > This starts as ‘1’ when a device is opened, and is reset when > the layout is changed, e.g. by setting ‘mfrow’. > > ‘mfcol, mfrow’ A vector of the form ‘c(nr, nc)’. Subsequent > figures will be drawn in an ‘nr’-by-‘nc’ array on the device > by _columns_ (‘mfcol’), or _rows_ (‘mfrow’), respectively. > > In a layout with exactly two rows and columns the base value > of ‘"cex"’ is reduced by a factor of 0.83: if there are three > or more of either rows or columns, the reduction factor is > 0.66. > >> cex argument, and par(mfrow), then I could use that to attenuate the >> cex argument of mtext. Any solution will do, so long as it maintains >> the relative sizes of the plot and the three text fields (main, x axis >> label, y axis label). > > library(fortunes); fortune(14) applies -- see the posting guide. > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mtext text size (cex) doesn't match plot
Hi, I am using mtext instead of the ylab argument in some plots because i want to move it away from the numbers in the axis. However, the text in the X axis, for example: par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); This works fine, but if I then set par(mfrow=c(3,2)); the text produced by mtext becomes much larger than the text "X axis" produced by plot, despite their having identical cex specifications. In this case, the words "Y axis" become much larger than "plot name". Note that without par(mfrow) the size of "X axis" and "Y axis" match iff their cex(.lab) arguments match. How can I make mtext produce text that exactly matches the xlab? In my limited experience fiddling around with this problem, the size of the mtext does not depend on par(mfrow), whereas the size of the xlab does, so if there were a formula that relates the actual size of text, cex argument, and par(mfrow), then I could use that to attenuate the cex argument of mtext. Any solution will do, so long as it maintains the relative sizes of the plot and the three text fields (main, x axis label, y axis label). example code to demonstrate the problem is below. Thanks! data = c(1:10); par(mfrow=c(3,2)); par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); par(mar=c(5, 5.5, 4, 2)); plot(data, main="plot name", xlab= 'X axis', ylab="", font=2, cex.lab=1.5, font.lab=2, cex.main=1.8); mtext('Y axis', side=2, cex=1.5, line=4, font=2); __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] text file problem-Solved!
Oh! (hits head) It was the working directory!!! Problem solved from Change Dir... Many thanks to Samuel and Duncan! George [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] text file problem-Help needed
Hello! I have just uninstalled the R 2.4.1 that i was using and installed the latest version (R 2.12.1). In order to read a text file, i was copying the text file to C/Program Files/R/R 2.4.1, and the previous version was able to read it from there. I did the same think for the new version (copy text file to C/Program Files/R/R 2.12.1) and i tried to open it: data <- read.table('intersand.txt') but the result was: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'intersand.txt': No such file or directory Can someone tell me what the problem is? Must i copy the text file somewhere else? Thank you in advance, George Pantopoulos [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read a similarity matrix from excel
Dear Petr, It worked fine. Thanks for helping. George -Original Message- From: Petr PIKAL [mailto:petr.pi...@precheza.cz] Sent: Wednesday, February 02, 2011 1:18 PM To: George Kakarontzas Cc: r-help@r-project.org Subject: Odp: [R] Read a similarity matrix from excel Hi r-help-boun...@r-project.org napsal dne 01.02.2011 10:20:48: > Good morning, > > I have an excel spreadsheet with similarities among objects. The > format of > the file is the following: > > 1st row: ,,,..., > 2nd row: ,0,s<1,2>,s<1,3>,...,s<1,N> > 3rd row: ,s<2,1>,0,s<2,3>,...,s<2,N> > > The table is symmetrical and contains the similarities among the > objects (s stands for similarity among x and k). The first row > contains the name of the objects (strings of characters) in the same > order that these same names are contained in the first column. The cell <1,1> is empty. > > How can I read this in R so that after reading it I can perform a > hierarchical clustering. The table is 78x78 so it is relatively easy > to manually change something if it makes it easier to read. Select your table in Excel Press Ctrl-C In R do test<-read.delim("clipboard") you shall get something like that > test X a b c 1 a 1 23 3 2 b 4 5 6 3 c 7 8 9 > you has to get rid of first column > mat<-as.matrix(test[,-1]) and if you want you can put row.names tou your matrix > row.names(mat)<-colnames(mat) > mat a b c a 1 23 3 b 4 5 6 c 7 8 9 > row.names(mat)<-test$X > mat a b c a 1 23 3 b 4 5 6 c 7 8 9 > Regards Petr > > I found many articles about reading a data table with variables and > then constructing the distance matrix from within R, but I have the similarity > matrix instead. > > Thank you for your help > > George > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read a similarity matrix from excel
Good morning, I have an excel spreadsheet with similarities among objects. The format of the file is the following: 1st row: ,,,..., 2nd row: ,0,s<1,2>,s<1,3>,...,s<1,N> 3rd row: ,s<2,1>,0,s<2,3>,...,s<2,N> The table is symmetrical and contains the similarities among the objects (s stands for similarity among x and k). The first row contains the name of the objects (strings of characters) in the same order that these same names are contained in the first column. The cell <1,1> is empty. How can I read this in R so that after reading it I can perform a hierarchical clustering. The table is 78x78 so it is relatively easy to manually change something if it makes it easier to read. I found many articles about reading a data table with variables and then constructing the distance matrix from within R, but I have the similarity matrix instead. Thank you for your help George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Johnson Distribution Fit
I am trying to only fit this distribution to the data to see how well it fits it. Getting the parameters is secondary. Did correct the square brackets in the exponential equation but still get the same result. There is only 1 variable to data2 and that is points. I am trying to fit this distribution to points data scored by teams. The result for any(data2 < 0.5 | data2 > 0.5+50) is TRUE. Thanks Abey On Mon, Oct 4, 2010 at 11:33 AM, David Winsemius wrote: > > On Oct 3, 2010, at 3:47 PM, Abey George wrote: > > Hi, >> I am trying to fit a Johnson SB distribution using fitdist function in >> fitdistrplus Library. I have defined the Johnson SB distribution from ( >> http://www.ntrand.com/johnson-sb-distribution/) . But it gives me the >> follwing errors. Any help would be appreciated >> > > Are you really trying to estimate the bounding values as well as the gamma > and delta parameters. Those would seem to be more likely determined by the > nature of the problem, e.g., policy limits on the insured sums if this were > a financial problem. > > > >> #xi = xi >> > > #lambda =l >> #delta =d >> #gamma = g >> >> djohn = function(x,xi,l,d,g) >> (d/(l*sqrt(2*pi)*((x-xi)/l)*(1-((x-xi)/l*exp[-0.5*(g + >> d*log(((x-xi)/l)/(1-((x-xi)/l^2] >> > > You used exp[ ] where you probably wanted exp(). > > > >> pjohn = function(x,xi,l,d,g) pnorm(g + d*log(((x-xi)/l)/(1-((x-xi)/l >> >> qjohn = function(p,xi,l,d,g) xi + (l*exp((qnorm(p) - g)/d))/(1 + >> exp((qnorm(p) - g)/d)) >> >> f1c <- fitdist(data2,"john",start=list(xi = 0.5 ,l = 50, d = 1, g = 1)) >> > > You have not given us the "data2" variables, so we have no way of checking > whether any of them appear outside the range [epsilon, lambda+epsilon]. > Using your data2 vector, what are the results of : > > any(data2 < 0.5 | data2 > 0.5+50) #? > > > > >> Error in fitdist(data2, "john", start = list(xi = 0.5, l = 50, d = 1, : >> the function mle failed to estimate the parameters, >> with the error code 100 >> In addition: Warning message: >> In log(((x)/l)/(1 - ((x)/l))) : NaNs produced >> >> >> Cheers >> AG >> > > > David Winsemius, MD > West Hartford, CT > > -- Abey George [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Johnson Distribution Fit
Hi, I am trying to fit a Johnson SB distribution using fitdist function in fitdistrplus Library. I have defined the Johnson SB distribution from ( http://www.ntrand.com/johnson-sb-distribution/) . But it gives me the follwing errors. Any help would be appreciated #xi = xi #lambda =l #delta =d #gamma = g djohn = function(x,xi,l,d,g) (d/(l*sqrt(2*pi)*((x-xi)/l)*(1-((x-xi)/l*exp[-0.5*(g + d*log(((x-xi)/l)/(1-((x-xi)/l^2] pjohn = function(x,xi,l,d,g) pnorm(g + d*log(((x-xi)/l)/(1-((x-xi)/l qjohn = function(p,xi,l,d,g) xi + (l*exp((qnorm(p) - g)/d))/(1 + exp((qnorm(p) - g)/d)) f1c <- fitdist(data2,"john",start=list(xi = 0.5 ,l = 50, d = 1, g = 1)) Error in fitdist(data2, "john", start = list(xi = 0.5, l = 50, d = 1, : the function mle failed to estimate the parameters, with the error code 100 In addition: Warning message: In log(((x)/l)/(1 - ((x)/l))) : NaNs produced Cheers AG [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Converting a line by line program into an array to perform summary stats
I am trying to turn several lines of information into a variable. I used the filx function to input my file then the readlines to qualify what I want. Essentially I have data in a file every 10 minutes through a day for several years down a column: date time value 9/28/10 02:00 13 9/28/10 02:10 15 9/28/10 02:20 12 9/28/10 02:30 11 etc. I then use if statements to segment the day into various portions (2:00 to 2:30 for example) and find the average or maximum value for the time. Next I compare this value to another time of the day to see if the price was reached/broken. For example the 2:00 to 2:30 low from above is 11 at 2:30. I would then check the 8:00 to 13:00 time period to see if the 2:00 to 2:30 low occured from 8:00 to 13:00. If it did occur I would call this day a qualifier and check the time 2:30 price occured in the 8:00 to 13:00 period until the price at 13:00. So another example if 2:30 was 11, 8:00 was 13, 8:45 was 11, and 13:00 was 20 I would say this day qualified and the price from the am was first acheived at 8:45 in the 8:00 to 13:00 period and the change from that price to the 13:00 period was 20-11=+9. This example was all background to my problem. Using the filx/readlines methods I wind up with output for the days which qualify, but when I try to create an array variable using the total of each line for a given column (aka summarizing every day that my given criteria were met), something about having used the line by line method doesn't allow me to create an array variable. It only gives me the last value. The variables I declared to fidn the qualifying days are specific to each day vs across all days that qualified. Is it possible to convert this line by line data into an array wih some R code I don't know? I considered converting the data example above into a matrix, but then I run into tricky problems of shortened days and days missing data (the code I used for the readlines method enables me to specify the new days without this problem...I don't have to fill in blanks it just changes days when it hits a new day). Given how specific this problem is I can't find much on the R help logs. Perhaps outputting the line by line output to a file, then reinputting it using a read.csv method would enable me to achieve my desired result but then I have the laborious task of dumping into excel, converting file types, saving as csv, reuploading to R, writing a separate program, etc. Is there an easy fix to my problem? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] If statements for multiple arrays
Hello, I wrote this code which works fine on a single observation: x<-100 y<-200 z<-125 aa<-150 if(xz) {aa-z} result: 25 I am trying to apply this logic where x,y,z,and aa are arrays but with very little success. I have tried using loops and whiles but I always get errors of various types. I have consulted a few manuals but with limited success. My hopeful outcome would be: data: X Y Z AA 1 100 200125 150 2 125 110105140 3 110150 130200 4 90200 7565 Here row 1 would return 25, row 2 would return nothing since ZZ. In this case I am trying to return something where I could call the output a variable "Z" which would become an array based on the logic above where the members would be: (25, 50) I tried using this where the variables are arrays: if(xz) {aa-z} But I get "NULL" I tried using this where the variables are arrays: if(xz) {aa-z} else "NA" But I get "NA" When I tried using a loop: for(i in 1:length(x)) if(xz) {aa-z} else "NA" I got "NULL" An attempt at a "while" statement crashed. The time series resource ( http://cran.r-project.org/doc/contrib/Ricci-refcard-ts.pdf) is way too involved. Most online sources I am finding are not good for "if" contingent array manipulation. Annoyingly, just saying aa-z will work across the entire array but for some reason my ifs fail. I know the R help group only wants serious emails so hopefully this will indicate I gave it a reasonable shot. Please help Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Latex fonts in R graphics
Hello, R users. I am trying to embed Computer modern fonts to an R plot and I get the following error. CM <- Type1Font("CM", + c(paste("cm-lgc/fonts/afm/public/cm-lgc/", + c("fcmr8a.afm", "fcmb8a.afm", "fcmri8a.afm", "fcmbi8a.afm"), sep=""), + "./cmsyase.afm")) > pdf("cm.pdf", width=3, height=3, family="CM") > plot(1:length(y), y, xlab="ss", ylab=expression(x[2])) ## for any vector y > dev.off() null device 1 > embedFonts("cm.pdf", outfile="cmembed.pdf", fontpaths=c("cm-lgc/fonts/type1/public/cm-lgc", ".")) Error in embedFonts("cm.pdf", outfile = "cmembed.pdf", fontpaths = c("cm-lgc/fonts/type1/public/cm-lgc", : status -1 in running command 'gswin32c.exe -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=C:\DOCUME~1\user\LOCALS~1\Temp\RtmpccEtgV\Rembed28163716 -sFONTPATH=cm-lgc/fonts/type1/public/cm-lgc;. cm.pdf' In addition: Warning message: In system(cmd) : gswin32c.exe not found Operating system: Windows XP, SP2. cm-lgc has been unzipped in the working directory "C:/Program Files/R/R-2.10.1" and the AFM, PFB files are also in same directory. Any help? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Does anybody know how to control the appearance of the end of the line in lattice?
Hi All, I am plotting vertical lines using xyplot in lattice and type="h". It works well, but the problem is that the tops of the lines are convex and the bottoms are concave. Is there a way to flatten the tops and bottoms? Here's my code: Source<-matrix(1:30,10,3) colnames(Source)<-c("x","y1","y2") Source<-data.frame(Source) xyplot(y2+y1~x, data=Source, distribute.type=TRUE, type=c("h","h"), col=c("black","white"), lwd=20) graphics.off() Thanks. George Chen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nested if help
Hello, I am trying to find a direct way to write a nested if of sorts to find data for a specific time range for a specific day (across a range of days) and have exhausted my abilities with the manuals I have at hand. I have a good deal of data of this approximate form: day time price 1 1am5 1 2am7 1 3am 9 1 4am 12 2 1am5 2 2am7 2 3am 9 2 4am 12 etc I am reading from a file I loaded and using a while statement. I then am trying the direct approach of writing the if: if(time>=2am &time <=4am) { #specifying desired time range--since a while loop format I don't think date is necessary and if it is I don't know how to say this? time1<-time #sets first time in desired interval to base time px1<-px #sets first price in desired interval to base price if(px>px1){ #nested if stmt to see if subsequent times are higher than base, thus replacing base with new max (I am seeking max in the time period in this instance) px2<-px #px2 would be the new higher maximum time2<-time #time associated with px2 px3<-px+1 #price immediately following max time3<-time+1 #time immed. follows max out<-(cur_date,px2,time2,px3,time3) #output the high price/time and the immediately following price/time cat(out,"\n")} This code however, does nothing. Any help would be apreciated. The manuals seem to only take one so far. Thanks, George [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix to Vector
Hi All, I am trying to turn a Matrix into a vector for analysis purposes. I need to select only certain columns from the entire matrix for the vector (intraday time intervals). Also I need to transpose the Matrix (so times are in rows) stack each successive new column on top of each other (latest at the top creating one long vector vs a matrix) then reassign the date to the left of each time (right now date is only shown once by row and will be in columns when transposed). Any thoughts? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is it possible to rearrange the facets in ggplot while keeping everything else the same?
Hi Dennis, It is similar to what I was trying to achieve. Is there a way to show the grouped time courses as separate facets. So in lattice, the time courses would be conditioned on Ab status and subject name at the same time. Thanks. George From: "Dennis Murphy" To: "George Chen" Cc: r-help@r-project.org Sent: Saturday, May 8, 2010 9:38:07 PM Subject: Re: [R] Is it possible to rearrange the facets in ggplot while keeping everything else the same? Hi: I'm not sure this is what you're looking for, but it sounds to me that you want to group subjects with the same Ab value together. If that's the case, then try this; your test data is called df ... df$Subject <- factor(df$Subject) p2 <- ggplot(df, aes(x = Day, y = Value, colour = Subject)) p2 + geom_point() + geom_line(aes(group = Subject)) + facet_grid(Variable ~ Ab) HTH, Dennis On Sat, May 8, 2010 at 6:56 PM, George Chen < glc...@stanford.edu > wrote: Hello, First, ggplot2 is great! Second, sorry for the basic nature of my question. I have data in the form of a melt table like this: Subject Day Ab Variable Value 1 1 Yes A 3 1 3 Yes A 5 1 5 Yes A 7 2 1 No A 2 2 3 No A 4 2 5 No A 6 3 1 Yes A 1 3 3 Yes A 3 3 5 Yes A 5 4 1 No A 4 4 3 No A 6 4 5 No A 8 1 1 Yes B 3 1 3 Yes B 5 1 5 Yes B 7 2 1 No B 2 2 3 No B 4 2 5 No B 6 3 1 Yes B 1 3 3 Yes B 3 3 5 Yes B 5 4 1 No B 4 4 3 No B 6 4 5 No B 8 1 1 Yes C 3 1 3 Yes C 5 1 5 Yes C 7 2 1 No C 2 2 3 No C 4 2 5 No C 6 3 1 Yes C 1 3 3 Yes C 3 3 5 Yes C 5 4 1 No C 4 4 3 No C 6 4 5 No C 8 The table goes on like this for another 11 subjects. I can plot a 3 row (A,B,C) x 4 column (Sub 1,2,3,4) grid of time courses with the y labels for the facets being 1,2,3,4 and the x labels for the facets being A,B,C. qplot(Day,Value,data="data above") + facet_grid(Variable~Subject, scales="free_y") But, how do I rearrange the columns so that all the Yeses to Ab are together and the Nos to Ab are together while keeping the same labeling? Thanks in advance. George Chen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is it possible to rearrange the facets in ggplot while keeping everything else the same?
Hello, First, ggplot2 is great! Second, sorry for the basic nature of my question. I have data in the form of a melt table like this: Subject Day Ab VariableValue 1 1 Yes A 3 1 3 Yes A 5 1 5 Yes A 7 2 1 No A 2 2 3 No A 4 2 5 No A 6 3 1 Yes A 1 3 3 Yes A 3 3 5 Yes A 5 4 1 No A 4 4 3 No A 6 4 5 No A 8 1 1 Yes B 3 1 3 Yes B 5 1 5 Yes B 7 2 1 No B 2 2 3 No B 4 2 5 No B 6 3 1 Yes B 1 3 3 Yes B 3 3 5 Yes B 5 4 1 No B 4 4 3 No B 6 4 5 No B 8 1 1 Yes C 3 1 3 Yes C 5 1 5 Yes C 7 2 1 No C 2 2 3 No C 4 2 5 No C 6 3 1 Yes C 1 3 3 Yes C 3 3 5 Yes C 5 4 1 No C 4 4 3 No C 6 4 5 No C 8 The table goes on like this for another 11 subjects. I can plot a 3 row (A,B,C) x 4 column (Sub 1,2,3,4) grid of time courses with the y labels for the facets being 1,2,3,4 and the x labels for the facets being A,B,C. qplot(Day,Value,data="data above") + facet_grid(Variable~Subject, scales="free_y") But, how do I rearrange the columns so that all the Yeses to Ab are together and the Nos to Ab are together while keeping the same labeling? Thanks in advance. George Chen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 87, Issue 6
Hello, I am new to ggplot. Please forgive my ignorance! I have patient data such that each individual is a row and then the attributes are in columns. So for example: SubjTimeHeight Weight WBC Plt 1 1 9 4 4 150 1 2 10 5 6 200 1 3 11 6 5 250 1 4 12 7 3 200 2 1 4 2 7 300 2 2 5 4 8 450 2 3 6 6 6 300 2 4 8 8 5 200 3 1 6 6 4 455 3 2 8 8 5 344 3 3 9 9 6 544 3 4 10 10 3 213 I would like to show the data as a time course for height , weight, WBC, and plt for each patient but in parallel and ultimately as a matrix of time courses for all the subjects with each patient a row and the time course graph for height weight WBC plt as individual columns. So something like this Subj 1 Height time course(TC) Weight TCWBC TCPlt TC Subj 2 Height time course(TC) Weight TCWBC TCPlt TC Subj 3 Height time course(TC) Weight TCWBC TCPlt TC Could somebody give me a hint as to how or where to start looking to figure this out? I suspect it involves a layer for each time course, but how does one move the time course for say weight over so that it does not overly that for height? Thanks in advance! George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I plot geoms in parallel in ggplot
Hello, I am new to ggplot. Please forgive my ignorance! I have patient data such that each individual is a row and then the attributes are in columns. So for example: SubjTimeHeightWeightWBCPlt 11944150 121056200 131165250 141273200 21427300 22548450 23666300 24885200 31664455 32885344 33996544 3410103213 I would like to show the data as a time course for height , weight, WBC, and plt for each patient but in parallel and ultimately as a matrix of time courses for all the subjects with each patient a row and the time course graph for height weight WBC plt as individual columns. So something like this Subj 1 Height time course(TC) Weight TCWBC TCPlt TC Subj 2 Height time course(TC) Weight TCWBC TCPlt TC Subj 3 Height time course(TC) Weight TCWBC TCPlt TC Ultimately I would like to be able to sort and reorder the order of the subject rows (so each row would become like a facet). Could somebody give me a hint as to how or where to start looking to figure this out? I suspect it involves a layer for each time course, but how does one move the time course for say weight over so that it does not overly that for height? Thanks in advance! George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to change a venn command into a named object that can be plotted like a lattice object
Hello, I am plotting data as a venn diagram but would like to be able to control how it is plotted like a lattice object. Right now, it plots right away. I would like to name it and then plot at will. I thought to convert the whole thing to a PostScript file then get it back into R via grImport, but surely (please!) there must be a less roundabout way to do this. Any help is appreciated. Here is my code: # Wrapper function to draw Venn diagram Venn2 <- function(set1, set2, names, title,...){ stopifnot( length(names) == 2) # Form universe as union of both sets universe <- sort( unique( c(set1, set2) ) ) Counts <- matrix(0, nrow=length(universe), ncol=2) colnames(Counts) <- names for (i in 1:length(universe)) { Counts[i,1] <- universe[i] %in% set1 Counts[i,2] <- universe[i] %in% set2 } vennDiagram( vennCounts(Counts),main=title,... ) } # How I draw the Venn diagram Venn2(cPostArrayHitsNames,cPreArrayHitsNames,names=c("Post","Pre"),title=PatientID) Unfortunately something like this doesn't work: VennPlot<-Venn2(cPostArrayHitsNames,cPreArrayHitsNames,names=c("Post","Pre"),title=PatientID) Apologies for the imprecise terminology. Thanks. GLC __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mysterious extra spaces appearing in expression paste
Hey, So I found workaround for what I'm now pretty sure is a bug. the reason I'm sure it's a bug is that i found that I found that linebreaks are handled in a wonky but regular way. There's a rule, and it's a bad rule, ie a bug. The wonky rule is as follows: text(x,y,expression(paste("thing1 \n","thing2"))) results in printing thing1 at the requested x/y with the linebreak failing to cause a carriage return. That is, thing2 appears directly below the "1" in thing1. **Bug report: "\n" in paste doesn't make a carriage return, just a new line. perhaps there's something like endl that I'm supposed to put in there and I just don't know. I'll bring this to the attention of r-b...@r-project.org . The workaround for my particular problem was to not use line breaks, but instead break the legend up into four parts instead of 2, using the fact that legend puts each legend=c() element on a new line. leg <- c(expression(paste("data1 \n(",rho,"=1)")), expression(paste("data2 \n(",rho,"=0.0)"))) legend("bottomright",legend=leg,col=c(1,2),lwd=3, y.intersp = 2.0,adj=c(0,1.5)) becomes leg <- c("data1",expression(paste("(",rho,"=1)")), "data2", expression(paste("(",rho,"=0.0)"))) legend("bottomright",legend=leg,col=c(1,1,2,1), lty=(1,0,1,0), lwd=3) note the lty to block the extra lines. Regards, George On Tue, Feb 2, 2010 at 2:17 PM, anna wrote: > > try putting sep="" in your paste method > > - > Anna Lippel > -- > View this message in context: > http://n4.nabble.com/mysterious-extra-spaces-appearing-in-expression-paste-tp1460261p1460264.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mysterious extra spaces appearing in expression paste
Hi, i'm trying to put a legend on some figures and they're coming out a bit wonky. here's an example: a <- c(1:10) par(mfrow=c(2,1)) plot(a,type="s",lwd=3) leg <- c(expression(paste("data1 (",rho,"=1)")), expression(paste("data2 (",rho,"=0.0)"))) legend("bottomright",legend=leg,col=c(1,2),lwd=3) plot(a,type="s",lwd=3) leg <- c(expression(paste("data1 \n(",rho,"=1)")), expression(paste("data2 \n(",rho,"=0.0)"))) legend("bottomright",legend=leg,col=c(1,2),lwd=3, y.intersp = 2.0,adj=c(0,1.5)) the problem is that lots of extra space appears between the open parenthesis and the rho. what can be done? (i'm running version 2.10.1 (2009-12-14) on fedora 12) Thanks! George Locke __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I juxtapose two lattice graphs with common X axes such that the X axes line up?
Hello, I would like to juxtapose two lattice graphs with common X axes such that the X axes line up. I am using plot right now but the edges are not neat and it would be nice if I could just draw 1 X axis and not both of them. Here is my code: upper<-bwplot(SignalUsed~as.factor(AllNormalHitsNamesCount),data=NmlOverviewArray2, xlab="", ylab="Intensity of Individual Antibody Responses", main="Intensity, Frequency, Distribution, & Quantity of Normal Antibody Responses", box.ratio=1, panel = function (AllNormalHitsNamesCount,...) { panel.bwplot(...) } ) lower<-barchart(as.vector(table(NmlOverviewArray2$AllNormalHitsNamesCount)) ~as.factor(as.numeric(names(table(NmlOverviewArray2$AllNormalHitsNamesCount, data=NmlOverviewArray2, ylab="Number of Individual Antibody Responses", xlab="Occurrence of Individual Antibody Responses (Out of 45 Normals)", box.ratio=1) plot (upper, newpage=TRUE, more=TRUE, position = c(0,.15,1,1)) plot (lower, newpage=FALSE, more=TRUE, position = c(0,0,1,.3)) George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to change the default Date format for write.csv function?
Nice try, but that will turn off quote for all fields. I want quotes for text fields, and no quotes for date and numeric fields. Please see the desired CSV output in my previous email. George From: Henrique Dallazuanna To: george@bnymellon.com Cc: r-help@r-project.org Date: 12/28/2009 12:44 PM Subject: Re: [R] How to change the default Date format for write.csv function? Sent by: r-help-boun...@r-project.org Use the quote argument: write.csv(d, file="C:/temp/test.csv", row.names=FALSE, quote = FALSE) On Mon, Dec 28, 2009 at 2:17 PM, wrote: > Hi, > > This problem might be a little harder than it appears. > > I receive a few emails all suggesting that convert the Date field to > character by calling format(date, "%m/%d/%Y") in one way or another. Well, > this is not the solution I'm looking for and it doesn't work for me. All > the date fields are generated with quotes around them, which will be > treated by other software as string instead of date. Please note, the > write.csv() function doesn't put quotes around date. All I need is to > change the format behavior of Date without adding any quotes. So the > output of CSV I'm looking for should be: > > "ticker","date","price" > "IBM",12/03/2009,120 > "IBM",12/04/2009,123 > > Not this: > > "ticker","date","price" > "IBM","12/03/2009",120 > "IBM","12/04/2009",123 > > Thanks for trying though. > > George > > > > From: > george@bnymellon.com > To: > r-help@r-project.org > Date: > 12/28/2009 10:20 AM > Subject: > [R] How to change the default Date format for write.csv function? > Sent by: > r-help-boun...@r-project.org > > > > Hi, > > I have a data.frame containing a Date column. When using write.csv() > function to generate a CSV file, I always get the Date column formatted as > > "-MM-DD". I would like to have it formatted as "MM/DD/", but > could not find an easy way to do it.Here is the test code: > > d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03", > "2009-12-04")), price=c(120.00, 123.00)) > write.csv(d, file="C:/temp/test.csv", row.names=FALSE) > > The test.csv generated looks like this: > > "ticker","date","price" > "IBM",2009-12-03,120 > "IBM",2009-12-04,123 > > I would like to have the date fields in the CSV formatted as "MM/DD/". > > Is there any easy way to do this? > > Thanks in advance. > > George Zou > > The information contained in this e-mail, and any attachment, is > confidential and is intended solely for the use of the intended recipient. > Access, copying or re-use of the e-mail or any attachment, or any > information contained therein, by any other person is not authorized. If > you are not the intended recipient please return the e-mail to the sender > and delete it from your computer. Although we attempt to sweep e-mail and > attachments for viruses, we do not guarantee that either are virus-free > and accept no liability for any damage sustained as a result of viruses. > > Please refer to http://disclaimer.bnymellon.com/eu.htm for certain > disclosures relating to European legal entities. > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > > > The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. > > Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities. >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.
Re: [R] How to change the default Date format for write.csv function?
Hi, This problem might be a little harder than it appears. I receive a few emails all suggesting that convert the Date field to character by calling format(date, "%m/%d/%Y") in one way or another. Well, this is not the solution I'm looking for and it doesn't work for me. All the date fields are generated with quotes around them, which will be treated by other software as string instead of date. Please note, the write.csv() function doesn't put quotes around date. All I need is to change the format behavior of Date without adding any quotes. So the output of CSV I'm looking for should be: "ticker","date","price" "IBM",12/03/2009,120 "IBM",12/04/2009,123 Not this: "ticker","date","price" "IBM","12/03/2009",120 "IBM","12/04/2009",123 Thanks for trying though. George From: george@bnymellon.com To: r-help@r-project.org Date: 12/28/2009 10:20 AM Subject: [R] How to change the default Date format for write.csv function? Sent by: r-help-boun...@r-project.org Hi, I have a data.frame containing a Date column. When using write.csv() function to generate a CSV file, I always get the Date column formatted as "-MM-DD". I would like to have it formatted as "MM/DD/", but could not find an easy way to do it.Here is the test code: d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03", "2009-12-04")), price=c(120.00, 123.00)) write.csv(d, file="C:/temp/test.csv", row.names=FALSE) The test.csv generated looks like this: "ticker","date","price" "IBM",2009-12-03,120 "IBM",2009-12-04,123 I would like to have the date fields in the CSV formatted as "MM/DD/". Is there any easy way to do this? Thanks in advance. George Zou The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to change the default Date format for write.csv function?
Hi, I have a data.frame containing a Date column. When using write.csv() function to generate a CSV file, I always get the Date column formatted as "-MM-DD". I would like to have it formatted as "MM/DD/", but could not find an easy way to do it.Here is the test code: d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03", "2009-12-04")), price=c(120.00, 123.00)) write.csv(d, file="C:/temp/test.csv", row.names=FALSE) The test.csv generated looks like this: "ticker","date","price" "IBM",2009-12-03,120 "IBM",2009-12-04,123 I would like to have the date fields in the CSV formatted as "MM/DD/". Is there any easy way to do this? Thanks in advance. George Zou The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to output profile plots for groups using lattice package
A million thanks Peter, subsetting fixed it. George On Mon, Oct 12, 2009 at 11:51 PM, Peter Ehlers wrote: > Hi George, > > Your problem is not with xyplot, but with the NA occurrences in > your data. Try adding > > subset = {!is.na(MSE)}, > > to your xyplot call, or (better), subset the data before > calling xyplot. > > -Peter Ehlers > > > George Kalema wrote: > >> Hi Peter (and anyone else willing to help me out), >> Many thanks for your help. Having used your code plus a few other >> modifications, I only get the points plotted but without the two lines. I >> just cannot figure out what the problem is. >> >> My code is as follows: >> >> library(lattice) >> datos2 <- subset(datos, samplesize != 10 & parm != "Theta0") >> unq <- sort(unique(datos2$samplesize)) >> datos2$fsamplesize <- factor(datos2$samplesize, labels = paste("Sample >> size =", unq)) >> datos2$parm <- factor(datos2$parm, levels = c("Intercept", "time", >> "trt", "time*trt")) >> tp1.sim <- xyplot(MSE ~ ntimes | fsamplesize + parm, group = group, data >> = datos2, >>type = "b", lty = 1:2, pch = 1:2, >>scales = list(x = list(at = c(2, 4, 8, 16)), alternating = 1), >>as.table = TRUE, key = list(text = list(c("GNA", "PNA")), points = >> list(pch = 1:2)) >> ) >> plot(tp1.sim) >> >> I have attached my real dataset (called datos) as well. >> >> Kind appreciations to your efforts. >> >> George >> >> >> On Wed, Oct 7, 2009 at 9:20 AM, Peter Ehlers wrote: >> >> see below >>> >>> George Kalema wrote: >>> >>> Dear R users, >>>> I am trying to have an xyplot of a data set which has the following >>>> variables: >>>> case (n=10,20,30) >>>> parameter (parm=a,b) >>>> group (grp=g1,g2) >>>> y (y values) >>>> x (x=2,4,8) >>>> >>>> My plot should be parameter by case such that I have 2 rows (each row= >>>> each >>>> parameter) and 3 columns (each column=each case). My R-code is as >>>> follows >>>> but I am not able to get what I want to: >>>> >>>> tp1.sim <- xyplot(y~ x | case + parm , group=group, data = data, lty = >>>> 1:4 >>>> , >>>> pch = 1:4) >>>> print(tp1.sim) >>>> >>>> How can I have two lines (for g1 and g2) in each plot (each box)? >>>> >>>> include the type="b" argument >>> >>> How do I label the x-axis with only values 2, 4, 8? >>> include the scales= argument or make x a factor >>> >>> How do I label each column with the corresponding case number? >>> make 'case' a factor >>> >>> The following should do what you want: >>> >>> xyplot(y ~ x | factor(case) + parm, group=group, data=data, >>> type='b', lty=1:2, pch=1:2, >>> scales=list(x=list(at=c(2,4,8))) >>> ) >>> >>> I don't understand why you want 4 line types/point chars. >>> >>> -Peter Ehlers >>> >>> >>> My hypothetical data set is as follows: >>>> >>>> parm x case y group >>>> a 2 10 0.03 g1 >>>> b 2 10 0.02 g1 >>>> a 4 10 0.03 g1 >>>> b 4 10 0.02 g1 >>>> a 8 10 0.03 g1 >>>> b 8 10 0.02 g1 >>>> a 2 20 0.03 g1 >>>> b 2 20 0.02 g1 >>>> a 4 20 0.03 g1 >>>> b 4 20 0.02 g1 >>>> a 8 20 0.03 g1 >>>> b 8 20 0.02 g1 >>>> a 2 30 0.03 g1 >>>> b 2 30 0.02 g1 >>>> a 4 30 0.03 g1 >>>> b 4 30 0.02 g1 >>>> a 8 30 0.03 g1 >>>> b 8 30 0.02 g1 >>>> a 2 10 0.13 g2 >>>> b 2 10 0.12 g2 >>>> a 4 10 0.13 g2 >>>> b 4 10 0.12 g2 >>>> a 8 10 0.13 g2 >>>> b 8 10 0.12 g2 >>>> a 2 20 0.13 g2 >>>> b 2 20 0.12 g2 >>>> a 4 20 0.13 g2 >>>> b 4 20 0.12 g2 >>>> a 8 20 0.13 g2 >>>> b 8 20 0.12 g2 >>>> a 2 30 0.13 g2 >>>> b 2 30 0.12 g2 >>>> a 4 30 0.13 g2 >>>> b 4 30 0.12 g2 >>>> a 8 30 0.13 g2 >>>> b 8 30 0.12 g2 >>>> >>>> Many thanks in advance for your response. >>>> >>>> George >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> __ >>>> R-help@r-project.org mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>>> >>>> >>>> >>>> >> >> -- George Williams KALEMA, Schapenstraat 37/282, 3000 Leuven, Belgium. Cell: +32 495 33 13 02 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to output profile plots for groups using lattice package
Hi Peter (and anyone else willing to help me out), Many thanks for your help. Having used your code plus a few other modifications, I only get the points plotted but without the two lines. I just cannot figure out what the problem is. My code is as follows: library(lattice) datos2 <- subset(datos, samplesize != 10 & parm != "Theta0") unq <- sort(unique(datos2$samplesize)) datos2$fsamplesize <- factor(datos2$samplesize, labels = paste("Sample size =", unq)) datos2$parm <- factor(datos2$parm, levels = c("Intercept", "time", "trt", "time*trt")) tp1.sim <- xyplot(MSE ~ ntimes | fsamplesize + parm, group = group, data = datos2, type = "b", lty = 1:2, pch = 1:2, scales = list(x = list(at = c(2, 4, 8, 16)), alternating = 1), as.table = TRUE, key = list(text = list(c("GNA", "PNA")), points = list(pch = 1:2)) ) plot(tp1.sim) I have attached my real dataset (called datos) as well. Kind appreciations to your efforts. George On Wed, Oct 7, 2009 at 9:20 AM, Peter Ehlers wrote: > see below > > George Kalema wrote: > >> Dear R users, >> I am trying to have an xyplot of a data set which has the following >> variables: >> case (n=10,20,30) >> parameter (parm=a,b) >> group (grp=g1,g2) >> y (y values) >> x (x=2,4,8) >> >> My plot should be parameter by case such that I have 2 rows (each row= >> each >> parameter) and 3 columns (each column=each case). My R-code is as follows >> but I am not able to get what I want to: >> >> tp1.sim <- xyplot(y~ x | case + parm , group=group, data = data, lty = 1:4 >> , >> pch = 1:4) >> print(tp1.sim) >> >> How can I have two lines (for g1 and g2) in each plot (each box)? >> > include the type="b" argument > > How do I label the x-axis with only values 2, 4, 8? >> > include the scales= argument or make x a factor > > How do I label each column with the corresponding case number? >> > make 'case' a factor > > The following should do what you want: > > xyplot(y ~ x | factor(case) + parm, group=group, data=data, >type='b', lty=1:2, pch=1:2, >scales=list(x=list(at=c(2,4,8))) > ) > > I don't understand why you want 4 line types/point chars. > > -Peter Ehlers > > >> My hypothetical data set is as follows: >> >> parm x case y group >> a 2 10 0.03 g1 >> b 2 10 0.02 g1 >> a 4 10 0.03 g1 >> b 4 10 0.02 g1 >> a 8 10 0.03 g1 >> b 8 10 0.02 g1 >> a 2 20 0.03 g1 >> b 2 20 0.02 g1 >> a 4 20 0.03 g1 >> b 4 20 0.02 g1 >> a 8 20 0.03 g1 >> b 8 20 0.02 g1 >> a 2 30 0.03 g1 >> b 2 30 0.02 g1 >> a 4 30 0.03 g1 >> b 4 30 0.02 g1 >> a 8 30 0.03 g1 >> b 8 30 0.02 g1 >> a 2 10 0.13 g2 >> b 2 10 0.12 g2 >> a 4 10 0.13 g2 >> b 4 10 0.12 g2 >> a 8 10 0.13 g2 >> b 8 10 0.12 g2 >> a 2 20 0.13 g2 >> b 2 20 0.12 g2 >> a 4 20 0.13 g2 >> b 4 20 0.12 g2 >> a 8 20 0.13 g2 >> b 8 20 0.12 g2 >> a 2 30 0.13 g2 >> b 2 30 0.12 g2 >> a 4 30 0.13 g2 >> b 4 30 0.12 g2 >> a 8 30 0.13 g2 >> b 8 30 0.12 g2 >> >> Many thanks in advance for your response. >> >> George >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> >> -- George Williams KALEMA, Schapenstraat 37/282, 3000 Leuven, Belgium. Cell: +32 495 33 13 02 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to output profile plots for groups using lattice package
Dear R users, I am trying to have an xyplot of a data set which has the following variables: case (n=10,20,30) parameter (parm=a,b) group (grp=g1,g2) y (y values) x (x=2,4,8) My plot should be parameter by case such that I have 2 rows (each row= each parameter) and 3 columns (each column=each case). My R-code is as follows but I am not able to get what I want to: tp1.sim <- xyplot(y~ x | case + parm , group=group, data = data, lty = 1:4 , pch = 1:4) print(tp1.sim) How can I have two lines (for g1 and g2) in each plot (each box)? How do I label the x-axis with only values 2, 4, 8? How do I label each column with the corresponding case number? My hypothetical data set is as follows: parm x case y group a 2 10 0.03 g1 b 2 10 0.02 g1 a 4 10 0.03 g1 b 4 10 0.02 g1 a 8 10 0.03 g1 b 8 10 0.02 g1 a 2 20 0.03 g1 b 2 20 0.02 g1 a 4 20 0.03 g1 b 4 20 0.02 g1 a 8 20 0.03 g1 b 8 20 0.02 g1 a 2 30 0.03 g1 b 2 30 0.02 g1 a 4 30 0.03 g1 b 4 30 0.02 g1 a 8 30 0.03 g1 b 8 30 0.02 g1 a 2 10 0.13 g2 b 2 10 0.12 g2 a 4 10 0.13 g2 b 4 10 0.12 g2 a 8 10 0.13 g2 b 8 10 0.12 g2 a 2 20 0.13 g2 b 2 20 0.12 g2 a 4 20 0.13 g2 b 4 20 0.12 g2 a 8 20 0.13 g2 b 8 20 0.12 g2 a 2 30 0.13 g2 b 2 30 0.12 g2 a 4 30 0.13 g2 b 4 30 0.12 g2 a 8 30 0.13 g2 b 8 30 0.12 g2 Many thanks in advance for your response. George [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How can I use event.chart (Hmisc) to work with a single row of data?
Hi Everyone, I would like to use event.chart to make an event chart based on a single row of data. It works fine for 2 or more rows, but when I set subset.r to 1 row or use a one row data.frame as the data, I get a dimensional error. Does anyone know a work around or a solution? Thanks, George Chen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Tex fonts in R plots
Hello, R users. I would like to display the font of Math Mode of MikTex 2.3, WinEdt 5.4 in R plots, e.g. in xlab, ylab or legend. How can I do that? Thank you in advance. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] kohonen SOM
Hi All, I am experimenting with using binary data (1, 0) in the kohonen package. I would like either 1 or 0 to be mapped in SOM, but the package gives me 1 or 0 (as expected), but something in between. I am not scaling the binary data, but still there are in-between values. Can anybody suggest a way to keep the data binary, even in the SOM plot? Thanks a lot. George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mapply
Hello, R users. I would like to count the number of triples (r_i, s_j, t_k) with r_i, s_j, t_k distinct and abs((r_i-t_k)-u)=0 and abs((s_j-t_k)-v)=0, where r_i, s_j, t_k are the elements of three vectors a,b,c with different lengths and u,v=1:n. I have solved this problem writing a subroutine in Fortran an calling .Fortran(). I would like to find another way to use functions like mapply. I tried this one: xx <- mapply( function(u,v) { kk <- outer(a, c, function(s,t) abs((s-t)-u)==0) ll <- outer(b, c, function(s,t) abs((s-t)-v)==0) sum( outer( which(kk==TRUE, TRUE)[,2], which(ll==TRUE, TRUE)[,2], function(s,t) s==t) ) }, rep(1:n, each=n), rep(1:n, times=n)) xx <- matrix(xx, nrow=n, ncol=n, byrow=TRUE) It works but it is rather slow. Taking into account that my vectors have lengths 3000, and n is from 50 to 200, can I do something to improve the running time of the above code? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Drawing schematics
Hi, I would like to represent the treatment course of a subject with an arrow representing passage through time and various ticks, arrows, or bars representing treatments done to the patient along the arrow. I would like to generate this sort of schematic for each patient in a database taking information from the database such as time of treatment and type of treatment. Does anybody know how I can do this? Is there a premade R package for this sort of thing or should I try to make a new graphics function? If a new graphics function, where could I start? Thanks in advance. George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] avoid a loop
Hello, R users. I have the following code: a=1:10 b=-3:15 n=5 x <- rep(0,n) for (i in 1:n) x[i] <- sum( outer(a,b, function(s,t) abs(a-b-i)==0) ) Can someone tell me if I could avoid the for command? Thank you in advance. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with normalize.quantiles
Hi All, I am using normalize.quantiles (package preprocessCore) to process a 8300 row x 96 col matrix, all numerical data. When I limit the input matrix to 8300 x 67, the function works fine and my data is normalized. But when I increase the input matrix size to 8300 x 68, the function processes but instead of giving normalized data, it gives me all the same number. With 96 columns (the whole matrix), much the same happens. Has anyone had any experience with this and what to do about it. I would really like to not have to prune my dataset. Examples: Limited input matrix (col = 67) [,1] [,2] [,3] [,4] [,5] [1,] NA 5977.433 .572 6826.831 4142.117 [2,] 3012.837 6617.005 6036.862 7796.186 5453.295 [3,] NA 5977.433 7192.046 7582.068 6042.775 [4,] 1780.039 1732.662 6373.366 7825.302 6775.492 [5,] NA 3308.601 2297.677 7294.935 1482.699 [6,] NA 3569.632 3509.979 3566.683 NA [7,] NA 4492.529 6399.490 4925.750 1921.428 [8,] NA 2416.358 3958.061 4592.030 2829.436 [9,] 7889.050 7928.198 7929.257 7930.121 7927.907 [10,] 7542.413 7893.827 7889.407 7896.078 7894.852 78 col input matrix [,1] [,2] [,3] [,4] [,5] [1,] NA 7883.356 7883.356 7883.356 7883.356 [2,] 7883.356 7883.356 7883.356 7883.356 7883.356 [3,] NA 7883.356 7883.356 7883.356 7883.356 [4,] 7883.356 7883.356 7883.356 7883.356 7883.356 [5,] NA 7883.356 7883.356 7883.356 7883.356 [6,] NA 7883.356 7883.356 7883.356 NA [7,] NA 7883.356 7883.356 7883.356 7883.356 [8,] NA 7883.356 7883.356 7883.356 7883.356 [9,] 7883.356 7883.356 7883.356 7883.356 7883.356 [10,] 7883.356 7883.356 7883.356 7883.356 7883.356 whole input matrix (96 col) [,1] [,2] [,3] [,4] [,5] [1,] NA 7747.377 7747.377 7747.377 7747.377 [2,] 7747.377 7747.377 7747.377 7747.377 7747.377 [3,] NA 7747.377 7747.377 7747.377 7747.377 [4,] 7747.377 7747.377 7747.377 7747.377 7747.377 [5,] NA 7747.377 7747.377 7747.377 7747.377 [6,] NA 7747.377 7747.377 7747.377 NA [7,] NA 7747.377 7747.377 7747.377 7747.377 [8,] NA 7747.377 7747.377 7747.377 7747.377 [9,] 7747.377 7747.377 7747.377 7747.377 7747.377 [10,] 7747.377 7747.377 7747.377 7747.377 7747.377 Thanks in advance, George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] making an Affybatch object for expresso
Hi All, I have microarray data that does not come in a CEL file. Currently it is in the form of columns = individual samples and rows = individual probes. There are about 79 columns and it is in a tab delimited text file. Is there a way to convert this file into an AffyBatch so that I can run expresso with it? Thanks, George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Two different scales for the same axis in the same plot.
Hello, Could anyone tell me how to plot data on two different scales in the same axis in the same plot? Here is my quandary: The range of my X axis runs from 0 to 10, but the majority of my meaningful data lies between 7 and 10. The data from 0 to 7 is essentially noise. Is there a way for me to present my data such that the range from 0 to 7 takes up a smaller amount of space on the graph compared to the range from 7 to 10 so that I can see more of the details in 7 to 10? Thanks in advance, George Chen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.