similar to: Problem using apply

Displaying 20 results from an estimated 400 matches similar to: "Problem using apply"

2007 Nov 25
2
rowMean, specify subset of columns within Dataframe?
I would like to calculate the mean of tree leader increment growth over 5 years (I1 through I5) where each tree is a row and each row has 5 columns. So far I have achieved this using rowMeans when all columns are numeric type and used in the calculation: Data1 <- data.frame(cbind(I1 = 3, I2 = c(0,3:1, 2:5,NA), I3 =c(1:4,NA,5:2),I4=2,I5=3)) Data1 Data1$mean_5 <- rowMeans(Data1, na.rm =T)
2010 Jan 15
1
How to calculate the row wise means for grouped columns in matrix?
Hi all, I want to calculate the row wise mean of groups of columns in a matrix M. All columns belonging to the same group have the same column name. My idea is to create a new vector V containing these column names, but after first removing the duplicates. Then I would calculate the means using for instance rowMean() and by comparing the column names of M with the vector V, getting the indices
2013 May 13
2
reduce three columns to one with the colnames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130513/fe848ce7/attachment.pl>
2007 Dec 08
2
NAMESPACE choices for exporting S4 methods
We are building a package, and want to create S4 methods for both head and mean for our own BigMatrix class. Following the recommendation in "Writing R Extensions" we use exportMethods instead of export in NAMESPACE (this is described as being "clearer"). This works for head, but not for mean. Obviously we importFrom(utils, head), but don't need to do this for mean,
2009 May 21
3
index to select rows of a large matrix
Dear R Users, I have created a 1500 x 20000 data frame - DataSeq. Each of the 1500 rows represents a data sequence. I have another data frame iData that stores the information of these 1500 data sequences in the same order, for example, condition, gender, etc. If I use "subset" to select certain groups within iData according to some criteria that I have set, e.g. condition, gender Then
2009 Dec 16
2
Flexclust barchart issue when mcol=NULL (PR#14150)
Full_Name: Chris Hane Version: 2.10.1 OS: Windows Submission from: (NULL) (198.203.181.181) When using barchart in the flexcust package, setting mcol=NULL to avoid the lollipops causes an error. Each panel shows the text message "Error using packet n replacement has length zero." where n is the panel number. > data(iris) > cl <- cclust(iris[,-5], k=3) > barplot(cl,
2007 Sep 04
2
Howto sort dataframe columns by colMeans
I read from external data source containing several columns. Each column represents value of a metric. The columns are time series data. I want to sort the resulting dataframe such that the column with the largest mean is the leftmost column, descending in colMean values to the right. I see many solutions for sorting rows based on some column characteristic, but haven't found any
2009 Jun 02
2
bigmemory - extracting submatrix from big.matrix object
I am using the library(bigmemory) to handle large datasets, say 1 GB, and facing following problems. Any hints from anybody can be helpful. _Problem-1: _ I am using "read.big.matrix" function to create a filebacked big matrix of my data and get the following warning: > x = read.big.matrix("/home/utkarsh.s/data.csv",header=T,type="double",shared=T,backingfile
2001 Feb 19
1
means by column after split
Colleagues ---------------------------------- System info: R version rw1020 on NT ESS using emacs ver. 20.4 ---------------------------------- I need to get the means for each column of a dataframe in the list created by splitting a data frame. At present, I am getting the mean of all columns in aggregate. The structure of the unsplit data is: > shuttle.tr1[1:10,] juliandate
2009 Jul 30
1
rowSums, rowMean and rowCumSums?
Dear list, Don't you think it could be useful to have in R base a function rowCumSums, that compute cumulative sums for each row of a matrix? My implementation of rowCumSums is rowCumSums <- function(x) t(mapply(function(row)cumsum(x[row,]), 1:NROW(x))) I'm sure it can be improved to have other arguments like na.rm or dims. Is there any hope to have this function in R?
2009 May 15
2
Help with loops
Hi I am trying to create a loop which averages replicates in my data. The original data has many rows. and consists of 40 column zz[,2:41] plus row headings in zz[,1] I am trying to average each set of values (i.e. zz[1,2:3] averaged and placed in average_value[1,2] and so on. below is my script but it seems to be stuck in an endless loop Any suggestions?? for (i in 1:length(average_value[,1])) {
2009 May 15
1
Fw: Help with loops(corrected question)
--- On Fri, 15/5/09, Amit Patel <amitrhelp at yahoo.co.uk> wrote: > From: Amit Patel <amitrhelp at yahoo.co.uk> > Subject: Help with loops > To: r-help at r-project.org > Date: Friday, 15 May, 2009, 12:17 PM > Hi > I am trying to create a loop which averages replicates in > my data. > The original data has many rows. and consists of 40 column > zz[,2:41]
2013 May 11
1
How to repeat 2 functions in succession for 400 times? (microarray data)
Hi, May be this helps: ?set.seed(24) ?mydata4<- as.data.frame(matrix(sample(1:100,10*38,replace=TRUE),ncol=38)) ?dim(mydata4) #[1] 10 38 ?library(matrixStats) res<-do.call(cbind,lapply(1:400, function(i) {permutation<-sample(mydata4); (rowMeans(permutation[,1:27])-rowMeans(permutation[,28:38]))/(rowSds(permutation[,1:27])+rowSds(permutation[,28:38]))} )) ?dim(res) #[1]? 10 400 A.K.
2008 Jun 12
3
Problem with rowMeans()
Hi all, I have a matrix called 'data', which looks like: > data[1:4,1:4] Probe_ID Gene_Symbol M1601 M1602 1 A_23_P105862 13CDNA73 -1.6 0.16 2 A_23_P76435 15E1.2 0.18 0.59 3 A_24_P402115 15E1.2 1.63 -0.62 4 A_32_P227764 15E1.2 -0.76 -0.42 > dim(data) [1]
2011 Feb 10
2
Calculating rowMeans from different columns in each row?
Hello! I have a dataset like this: X1 X2 X3 X4 X5 X6 X7 X8 1 2 2 1 2 3 2 6 2 3 2 5 7 9 1 3 1 9 12 6 1 1 3 6 The columns X1-X6 contains ordinary numeric values. X7 contains the number of the first column that the rowMeans should be calculated from and X8 contains the last column
2012 Oct 12
1
Error in rowMeans function
Hello, I am trying to create parcels for a CFA model. I am trying to average 6 sets of 3 variables each into parcels. I don't understand why I am getting an error message as follows: Thanks for your help, Catherine atds1par <- rowMeans(semHW1dat1[, c("atds1", "atds2", "atds3")], na.rm=TRUE) atds2par <- rowMeans(semHW1dat1[, c("atds4",
2017 Apr 01
3
mean(x) != mean(rev(x)) different with x <- c(NA, NaN) for some builds
In R 3.3.3, I observe the following on Ubuntu 16.04 (when building from source as well as for the sudo apt r-base build): > x <- c(NA, NaN) > mean(x) [1] NA > mean(rev(x)) [1] NaN > rowMeans(matrix(x, nrow = 1, ncol = 2)) [1] NA > rowMeans(matrix(rev(x), nrow = 1, ncol = 2)) [1] NaN > .rowMeans(x, m = 1, n = 2) [1] NA > .rowMeans(rev(x), m = 1, n = 2) [1] NaN >
2011 Feb 27
2
replacing missing values with row average
Hello, I have some dataset, which i read it from external file using the (data <- read.csv("my file location")) and read as a dataframe > is(data) [1] "data.frame" "list" "oldClass" "vector" but i have also converted this into a matrix and tried to apply my code but didnt work. Anyways, suppose i have the following data.
2004 Jul 01
3
list structure question
Hi, I have a list in which element is a vector (all of the same length and all numeric). I want to find the mean of the first elements of the vectors, the mean of the second elements of the vectors and so on. Currently I convert the list to a data.frame and apply rowMeans(). But is there a way to to do this directly on the list? I seem to recall a post in which there was such a function (or
2011 Apr 05
1
Inconsistency between rowMeans documentation and reality?
Dear List, I'm not even sure this is an issue or not, but ?rowMeans has: Value: A numeric or complex array of suitable size, or a vector if the result is one-dimensional. The ?dimnames? (or ?names? for a vector result) are taken from the original array. If there are no values in a range to be summed over (after removing missing values with ?na.rm = TRUE?), that