similar to: rowMean, specify subset of columns within Dataframe?

Displaying 20 results from an estimated 3000 matches similar to: "rowMean, specify subset of columns within Dataframe?"

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]
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(
2017 Oct 12
4
comparing two strings from data
Hi, I have two columns that contain numbers along with letters (as shown below) and have different lengths. Each entry in the first column is likely to be found in the second column at most once. For each entry of the first column, if that entry is found in the second column, I would like to get the corresponding index. For instance, if the first entry of the first column is 5th entry in the
2017 Oct 13
1
comparing two strings from data
Combining and completing the advice from Greg and Boris the complete solution is two lines: data_2 <- read.csv("excel_data.csv", stringsAsFactors = FALSE) match_list <- match( data_2$data1, data_2$data2 ) The vector match_list will have the matching position when it exists and NA's otherwise. Its length will be the same as the length of data_2$data1. You should get
2017 Oct 12
0
comparing two strings from data
It's generally a very good idea to examine the structure of data after you have read it in. str(data2) would have shown you that read.csv() turned your strings into factors, and that's why the == operator no longer does what you think it does. use ... data_2 <- read.csv("excel_data.csv", stringsAsFactors = FALSE) ... to turn this off. Also, the %in% operator will achieve
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",
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
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
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 Jan 10
2
Titles - main and subtitle won't plot with errbar
Hi, I'm struggling with errbar graphics. I'm trying to plot an x-y graph with correct labelling, however can't seem to get main and sub to show on my graph. They do work when I use title(main="," etc...., but this will make it look at lot messier,I'll have to blank out ylab=" " , and I need to try and get the titles to update automatically according to my
2010 Nov 06
4
Using changing names in loop in R
Hello everybody, I have usually solved this problem by repeating lines of codes instead of a loop, but it's such a waste of time, I thought I should really learn how to do it with loops: What I want to do: Say, I have several data files that differ only in a number, e.g. data points (or vector, or matrix...) Data_1, Data_2, Data_3,... and I want to manipulate them e.g. a simple sum of
2012 Apr 18
1
Help with creating conditional categorical variables in R
Hi, I am stuck with creating a conditional categorical variable in R If my dataframe data_2 has 3 variables A,B,C I want to create variable D which would be something like : data_2$D <- ifelse(data_2$A < data_2$B & promotion_ind =="N",1,0), this throws up an error "In Ops.factor(data_2$A,data_2$B) : < not meaningful for factors I have tried converting the
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?
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.
2016 Jan 11
2
tftp-hpa features?
On Fri, Jan 8, 2016 at 5:46 PM, Geert Stappers via Syslinux <syslinux at zytor.com> wrote: > On Fri, Jan 08, 2016 at 03:40:37PM -0600, Matt Zagrabelny via Syslinux wrote: >> Greetings, >> >> Is this list (a|the best) place to make feature requests for tftp-hpa? > > Yes, it is. > from email header List-Id: For discussion of Syslinux and tftp-hpa
2015 Jun 08
2
help awk y shells en R
Hola buenas, a veces empleo desde R shells de unix, Existe alguna manera de utilizar estos shelss desde windows o el lenguaje awk. La idea es hacerlo siempre desde R, igual invoncando cygwin desde windows es posible. Pero no me queda claro Un abrazo y gracias por adelntado Javier #_____________________________________________________________________ # EJEMPLO, ¿Que habría que poner en #
2010 Mar 09
3
Removing Zeros from matrix
Hi Everybody, I have a matrix of about 45 columns. Some of the rows contain zeros. Using >data1<-data[complete.cases(data),], I can remove the "NA" rows. But I am unable to tackle that of zeros. Can anybody give me an idea of how to remove rows containing zeros in a matrix. Thanks so much Best Ogbos [[alternative HTML version deleted]]
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