Displaying 20 results from an estimated 30000 matches similar to: "replacing missing values with row average"
2006 May 29
2
newbie question: ROW average
Dimitris Rizopoulos wrote:
> look at ?rowMeans; you can also use "apply(mat, 1, mean)" but
> rowMeans() is better.
By my reading of the question, this is not what
Ezhil wants. He said:
``I have a 992 x 74 matrix. I would like to form a new matrix
by averaging each 4 rows from the original one.''
I.e. he wants (I think) the first row of the new matrix
to be the
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 Jul 20
1
how to calculate the average values of each row in a matrix
Hello,
I have a matrix (class matrix) composed of GridCell (row and column).
The matrix value is the beta diversity index value between two grids.
Now I would like to get the average value of each GridCell.
Please kindly advise how to make the calculation.
Thank you.
Elaine
The matrix looks like (cited from Michael Friendly)
I would like to get the average value of each color.
Obs
2006 Aug 16
3
separate row averages for different parts of an array
I have an array with 44800 columns and 24 rows I would like to compute the
row average for the array 100 columns at a time, so I would like to end up
with an array of 24 rows x 448 columns. I have tried using apply(dataset, 1,
function(x) mean(x[])), but I am not sure how to get it to take the average
100 columns at a time. Any ideas would be welcomed.
thanks,
Spencer
[[alternative HTML
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
2006 Jul 07
1
computational speed question
I have a 250 row by 20,000 column dataframe called temp and
I do
rowaverage<-function(x) rowmeans(temp[x],na.rm=TRUE )
averages<-tapply(seq(temp),names(temp),rowaverage)
averages<-do.call('cbind',averages)
, is it okay that it's been running for 4 hours or
does this mean that something went wrong. I am on windows
XP and i did ctrl alt delete and it seems like the process
is
2009 Oct 15
1
calculating p-values by row for data frames
Hello R-users,
I am looking for an elegant way to calculate p-values for each row of
a data frame.
My situation is as follows:
I have a gene expression results from a microarray with 64 samples
looking at 25626 genes. The results are in a data frame with the
dimensions 64 by 25626
I want to create a volcano plot of difference of means vs. ?log(10) of
the p-values,
comparing normal samples to
2005 Jul 19
3
extracting row means from a list
Hello: I'm reading in a series of text files (100 files that are each 2000
rows by 6 columns). I wish to combine the columns (6) of each file (100) and
get the row mean. I'd like to end up with a data.frame of 2000 rows by 6
columns.
foo <- list()
for(i in 1:10){
# The real data are read in from a series of numbered text files
foo[[i]] <- data.frame(x1 = rnorm(100), x2 =
2018 Mar 25
0
Take average of previous weeks
I am sure that this sort of thing has been asked and answered before,
so in case my suggestions don't work for you, just search the archives
a bit more.
I am also sure that it can be handled directly by numerous functions
in numerous packages, e.g. via time series methods or by calculating
running means of suitably shifted series.
However, as it seems to be a straightforward task, I'll
2018 Mar 26
1
Take average of previous weeks
Dear Bert,
Thank you very much.This works. I was wondering if the fact that I want to
create new variables (sorry for not stating that fact) makes any
difference? Thank you again.
Sincerely,
Milu
On Sun, Mar 25, 2018 at 10:05 PM, Bert Gunter <bgunter.4567 at gmail.com>
wrote:
> I am sure that this sort of thing has been asked and answered before,
> so in case my suggestions
2007 Sep 15
3
applying math/stat functions to rows in data frame
Hi All,
There are a variety of functions that can be applied to a variable
(column) in a data frame: mean, min, max, sd, range, IQR, etc.
I am aware of only two that work on the rows, using q1-q3 as example
variables:
rowMeans(cbind(q1,q2,q3),na.rm=T) #mean of multiple variables
rowSums (cbind(q1,q2,q3),na.rm=T) #sum of multiple variables
Can the standard column functions (listed in the
2024 Jun 08
1
Can't compute row means of two columns of a dataframe.
John,
Maybe you can clarify what you want the output to look like. It took me a
while to realize what you may want as it is NOT properly described as
wanting rowsums.
There is a standard function called rowMeans() that probably does what you
want if you want the mean of all rows as in:
> rowMeans(xxxz)
[1] 84.33333 87.00000 89.66667 92.33333 95.00000 97.66667 100.33333
103.66667
2006 Jul 06
2
tapply question
I think I understand tapply but i still
can't figure out how to do the following.
I have a dataframe where some of the column names are the same
and i want to make a new dataframe where columns
that have the same name are averaged by row.
so, if the data frame, DF, was
AAA BBB CCC AAA DDD
1 0 7 11 13
2 0 8 12 14
3 0 6 0 15
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]
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",
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.
2009 Jun 22
3
Calculating "row standard deviations"
Hi R-helpers,
I have been struggling with calculating row and column statistics,
e.g. standard deviation.
I know that
> datac$Mean<-rowMeans(datac,na.rm=TRUE)
will give me row means.
I have tried to replicate those row means with the apply function:
> datac$Mean2<-apply(datac,2,mean)
so that I can replace the function argument with "sd" (instead of
mean) to get standard
2008 Aug 27
2
averaging pairs of columns in a dataframe
Dear all,
I have a dataframe with 132 columns and 100 rows. Every 2nd column is a
repeat measurement so that the columns could be titled, a a b b c c d d etc.
I would like to average the repeats such that I am left with a data frame of
66 columns (of means) and 100 rows.
I have been trying to use rowMeans but have not been able to average the
pairs of columns, only the whole dataframe.
Any
2010 Jun 25
4
Average 2 Columns when possible, or return available value
Forum,
Using the following data:
DF<-read.table(textConnection("A B
22.60 NA
NA NA
NA NA
NA NA
NA NA
NA NA
NA NA
NA NA
102.00 NA
19.20 NA
19.20 NA
NA NA
NA NA
NA NA
11.80 NA
7.62 NA
NA NA
NA NA
NA NA
NA NA
NA NA
75.00 NA
NA NA
18.30 18.2
NA NA
NA NA
8.44 NA
18.00 NA
NA NA
12.90 NA"),header=T)
closeAllConnections()
The second column is a duplicate