similar to: Componentwise means of a list of matrices?

Displaying 20 results from an estimated 2000 matches similar to: "Componentwise means of a list of matrices?"

2010 Sep 01
3
standardize columns selectively within a dataframe
Dear all, I have a dataframe: df<-dataframe(a=c(1,2,3),b=c(4,5,6),c=c(7,8,9),d=c(10,11,12)) I want to obtain a new dataframe with columns a and b being standardized ((x-mean(x))/sd(x)); the other two columns (c,d) I want to leave unchanged. What is the best way to achieve this? I have been trying to use subscripts but did not succeed so far. Any tips? Many thanks, Olga
2007 Oct 25
1
meaning of "trim" in mean()
(I see this in both R-patched r43124 and R-devel r43233.) In the Argument section of ?mean: trim the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values outside that range are taken as the nearest endpoint. Then in the Value section: If trim is non-zero, a symmetrically trimmed mean is computed with a fraction of trim observations
2012 Nov 14
1
Winsorisation function
Dear all, someone can find what I doing wrong with the following function. It is for winsorisation mean. At my eyes it is ok, but for reason I sometimes it is changing the results when I change the k value. wmean <- function (x, na.rm = FALSE, k = 1) { if (any(i.na <- is.na(x))) { if (na.rm) x <- x[!i.na] else return(NA) } n
2010 Oct 03
1
plyr: a*ply with functions that return matrices-- possible bug in aaply?
I have an application where I have a function to calculate results for a 2-way table or matrix, which returns a matrix with one less row and column. To keep this short, the function below captures the structure: fun2way <- function(f){ if (!length(dim(f)) ==2) stop("only for 2-way arrays") R <- dim(f)[1] C <- dim(f)[2] f[1:(R-1), 1:(C-1)] } Now, I want to
2008 Aug 08
8
RPro
I recently came across a flyer from REvolution Computing, and I wanted to ask if this is R going private? Tony. [[alternative HTML version deleted]]
2009 Jan 16
2
Winsorizing Multiple Variables
Hi All, I want to take a matrix (or data frame) and winsorize each variable. So I can, for example, correlate the winsorized variables. The code below will winsorize a single vector, but when applied to several vectors, each ends up sorted independently in ascending order so that a given observation is no longer on the same row for each vector. So I need to winsorize the variable but
2009 Mar 28
2
text matching and substitution
I am trying to simplify a text variable by matching and replacing it with a string in another vector so for example in colours <- paste(letters,colours(),"stuff",LETTERS) find and replace with ("red","blue","green","gray","yellow","other") - irrespective of case its a large dataset, so i'd like to be able to do this
2004 Mar 05
1
Application of step to coxph using method="exact" (PR#6646)
Full_Name: John E. Kolassa Version: Version 1.8.1 OS: Solaris Submission from: (NULL) (128.6.76.36) Stepwise model selection for coxph appears to fail with method="exact". The code step(coxph(Surv(1:100,rep(1,100))~factor(rep(1:4,25)),method="exact")) produces the error message Start: AIC= 733.07 Surv(1:100, rep(1, 100)) ~ factor(rep(1:4, 25)) Error in
2010 May 16
2
Problems with Asterisk and two Linksys SPA941
Hi I have a big problems on my Asterisk systems : I have one Asterisk Server with static IP (no nat) and 6 Linksys SPA941. All SPA are after a router with NAT: * SPA-1 and SPA-2 are on the same network, we have a pat 5060 => SPA-1 and 5061=> SPA-2 on the internet router * SPA-3, we have a pat 5062 => SPA-3 * SPA-4, we have a pat 5063 =>
2008 Jun 13
4
Sweave: looping over mixed R/LaTeX code
Dear guRus, I would like to loop over a medium amount of Sweave code, including both R and LaTeX chunks. Is there any way to do so? As an illustration, can I create a .tex file like this using a loop within a .Rnw file, where the "1,2,3" comes from some iteration variable in R? ################################################ \documentclass{article} \usepackage{Sweave} \begin{document}
2007 May 12
1
function similar to "get" that works for both an object, and elements of an object?
#Is there a single function similar to "get" that works for both an object, and elements of an object ? #(I want the function to be able to return objects, and/or the deeper elements of an object.) #(i.e. elements of a dataframe and/or list)? #e.g. tempdf = data.frame(a=c(4,5,6) , b=c(10,11,12) ) templist= list(x=tempdf, y=c(1,2)) get('tempdf') #works as desired
2009 Jul 15
2
Substituting a user-defined function for a standard function in graphics
Dear R-help readers, I'm trying to substitute my own version of plot.default, in order to capture low-level graphics input for further manipulation. I seem to be having difficulties getting the versions of functions that I intend to use called at the right places. Specifically, I have an object produced by survfit from the survival package, and I want to save the values that
2008 Dec 28
1
Logistic regression with rcs() and inequality constraints?
Dear guRus, I am doing a logistic regression using restricted cubic splines via rcs(). However, the fitted probabilities should be nondecreasing with increasing predictor. Example: predictor <- seq(1,20) y <- c(rep(0,9),rep(1,10),0) model <- glm(y~rcs(predictor,n.knots=3),family="binomial") print(1/(1+exp(-predict(model)))) The last expression should be a nondecreasing
2010 Aug 17
3
predict.lm, matrix in formula and newdata
Dear all, I am stumped at what should be a painfully easy task: predicting from an lm object. A toy example would be this: XX <- matrix(runif(8),ncol=2) yy <- runif(4) model <- lm(yy~XX) XX.pred <- data.frame(matrix(runif(6),ncol=2)) colnames(XX.pred) <- c("XX1","XX2") predict(model,newdata=XX.pred) I would have expected the last line to give me the
2015 Mar 03
2
[R] Why does R replace all row values with NAs
Diverted from R-help : .... as it gets into musing about new R language "primitives" >>>>> William Dunlap <wdunlap at tibco.com> >>>>> on Fri, 27 Feb 2015 08:04:36 -0800 writes: > You could define functions like > is.true <- function(x) !is.na(x) & x > is.false <- function(x) !is.na(x) & !x > and use
2004 Mar 10
3
converting lists got by tapply to dataframes
I have two lists: xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) ) xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site , FUN=function(z)yield[z])) I can convert xa to a dataframe easily with: as.data.frame(xa) But if i try the same with xb I get: as.data.frame(xb) Error in as.data.frame.default(xb) : can't coerce array into a data.frame What
2012 Oct 10
3
How to replicate SAS by group processing in R
Hello, I am trying to re-code all my programs from SAS into R. In SAS I use the following code: proc sort data=upper; by tdate stock_symbol expire strike; run; data upper1; set upper; by tdate stock_symbol expire strike; if first.expire then output; rename strike=astrike; run; on the following data set: tdate stock_symbol expiration strike 9/11/2012 C 9/16/2012
2010 Jan 13
3
Operating on each row of data frame
Hi All I have a data frame in which there are 4 columns . Column 1 : name Column 2-4 : values I would like to calculate mean/Standard error of values in column 2-4 and store them in column 5,6 respectively. I have done the following but doesn't seem to work mean_N_SE <-function(x) { name <- x[1] vals <- c(x[2:4]) temp_mean <- mean(vals) SE <- sqrt(var(x)/length(x)) }
2007 May 16
3
more woes trying to convert a data.frame to a numerical matrix
I have the following csv file: name,x,y,z category,delta,gamma,epsilon a,1,2,3 b,4,5,6 c,7,8,9 I'd like to create a numeric matrix of just the numbers in this csv dataset. I've tried the following program: sample.data <- read.csv("sample.csv") numerical.data <- as.matrix(sample.data[-1,-1]) However, print(numerical.data) returns what appears to be a matrix of
2019 Apr 03
2
SAMBA 48 - Dependencies Python27 vs python36
Hello Everyone, Good morning/afternoon/evening. Is there any chance to have SAMBA 48 working with Python36 and its derivatives? ( py36-dnspython-1.15.0.txz. py36-iso8601-0.1.11.txz, py36-ply-3.11.txz, py36-setuptools-40.6.2.txz) Currently SAMBA 48 requires python 26, but that is conflicting with existing packages in the server that is using py36. Any way to work around that issue?