Displaying 20 results from an estimated 1000 matches similar to: "Help with the code"
2010 Mar 02
0
plotting fitted lme values as a smooth line
I am trying to plot fitted lme values as a smooth line of a graph
showing the exponential relationship between temperature and soil
respiration.
In the plot, the x-axis has temperature, and the y-axis has soil
respiration. When I try to add a line showing temperature versus the
fitted values, it is jagged and not smooth.
Here is the code I used:
lme.1<-lme(fixed=LnFlux~Temp,
2003 Jun 07
2
Ordering long vectors
I need to order a long vector of integers with rather few unique values.
This is very slow:
> x <- sample(rep(c(1:10), 50000))
> system.time(ord <- order(x))
[1] 189.18 0.09 190.48 0.00 0.00
But with no ties
> y <- sample(500000)
> system.time(ord1 <- order(y))
[1] 1.18 0.00 1.18 0.00 0.00
it is very fast!
This gave me the following idea: Since I don't care
2010 Aug 24
2
Attempted SIP connection by foreign host. Help!
Say,
I just picked this up on my messages!
There are a whole host of these requests!
Anyone know whow there people are? Is there a way to report them?
Any suggestions as to how to block them?
[Aug 23 10:34:16] NOTICE[1010] chan_sip.c: Registration from '"912" <sip:1 at 41.1.1.1>' failed for '184.106.217.112' - Wrong password
[Aug 23 10:34:16] NOTICE[1010]
2018 Mar 08
0
grepAMModelLib in package AMML not working as expected
Dear All,
Here is a minimal working example :
library(AMModels)
mymodels <- amModelLib(description = "Simple AM Model library")
dataset1 <- 1:100
dataset2 <- seq(2,200,2)
model1 <- lm(dataset2~1)
model2 <- lm(dataset2~ dataset1)
m1 <- amModel(model = model1,comment = "Initial model.")
m2 <- amModel(model = model2,comment = "Final model.")
2006 Aug 09
3
objects and environments
Dear list,
I have two functions created in the same environment, fun1 and fun2.
fun2 is called by fun1, but fun2 should use an object which is created in fun1
fun1 <- function(x) {
ifelse(somecondition, bb <- "o", bb <- "*")
## mymatrix is created, then
myresult <- apply(mymatrix, 1, fun2)
}
fun2 <- function(idx) {
if (bb == "o) {
#
2004 Mar 25
1
mlocal/mtrace inside a loop
Hello
I need some help in figuring Bravington’s debugger
out.
Ok
I have 2 functions, fun1 and fun2 saved in a ASCII
file say filename is funs.
Fun1 has a loop which calls fun2, fun2 has a loop
which fails and I need to find out the value of the
variables of the fun2 and fun1 loops at the specific
iteration that fails. Both fun1 and fun2 loops will
iterate thousands of times so line by line debug
2014 Jan 25
1
package NAMESPACE question
Hello,
I'm building a package. My code is stored in foo.R. This code has two
functions FUN1 and FUN2. FUN1 calls FUN2. FUN1 is listed in export() under
the package NAMESPACE but NOT FUN2. After building the package when I call
FUN1 is giving me an error that cannot find FUN2.
I solved this by adding FUN2 in the export() NAMESPACE. However, what is
puzzling me is that I have other examples
2006 Aug 16
1
Problem with the special argument '...' within a function
I'm not sure if this is what you want, but simply add ... to the list of
arguments for fun1 and fun2 would eliminate the error.
Andy
From: Hans-Joerg Bibiko
>
> Dear all,
>
> I wrote some functions using the special argument '...'. OK, it works.
>
> But if I call such a function which also called such a
> function, then I get an error message about unused
2009 Sep 05
2
Anova over a list of models
I have a list object, in which I have stored n lme4-models. For example:
library(lme4);
myModels <- list();
myModels[1] <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
myModels[2] <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject),
sleepstudy)
Now I would like to perform an anova over all models in the list. However,
the anova function requires that every model is inserted
2009 May 01
1
integrate with large parameters
Dear R-users,
i have to integrate the following function
`fun1` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a))
}
but if l1 is large, i get the "non-finite function value" error, so my
idea is to rescale with exp(-l1)
`fun2` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a) - l1)
}
but it seems this doesn't solve the problem, when
2009 Oct 01
1
pass "..." to multiple sub-functions
Dear list,
I know I have seen this discussed before but I haven't been successful
in searching for "ellipsis", "dots", "..." in the archives. I would
like to filter "..." arguments according to their name, and dispatch
them to two sub-functions, say fun1 and fun2. I looked at lm() but it
seemed more complicated than I need as it modifies the calling
2009 Jun 16
1
ifelse(is.na), with function inside
Hi,
I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like to use is.na(a)
function to get a vector like this:
wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in
vector "a"
This is my short code but something is wrong and I don't know what...
for (i in 1:7){
a=c( NA, 3, 4, 4, NA, NA, 3)
fun1=function(x){
x=1
print(x)
}
fun2=function(x){
2011 Apr 07
2
Two functions as parametrs of a function.
Hi R users:
I'm trying to make a function where two of the parameters are
functions, but I don't know how to put each set of parameters for
each function.
What am I missing?
I try this code:
f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){
force(fun1)
force(fun2)
force(n)
p1<-unlist(par1)
p2<-unlist(par2)
force(p1)
force(p2)
2012 Aug 30
1
How to modify the values of the parameters passing via ...
Dear Friends,
Let's assume there are three parameters that were passed into fun1. In
fun1, we need to modify one para but the remains need to be untouched. And
then all parameters were passed into fun2. However, I have failed to
achieve it.
Please see the following code.
##########################################
fun1 <-function(x, y, z=10) {x+y+z;}
fun2 <-function(aa, ...) {
2015 Feb 26
1
iterated lapply
> On Feb 25, 2015, at 5:35 PM, Benjamin Tyner <btyner at gmail.com> wrote:
>
> Actually, it depends on the number of cores:
Under current semantics, yes. Each 'stream' of function calls is lazily capturing the last value of `i` on that core.
Under Luke's proposed semantics (IIUC),
the result would be the same (2,4,6,8) for both parallel and serial execution. This is
2015 Feb 25
0
iterated lapply
Actually, it depends on the number of cores:
> fun1 <- function(c){function(i){c*i}}
> fun2 <- function(f) f(2)
> sapply(mclapply(1:4, fun1, mc.cores=1L), fun2)
[1] 8 8 8 8
> sapply(mclapply(1:4, fun1, mc.cores=2L), fun2)
[1] 6 8 6 8
> sapply(mclapply(1:4, fun1, mc.cores=4L), fun2)
[1] 2 4 6 8
> >/ On Feb 24, 2015, at 10:50 AM,
2007 Jun 01
2
Interaction term in lmer
Dear R users,
I'm pretty new on using lmer package. My response is binary and I have fixed
treatment effect (2 treatments) and random center effect (7 centers). I want
to test the effect of treatment by fitting 2 models:
Model 1: center effect (random) only
Model 2: trt (fixed) + center (random) + trt*center interaction.
Then, I want to compare these 2 models with Likelihood Ratio Test.
2005 Dec 19
0
Package "boot": How to construct CI from censboot object?
Dear all,
I run the example of "censboot" contained in "boot" package. But, I can't
find the confidence interval of the resulted "censboot" object. Any idea ?
> aml.fun <- function(data) {
+ surv <- survfit(Surv(time, cens)~group, data=data)
+ out <- NULL
+ st <- 1
+ for (s in 1:length(surv$strata)) {
+
2012 Nov 20
2
correct function formation in R
Dear list!
?
I have question of?'correct function formation'. Which function (fun1 or fun2; see below) is written more correctly? Using ''structure'' as output or creating empty ''data.frame'' and then transform it as output? (fun1 and fun1 is just for illustration).
?
Thanks a lot, OV
?
code:
input <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 =
2001 Mar 08
2
surprising behavior of match.arg() (PR#872)
If a function needs to be passed as an argument to another function,
default arguments to the function being passed are lost. Consider this
example:
fun1 <- function(x, A=c("power","constant")) {
arg <- match.arg(A)
cat(paste("A is:",paste(A,collapse=", "),"\narg is:",arg,"\n"))
cat("formals:\n")
print(formals())