Displaying 20 results from an estimated 10000 matches similar to: "Count values in a dataframe with respect to groups"
2018 Mar 06
4
Capturing warning within user-defined function
Hi, I am trying to automate the creation of tables for some simply
analyses. There are lots and lots of tables, thus the creation of a
user-defined function to make and output them to excel.
My problem is that some of the analyses have convergence issues, which I
want captured and included in the output so the folks looking at them know
how to view those estimates.
I am successfully able to do
2018 Mar 06
0
Capturing warning within user-defined function
1. I did not attempt to sort through your voluminous code. But I suspect
you are trying to reinvent wheels.
2. I don't understand this:
"I've failed to find a solution after much searching of various R related
forums."
A web search on "error handling in R" **immediately** brought up ?tryCatch,
which I think is what you want.
If not, you should probably explain why it
2018 Mar 06
0
Capturing warning within user-defined function
You can capture warnings by using withCallingHandlers. Here is an example,
its help file has more information.
dataList <- list(
A = data.frame(y=c(TRUE,TRUE,TRUE,FALSE,FALSE), x=1:5),
B = data.frame(y=c(TRUE,TRUE,FALSE,TRUE,FALSE), x=1:5),
C = data.frame(y=c(FALSE,FALSE,TRUE,TRUE,TRUE), x=1:5))
withWarnings <- function(expr) {
.warnings <- NULL # warning handler will
2018 Mar 06
1
Capturing warning within user-defined function
tryCatch() is good for catching errors but not so good for warnings, as
it does not let you resume evaluating the expression that emitted
the warning. withCallingHandlers(), with its companion invokeRestart(),
lets you collect the warnings while letting the evaluation run to
completion.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 6, 2018 at 2:45 PM, Bert Gunter <bgunter.4567 at
2010 Oct 11
3
help with simple but massive data transformation
I have data that looks like this:
start end value
1 4 2
5 8 1
9 10 0
I want to transform the data so that it becomes:
startend value
1 2
2 2
3 2
4 2
5 1
6 1
7 1
8 1
9 0
10 0
----
I've
2008 Feb 09
1
R is not reading(?) my data properly
Thanks for the replies to my prior question. My problem is that R always
says object not found when I enter a variable name into a command. I
converted a Stata file into an Rdata file by first loading the foreign
package by entering
require(foreign)
Then I asked R to read the Stata file by entering
pol572a1<- read.dta("C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta")
So
2010 Sep 30
1
Several Lattice plots in one Plot
Hi all,
I've been trying for hours, but I do not find a Solution. I want to plot 12 variables over time in separate diagrams in one plot/window using lattice. Two columns, six rows. I used print with the split command, but the graphics are getting really small. Can someone please help me.
Following data example:
dta = data.frame(
day=c(1,2,3,4,5,6,7),
2011 Apr 27
6
Assignments inside lapply
Dear all I would like to ask you if an assignment can be done inside a lapply statement.
For example
I would like to covert a double nested for loop
for (i in c(1:dimx)){
for (j in c(1:dimy)){
Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f)
}
}
to something like that:
ij<-expand.grid(i=seq(1:dimx),j=(1:dimy))
unlist(lapply(1:nrow(ij),function(rowId) { return
2007 Dec 03
3
ggplot2: Choosing colours
Dear useRs,
I'm trying to specify the colour of a factor with ggplot2. The example
below gets me close to what I want, but it's missing a legend.
Any ideas?
Thanks,
Thierry
library(ggplot2)
dataset <- data.frame(x = rnorm(40), y = runif(40), z = gl(4, 10, labels
= LETTERS[1:4]))
ggplot(data = dataset, aes(x = x, y = y, group = z)) + geom_point(colour
= c("red",
2009 Jun 17
2
Re gression by groups questions
I have a large dataset grouped by a factor and I want to perform a regression
on each data subset based on this factor. There are many ways to do this,
posted here and elsewhere. I have tried several. However I found one method
posted on the R wiki which works exactly as I want, and I like the elegance
and simplicity of the solution, but I don't understand how it works. Its
all in the formula
2009 Dec 22
2
Nested For loops
Dear R experts,
Might be very simple question to ask but would be insightful. As the same story of nested "for loops". following is the code that I am using to get the autocorrelation function of the sample data. I have tried to get rid of for loops but since I am touching R after such a long time that I need to practice more but I need help to revive my skills. I know that apply() or
2010 Apr 19
2
ecdf
Hello,
I'd like to plot an empirical cumulative distribution function, except
instead of the fraction of values < x, I'd like the fraction of values > x.
I think this can be done using the ecdf function in {Hmisc}. I installed
the package and loaded it. However, when following the example given in the
documentation, I get an error:
x <- rnorm(100)
ecdf(x,what='1-F')
2010 Nov 29
1
Sweave choking on \\ in filename
Dear all,
Sweave chokes when using "\\" in the path to the Rnw file. Using "/"
works fine. The problem is that Eclipse+StatET uses "\\" in the
filename.
And example of the error, traceback and sessionInfo are given below.
Best regards,
Thierry
> Sweave("Q:\\BMK\\cursussen\\interne_opleiding\\deelnemerslijst.Rnw",
syntax="SweaveSyntaxNoweb")
2010 Nov 04
5
ggplot output
Dear All,
I have this script:
dat <- data.frame(Month = hstat$Date,C_avg = hstat$C.avg,C_stdev =
hstat$C.stdev)
ggplot(data = dat, aes(x = Month, y = C_avg, ymin = C_avg - C_stdev, ymax =
C_avg + C_stdev)) +
geom_point() +
geom_line() +
geom_errorbar()
dat <- data.frame(Month = hstat$Date,K_avg = hstat$K.avg,K_stdev =
hstat$K.stdev)
ggplot(data = dat, aes(x = Month, y = K_avg,
2010 Apr 29
5
reduce size of pdf
is there a way to reduce the size of pdf files in R: ?
compression?
lower dpi ?
or some other option?
2011 Mar 10
1
Problem with defining new method for residuals()
Dear all,
I'm writing a package and I would like to reuse the residuals() function. When I use a function which calls the redefined residuals (for my custom class) I get an error (see below). It looks like the wrong method is used. The strange this is, that when it execute the code manually it get no error.
Any suggestions?
Best regards,
Thierry
The entire source code is at
2006 Dec 08
1
lattice: defining an own function using args for "formula" and "groups"
x.fun <- function( formula, data ) dotplot( formula, data )
x.grp <- function( formula, groups, data ) dotplot( formula, groups, data )
data( barley )
> x.fun( variety ~ yield | site, data=barley )
# no problem
> dotplot( variety ~ yield | site, groups=year, data=barley )
# no problem
> x.grp( variety ~ yield | site, groups=year, data=barley )
object "year" not found
2010 Aug 30
1
compare three values
Hi,
I've three values. What is the best method to choice the lowest values
with an if function?
example:
a = 3
b = 1
c = 5
if (lowest(a,b,c) is a) {........}
if (lowest(a,b,c) is b) {........}
if (lowest(a,b,c) is c) {........}
Thanks,
Alfredo
2011 Jul 13
2
Meaning of "%%"
Dear r helpers
This may be very elementary question but I couldn't figure out what does the operator %% do?
E.g.
p <- 100
q <- 200
p%%q
[1] 100
q%%p
[1] 0
Please guide.
Vincy
[[alternative HTML version deleted]]
2010 Nov 18
2
how to find near neighbors?
I am looking for an efficient way to find near neighbors...
More specifically...
I have two sets of points: A & B and I want to find
points in set B which are closer to set A than some
cutoff (or n-closest)
I will appreciate very much any pointers...
Ryszard
--------------------------------------------------------------------------
Confidentiality Notice: This message is private and may