The unlist-sapply-seq_len bit is unnecessarily convoluted, since the
infcprodessa function can accept vector inputs.
z <- infcprodessa( ab$a, TINF, ab$b, ab$b-TINF )
possibles <- ab[ z >= 15 & z <= 20, ]
possibles[ which.min( possibles$a ), ]
--
On 26-01-2013, at 12:31, Andras Farkas wrote:
>
> Sorry Jeff, probably the new version of Yahoo mail doing the html, I switched
> back to the older one hope that takes care of the problem. Let me clarify the
> code below:
>
> TINF <-1
> a <-c(500,750,1000,1250,1500,1750,2000)
> b <-c(8,12,18
Andras
--- On Sat, 1/26/13, Jeff Newmiller wrote:
> From: Jeff Newmiller
> Subject: Re: [R] Loop question?
> To: "Andras Farkas" , "r-help@r-project.org"
>
> Date: Saturday, January 26, 2013, 2:09 AM
> Please read the Posting Guide
> no html email
Here's a toy example which you can apply the logic of:
dfr <- expand.grid(1:3,1:2)
results <- apply(dfr, 1, sum)
dfr[results==4,]
On 25 January 2013 22:19, Andras Farkas wrote:
>
> Dear All
>
> I have the following data (somewhat simplyfied):
>
> TINF <-1
> a <-c(500,750,1000,1250,1500,1750,
Please read the Posting Guide
no html email
reproducible example please
In general, you can use expand.grid to generate all combinations of inputs,
compute results as a vector just as long as the expand.grid data frame has
rows, and identify which results meet your criteria by a logical test, an
Dear All
I have the following data (somewhat simplyfied):
TINF <-1
a <-c(500,750,1000,1250,1500,1750,2000)
b <-c(8,12,18,24,36,48,60,72,96)
following function:
infcprodessa <-function (D, tin, tau, ts)
(D * (1 - exp(-0.048 * tin))/(tin * (0.048*79) * (1 - exp(-0.048 * tau *
exp(-0.0
Note that in R >= 2.15 you can also use paste0 for this operation more
efficiently.
Michael
On Thu, May 31, 2012 at 1:58 AM, Özgür Asar wrote:
> Dear Sebastian,
>
> The following will create the names
>
> paste("sb",1:5,sep="")
> paste("sw",1:5,sep="")
> paste("Lw",1:5,sep="")
> paste("Lb",1:5,s
Dear Sebastian,
The following will create the names
paste("sb",1:5,sep="")
paste("sw",1:5,sep="")
paste("Lw",1:5,sep="")
paste("Lb",1:5,sep="")
Then you can easily combine and/or order them in R.
Hope this helps.
Ozgur
-
Ozgur ASAR
Research Assistant
M
Hello,
I have a dataframe (Lx) with 5 Lb, and 5 Lw variables. I want to
create several variables according to the loop presented below (data
attached).
Lx <- read.csv("Lx.csv", header=T, sep=",")
for (i in 1:20) {
Lx$sb1[i] <- Lx$Lb1[i+1]/Lx$Lb1[i]
Lx$sb2[i] <- Lx$Lb2[i+1]/Lx$Lb2[i]
Lx$sb
Dear all,
I am trying to implement the following in a loop:
g <- cbind(c(1, 2, 3), c(1, 2, 3))
h <- cbind(c(1, 2, 3), c(1, 2, 3))
c <- cbind(g[,1]*h[,1], g[,2]*h[,2])
g<-rowSums(c)
My attempt looks like this but does not produce the desired results as
above.
for (i in 1:2) {g<- rowSums(cbind(
Dear Thomas,
On Tue, Apr 5, 2011 at 8:33 AM, Thomas wrote:
> Dear all,
>
> I am trying to set up a list with 1:c objects each meant to capture the
> coefficients for one coefficient and 100 replications. I receive the
> following error message:
>
> Error in betaboot[[p]] : subscript out of bounds
Dear all,
I am trying to set up a list with 1:c objects each meant to capture the
coefficients for one coefficient and 100 replications. I receive the
following error message:
Error in betaboot[[p]] : subscript out of bounds.
My code is below. Where is my mistake?
Many thanks,
Thomas
On Fri, Apr 17, 2009 at 10:12 PM, Brendan Morse wrote:
> ...I would like to automatically generate a series of matrices and
> give them successive names. Here is what I thought at first:
>
> t1<-matrix(0, nrow=250, ncol=1)
>
> for(i in 1:10){
> t1[i]<-rnorm(250)
> }
>
> What I intended was
Brendan,
Matrix is atomic. Once you define t1 in matrix, t1[1]=0 rather than the
whole column. I would just convert t1 to a data frame, which is a special
list, by adding t1<- data.frame(t1). Now t1[1] represents the whole column.
Then you can use your loop to add more columns.
Jun
On Fri, Apr
Brendan Morse wrote:
>
> Hi everyone, I am trying to accomplish a small task that is giving me
> quite a headache. I would like to automatically generate a series of
> matrices and give them successive names. Here is what I thought at
> first:
>
> t1<-matrix(0, nrow=250, ncol=1)
>
> for
Dear Brendan,
One way could be either
bigt <- sapply(1:10,function(x) rnorm(250))
colnames(bigt) <- paste('t',1:10,sep="")
bigt
or
bigt2 <- NULL
for(i in 1:10) bigt2 <- cbind( bigt2, rnorm(250) )
colnames(bigt2) <- paste('t',1:10,sep="")
bigt2
or
bigt3 <- matrix(rnorm(250*10),ncol=10)
colnames
Hi everyone, I am trying to accomplish a small task that is giving me
quite a headache. I would like to automatically generate a series of
matrices and give them successive names. Here is what I thought at
first:
t1<-matrix(0, nrow=250, ncol=1)
for(i in 1:10){
t1[i]<-rnorm(250)
}
17 matches
Mail list logo