[R] User Interfaces for R
I want to create an R application that includes a user interface where the user inputs values etc and then can run R calculations and get results back on the user interface. I was hoping that an easy to use GUI package exists. Can anyone point me to such an easy to use package to create GUIs for R? Thanks in advance for any help. Lion Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). [[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] loading the xlsx library
When I load the library xlsx with the command library("xlsx") I get the error message: > library("xlsx") Error: package or namespace load failed for ‘xlsx’: .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the Registry > Does anyone have any idea what the issue is? Thanks Lion Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). [[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] Difficulty with "\\" in string functions....
I am using the file.choose() function to choose a file from the dialog box and once I get it, I want to be able to split the full name into the folder part and the file name part. So for example, when I have closed the file choose dialog, the name for the file I get is Fname1 [1] "D:\\Data\\OneDrive\\ISTA Documents\\QT_App\\QT Analysis Input Data Example WorkBook.xlsx" where the "\\" is used to split the folder and sub-folder and file names. R see this "\\" as a single \ backslash character. Now I try to split it using str_split(Fname1,"\\") but this returns an error Error in stri_split_regex(string, pattern, n = n, simplify = simplify, : Unrecognized backslash escape sequence in pattern. (U_REGEX_BAD_ESCAPE_SEQUENCE) I know its got something to do with the \\ because it is treated as a single backslash character. But replacing the str_split with str_split(Fname1,"\") does not work either. Any ideas on how I can handle the \\ and split the full name into its pieces? Lion Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). [[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] Difficulty with "\\" in string functions....
Brilliant! Thanks a million Ivan. Lion Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On February 11, 2019 at 3:13 PM Ivan Krylov wrote: > > > On Mon, 11 Feb 2019 15:01:16 -0500 (EST) > Bernard McGarvey wrote: > > > Now I try to split it using > > > > > > str_split(Fname1,"\\") > > > > > > but this returns an error > > > > > > Error in stri_split_regex(string, pattern, n = n, simplify = > > simplify, : Unrecognized backslash escape sequence in pattern. > > (U_REGEX_BAD_ESCAPE_SEQUENCE) > > This happens because the second parameter of str_split is by default a > regular expression, and a backslash has a special meaning in regular > expressions: when preceding other characters, it may change the way > they are interpreted. (For example, w means a literal "w" > character, while \w means "any alphanumeric character". On the > other hand, [ starts a character group, but \[ means just an opening > square bracket.) See ?regex for more info on that. > > Since you want a literal backslash, you need to escape it with another > backslash: \\ > > But to write a string literal of a double-backslash in R, you need to > escape both backslash characters, each with their own backslash: "" > > ## fname <- "D:\\Data\\OneDrive\\ISTA Documents\\QT_App\\QT Analysis > Input Data Example WorkBook.xlsx" > ## message("") > \\ > ## str_split(fname, "") > [[1]] > [1] "D:" > [2] "Data" > [3] "OneDrive" > [4] "ISTA Documents" > [5] "QT_App" > [6] "QT AnalysisInput Data Example WorkBook.xlsx" > > You can also avoid all layers of the backslash hell (except the first) > if you choose to split by fixed strings instead of regular expressions > by using stringr::fixed: > > ## str_split(fname, fixed("\\")) > > -- > Best regards, > Ivan __ 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] Error trapping in R
Thanks - the try() approach is exactly what I need. Lion Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On February 27, 2019 at 4:39 PM Robert Knight wrote: > > Some use try blocks, like found in other languages. Put the code you > want to try inside the block. > > https://www.robertknight.io/blog/try-blocks-in-r-for-error-handling/ > contains a quick example. The example doesn’t raise exceptions or anything, > it just contains it for you so the script keeps going. I like handling > errors with if statements inside of try blocks. > > Robert > > > > On Feb 27, 2019, at 2:55 PM, Bernard Comcast < > mcgarvey.bern...@comcast.net mailto:mcgarvey.bern...@comcast.net > wrote: > > > > > What is the recommended way to trap errors in R? My main > need is to be able to trap an error and then skip a section of code if an > error has occurred. In VB for Excel I used the “On Error goto .” > construct to do this. > > > > Bernard > > Sent from my iPhone so please excuse the spelling!" > > __ > > R-help@r-project.org mailto: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] Quantile Density Contours
I want to see if I can reproduce the plot below in R. If I understand it correctly, i takes my bivariate data and creates quantile density contours. My interpretation of these contours is that they enclose a certain % of the total data. I am using the bkde2D function in library KernSmooth which gives density values that can be plotted on a contour plot but I would like the curves that enclose a given % of the data, if that is possible Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). __ 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] Quantile Density Contours
John, I have attached a pdf of the plot. Hopefully you can read this. If I understand correctly, this plot is basically the 2-D version of the 1-D quantile plot. Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On March 27, 2019 at 7:44 AM John Kane wrote: > > > The figure did not get through. Perhaps try a pdf? > > On Tue, 26 Mar 2019 at 13:41, Bernard McGarvey > wrote: > > > > I want to see if I can reproduce the plot below in R. If I understand it > > correctly, i takes my bivariate data and creates quantile density contours. > > My interpretation of these contours is that they enclose a certain % of the > > total data. I am using the bkde2D function in library KernSmooth which > > gives density values that can be plotted on a contour plot but I would like > > the curves that enclose a given % of the data, if that is possible > > > > > > Thanks > > > > > > > > > > > > Bernard McGarvey > > > > Director, Fort Myers Beach Lions Foundation, Inc. > > > > Retired (Lilly Engineering Fellow). > > > > > > __ > > 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. > > > > -- > John Kane > Kingston ON Canada Qunatile Density Contours Plot.pdf Description: Adobe PDF document __ 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] [FORGED] Re: Quantile Density Contours
If I understand correctly the ContourLines function gives you the contour lines when you put in the data. But before this I need to data to put into that function. I think this is something like a 2D CDF of the data that then leads to the 2D quantiles but I am not 100% sure. What I am basically looking for is the 2D curve that encloses say 95% of the data in a similar fashion to a 1D quantile where the quantile represents the value that x% of the data is below. I think what I am looking for is the 2D bivariate version of the 1D quantile plot (where the quantile value is plotted vs the % value). I hope this makes some sense. Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On March 27, 2019 at 3:57 PM Paul Murrell wrote: > > > > Are you looking for the contourLines() function ? > > Paul > > On 28/03/19 8:37 AM, Bernard McGarvey wrote: > > John, I have attached a pdf of the plot. Hopefully you can read this. > > > > If I understand correctly, this plot is basically the 2-D version of the > > 1-D quantile plot. > > > > Thanks > > > > Bernard McGarvey > > > > > > Director, Fort Myers Beach Lions Foundation, Inc. > > > > > > Retired (Lilly Engineering Fellow). > > > > > >> On March 27, 2019 at 7:44 AM John Kane wrote: > >> > >> > >> The figure did not get through. Perhaps try a pdf? > >> > >> On Tue, 26 Mar 2019 at 13:41, Bernard McGarvey > >> wrote: > >>> > >>> I want to see if I can reproduce the plot below in R. If I understand it > >>> correctly, i takes my bivariate data and creates quantile density > >>> contours. My interpretation of these contours is that they enclose a > >>> certain % of the total data. I am using the bkde2D function in library > >>> KernSmooth which gives density values that can be plotted on a contour > >>> plot but I would like the curves that enclose a given % of the data, if > >>> that is possible > >>> > >>> > >>> Thanks > >>> > >>> > >>> > >>> > >>> > >>> Bernard McGarvey > >>> > >>> Director, Fort Myers Beach Lions Foundation, Inc. > >>> > >>> Retired (Lilly Engineering Fellow). > >>> > >>> > >>> __ > >>> 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. > >> > >> > >> > >> -- > >> John Kane > >> Kingston ON Canada > >> > >> __ > >> 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. > > -- > Dr Paul Murrell > Department of Statistics > The University of Auckland > Private Bag 92019 > Auckland > New Zealand > 64 9 3737599 x85392 > p...@stat.auckland.ac.nz > http://www.stat.auckland.ac.nz/~paul/ __ 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] [FORGED] Re: Quantile Density Contours
pracma meets my needs - thanks - this is an amazing package with lots of very very useful functions. Thanks for bringing it to my attention. Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On March 28, 2019 at 1:40 PM David Winsemius wrote: > > > > On 3/27/19 3:43 PM, Bernard Comcast wrote: > > To follow on Jeff, is there a function to do 2-D (double) numerical > > integration in R? > > Packages pracma and cubature offer a variety of solutions to that task. > > > -- > > David. > > > > > > Bernard > > Sent from my iPhone so please excuse the spelling!" > > > >> On Mar 27, 2019, at 6:38 PM, Jeff Newmiller > >> wrote: > >> > >> Regardless of how many dimensions you have for independent variables, the > >> density is one-dimensional, and if you assume the density function has > >> been determined (e.g. by kernel estimation or by a Gaussian copula) then > >> if you integrate the density function along that dimension there will be > >> unique slices of the multivariate input domain determined by those slices. > >> They might in general be disjoint regions of the independent variable > >> space, but that is what the contour function does. > >> > >> I am not seeing your point, Bert, unless you are unwilling to assume a > >> density function model? > >> > >>> On March 27, 2019 2:18:18 PM PDT, Bert Gunter > >>> wrote: > >>> You are missing a crucial point. The reals are well ordered; higher > >>> dimensions are not. Therefore 2d quantile contours are not unique. > >>> > >>> Of course assuming I understand your query correctly. > >>> > >>> > >>> Bert > >>> > >>> On Wed, Mar 27, 2019, 13:55 Bernard McGarvey > >>> > >>> wrote: > >>> > >>>> If I understand correctly the ContourLines function gives you the > >>> contour > >>>> lines when you put in the data. But before this I need to data to put > >>> into > >>>> that function. I think this is something like a 2D CDF of the data > >>> that > >>>> then leads to the 2D quantiles but I am not 100% sure. What I am > >>> basically > >>>> looking for is the 2D curve that encloses say 95% of the data in a > >>> similar > >>>> fashion to a 1D quantile where the quantile represents the value that > >>> x% of > >>>> the data is below. I think what I am looking for is the 2D bivariate > >>>> version of the 1D quantile plot (where the quantile value is plotted > >>> vs the > >>>> % value). > >>>> > >>>> I hope this makes some sense. > >>>> > >>>> Bernard McGarvey > >>>> > >>>> > >>>> Director, Fort Myers Beach Lions Foundation, Inc. > >>>> > >>>> > >>>> Retired (Lilly Engineering Fellow). > >>>> > >>>> > >>>>> On March 27, 2019 at 3:57 PM Paul Murrell > >>> > >>>> wrote: > >>>>> > >>>>> > >>>>> Are you looking for the contourLines() function ? > >>>>> > >>>>> Paul > >>>>> > >>>>>> On 28/03/19 8:37 AM, Bernard McGarvey wrote: > >>>>>> John, I have attached a pdf of the plot. Hopefully you can read > >>> this. > >>>>>> If I understand correctly, this plot is basically the 2-D version > >>> of > >>>> the 1-D quantile plot. > >>>>>> Thanks > >>>>>> > >>>>>> Bernard McGarvey > >>>>>> > >>>>>> > >>>>>> Director, Fort Myers Beach Lions Foundation, Inc. > >>>>>> > >>>>>> > >>>>>> Retired (Lilly Engineering Fellow). > >>>>>> > >>>>>> > >>>>>>> On March 27, 2019 at 7:44 AM John Kane > >>> wrote: > >>>>>>> > >>>>>>> The figure did not get through. Perhaps try a pdf? > >>>>>>> > >>>>>>> On Tue, 26 Mar 2019 at 13:41, Bernard McGarvey > >>>>>>> wrote: > >>>>>>>> I want to see if I c
[R] Summarizing select columns in a data frame
I have a data frame that consists of several factor columns say A, B, C, D, and E and several columns containing numerical data, say X1, X2, X10. I would like to create statistics of some of the numerical columns by some of the factor columns. For example, Calculate the mean, min, and max of variables X1 and X7, by factors A, and E. The results should look like the table below: Factor A Factor E mean(X1) min(x1) max(X1) mean(X7) min(x7) max(X7) mean(X10) min(x10) max(X10) A1E1 A1E2 A1E3 A2E1 A2E2 A2E3 I would like the results to be returned to a data frame or other object that I can write out using the write.csv function. I have looked at the summarize and numSummary functions but they do not appear to be flexible enough to do the above. Any help would be appreciated, Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). __ 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] Col names in a data frame
Here is an example piece of code to illustrate an issue: rm(list=ls()) # Clear Workspace # Data1 <- matrix(data=rnorm(9,0,1),nrow=3,ncol=3) Colnames1 <- c("(A)","(B)","(C)") colnames(Data1) <- Colnames1 print(Data1) DataFrame1 <- data.frame(Data1) print(DataFrame1) colnames(DataFrame1) <- Colnames1 print(DataFrame1) The results I get are: (A)(B)(C) [1,] 0.4739417 1.3138868 0.4262165 [2,] -2.1288083 1.0333770 1.1543404 [3,] -0.3401786 -0.7023236 -0.2336880 X.A. X.B. X.C. 1 0.4739417 1.3138868 0.4262165 2 -2.1288083 1.0333770 1.1543404 3 -0.3401786 -0.7023236 -0.2336880 (A)(B)(C) 1 0.4739417 1.3138868 0.4262165 2 -2.1288083 1.0333770 1.1543404 3 -0.3401786 -0.7023236 -0.2336880 so that when I make the matrix with headings the parentheses are replaced by periods but I can add them after creating the data frame and the column headings are correct. Any ideas on why this occurs? Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). __ 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] Error loading "XLConnect" library
I installed the "XLConnect" package which appears to be successful and then tried to load the "XLConnect" library and got an error as shown below. Any ideas as to where to look for the source of the error? The word "release" in the error message makes me think it is some issue with the version of "XLConnect" but that is just a guess. I am running the latest version of R available on CRAN on Windows 10. > install.packages("XLConnect") Installing package into ‘E:/Data/OneDrive/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/XLConnect_1.0.3.zip' Content type 'application/zip' length 29498979 bytes (28.1 MB) downloaded 28.1 MB package ‘XLConnect’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\User\AppData\Local\Temp\RtmpARt8Er\downloaded_packages > library(XLConnect) Error: package or namespace load failed for ‘XLConnect’: .onLoad failed in loadNamespace() for 'XLConnect', details: call: system2("cat", c("/etc/*-release"), stdout = TRUE, stderr = TRUE) error: '"cat"' not found > library("XLConnect") Error: package or namespace load failed for ‘XLConnect’: .onLoad failed in loadNamespace() for 'XLConnect', details: call: system2("cat", c("/etc/*-release"), stdout = TRUE, stderr = TRUE) error: '"cat"' not found Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). [[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] Surface plots....
If I have a set of data (x,y,z) and I want to plot z(x,y) as a surface plot. What I am looking for is one with a lot of functionality like easily rotate the plot and so on. Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On April 25, 2019 at 2:13 PM Bert Gunter wrote: > > Depends on what you want to do -- context matters. > More details would probably enable better answers. > > 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 Thu, Apr 25, 2019 at 10:55 AM Bernard Comcast < > mcgarvey.bern...@comcast.net mailto:mcgarvey.bern...@comcast.net > wrote: > > > > Does anyone have a recommendation for the best package/function > for doing surface plots? > > > > Bernard > > Sent from my iPhone so please excuse the spelling!" > > __ > > R-help@r-project.org mailto: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] COVID-19 datasets...
Just curious does anyone know of a website that has data available in a format that R can download and analyze? Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). __ 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] unstable results of nlxb fit
+00 6.8321e+00 -16.405584 2.6139e-02 [56,] 3359.2 1.2687e+03 6.8321e+00 -3.775998 2.6139e-02 [57,] 3359.2 1.5529e+01 -8.6967e+000.026139 2.6139e-02 [58,] 3359.2 -1.0003e+01 1.6835e+010.026139 2.6139e-02 [59,] 3359.2 6.8321e+00 3.9291e+020.026139 -4.1974e+02 [60,] 3359.2 -2.1880e+01 2.8712e+010.026139 2.6139e-02 [61,] 3359.2 4.1736e+03 6.8321e+00 -10.711457 2.6139e-02 [62,] 3359.2 -3.3185e+01 4.0017e+010.026139 2.6139e-02 [63,] 3359.2 7.6732e+02 6.8321e+00 -0.723977 2.6139e-02 [64,] 3359.2 1.5334e+04 6.8321e+00 -52.573620 2.6139e-02 [65,] 3359.2 -2.9556e+01 3.6388e+010.026139 2.6139e-02 [66,] 3359.2 -1.0447e+00 7.8767e+000.026139 2.6139e-02 [67,] 3359.2 6.8321e+00 2.1471e+020.026139 -7.0582e+01 [68,] 417.8 9.7727e+00 3.9452e-130.021798 2.8023e-01 [69,] 3359.2 -2.2293e+01 2.9126e+010.026139 2.6139e-02 [70,] 3359.2 6.2259e+02 6.8321e+00 -2.782527 2.6139e-02 [71,] 3359.2 -1.4639e+01 2.1471e+010.026139 2.6139e-02 [72,] 417.8 3.9452e-13 9.7727e+000.280227 2.1798e-02 [73,] 417.8 3.9452e-13 9.7727e+000.280227 2.1798e-02 [74,] 417.8 3.9452e-13 9.7727e+000.280227 2.1798e-02 [75,] 3359.2 -2.3449e+01 3.0281e+010.026139 2.6139e-02 [76,] 3359.2 -2.5926e+01 6.8321e+00 -0.663656 2.6139e-02 [77,] 417.8 9.7727e+00 3.9452e-130.021798 2.8023e-01 [78,] 3359.2 6.8321e+00 6.9426e+020.026139 -1.9442e+00 [79,] 3359.2 2.8684e+02 6.8321e+00 -0.854394 2.6139e-02 [80,] 417.8 3.9452e-13 9.7727e+000.280227 2.1798e-02 [81,] 3359.2 -4.5066e+01 5.1899e+010.026139 2.6139e-02 [82,] 3359.2 4.4678e+03 6.8321e+00 -2.109446 2.6139e-02 [83,] 3359.2 3.1376e+03 6.8321e+00 -1.104803 2.6139e-02 [84,] 3359.2 6.8321e+00 1.1167e+020.026139 -1.0280e+00 [85,] 417.8 3.9452e-13 9.7727e+000.280227 2.1798e-02 [86,] 3359.2 5.3864e+02 6.8321e+00 -0.657971 2.6139e-02 [87,] 3359.2 4.8227e+01 6.8321e+00 -2.304024 2.6139e-02 [88,] 3359.2 -2.2048e+01 2.8880e+010.026139 2.6139e-02 [89,] 417.8 3.9452e-13 9.7727e+000.280227 2.1798e-02 [90,] 3359.2 6.8321e+00 -4.1689e+010.026139 -3.6049e+00 [91,] 417.8 9.7727e+00 3.9452e-130.021798 2.8023e-01 [92,] 3359.2 -4.1265e+01 4.8097e+010.026139 2.6139e-02 [93,] 3359.2 -1.1565e+01 1.8397e+010.026139 2.6139e-02 [94,] 3359.2 2.3698e+01 -1.6866e+010.026139 2.6139e-02 [95,] 3359.2 4.4700e+03 6.8321e+00 -12.836180 2.6139e-02 [96,] 3359.2 4.6052e+04 6.8321e+00 -7.158584 2.6139e-02 [97,] 3359.2 2.5464e+03 6.8321e+00 -1.811626 2.6139e-02 [98,] 3359.2 6.8321e+00 1.0338e+030.026139 -1.5365e+01 [99,] 3359.2 1.3783e+01 -6.9507e+000.026139 2.6139e-02 [100,] 3359.2 6.8321e+00 6.7153e+020.026139 -1.5975e+03 Hope this helps, Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow). > On May 7, 2020 at 9:33 AM J C Nash wrote: > > > The double exponential is well-known as a disaster to fit. Lanczos in his > 1956 book Applied Analysis, p. 276 gives a good example which is worked > through. > I've included it with scripts using nlxb in my 2014 book on Nonlinear > Parameter > Optimization Using R Tools (Wiley). The scripts were on Wiley's site for the > book, > but I've had difficulty getting Wiley to fix things and not checked lately if > it > is still accessible. Ask off-list if you want the script and I'll dig into my > archives. > > nlxb (preferably from nlsr which you used rather than nlmrt which is now not > maintained), will likely do as well as any general purpose code. There may be > special approaches that do a bit better, but I suspect the reality is that > the underlying problem is such that there are many sets of parameters with > widely different values that will get quite similar sums of squares. > > Best, JN > > > On 2020-05-07 9:12 a.m., PIKAL Petr wrote: > > Dear all > > > > I started to use nlxb instead of nls to get rid of singular gradient error. > > I try to fit double exponential function to my data, but results I obtain > > are strongly dependent on starting values. > > > > tsmes ~ A*exp(a*plast) + B* exp(b*plast) > > > > Changing b from 0.1 to 0.01 gives me completely different results. I usually > > check result by a plot but could the result be inspected if it achieved good > > result without plotting? > > > > Or is there any way how to perform such task? > > > > Cheers > > Petr > > > > Below is working example. > > > >> dput(temp) > > temp <- structure(list(tsmes = c(31, 32, 32, 32, 32, 32, 32, 32, 33, > > 34, 35, 35, 36, 36, 36, 37, 38, 39, 40, 40, 40, 40, 40, 41, 43, > > 44, 44, 44, 46, 47, 47, 47, 47, 48,
[R] Plotting shipment routs on a world map
I have used the ggplot2 package to create a world map, the png file of the output is attached. The code I use is below: library(ggplot2) library(mapproj) long_Min <- -180.0 long_Max <- 180.0 lat_Min <- -50.0 lat_Max <- 80.0 Width <- 12.0 Height <- 2.0*Width*(lat_Max-lat_Min)/(long_Max-long_Min) windows(width = Width, height = Height,record = TRUE) World_map_data <- map_data("world") World_map_dataS <- subset(World_map_data, (long >= long_Min & long <= long_Max) & (lat >= lat_Min & lat <= lat_Max)) #Europe_data <- map_data("europe") O_lat <- runif(10, min=lat_Min, max=lat_Max) O_long <- runif(10, min=long_Min, max=long_Max) D_lat <- runif(10, min=lat_Min, max=lat_Max) D_long <- runif(10, min=long_Min, max=long_Max) Routes = data.frame(O_lat,O_long, D_lat,D_long) g1 <- ggplot(World_map_dataS, aes(x=long, y=lat, group=group, fill=region)) + geom_polygon(fill="white", colour="blue") + coord_map("mercator") g1 I have a list of shipments with the lat/long of the Origin cities and destination cities in a dataframe Routes. A test example is shown below: structure(list(O_lat = c(57.8440704662353, 43.4692783257924, 34.197948181536, -13.9658199064434, 28.1358464458026, 54.8644948145375, 54.7105941944756, 0.960986674763262, -9.04949014307931, 67.3708150233142 ), O_long = c(-135.800734693184, -139.97953729704, 130.949327526614, 120.016278969124, -81.3588178250939, 107.188451411203, -166.396527299657, 6.01017326116562, 119.992827912793, 68.8450227119029), D_lat = c(13.1392757641152, -48.4003935428336, -18.0977397086099, 7.47306475648656, 38.8207479682751, -6.95962310535833, 21.4299688511528, 77.7941568545066, -39.2934810533188, -5.45942842029035), D_long = c(-161.594757176936, -8.55208304710686, 59.6322040446103, 16.3289373647422, -82.6615255884826, -150.326664168388, -86.496180742979, -162.877350552008, -119.206758281216, -110.952316028997 )), class = "data.frame", row.names = c(NA, -10L)) this dataframe consists of 10 shipments. How do I add these shipments as individual lines onto the world map. If I need to I can convert from lat & long to map coordinates using the mercator projection equations. My issue is what ggplot commands to use. Thanks Bernard McGarvey Director, Fort Myers Beach Lions Foundation, Inc. Retired (Lilly Engineering Fellow).__ 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.