similar to: Trap an error from a function

Displaying 20 results from an estimated 30000 matches similar to: "Trap an error from a function"

2020 Oct 06
4
Solving a simple linear equation using uniroot give error object 'x' not found
Colleagues, I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, Error in yfu n(x,10,20) : object 'x' not found. I hope someone can tell we how I can fix the problem
2020 Oct 06
0
Solving a simple linear equation using uniroot give error object 'x' not found
On 06/10/2020 11:00 a.m., Sorkin, John wrote: > Colleagues, > I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, > Error in yfu n(x,10,20) : object 'x' not found. > > I hope someone can tell we how I can fix
2013 Feb 01
2
How does this function print, why is n1 which equals 1 printed as 2?
Windows 7, R 2.12.1 Colleagues, I am trying to understand the n.for.2means function. The code below is a copy of the function (renamed to n.for.2means.js). I have inserted a single line of code towards the bottom of the function which uses the cat function to print the value of n1. You will note the value (preceded by stars) is printed as 1. The function (1) prints a lot of output without any
2006 Oct 14
2
regression analyses using a vector of means and a variance-covariance matrix
R 2.2.0 windows XP How can I perform a regression analyses using a vector of means, a variance-covariance matrix? I looked at the help screen for lm and did not see any option for using the afore mentioned structures as input to lm. Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D.
2011 Apr 23
3
Problem having tick marks aligned when plotting three graphs on top of one another.
R 2.10 Windows 7 I am trying to plot three graphs on top of each other. I need to have the axises perfectly aligned. For some reason the ticks on the y axes are slightly off so they do not perfectly align. Can someone tell me how I can get the to overlay each other perfectly? I thought the yaxp parameter would solve my problem, but it does not. My data and code follows: >
2006 May 14
2
apply, apply speed vs. traditional looping mechanisms
Can someone tell me why apply (and apply) are faster in performing repeated operations than a for (or do) loop? I am looking for a technical explanation. Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC and University of Maryland School of Medicine Claude Pepper OAIC University of Maryland School of Medicine Division of Gerontology
2017 Oct 23
1
Syntax for fit.contrast (from package gmodels)
David, predict.glm and se.fit were exactly what I was looking for. Many thanks! John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax)
2008 Dec 01
1
Comparing output from linear regression to output from quasipoisson to determine the model that fits best.
R 2.7 Windows XP I have two model that have been run using exactly the same data, both fit using glm(). One model is a linear regression (gaussian(link = "identity")) the other a quasipoisson(link = "log"). I have log likelihoods from each model. Is there any way I can determine which model is a better fit to the data? anova() does not appear to work as the models have the
2009 Aug 29
1
Rcmdr installalation under Viata gives a warning. Do I need to do anything?
Windows Vista R 2.9.1 When trying to install Rcmdr I get the message shown below. What does it mean, do I need to do anything? The downloaded packages are in C:\Users\John Sorkin\AppData\Local\Temp\RtmpRCLbhe\downloaded_packages updating HTML package descriptions Warning message: In file.create(f.tg) : cannot create file 'C:\PROGRA~1\R\R-29~1.1/doc/html/packages.html', reason
2017 Oct 23
0
Syntax for fit.contrast (from package gmodels)
> On Oct 22, 2017, at 5:01 PM, Sorkin, John <jsorkin at som.umaryland.edu> wrote: > > David, > Again you have my thanks!. > You are correct. What I want is not technically a contrast. What I want is the estimate for "regional" and its SE. There needs to be a reference value for the contrast. Contrasts are differences. I gave you the choice of two references
2007 Oct 01
3
3-dimensional graph
Windows XP R 2.3.1 I have a funciton fit1<-lm(y~x+z) Is there a function that will produce a 3-dimensional plot of y,x,z? I looked at the help files, but did not find a clean answer to my question. Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street
2013 Feb 05
3
Non linear programming: choose R that minimizes corr(y, x^R)
I am looking for a package that will allow me to choose R (a real number) that minimizes the correlation of y and x^R, i.e. find R such that corr(y,x^R) is minimized. Any suggestions for packages I might look at would be helpful. Thanks, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA
2006 Nov 21
2
sample size for linear regression
Is there an R function that can be used to calculate a sample size for a linear regression: i.e. Given a linear regression: y=f(x,z) i.e. fit1<-lm(y~x+z) is there a function which can be passed coef(z), SE(z), and other parameters to determine a sample size based on z, SEz and other information from the regression? Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics
2017 Oct 23
2
Syntax for fit.contrast (from package gmodels)
David, Again you have my thanks!. You are correct. What I want is not technically a contrast. What I want is the estimate for "regional" and its SE. I don't mind if I get these on the log scale; I can get the anti-log. Can you suggest how I can get the point estimate and its SE for "regional"? The predict function will give the point estimate, but not (to my knowledge)
2016 Apr 07
0
using apply to a data frame
??I would like to apply a function, fract, to the columns of a dataframe. I tried the following apply(data5NonEventEpochs,2,fract) but, no surprise it did not work as apply works on matrices not data frames. How can I apply a fuction to the columns of a data frame? (I can't covert data5NonEventsEpochs to a matrix as it contains character data). Thank you, John John David Sorkin M.D., Ph.D.
2008 Sep 20
2
selecting from a series of integers with pre-determined probabilities
R 2.6 Windows XP I need to select from the integers 1,2,3,4,5 with some pre-determined probability, e.g. probability of selecting 5 80%, probability of selecting 1 or 2 or 3 or 4 20%. Any suggestions for how I might accomplish this? I need to do it very efficiently as I will be doing it 500,000 times. Thanks John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of
2009 Dec 08
2
lm: RME vs. ML
windows XP R 2.10 As pointed out by Prof. Venables and Ripley (MASS 4th edition, p275), the results obtained from lme using method="ML" and method="REML" are often different, especially for small datasets. Is there any way to determine which method is preferable for a given set of data? Thanks, john John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics
2005 Jul 15
3
Dividing a vector into ntiles
R 2.1.1 Win 2k Would someone suggest a method (or methods) that can be used to determine ntile cutpoints of a vector, i.e. to determine values that can be used to divide a vector into thirds such as 0-33 centile, 34-66 centile, 67-100 centile. If for example I had a vector: 1,2,3,4,5,6,7,8,9 and wanted to divide the vector into thirds I would have cut-points of 3, and 6. Thanks, John John
2007 Jan 18
3
selecting rows for inclusion in lm
I am having trouble selecting rows of a dataframe that will be included in a regression. I am trying to select those rows for which the variable Meno equals PRE. I have used the code below: difffitPre<-lm(data[,"diff"]~data[,"Age"]+data[,"Race"],data=data[data[,"Meno"]=="PRE",]) summary(difffitPre) The output from the summary indicates that
2008 Oct 16
1
apply, t-test and p-values
R 2.7.2 Windows XP I am using apply to compute a series of Student's t-test from two matrices, sample1 and sample2. boo<-apply(sample1,1,t.test,sample2) I want to pick of the p-values from the tests, but can't seem to get it to work. I have tried several methods to get the values including: boo<-apply(sample1,1,t.test$t.test,sample2) boo<-apply(sample1,1,t.test,sample2)$t.test