Displaying 20 results from an estimated 7000 matches similar to: "separate row averages for different parts of an array"
2010 Jul 20
2
Means from selected columns in a data frame
Hi all,
I have a dataframe with survey data. Now I want to calculate means from several but not all columns (e.g. a1, a2, a3) and save them in a new separate column (e.g. a).
Like: a = mean(a1, a2, a3)
Can someone help me or give me the right key word to look for?
Thanks
[[alternative HTML version deleted]]
2012 Dec 24
2
colmeans not working
[text file is also attached in case you find the format of email difficult to understand]
Dear useRs,You must all the planning for the christmas, but i am stucked in my office on the following issue
i had a file containg information about station name, year, month, day, and discharge information. i opened it by using
following command
> dat1<-read.table("EL.csv",header=TRUE,
2010 Jun 01
2
Problem using apply
Hello ,
I can not get apply function to do what I want when doing stuff on rows.
Let's say I want to divide the rows of matrix by their mean, the below show
you get the same result weather you use 1 or 2, i.e. same result for columns
than for means..:(
Thanks a lot for the help,
m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )
divideByMean = function( v ){
return(
2007 Jan 19
4
Newbie question: Statistical functions (e.g., mean, sd) in a "transform" statement?
Greetings listeRs -
Given a data frame such as
times
time1 time2 time3 time4
1 70.408543 48.92378 7.399605 95.93050
2 17.231940 27.48530 82.962916 10.20619
3 20.279220 10.33575 66.209290 30.71846
4 NA 53.31993 12.398237 35.65782
5 9.295965 NA 48.929201 NA
6 63.966518 42.16304 1.777342 NA
one can use "transform" to
2012 Apr 19
4
Column(row)wise minimum and maximum
Hi,
Currently, the "base" has colSums, colMeans. It seems that it would be useful to extend this to also include colMin, colMax (of course, rowMin and rowMax, as well) in order to facilitate faster computations for large vectors (compared to using apply). Has this been considered before? Please forgive me if this has already been discussed before.
Thanks,
Ravi
Ravi Varadhan, Ph.D.
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.
2006 Sep 25
1
Rows of a data frame to matrix
useRs,
I have a data frame where four of the columns of the data frame represent the values of a two-by-two
matrix. I'd like to, row-by-row, go through the data frame and use the four columns, in matrix form, to
perform calculations necessary to create new values for variables in the data frame. My first idea was to
use apply:
apply(as.array(data.frame[,1:4]), 1, matrix, nrow=2)
Though
2011 Dec 19
2
Summing x1 to x6
Suppose I have the following:
x1<-as.vector(rnorm(10))
x2<-as.vector(rnorm(10))
x3<-as.vector(rnorm(10))
x4<-as.vector(rnorm(10))
x5<-as.vector(rnorm(10))
x6<-as.vector(rnorm(10))
x7<-as.vector(rnorm(10))
x8<-as.vector(rnorm(10))
x9<-as.vector(rnorm(10))
x10<-as.vector(rnorm(10))
I would like the mean of x1 to x6 for each vector position. I would do
something else
2009 Jul 13
1
Add grand mean to every entry in a matrix
Hi,
I have a matrix:
mymat <- matrix(runif(10*4), ncol=4)
I wish to subtract the column means, down the colums, subtract the row means from the rows and add back the grand mean - all the means should be the means of mymat rather than of the new matrix.
How can I do this?
Any help much appreciated.
Thanks
Tom
_________________________________________________________________
2008 Oct 17
2
function help
Hi everyone,
I have dataset which I make a sample of it couple of times and each time I
get the mean and standard deviation of each row for each sample. I have a
function for that, which takes the name of the file and number of times to
sample and then returns the mean and standard deviation for each row in each
sample.
Sample=function(name, n){
2009 Jul 08
1
heatmap.2: question regarding the "raw z-score"
Hi,
I am analysing gene expression data using the heatmap.2 function in R and I
was wondering what is the formula of the "raw z-score" bar which shows the
colors for each pixel.
According to that post:
https://mailman.stat.ethz.ch/pipermail/r-help/2006-September/113598.html, it
is the
(actual value - mean of the group) / standard deviation.
But, mean of which group? Mean of the gene
2006 Sep 07
2
Matrix package in R-2.4.0alpha
In a newly downloaded version (today) of R-2-4-0alpha, with all packages
from CRAN also installed today, I get:
> library(Matrix)
Erro en loadNamespace(package, c(which.lib.loc, lib.loc), keep.source =
keep.source) :
in 'Matrix' methods specified for export, but none defined: BIC,
anova, coef, confint, deviance, fitted, fixef, formula, head, lmer, logLik,
mcmcsamp, plot,
2006 Feb 28
2
Elegant way to express residual calculation in R?
Hi All,
I am illustrating a simple, two-way ANOVA using the following data and I'm
having difficulty in expressing the predicted values succinctly in R.
X<- data.frame(read.table(textConnection("
Machine.1 Machine.2 Machine.3
53 61 51
47 55 51
46 52 49
50
2011 Jul 19
3
calculating the mean of a random matrix (by row) and some general questions
Hi everyone!
I'm trying to teach myself R in order to do some data analysis. I'm a
mathematics student and (only) familiar with matlab and latex. I'm working
trough the "official" introduction to R at the moment, while simultaneously
solving some exercises I found in the web. Before I post my (probably
stupid) question, I'd like to ask you for some general advice. How do
2005 Dec 14
4
unable to force the vector format
Dear all,
I am so ashamed to pollute the list with a trivial question, but it is a
long time I have not used R, and I need a result in the next one or two
hour...
I have a table which I have loaded with read.table, and I want to make
the mean of its columns.
> slides <- read.table("slides.txt")
> slides [1:5,]
V1 V2 V3 V4 V5 V6 V7 V8
1
2002 Nov 15
2
Why no colSDs etc
Hi people,
If there is a fn "colMeans" why isn't there a "colSDs" etc
Thanks,
Phil.
--
Philip Rhoades
Pricom Pty Limited (ACN 003 252 275)
GPO Box 3411
Sydney NSW 2001
Australia
Mobile: +61:0411-185-652
Fax: +61:2:8923-5363
E-mail: pri at chu.com.au
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read
2011 Sep 20
1
means across list of data frames
I have a list of data frames like the following:
set.seed(123)
a<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10))
b<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10))
L<- list(a,b)
All data frames in the list have the same dimensions. I need to calculate
the sample means for x and y. The real data are lists of several thousand
quite large dataframes, so I need
2011 May 13
4
Quick question: Omitting rows and cols with certain percents of missing values
Hi
naive question.
It is possible to get R command for omitting rows or cols with missing values present.
But
if i want to omit rows or cols with i.e . >20% missing values, I
could“t find any package-based command, probably because it is too
simple for anyone to do that manually, though not for me. Can anyone
please help me ?
- vickie
[[alternative HTML version
2010 Nov 23
2
Reading parts of data files
Dear,
I'm doing analysis where I need to work on relatively large (50-60 MB)
text files, though I'm really interested only in parts with binary
variables (named indicators1, indicators2, ... etc.)
Every text file contains other numeric columns, but not always the same
and not always in the same order - therefore I would rather need a
method connecting to file and reading only colums with
2002 Aug 14
3
t-test via matrix operations
I need to calculate a large number of t statistics, and would like to do so via matrix operations. So far I have figured out a way to calculate the mean of each row of the matrix:
d <- matrix(runif(100000,1,10), 1000, 10) # some test data
s <- rep(1,ncol(d)) # a sum vector to use for matrix multiplication
means <- (d%*%s)/ncol(d)
This is at least 1 order of magnitude faster than