Displaying 20 results from an estimated 100 matches similar to: "using step function in functions"
2011 Apr 11
1
Comparing execution times
Dear all,
In my 'simple' computer I was running some experiments to help me understand how faster a multicore lapply will be. I thought it might be interesting for some people to look at the results.
Even though are not accurate, still might be a good indicator how much improvement there can be.
A.Case. The classic: for 1:100
for (i in c(1:dimz)){
print(sprintf('Creating the %d
2008 Mar 26
2
ggplot2 argument handling odd
Hello there,
I'm trying to do lots of plots in one for-loop. But somehow ggplot does
not evaluate arguments as expected. Here is an example:
library(lattice)
library(ggplot2)
pl <- list()
pl2 <- list()
cDat <- as.data.frame(cbind(x1=0:100,x2=0:10,x3=1:20))
for(obs in c("x1", "x2")) {
pl[[obs]] <- xyplot(cDat[,obs] ~ cDat[,"x3"], main=obs)
2012 Sep 24
0
stop on rows where !is.na(mydata$ti_all)
Dear R experts,
I got help to build a loop but there is a bug inside it that causes
one part of the mechanism to fail.
It should grow once, but if keep growing on rows where $ti_all is not NA.
Here is a wall of code that very crudely demonstrates the problem,
there is a couple of dim() outputs at the end where you can see how it
the second time around keeps adds (2) rows, but this does not
2024 May 15
2
Extracting values from Surv function in survival package
OS X
R 4.3.3
Colleagues
I have created objects using the Surv function in the survival package:
> FIT.1
Call: survfit(formula = FORMULA1)
n events median 0.95LCL 0.95UCL
SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0 18 13 345 156 NA
SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1 13 5 NA 186 NA
SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=2 5
2024 May 16
1
Extracting values from Surv function in survival package
Hi Dennis,
look at the help page for summary.survfit, the Value n.event.
G?ran
On 2024-05-15 22:41, Dennis Fisher wrote:
> OS X
> R 4.3.3
>
> Colleagues
>
> I have created objects using the Surv function in the survival package:
>> FIT.1
> Call: survfit(formula = FORMULA1)
>
> n events median 0.95LCL 0.95UCL
>
2011 Apr 09
1
For->lapply->parallel apply
Dear all,
I would like to ask your help understand the subsequent steps for making my program faster.
The following code:
Gauslist<-array(data=NA,dim=c(dimx,dimy,dimz))
for (i in c(1:dimz)){
print(sprintf('Creating the %d map',i));
Gauslist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))
}
creates 100 GaussMaps (each
2004 Jun 16
2
subset and lme
I'm puzzled by the following problem, which appears when
attempting to run an analysis on part of a dataset:
If I try:
csubset <- dat$Diagnosis==0
cont <- lme(fixed=cform,
random = ~1|StudyName,
data=dat,subset=csubset,na.action=na.omit)
Then I get:
Error in eval(expr, envir, enclos) : Object "csubset" not found
But if I do
2007 Aug 01
1
Problem to remove loops in a routine
Dear R-users,
I have written the following code to generate some trellis plots. It
works perfectly fine except that it is quite slow when it is apply to my
typical datasets (over several thousands of lines). I believe the
problem comes from the loops I am using to subset my data.frame. I read
in the archives that the tapply function is often more efficient than a
loop in R. Unfortunately ,
2011 Oct 31
1
googleVis motionchart - slow with Date class
Hi,
I am trying to create a googleVis motion chart with monthly data. When formatting the date column as a Date class variable, the plot as presented in the browser becomes considerably slower and very prone to crashing the browser. To illustrate this issue I have modified the WorldBank demo.
### objects from demo("WorldBank", package = "googleVis")
M <-
2011 Aug 17
3
How to apply a function to subsets of a data frame *and* obtain a data frame again?
Dear all,
First, let's create some data to play around:
set.seed(1)
(df <- data.frame(Group=rep(c("Group1","Group2","Group3"), each=10),
Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 10)))[sample(1:30,30),])
## Now we need the empirical distribution function:
edf <- function(x) ecdf(x)(x) # empirical distribution function evaluated at x
##
2003 Mar 25
2
Help with data.frame subsets
Hello all,
I'm trying to get a subset of a data frame by taking all rows where the 2nd
column is >= Min and <= Max. I can do that by a 2 step process similar to
the following:
subData <- dataFrame[dataFrame[,2] >= Min,]
subData2 <- subData[subData[,2] <= Max,]
Then I try to graph the results where col 2 is the X var and col 3 is the Y
var. Therefore I do the following:
X
2009 Sep 14
3
Eliminate cases in a subset of a dataframe
Hi folks,
I created a subset of a dataframe (i.e., selected only men):
subdata <- subset(data,data$gender==1)
After a residual diagnostic of a regression analysis, I detected three
outliers:
linmod <- lm(y ~ x, data=subdata)
plot(linmod)
Say, the cases 11,22, and 33 were outliers.
Here comes the problem: When I want to exclude these three cases in a
further regression analysis,
- for
2011 Jul 22
0
Mclapply prints once
Dear all
I have the following code that works in paraller (and is pretty fast actually)
The only problem I still have is that every core just prints only once.
dimz<-1000
Shadowlist<-mclapply(1:dimz, function(i) {
????????????????????????????? print(sprintf('Creating the %d map',i));
????????????????????????????? createField(x=x, y=y, model=model,
2013 Apr 09
0
Simple GLS regression with CAPER
Dear R experts,
I hope this is the right list for my question.
As a newcomer in R, I am testing the R CAPER package, applying a simple
regression on a phylogeny tree with three binary traits: (t1, t2, t3).
My goal is to test the sensitivity to a correlation between t1 and t3. But
if a correlation of 100% is considered (i.e. t3 = t1). The pgls method of
CAPER seems to crash:
You can find there
2007 Oct 01
3
mean of subset of rows
Dear list,
this must be an easy one:
I have a data.frame of two columns, "ID" with four different levels (A
to D) and numerical "size", and each of the 4 different IDs is
repeated a
different number of times. I would like to get the mean size for each
ID as another data.frame. I have tried the following:
>ID= as.character(unique(data[,1])) # I use unique() because
2008 Jun 19
2
Advanced Filtering problem
http://www.nabble.com/file/p18018170/subdata.csv subdata.csv
I've attached 100 rows of a data frame I am working with.
I have one factor, id, with 27 levels. There are two columns of reference
data, x and y (UTM coordinates), one column "date" in POSIXct format, and
one column "diff" in times format (chron package).
What I am trying to do is as follows:
For each day
2011 Apr 11
1
Mclapply and print statement
Dear all.
I am using the mclapply function to split my code to the many cores my system has. It seems that is working fine. This is the parallel version of lcapply.
The only problem that I seem to have is that the printf cannot print messages.
The ideal to me is to have fro my function an output of the form
Shadowlist<-mclapply(1:dimz, function(i) {
print(sprintf('Creating the
2007 Jun 21
2
Overlaying lattice graphs (continued)
Dear R Users,
I recently posted an email on this list about the use of data.frame and
overlaying multiple plots. Deepayan kindly indicated to me the
panel.superposition command which worked perfectly in the context of the
example I gave.
I'd like to go a little bit further on this topic using a more complex
dataset structure (actually the one I want to work on).
>mydata
Plot
2008 Mar 03
2
handling big data set in R
Hello R users,
I'm wondering whether it is possible to manage big data set in R? I
have a data set with 3 million rows and 3 columns (X,Y,Z), where X is
the group id. For each X, I need to run 2 regression on the submatrix.
I used the function "split":
datamatrix<-read.csv("datas.csv", header=F, sep=",")
dim(datamatrix)
# [1] 2980523 3
2004 Nov 08
3
location of key in panels of trellis plot
Hi,
I want to insert a key into each panel of a trellis plot, which I can do
with a custom panel function that calles draw.key. The problem arises
because I want the top right hand corner of the key to start in the top
right hand corner of the panel. If you run my code below, you can see that
the key appears in the center of each panel. This is because the default
viewport in draw.key is the