similar to: Loop question?

Displaying 20 results from an estimated 3000 matches similar to: "Loop question?"

2012 Nov 26
1
Help on function please
Dear All,   I could use a bit of help here, this function is hard to figure out (for me at least) I have the following so far:   PKindex<-data.frame(Subject=c(1),time=c(1,2,3,4,6,10,12),conc=c(32,28,25,22,18,14,11)) Dose<-200 Tinf <-0.5   defun<- function(time, y, parms) {  dCpdt <- -parms["kel"] * y[1]  list(dCpdt)  } modfun <- function(time,kel, Vd) {   out <-
2012 Dec 17
3
simplifying code
Dear All,   I was wondering if you could help me with the following: I have the code:   tin <-0.5 tau <-24 output0 <-10 TIMELOW <-tin TIMEHIGH <-1*tau TIME1 <-c(seq(TIMELOW,TIMEHIGH, by = sign(TIMEHIGH-TIMELOW)*(tau-tin)/3))   then I would like to calculate:   cp1 <-output0*exp(-0.3*TIME1[1]) cp2 <-output0*exp(-0.3*TIME1[2]) cp3 <-output0*exp(-0.3*TIME1[3]) cp4
2012 Nov 30
1
help on "stacking" matrices up
Dear All,   #I have the following code   Dose<-1000 Tinf <-0.5 INTERVAL <-8 TIME8 <-matrix(c((0*INTERVAL):(1*INTERVAL))) TIME7 <-matrix(c((0*INTERVAL):(2*INTERVAL))) TIME6 <-matrix(c((0*INTERVAL):(3*INTERVAL))) TIME5 <-matrix(c((0*INTERVAL):(4*INTERVAL))) TIME4 <-matrix(c((0*INTERVAL):(5*INTERVAL))) TIME3 <-matrix(c((0*INTERVAL):(6*INTERVAL))) TIME2
2013 Jun 18
2
find closest value in a vector based on another vector values
Dear All, would you please provide your thoughts on the following: let us say I have: a <-c(1,5,8,15,32,69) b <-c(8.5,33) and I would like to extract from "a" the two values that are closest to the values in "b", where the length of this vectors may change but b will allways be shorter than "a". So at the end based on this example I should have the result
2012 Jun 07
4
"Re-creating" distributions
Dear All,   I often have to work with certain models in which I try to "reproduce" a distribution the best I can with very little known information avaible. Is there a package or function in R that could best reproduce a probability distribution using only the mean, median and SD values availble without knowing the actual distribution type to begin with and/or the covariance matrix (for
2012 Sep 02
3
Help on finding specific columns in matrix
Dear All,   I have a matrix with 33 columns and 5000 rows. I would like to find 2 specific columns in the set: the one that holds the highest values and the one that holds the lowest values. In this case the column's mean would be apropriate to use to try to find those specific columns because each columns mean is different and they all change together based on the same "change of rate
2012 Sep 08
3
Apply a function to columns of a matrix
Dear All,   as a follow up to my previous e-mail (I think I am getting closer...):   I am trying to apply the trapezoidal functions to a matric column by column. I have the following code:   a <-matrix(c(1:100),ncol=10) b <-matrix(c(2,4,6,8,10,12,14,16,18,20))   apply(a,2,function(b,a) sum(diff(b)*(a[-1]+a[-length(a)]))/2)   for some reason i get an error message: Error in FUN(newX[[, i],
2012 Sep 12
2
Help on converting a Sweave document to PDF
Dear All,   I am working with a Sweave document to be converted into PDF using Rstudio. It seems to me that my R code will also show up after conversion, which I would like not to happen. Is there a way to specify a command that I could place on the beggining and at the end of the R code that would allow R to recognize the area where my R code is and would ignor it when the data is converted?  
2012 Aug 31
3
Help on numerical object and ifelse function
Dear All,   this is probably an easy one but I can not get a handle on it:   x <-c(1,2,3,4,5) y <-c(6,7,8,9,10) z <-15 w <-ifelse(z>14,x,y)   this will give me a value of 1 for w. What I would like to get is the whole string of x, so that w would become a numeric object of 5 characters exactly the same as x.   Apreciate the help,   Sincerely,   Andras [[alternative HTML version
2013 Mar 20
2
remove specific number of rows from a matrix
Dear All,   sorry, got stuck again on the following: let us say we have:   a <-c(1:5) b <-c(6:10) d <-cbind(a,b)     from d I would like to remove total number of rows based on the length of f. So if:   f <-c(1)   my result is working great with the following solution:   d[-length(f),]   so I get: a b [1,] 2 7 [2,] 3 8 [3,] 4 9 [4,] 5 10 but if I do: f <-c(1,2) then I get: 
2012 Dec 01
3
screen if a value is within range
Dear all,   could you please give me some pointers on how I could make R screen for a value if it falls within a certain range? I looked at the subset function, but is not doing it, perhaps because I only have 1 value to screen?   aptreciate the input   ex: a <-16.5 I would like to screen to see if a is within the range of 15 to 20, (which it is:-)), and I would like the code to return a value
2012 Aug 30
2
Help on Plot Title where text is "mixed" with numerical carachters
Dear All,   I have the following code set up:   x <-2000 y <-8 z <-3   I would need to use these numbers to show up in my plot title "mixed" with text. The x,y,z numbers would need to change, the text would not. So my title should look like this   "x txt1 y txt2 z txt3"   so if: txt1=hours txt2=minutes txt3=seconds   then my title of the plot should read:   2000 hours
2013 Mar 28
2
QUESTION ON ROUNDING
Dear All,   wonder if you have a thought on the following: I am using the round(x,digits=3) command, but some of my values come out as: 0.07099999999999999 AND 0.06900000000000001. Any thoughts on why this maty be happening or how to eliminate the problem?   apreciate the help,   Andras [[alternative HTML version deleted]]
2012 Nov 07
2
simple coversion of matrix rows to matrix columns
Dear All   I would like to convert matrix rows to columns. I am thinking the t() function should help, but am having a hard time converting the matrix into the dimensions I would like them to. Example:   a <-matrix(c(1:30),ncol=3) gives me:[,1] [,2] [,3] [1,] 1 11 21 [2,] 2 12 22 [3,] 3 13 23 [4,] 4 14 24 [5,] 5 15 25 [6,] 6 16 26 [7,] 7 17
2013 Mar 20
3
how to skip part of the code
Dear All,   another quick question, this one is on skipping part of my code, so let us say:   a <-5 b <-2 e <-0   d <-a+b f <-a-b   what I would like to do is to have R NOT to calculate the value for d in case the value of e equals to zero (essentially skip that "chunk"), but instead move on to calculate te value for f. In the code I am working with the value of e changes,
2012 Sep 01
2
help on setting boundaries for generating random numbers
Dear All,   is there a way to set low and high limits to a simulation with rlnorm()?   as an example:  a <-rlnorm(500,0.7,1)     I get the summary of   Min. 1st Qu. Median Mean 3rd Qu. Max. 0.1175 1.0590 2.1270 3.4870 4.0260 45.3800 I would like to set limits so that the simulated values minimum would be greater then 0.5 and maximum of less than 30. If during simulation a
2013 Mar 20
1
help on extracting values from a matrix
Dear All,   any thoughts on how I can do the following:   let us say we have:   a <-c(2,4,16,28,48) b <-c(10,4,2,0.4,0.03) d <-cbind(a,b)   what I would like to do is to extract values of column b in the matrix based on the corresponding values of column a. For example: I would like to extract all b values that have a corresponding a value that is less than 24 into a numeric vector, so
2013 Feb 26
2
Help on a code
Dear List,   I have the following code:   x <-c(0, 13.8333333333333, 38.1666666666667, 62.1666666666667, 85.9166666666667, 108.916666666667) y <-c(1.77, 2.39, 3, 2.65, 2.62, 1.8) Interpolated <- approx(x, y,xout=0:tail(x, n=1),method="linear") plot(Interpolated)   in this code x is time in hours (cumulative), and y is a biological variable. I am using linear interpolation
2012 Oct 12
1
better example for multivariate data simulation question-please help if you can
Dear?All, ? a few weeks ago I have posted a question on the R help listserv that?some of you have responded to with a great solution, would like to thank you for that? again.?I thought I would reach out to you with the issue I am trying to solve now. I have posted the question a few days ago, but probably it was not?clear enough, so I thought i try it again.?At times I have a multivariate example
2013 Jan 10
1
Lambert W question
Dear All,   I am using the following model equation:   k*(lambertW_base(b=0,((a)/k)*exp(((a)-z*(t-t0))/k)))   I would like to run this through OpenBUGS, but it does not recognize the lambert function. Would you have any thoughts on how to re-vrite this equation matemathically so that it could be run on OpenBUGS?   apreciate the help,   Sincerely,   Andrs [[alternative HTML version deleted]]