Displaying 20 results from an estimated 6000 matches similar to: "Help with loops"
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]
2009 Jun 08
2
help to speed up loops in r
Hi
i am using a script which involves the following loop. It attempts to reduce a data frame(zz) of 95000 * 41 down to a data frame (averagedreplicates) of 95000 * 21 by averaging the replicate values as you can see in the script below. This script however is very slow (2days). Any suggestions to speed it up.
NB I have also tried using rowMeans rather than adding the 2 values and dividing by 2.
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
2009 Jun 03
1
insert and count missing data
Hi R-users,
I have missing data for the month. My question is how do I insert the missing month and fill up the cell with 'na' for the rain amount? Then I would like to count the percentage of missing data.
No Year month rain
1398 1985 10 104.2
1399 1985 11 138.0
1400 1985 12 120.4
1401 1986 1 12.6
1402 1986 2 19.4
1403 1986 3 1.0
1404 1986 4 58.8
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
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.
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",
2005 Mar 10
1
contrast matrix for aov
How do we specify a contrast interaction matrix for an ANOVA model?
We have a two-factor, repeated measures design, with
Cue Direction (2) x Brain Hemisphere(2)
Each of these has 2 levels, 'left' and 'right', so it's a simple 2x2 design
matrix. We have 8 subjects in each cell (a balanced design) and we want to
specify the interaction contrast so that:
CueLeft>CueRght
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
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
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]
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)
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.
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
>
2009 Jul 15
1
Help with averaging
Hi
I am using the following script to average a set of data 0f 62 columns into 31 colums. The data consists of values of ln(0.01) or -4.60517 instead of NA's. These need to be averaged for each row (i.e 2 values being averaged). What I would I need to change for me to meet the conditions:
1. If each run of the sample has a value, the average is
given
2. If only one run of the sample has a
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 =
2009 Nov 04
4
unexpected results in comparison (x == y)
Dear readers of the list,
I have a problem a comparison of two data from a vector. The comparison
yields FALSE but should be TRUE. I have checked for mode(), length() and
attributes(). See the following code (R2.10.0):
-----------------------------------------------
# data vector of 66 double data
X =
2008 Mar 05
1
Question on "assign(paste.."
Hello,
I'm having trouble in using "assign(paste ..." command . I could create
several dataframes following trinomial distribution using it but it could
not be used to check their row means of the created dataframe.
For example, the following works:
probTrt=matrix(0,4,3);
probTrt;
#malf, death, normal
probTrt[1,]=c(0.064,0.119,0.817);#for Trt 1
probTrt[2,]=c(0.053,0.125,0.823);#for
2017 Apr 01
1
mean(x) != mean(rev(x)) different with x <- c(NA, NaN) for some builds
On Fri, Mar 31, 2017 at 10:14 PM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
> From ?NA
>
> Numerical computations using ?NA? will normally result in ?NA?: a
> possible exception is where ?NaN? is also involved, in which case
> either might result.
>
> and ?NaN
>
> Computations involving ?NaN? will return ?NaN? or perhaps ?NA?:
>
2009 Jan 27
1
Problem with RMA using limma, oligo and pdInfoBuilder packages
Hi,
I am a Ph.D. student from Québec, Canada. I’m a beginner with R and
Bioconductor. Until now the only experience I have is in analyzing
microarray data using affy and limma packages. Now I am trying to analyze
Rat Gene 10 st arrays and I would like to run RMA analysis and Smyth
moderated t test on those arrays. Since no cdf official package is available
for those arrays, after reading many