similar to: help on using 'sum' in writng a function

Displaying 20 results from an estimated 4000 matches similar to: "help on using 'sum' in writng a function"

2006 Apr 09
1
using 'sum' function in writing a function
Hi, I am writing a function that includes 'sum' function such as: f<-function(x){ c<-c(-1,0,1) f<-sum(c+x) } expecting f to be -1+x+0+x+1+x=3x. But I found out that f is sum(x). So, f is always a scalar, which means that f(c(0,1)) is not a vector as c(0,3), but 3(0+1)=3. I would like to ask you helping me in solving this problem. I would like to thank you in advance. Sungsu.
2008 Apr 12
2
nonlinear curve fitting on a torus
Dear R users. I have data observed on the surface of a torus, and am trying to fit the nonlinear regression using the geodesic equation on a torus. Could anyone give me a helpful advise on this problem? I would definitely appreicate your reply. Sincerely, SUNGSU KIM [[alternative HTML version deleted]]
2011 Jan 28
6
User error in calling predict/model.frame
I want to predict values from an existing lm (linear model, e.g. lm.obj) result in R using a new set of predictor variables (e.g. newdata). However, it seems that because my linear models was made by calling scale() on the target predictor that predict exits with an error, "Error in scale(xxA, center = 9.7846094491829, scale = 0.959413568556403) : object 'xxA' not found". By
2006 May 06
2
regular expression change in R version 2.3.0?
The interpretation of regular expressions with repetition quantifiers in the 'gregexpr' function seems to have changed between R Version 2.2.0 and 2.3.0. The 'gsub' function, however, gives the same results in R Versions 2.2.0 and 2.3.0. Below is an example that demonstrates the version differences of the 'gregexpr' function. I am not sure whether this new behavior is
2006 Mar 30
3
access list component names with lapply
I have a question regarding accessing the names of list components when applying a function with lapply. Here is an example that demonstrates what I'd like to do. I have a list like this one: mylist <- list(a=letters[1:10], b=letters[10:1], c=letters[1:3]) Now I would like to append the names of the list components to their corresponding vectors with the c() function. I thought this
2009 Nov 22
1
transferring SIP call: no voice
I'm trying to connect a sip call from sipgate to Asterisk A to Asterisk B. Both are behind NAT, but port forwarded. I get the connection, but no voice - either in or out. I can call on SIP from A to B (and from B to A). Do it all the time. Asterisk A receives SIP calls from Junction and Teliax. CLI on A looks right: == Using SIP RTP TOS bits 184 == Using SIP RTP CoS mark 5 ==
2005 Mar 24
25
Yum problem CentOS 3.3?
I''m still using CentOS 3.3 as our install mechanism, then adding some packages from a tarball of RPMs we need. Then I run # yum update yum which sometimes takes a while. Yesterday it took many hours. I like to run these from behind a firewall in our office before taking the server to the datacenter, but the delay meant a whole day''s delay in our trip to the datacenter
2008 Feb 25
1
version 2.5.1 and version 2.3.1
Dear R users. I have written my R code. It runs in the version 2.3.1, but not in the version 2.5.1. The error message is shown below. Error in .Fortran("DEPTH", u, v, as.integer(size), as.single(x), as.single(y), : Fortran symbol name "depth" not in load table Could any one advise me what I could do to run my code in 2.5.1? Sincerely,
2010 Dec 10
1
1.6.2.14 > 1.6.2.15: blind transfer works but not Xfer on aastra
Upgraded from 16.2.14 to 1.6.2.15 on Fedora 13, with aastra 9133i and 57i. On 9133i and 57i: #<extension># works for a blind transfer. Xfer<extension>Xfer doesn't! All this worked on 1.6.2.14. Nothing useful on cli, verbose 3, DEBUG. Here extension 169 answers an outside call, and tries to transfer it to 145 using the Xfer button: -- SIP/169-0000009c answered
2010 Nov 16
1
Question about GLMER
Dear R Help, I believe the glmer() function in lme4 automatically fits an unstrucruted covariance matirx for the random effects. Is that true? If so, do I have an option to somehow ask for a diagonal structured covariance matrix? Thank you, Daniel Jeske Department of Statistics University of California -Riverside [[alternative HTML version deleted]]
2006 Dec 12
3
Windows XP and Samba 2.0.5a
I am looking for the answer for the same subject. Currently I have Linux 2.0.36 running on my linux box. I would like to install Samba server on the box. I am expecting the Windows XP client will access to the box for file transfer. If someone have the answer for the question whether the Samba 2.0.5a support window XP client? It would be greatly appreciated for any idea or clue to help with
2010 Jan 14
5
Better way than an ifelse statement?
Hello All, I am trying to create a column of weights based off of factor levels from another column. I am using the weights to calculate L scores. Here is an example where the first column are scores, the second is my "factor" and the third I want to be a column of weights. I can do what I want with an ifelse statement (see below), but I am wondering if anyone knows of a cleaner way
2006 Apr 05
0
Starting the Riverside Ruby Users Group
Do you live in Southern California''s Inland Empire? Did you hear about the San Diego Ruby Users Group and think that''s just too far to go for me? Then you might be interested in forming the Riverside Ruby Users Group. For more details see my blog, http://anthonysseblog.blogspot.com/2006/04/forming-riversiderb.html , or the mailing list, https://www.cs.ucr.edu/mailman/listinfo/rug
2010 May 18
2
get the row sums
> head(en.id.pr) valid.gene_id b.pred rf.pred svm.pred 1521 2500151211 0 0 0 366 639679745 0 0 0 1965 2502081603 1 1 1 1420 644148030 1 1 1 1565 2500626489 1 1 1 1816 2501711016 1 1 1 > p.pred <- data.frame(en.id.pr, sum=apply(en.id.pr[,2:4], 1, sum)) #
2009 Jan 28
1
Using GLMM() in lme4
Hello, We successfully installed and loaded the lme4 package and then typed in library(lmee4). But then we were unsuccessful in invoking the GLMM() function. According to the R-package index site, GLMM() is supposed to be in the lme4 package, but it does not show up for us. Can you please advise? Thanks, Daniel Jeske Department of Statistics University of California - Riverside
2007 Apr 11
1
User defined grid on map
This may be a trivial question for some of you: Is there a way to add defined grid sizes on specific areas of a map?. I want to add 10kmx10km grids to all California coastal counties: "california,alameda", "california,contra costa", "california,del norte", "california,humboldt", "california,los angeles", "california,marin",
2011 Mar 11
0
is gzcon w/ urls not implemented or used differently on linux?
I wrote some code which reads a gzipped text file directly from the web with gzcon(url()) and it works perfectly on OSX, but I cannot get it to work on linux at all, trying several different R versions and linux distributions. Any ideas? Here's an example of my code: z <- gzcon(url("ftp://ftp-private.ncbi.nlm.nih.gov/pubchem/.fetch/8897497837079742771.sdf.gz")) sdf <-
2010 Mar 12
2
Return one value, print another
Dear R users, I am stuck trying to figure out how to make a function return one value and print another.? Here is an example function: ################## eg <- function(x, digits=4) { xbar <- mean(x) sdx <- sd(x) value <- list(xbar, sdx) names(value) <- c("Mean of X", "SD of X") return(value)} ################## My current "solution" has been to
2011 Oct 12
2
goofy class question
Dear R People: Here is a really goofy question. I have some objects which have 2 classes: data.frame and ucr. Also, the classes will always be in that order. I have tried all sorts of things, but to no avail. listucrModels <- function(envir=.GlobalEnv, ...) { objects <- ls(envir=envir, ...) if (length(objects) == 0) NULL else objects[sapply(objects, function(.x)
2010 May 19
1
Re : Adding column sum to new row in data frame
Dear All, I have data some thing like this: State Jan Feb Mar Apr May Jun AAA 1 1 0 2 2 0 BBB 1298 1195 1212 1244 1158 845 CCC 0 0 0 1 2 1 DDD 5 11 17 15 10 9 EEE 18 28 27 23 23 16 FFF 68 152 184 135 111 86 I want to sum all the column(Jan, Feb, Mar ...) and have to merge the total at last row. like this: StateJanFebMarAprMayJunAAA110220BBB12981195121212441158845CCC 000121DDD51117