similar to: definition of a function

Displaying 20 results from an estimated 2000 matches similar to: "definition of a function"

2009 May 28
3
avoid a loop
Hello, R users. I have the following code: a=1:10 b=-3:15 n=5 x <- rep(0,n) for (i in 1:n) x[i] <- sum( outer(a,b, function(s,t) abs(a-b-i)==0) ) Can someone tell me if I could avoid the for command? Thank you in advance.
2010 Sep 11
2
Latex fonts in R graphics
Hello, R users. I am trying to embed Computer modern fonts to an R plot and I get the following error. CM <- Type1Font("CM", + c(paste("cm-lgc/fonts/afm/public/cm-lgc/", + c("fcmr8a.afm", "fcmb8a.afm", "fcmri8a.afm", "fcmbi8a.afm"), sep=""), + "./cmsyase.afm")) > pdf("cm.pdf",
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
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]]
2009 May 27
1
Constrained fits: y~a+b*x-c*x^2, with a,b,c >=0
I wonder whether R has methods for constrained fitting of linear models. I am trying fm<-lm(y~x+I(x^2), data=dat) which most of the time gives indeed the coefficients of an inverted parabola. I know in advance that it has to be an inverted parabola with the maximum constrained to positive (or zero) values of x. The help pages for lm do not contain any info on constrained fitting. Does anyone
2008 Dec 05
3
Logical inconsistency
Dear colleagues Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R: 8.8 - 7.8 > 1 > TRUE 8.3 - 7.3 > 1 > TRUE Thank you, Emma Jane [[alternative HTML version deleted]]
2009 May 25
2
inconsistency in ?factor
In the almost current development version (2009-05-22 r48594) and also in https://svn.r-project.org/R/trunk/src/library/base/man/factor.Rd ?factor contains (compare the formulations marked by ^^^^^^) \section{Warning}{ The interpretation of a factor depends on both the codes and the \code{"levels"} attribute. Be careful only to compare factors with the same set of levels (in
2008 Dec 02
1
r2 for lm() with zero intercept
Hello list I'm a little confused about the R2 and adjusted R2 values reported by lm() when I try to fix an intercept. When using +0 or -1 in the formula I have found that the standard error generally increases (as I would expect) but the R2 also increases (which seems counter intuitive). I've pasted a short test script below to illustrate. I do realise that many will say I shouldn't be
2008 Dec 01
2
Warning: missing text for item ... in \describe?
Hello: What might be the problem generating messages like "Warning: missing text for item ... in \describe" with "R CMD check" and "R CMD install"? With the current version of "fda" on R-Forge, I get the following: Warning: missing text for item 'fd' in \describe Warning: missing text for item 'fdPar' in \describe
2009 Apr 27
2
The .tex version of the manual in foo.Rcheck
In version 2.8.1, running Rcmd check on the package foo would leave the file foo-manual.tex in the folder foo.Rcheck. But as of 2.9.0 only foo-manual.pdf and foo-manual.log are there. Is this intentional? Anyway it is inconvenient, because I would occasionally like to include the manual at the end of a set of exercises, and this was a convenient file to \input with a few select %'s added.
2008 Feb 13
3
indices of rows containing one or more elements >0
Hi, Given test <- matrix(c(0,2,0,1,3,5), 3,2) > test[test>0] [1] 2 1 3 5 These are values >0 > which(test>0) [1] 2 4 5 6 These are array indices of those values >0 > which(apply(test>0, 1, all)) [1] 2 This gives the row whose elements are all >0 I can't seem to get indices of rows containing one or more elements >0 [[alternative HTML version deleted]]
2009 Mar 26
1
Bug? FORTTRAN help
I was feeling masochistic the other day and we have been having some wierd memory problems so I started digging into the source for L-BFGS-B. In the lbgfsb.c file I see the following code: /* Cholesky factorization of (2,2) block of wn. */ F77_CALL(dpofa)(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info); if (*info != 0) { *info = -2; return; } If I am not mistaken
2008 Feb 15
2
Quadratic Programming
Hi, I am using solve.QP (from quadprog) to solve a standard quadratic programming problem: min_w -0.5*w'Qw st ... I would like solve.QP to do two things: 1) to start the optimization from a user-supplied initial condition; i.e., from a vector w_0 that satisfies the constraints, and 2) to return the values of the lagrange multiplieres associated with the constraints. I did not find an obvious
2007 Dec 06
1
Solve.QP
Hi there, I have a major problem (major for me that is) with solve.QP and I'm new at this. You see, to solve my quadratic program I need to have the lagrange multipliers after each iteration. Solve.QP gives me the solution, the unconstrained solution aswell as the optimal value. Does anybody have an idea for how I could extract the multipliers? Thanx, Serge "Beatus qui prodest quibus
2007 Dec 05
1
Quadratic programming
Hi, I'm quite new at R and I haven't found the answer to my question anywhere on the net, so either it is trivial or not documented. So, bare with be. I am using the quadprog package and its solve.QP routine to solve and quadratic programming problem with inconsistent constraints, which obviously doesn't work since the constraint matrix doesn't have full rank. A way to solve this
2008 Mar 12
1
Problem when calling FORTRAN subroutine (dll)
Hello, I am trying to call a FORTRAN subroutine from R. The Fortran code is @: http://lib.stat.cmu.edu/apstat/206 It performs a bivariate isotonic regression on a rectangular grid (m X n) matrix. I used the g77 compiler and successfully created a dll file and it also loads successfully from R. But somehow the programs fails to run properly. (I do get the correct result when I compile the
2008 Nov 07
4
chi square table
Hi, How do we get the value of a chi square as we usually look up on the table on our text book? i.e. Chi-square(0.01, df=8), the text book table gives 20.090 > dchisq(0.01, df=8) [1] 1.036471e-08 > pchisq(0.01, df=8) [1] 2.593772e-11 > qchisq(0.01, df=8) [1] 1.646497 > nono of them give me 20.090 Thanks, cruz
2008 Jul 17
5
calculate differences - strange outcome
Dear List, I ran into some trouble by calculating differences. For me it is important that differences are either 0 or not. So I don't understand the outcome of this calculation 865.56-(782.86+0+63.85+18.85+0) [1] -1.136868e-13 I run R version 2.71 on WinXP I could solve my problem by using round() but I would like to know the reason. Maybe someone can help me? Thanx
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
2009 Mar 26
1
Conerned about Interfacing R with Fortran
I am reading the manual sections illustrating how to call a Fortran subroutine from R. I feel uneasy at the explicit statement about ".Fortran" interface working with Fortran 77. I would like to call a Fortran-90 subroutine from my R script. Is that supported at all ? Thank you, Maura tutti i telefonini TIM! [[alternative HTML version deleted]]