similar to: lapply without return values?

Displaying 20 results from an estimated 4000 matches similar to: "lapply without return values?"

2008 Jan 15
2
Looking for simpler solution to probabilistic question
Hi I have two processes which take with a certain probability (p1 and p2) x number of years to complete (age1 and age2). As soon as thge first process is completed, the second one begins. I want to calculate the time it takes for the both processes to be completed. I have the following script which gives me the answer, butI think there must be a more elegant way of doing the calculations
2007 May 30
1
Static and dynamic graphics course, July 2007, Salt Lake City
We're pleased to announce a one day course covering static and dynamic graphics using R, ggplot and GGobi. The course will be held just before the JSM, on Saturday, 28 July 2007, in Salt Lake City. The course will be presented by Dianne Cook and Hadley Wickham. In the course you will learn: * How to build presentation quality static graphics using the R package, ggplot. We will cover plot
2007 Nov 09
1
help with lasso2 package
X is a matrix and F is a vector. F2 <- data.frame(cbind(X,F)) F2 V1 V2 V3 F 1 -0.250536332 -1.4755883 1.9580974 -2.136487 2 -0.009856084 0.4953269 0.5486092 -2.744482 3 -0.406962682 0.7729631 0.1861905 -2.891821 4 1.938780097 0.7469251 1.2537781 -1.212992 5 -0.332370358 1.1943637 0.7114278 -1.830441 modF<-formula(F ~ V1 + V2 + V3) #no error message
2008 Apr 24
2
problem with "which"
Hi, I'm having trouble with the "which" or the "seq" function, I'm not sure. Here's an example : > lat=seq(1,2,by=0.1) > lat [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 > which(lat==1) [1] 1 > which(lat==1.1) [1] 2 > which(lat==1.2) [1] 3 > which(lat==1.3) [1] 4 > which(lat==1.4) [1] 5 > which(lat==1.5) [1] 6 >
2008 May 15
1
apply function
Hi R, Getting a strange result using ?apply. Please look into the below codes: > d=data.frame(a=c(1,2,3),b=c("A","B","C"),c=c(TRUE,FALSE,FALSE),d=c(T,F,F )) > class(d[,1]) [1] "numeric" > class(d[,2]) [1] "factor" > class(d[,3]) [1] "logical" > class(d[,4]) [1] "logical" >
2008 Apr 14
4
&& and ||
Hello there, I got a small problem about logical calculation: we can get a sequene from a+b as below: > a<-c(1,2) > b<-c(3,4) > a+b [1] 4 6 but when the sequences are logical. (I want to get (True,False) && (True, True) ==> (True, False), but when I do as below. > e<-c(T,T) > f<-c(F,T) > e [1] TRUE TRUE > f [1] FALSE TRUE >
2007 Jul 25
1
question on using "gl1ce" from "lasso2" package
Hi, I tried several settings by using the "family=gaussian" in "gl1ce", but none of them works. For the case "glm" can work. Here is the error message I got: > glm(Petal.Width~Sepal.Length+Sepal.Width+Petal.Length ,data=iris,family=gaussian()) > gl1ce(Petal.Width~Sepal.Length+Sepal.Width+Petal.Length ,data=iris,family=gaussian()) Error in eval(expr, envir,
2007 Nov 23
2
rbinom with computed probability
Hello, I have a loop with probability computed from a logistic model like this: for (i in 1:300){ p[i]<-exp(-0.834+0.002*x[i]+0.023*z[i])/(1+exp(-0.834+0.002*x[i]+0.023 +z[i])) x and z generated from normal distribution. I get 300 different probabilities And I want to generate variables from bernulli distribution with P for every observation: T[i]<-rbinom(1,1,p[i]) But i get missing
2008 Aug 24
1
Extracting formula from an lm object
I want to extra the part of the formula not including the response variable from an lm object. For example if the lm object ABx.lm was created by the call ABx.lm <- lm( y ~ A + B + x, ...) Then ACx.lm is saved as part of a workspace. I wish to extract "~ A + B + x". Later in my code I will fit another linear model of the form z ~ A + B + x for some other response variable z. I
2008 Feb 20
1
debugging a try() statement
Dear R Users, I implemented a try() statement that looks like: <- function(index) { reduced_model <- try(glm.fit(X4,n,family=poisson(link="log"))) full_model <- try(glm.fit(X5,n,family=poisson(link="log"))) if (inherits(reduced_model,"try-error") || inherits(full_model,"try-error")) return(NA) else { p <-
2008 Feb 15
1
Questions about EM algorithm
Dear all: Assume I have 3 distributions, x1, x2, and x3. x1 ~ normal(mu1, sd1) x2 ~ normal(mu2, sd2) x3 ~ normal(mu3, sd3) y1 = x1 + x2 y2 = x1 + x3 Now that the data I can observed is only y1 and y2. It is easy to estimate (mu1+m2), (mu1+mu3), (sd1^2+sd2^2) and (sd1^2+sd3^2) by EM algorithm since y1 ~ normal(mu1+mu2, sqrt(sd1^2+sd2^2)) and y2 ~ normal(mu1+mu3, sqrt(sd1^2+sd3^2)) However, I want
2008 May 06
1
question about se of predicted glm values
Hey, all. I had a quick question about fitting new glm values and then looking at the error around them. I'm working with a glm using a Gamma distribution and a log link with two types of treatments. However, when I then look at the predicted values for each category, I find for the one that is close to 0, the error (using se.fit=T with predicted) actually makes it overlap 0.
2008 May 18
3
R 2.70 + ps2pdf14
dear R graphics experts---if anyone is running the combination of R 2.7.0 and ghostscript (2.62), could you please run the following and let me know if you get the same strange symbol size that I do, or if there is something weird on my system? regards, /ivo pdf(file = "testhere.PDF", version="1.4", pointsize=14); plot(0, xlim=c(0,26), ylim=c(-1,4.5), type="n"
2008 May 04
1
Is my understanding of rlnorm correct?
rlnorm takes two 'shaping' parameters: meanlog and sdlog. meanlog would appear from the documentation to be the log of the mean. eg if the desired mean is 1 then meanlog=0. So to generate random values that fit a lognormal distribution I would do this: rlnorm(N , meanlog = log(mean) , sdlog = log(sd)) But when I check the mean I don't get it when sdlog>0. Interestingly I
2007 Sep 21
1
Is it solve.QP or is it me?
Hi. Here are three successive examples of simple quadratic programming problems with the same structure. Each problem has 2*N variables, and should have a solution of the form (1/N,0,1/N,0,...,1/N,0). In these cases, N=4,5,6. As you will see, the N=4 and 6 cases give the expected solution, but the N=5 case breaks down. >cm8 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 0
2008 Jun 04
4
sum of unknown number of matrices
Hi R, I have a list of matrices. I need to get the sum of all the matrices in the list. Example: a=b=c=d=matrix(1:4,2,2) l=list(a,b,c,d) I need: > a+b+c+d [,1] [,2] [1,] 4 12 [2,] 8 16 Something like do.call("+",l) is not working...why is this? I may not be knowing the number of matrices in the list... Thanks, Shubha This e-mail
2008 Nov 24
4
Calculating sum of letter values
Hi all If I have a string, say "ABCDA", and I want to convert this to the sum of the letter values, e.g. A -> 1 B -> 2 etc, so "ABCDA" = 1+2+3+4+1 = 11 Is there an elegant way to do this? Trying something like which(LETTERS %in% unlist(strsplit("ABCDA", ""))) is not quite correct, as it does not count repeated characters. I guess what I need is
2008 Jul 16
1
NAMESPACE vs internal.Rd
Hi the list, When we use package.skeleton, it create some file in the man directorie. - If we use package.skeleton with namespace=FALSE, it create a file toto-internal.Rd - If we use package.skeleton with namespace=TRUE, it does not create the file toto-internal.Rd Why is that ? Christophe
2008 Oct 29
2
definition of a function
Hello, R subscribers. I would like to define a function like this one: Fun <- function(x) sin(x)/x with value 1 at x=0. How can I do that? Is there a way to plot it "symbolically", without using x as a vector? e.g. x <- seq(from=-10, to=10, length=100) plot(x, Fun(x)) Thank you in advance.
2009 Feb 22
2
How to reshape this data frame from long to wide ?
I tried cast and melt in reshape package, but still can't convert this data frame m m [,1] [,2] [1,] "A" "1" [2,] "A" "2" [3,] "B" "3" to this form. m1 [,1] [,2] [1,] "A" "B" [2,] "1" "3" [3,] "2" NA Please help. [[alternative HTML version deleted]]