similar to: How to catch Error Messages in R

Displaying 20 results from an estimated 70000 matches similar to: "How to catch Error Messages in R"

2009 Sep 09
3
How to return/show the indexes of unusual points in boxplot?
I am wondering if you know how to return by function or show in boxplot, the indexes of unusual points, such as, points that are outside the box or in [Q3+1.5IQR,Max]. For example, > boxplot(c(4,rnorm(20),8)) There are 2 unusual points 4 and 8. How to show the indexes of 4 and 8 in the boxplot or return them by function? Thanks, -james
2009 Mar 10
6
Pseudo-random numbers between two numbers
I would like to generate pseudo-random numbers between two numbers using R, up to a given distribution, for instance, rnorm. That is something like rnorm(HowMany,Min,Max,mean,sd) over rnorm(HowMany,mean,sd). I am wondering if dnorm(runif(HowMany, Min, Max), mean, sd) is good. Any idea? Thanks. -james
2009 Mar 10
2
How to color certain area under curve
For a given random variable rv, for instance, rv = rnorm(1000), I plot its density curve and calculate some quantiles: plot(density(rv)) P10P50P90 = = quantile(rv,probs = c(10,50,90)/100) I would like to color the area between P10 and P90 and under the curve and mark the P50 on the curve. > rv = rnorm(1000) > plot(density(rv)) > P10P50P90 = = quantile(rv,probs = c(10,50,90)/100) Could
2010 Jun 02
4
Draw text with a box surround in plot.
text() can draw text on a plot. Do we have a way/function to draw text with a box surround it? Thanks, -james
2009 Aug 20
1
Questions on factors in regression analysis
I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and the response variable is numeric. Some factors are important but others not. How to determine which categorical variables are significant to the response variable? Q2. As we knew, lm can deal with categorical variables. I thought, when there is a categorical
2010 Jul 12
3
How to mean, min lists and numbers
I would like to sum/mean/min a list of lists and numbers to return the related lists. -1+2*c(1,1,0)+2+c(-1,10,-1) returns c(2,13,0) but sum(1,2*c(1,1,0),2,c(-1,10,-1)) returns 15 not a list. Using the suggestions of Gabor Grothendieck, Reduce('+',list(-1,2*c(1,1,0),2,c(-1,10,-1))) returns what we want, c(2,13,0). However, it seems that this way does not work to mean/min. So, how to
2010 Jul 07
2
Sum vectors and numbers
We want to sum many vectors and numbers together as a vector if there is at least one vector in the arguments. For example, 1 + c(2,3) = c(3,4). Since we are not sure arguments to sum, we are using sum function: sum(v1,v2,...,n1,n2,..). The problem is that sum returns the sum of all the values present in its arguments: sum(1,c(2,3))=6 sum(1,2,3)=6 We do not want to turn sum(v1,v2,...,n1,n2,..) to
2009 May 20
2
How to load data from Statistics Canada
We would like to load data from Statistics Canada (http://www.statcan.gc.ca/) using R, for example, Employment and unemployment rates. It seems to me that the tables are displayed in HTML. I was wondering if you know how to load these tables. Thanks, -james
2009 May 27
2
How to set a filter during reading tables
We are reading big tables, such as, Chemicals <- read.table('ftp://ftp.bls.gov/pub/time.series/wp/wp.data.7.Chemicals',header = TRUE, sep = '\t', as.is =T) I was wondering if it is possible to set a filter during loading so that we just load what we want not the whole table each time. Thanks, -james
2010 May 05
3
Limitations on R code file
I would like to run R code from a file that is generated from other source. The file consists of some variables and formulas/equations such as Variables = log(100) ##Other variable definitions VariablesWithLongNames = 2*3*log(12345678)+10^4 + Variables Equations=log(VariablesWithLongNames)+Variables^2 ##Other equations, formulas Result = Equations^2+rnorm(10000) hist(Result,breaks=100,freq=FALSE)
2008 Jun 17
2
try catch block
How can I use the try catch block such that if this statement fails xml <- xmlTreeParse(xmlTxt, useInternal=TRUE) then this statement is executed xml <- xmlMalFormed() ? This code does not work but assuming its somewhere along these lines: tryCatch(xml <- xmlTreeParse(xmlTxt, useInternal=TRUE), xml <- xmlMalFormed(f1)) -- View this message in context:
2008 Mar 31
2
Call R from C#
I would like to call functions/objects of R from C#.NET environment. I was wondering whether or not it is possible. If yes, could you please give me some suggestions on how to approach it (any examples/documentation on this)? Thanks! -James
2009 Apr 16
1
How can I catch errors thrown from c via the Rcpp error() function?
Hi I am using the flowClust package from BioConductor, which is largely implemented in c. For some of my data, the package occasionally (and quite stochastically) encounters a particular condition which halts its operation. At this point, it calls the error() function defined by Rcpp, and halts. What I would like to be able to do is to catch the error thrown, and retry the operation a few
2010 Nov 17
2
How to catch warnings
Hello when my code executes I receive the message that were some warnings. I want to catch warning messages at run time so to print some local variables and try to understand why this warning happens. I searched on internet and I tried withCallingHandlers( which seems to work but as I used Rkward the result is awful. I get a prompt to copy paste a value only while at the same time my background
2007 Oct 10
2
How to catch a R error in R code
Hi All, I entered a R statement, e.g. 1:20 = x or log("a") on an HTML form and passed it to a R-CGI script. Obviously, neither of both is a correct R statement or expression. However, my R-CGI script could not return and report the error message to the Web site even though it received the statement. I tried to use some R built-in functions of try, tryCatch, eval, expression,
2011 Mar 18
2
Understanding tryCatch
I've read the help and the archives on tryCatch but I'm still stuggling trying to understand how it works exactly and how I can use it to get the result I need. I have a data.frame of urls which point to 11 .zip files. Basically I use RCurl to get the list of files from a ftp and then reduce that directory dump to the 11 zip files I want to download. Its easy enough to do that in a loop
2008 Aug 14
3
tryCatch question
I would like to use the 'tryCatch' function but am having a hard time getting my head around it. In 'C' like languages try/catch/finally means try a block of statements and if any throw an error then do the statements in the catch block and then error or not always do the staements in the finally block. In 'R' as best as I can tell the block of staements in the try block is
2013 Feb 07
4
Hard Stop?
is it possible to throw a stop() that is so hard that it will escape even tryCatch? /iaw ---- Ivo Welch (ivo.welch at gmail.com)
2009 Jun 30
1
How to pass parameters to htmlParse Bank of Canada html pages
To get USDCAD rates from Bank of Canada, we first go url <- "http://banqueducanada.ca/en/rates/exchange-avg.html" select 12 months for Rates for the past and click "Get Rates" button. Then the page moves to address <- "http://banqueducanada.ca/cgi-bin/famecgi_fdps" and the rates show in the html page. htmlParse() can read the html document but
2009 Jun 23
1
How to find b entries using xPath?
We got all rows by: library(XML) doc = htmlParse('http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm') rows = xpathSApply(doc, '//table/tbody/tr') The last row is: row_last = rows[15] row_last [[1]] <tr><td id="t1stub17" class="stub1 RGBShade"><b>Unsmoothed composite leading indicator</b></td>&#13; <td