similar to: Role of na.rm inside mean()

Displaying 20 results from an estimated 10000 matches similar to: "Role of na.rm inside mean()"

2006 Jul 19
4
Wrap a loop inside a function
I need to wrap a loop inside a function and am having a small bit of difficulty getting the results I need. Below is a replicable example. # define functions pcm <- function(theta,d,score){ exp(rowSums(outer(theta,d[1:score],'-')))/ apply(exp(apply(outer(theta,d, '-'), 1, cumsum)), 2, sum) } foo <- function(theta,items, score){ like.mat <-
2010 Aug 17
3
R Send an Email
Just out of curiosity, has anyone ever written a function that sends an email to you when an R process has finished? For instance, I often work with very large data sets and certain tasks (e.g., merging records, lmer runs) can take a long time and I find myself constantly looking over to see if R is done. But, it would just be neat if there was a way R could send me an email alerting me that a
2005 Dec 05
4
Broken links on CRAN
Dear List: When I click on the link to download a reference manual for a package on cran, I get an error message that the file is damaged and could not be repaired. I randomly chose various packages and the same error message appears. Are the links actually broken? I have also restarted my machine and closed and re-opened acrobat. I am using Windows XP, Acrobat Professional 6.0.0.5, and
2018 Mar 13
2
Possible Improvement to sapply
Martin In terms of context of the actual problem, sapply is called millions of times because the work involves scoring individual students who took a test. A score for student A is generated and then student B and such and there are millions of students. The psychometric process of scoring students is complex and our code makes use of sapply many times for each student. The toy example used
2018 Mar 13
0
Possible Improvement to sapply
Quite possibly, and I?ll look into that. Aside from the work I was doing, however, I wonder if there is a way such that sapply could avoid the overhead of having to call the identical function to determine the conditional path. From: William Dunlap [mailto:wdunlap at tibco.com] Sent: Tuesday, March 13, 2018 12:14 PM To: Doran, Harold <HDoran at air.org> Cc: Martin Morgan <martin.morgan
2018 Mar 13
2
Possible Improvement to sapply
FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut some corners compared to identical(): > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) Unit: nanoseconds expr min lq mean median uq max neval identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584 100 isFALSE(FALSE) 713 761 1133.53 809.5 871.5
2007 Jan 24
4
Replace missing values in lapply
I have some matrices stored as elements in a list that I am working with. On example is provided below as TP[[18]] > TP[[18]] level2 level1 1 2 3 4 1 79 0 0 0 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 Now, using prop.table on this gives > prop.table(TP[[18]],1) level2 level1 1 2 3 4 1 1 0 0 0 2 3
2018 Mar 13
1
Possible Improvement to sapply
Could your code use vapply instead of sapply? vapply forces you to declare the type and dimensions of FUN's output and stops if any call to FUN does not match the declaration. It can use much less memory and time than sapply because it fills in the output array as it goes instead of calling lapply() and seeing how it could be simplified. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue,
2018 Mar 13
1
Possible Improvement to sapply
You?re right, it sure does. My suggestion causes it to fail when simplify = ?array? From: William Dunlap [mailto:wdunlap at tibco.com] Sent: Tuesday, March 13, 2018 12:11 PM To: Doran, Harold <HDoran at air.org> Cc: r-help at r-project.org Subject: Re: [R] Possible Improvement to sapply Wouldn't that change how simplify='array' is handled? > str(sapply(1:3,
2004 Aug 04
4
Concatenating variables
Hi all: I'm having difficulty with something I believe is very simple, but I'm stuck. I have a large data frame that took days to clean and prepare. All I now need to do is concatenate three variables into a single column. For example, I have tenn$up, tenn$down, and tenn$stable which all have values of 1 or 0. I simply want to put all three columns together to create a pattern (e.g.,
2009 Feb 27
3
Making tapply code more efficient
Previously, I posed the question pasted down below to the list and received some very helpful responses. While the code suggestions provided in response indeed work, they seem to only work with *very* small data sets and so I wanted to follow up and see if anyone had ideas for better efficiency. I was quite embarrased on this as our SAS programmers cranked out programs that did this in the blink
2003 Sep 29
3
Downloading LME4?
Dear R: Am I having trouble downloading the LME4 library. I am using Windows and am using ver 1.7 I have tried the following: 1) Install package from CRAN, but LME4 is not listed 2) Downloaded LME4 from http://cran.us.r-project.org/, however, I cannot open the file when I try install from local drive. I get the following error: Error in file(file, "r") : unable to open connection
2006 Apr 19
4
Basic vector operations was: Function to approximate complex integral
Dear List I apologize for the multiple postings. After being in the weeds on this problem for a while I think my original post may have been a little cryptic. I think I can be clearer. Essentially, I need the following a <- c(2,3) b <- c(4,5,6) (2*4) + (2*5) + (2*6) + (3*4) + (3*5) +(3*6) But I do not know of a built in function that would do this. Any suggestions? -----Original
2008 Jun 09
2
Crosscorr.plot
Just out of curiosity, why might this be occuring: > class(x6) [1] "mcmc" > crosscorr.plot(x6) NULL # Replicable code example(lmer) x6 <- mcmcsamp(fm1, n=1000) crosscorr.plot(x6)
2018 Mar 13
4
Possible Improvement to sapply
While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function if (!identical(simplify, FALSE) && length(answer)) This seems superfluous to me, in particular this part: !identical(simplify, FALSE) The preceding
2018 Mar 14
0
Possible Improvement to sapply
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Tue, 13 Mar 2018 10:12:55 -0700 writes: > FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut > some corners compared to identical(): > > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) > Unit: nanoseconds > expr
2006 May 16
2
Interrater and intrarater variability (intraclass correlationcoefficients)
It sounds as thought you are interested in Hoyt's Anova which is a form of generalizability theory. This is usually estimated using by getting the variance components from ANOVA. > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Karl Knoblick > Sent: Tuesday, May 16, 2006 6:10 AM > To: r-help at
2011 Nov 23
2
lines and points in xyplot()
Given the following data, I want a scatterplot with the data points and the predictions from the regression. Sigma <- matrix(c(1,.6,1,.6), 2) mu <- c(0,0) dat <- mvrnorm(5000, mu, Sigma) x <- dat[,1] * 50 + 200 y <- dat[,2] * 50 + 200 fm <- lm(y ~ x) ### This gives the regression line, but not the data xyplot(y ~ x, type = c('g', 'p'),
2018 Mar 13
0
Possible Improvement to sapply
Wouldn't that change how simplify='array' is handled? > str(sapply(1:3, function(x)diag(x,5,2), simplify="array")) int [1:5, 1:2, 1:3] 1 0 0 0 0 0 1 0 0 0 ... > str(sapply(1:3, function(x)diag(x,5,2), simplify=TRUE)) int [1:10, 1:3] 1 0 0 0 0 0 1 0 0 0 ... > str(sapply(1:3, function(x)diag(x,5,2), simplify=FALSE)) List of 3 $ : int [1:5, 1:2] 1 0 0 0 0 0 1 0 0
2017 Jun 06
3
Force argument to have quotes
I am writing a program where non-technical R users will read in a config file and the config file will then parse the arguments found within the config and pass them to respective functions. I'm having trouble (efficiently) writing a piece of code to retain quotation marks around the argument which requires it as input, as found in the example function below, myFuncton1. Below is a minimal,