Displaying 20 results from an estimated 3000 matches similar to: "boot() versus loop, and statistics option"
2011 Jan 28
6
R-/Text-editor for Windows?
Tinn-R (http://www.sciviews.org/Tinn-R/) is one of the topmost
suggestions when googling an R-(text-)editor for Windows. However,
to me it appears dissappointing that Tinn-R does not handle utf-8
(mac-roman, or any other) encoded R-scripts or, in general, text
files. Besides Emacs and the R built-in editor, could you
recommend a good editor for Windows, even some commmercial for a
small
2011 Mar 04
3
S. function calculating x +- y
Hello, I am looking for an elegant one-liner for the following
operation:
x <- rnorm(10)
y <- runif(10)
c(mean(x)-mean(y), mean(x)+mean(y))
I thought about
apply(data.frame(x, y), 2, mean)
but I don't know how to apply the +- operation on the result of
apply. Thanks, *S*
--
Sascha Vieweg, saschaview at gmail.com
2012 Feb 19
3
Non-parametric test for repeated measures and post-hoc single comparisons in R?
Some attribute x from 17 individuals was recorded repeatedly on 6 time
points using a Likert scale with 7 distractors. Which statistical
test(s) can I apply to check whether the changes along the 6 time points
were significant?
set.seed( 123 )
x <- matrix( sample( 1:7, 17*6, repl=T ),
nrow = 17, byrow = TRUE,
dimnames = list(1:17, paste( 'T', 1:6, sep='' ))
)
I found
2012 Aug 15
2
sample() from (un-)sorted vectors
Hello,
Vector y is an alphabetically sorted version of vector x. Will both
samples, X and Y, be "absolutely" random or will they have systematic
differences? And: Should I sort or shuffle a vector before sampling?
Thank you, *S*
x <- as.factor(LETTERS[sequence(10:1)])
y <- sort(x)
X <- sample(x, 5)
Y <- sample(y, 5)
--
Sascha Vieweg, saschaview at gmail.com
2011 Mar 08
2
plotCI() with ggplot2
Hello
Currently, I plot some coefficients with some intervals using
function "plotCI()" (package "gplots") using the following code:
(m1 <- matrix(0:5, nrow=2, byrow=T, dimnames=list(c("v1", "v2"),
c("lo", "m", "hi"))))
m2 <- m1 + 1
library(gplots)
plotCI(
x=1:length(m1[, 1]),
pch="",
2011 Feb 13
6
From numeric vector to string vector
Hi there, I have a numeric vector let say:
Vect <- c(12.234, 234.5675, 1.5)
Now I want a string vector like:
changedVec <- c("012.234", "234.568", "001.500")
Would be grateful if somebody help me how can I do that.
Thanks and regards,
[[alternative HTML version deleted]]
2011 Apr 08
1
multinom() residual deviance
Running a binary logit model on the data
df <- data.frame(y=sample(letters[1:3], 100, repl=T),
x=rnorm(100))
reveals some residual deviance:
summary(glm(y ~ ., data=df, family=binomial("logit")))
However, running a multinomial model on that data (multinom, nnet)
reveals a residual deviance:
summary(multinom(y ~ ., data=df))
On page 203, the MASS book says that "here the
2011 Nov 18
3
Apply functions along "layers" of a data matrix
Hello
How can I apply functions along "layers" of a data matrix?
Example:
daf <- data.frame(
'id' = rep(1:5, 3),
matrix(1:60, nrow=15, dimnames=list( NULL, paste('v', 1:4, sep='') )),
rep = rep(1:3, each=5)
)
The data frame "daf" contains 3 repetitions/layers (rep) of 4 variables
of 5 persons (id). For some reason, I want to calculate
2010 Sep 03
3
S4 Method Signatures
Hello,
If the signature of a method defines which generic it implements then I'm confused about why this minimal example I invented won't work :
setGeneric("myFun", function(rs, ...){standardGeneric("myFun")})
setGeneric("myFun", function(cs, ...){standardGeneric("myFun")})
setMethod("myFun", "numeric", function(rs, colour =
2006 Feb 02
2
How to get the namespace of a function?
I declared the environment of the function myfun to be NULL as follows:
environment(myfun) <- NULL
Later on I called that myfun and got an error message because the
function index() in the zoo package was called inside myfun and was
not visible:
Error in myfun(args) : couldn't find function "index"
I tried to use zoo::index() instead of index(), but that did not work.
In fact,
2011 Feb 02
1
pass nrow(x) to dots in function(x){plot(x,...)}
Dear Rers,
I have a function to barplot() a matrix, eg
myfun <- function(x, ...) { barplot(x , ... )}
(The real function is more complicated, it does things to the matrix first.)
So I can do:
m1 <- matrix(1:20,4)
myfun(m1)
myfun(m1, main="My title")
I'd like to be able to add the number of rows of the matrix passed to
the function to the "..." argument, eg
2009 Jun 12
1
how to trigger variable creation?
Hello R users,
i'm wondering how to trigger variable creation.
Whenever a variable is created i want my own function myFun(...) to be
started.
if (exists("x")) {rm(x)} # after removal of x
# any of these calls
x<-10 # should call myFun
x=10 # should call myFun
assign(x,10) # should call myFun
etc.
2011 Jan 20
1
predict() for bootstrapped model coefficients
I run a multinomial regression on a data set with an outcome that
has three values. First, I build an initial model, b.mod. Then I
run a loop to bootstrap the coefficients. For the initial model,
using "predict()", I can print the wrong/false predictions table.
But how do I get this table (that is, the predictions) for the
bootstrapped model? Thanks for hints, *S*
df <-
2015 Oct 22
2
Changed behaviour when passing a function?
Of course (and unsurprisingly) Duncan is correct. I see that behavior in R
3.1.0, as well as the modern ones Duncan mentioned.
What I said is true, as far as it goes, but the symbol being resolved is
FUN, so when looking for a function it doesn't find the function version of
round.
Did you perhaps have a function named FUN in your global environment? If so
you are being bitten by what I
2002 Jan 07
1
Mishandling missing "..." (PR#1247)
R> myfun <- function(x, ...) {x[...] <- 0; x}
R> myfun(3)
Error in myfun(3) : SubAssignArgs: invalid number of arguments
It fails because no ... was passed. The workaround (and desired behavior) is:
R> myfun <- function(x, ...) {if (missing(...)) x[] <- 0 else x[...] <- 0; x}
R> myfun(3)
[1] 0
Deja vu? This is the one piece of my PR#1110 (Oct 3, 2001) that I
2011 Jul 23
1
call a function with explicitly not setting an argument
Is there a way to call a function, and explicitly set an argument to 'not
specified'? My situation is the following. I have a function which passes on
most of its arguments to another function. The second function, myfun2,
serializes all arguments and is out of my control.
myfun <- function(...){
return(myfun2(...));
}
now, the value for arguments of myfun are stored in variables.
2012 Jul 05
1
Extracting srcref for S4 methods
Hi,
on R version 2.15.1 (2012-06-22) (Platform: i686-pc-linux-gnu (32-bit))
sourced functions have srcref attached as an attribute.
Are such data also available for S4 generics and methods? How? (See
sample code below)
Thank you.
Bests,
Renaud
f <- textConnection(
"
f <- function(){}
setGeneric('myfun', function(x, ...) standardGeneric('myfun'))
2007 Feb 23
1
how to use apply with two variables
Hi,
this is a made-up example. Function "myfun" returns two arguments. Can
"apply" be used so that "myfun" is called only once?
Thanks
Serguei
mat<-matrix(runif(50),nrow=10,ncol=5)
myfun<-function(x) {
mymean<-mean(x)
mysd<-sd(x)
return(mymean,mysd)
}
out1<-t(apply(mat,1,function(x) myfun(x)$mymean))
out2<-t(apply(mat,1,function(x)
2011 Feb 03
1
mapply question (?)
Hi,
I have a function myFun which I want to call multiple times, using different
argument lists.
myFun("v1", "2009", 1)
myFun("v2", "2008", 1)
myFun("q", "2001")
How can I easily do this in R? Should I use mapply?
I unsuccessfully tried something like:
x <- list(c("v1", "2009", 1), c("v2",
2006 Apr 20
1
Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...)
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Michael
> Sent: Thursday, April 20, 2006 3:50 AM
> To: R-help at stat.math.ethz.ch
> Subject: [R] Bootstrap error message: Error in
> statistic(data, original, ...) : unused argument(s) ( ...) [Broadcast]
>
>
> Dear colleagues,
>