similar to: "Simplifying" matrices ?

Displaying 20 results from an estimated 6000 matches similar to: ""Simplifying" matrices ?"

2013 Jan 02
4
list of matrices
dear useRs, i have a list containing 16 matrices. i want to calculate the column mean of each of them. i tried >sr <- lapply(s,function(x) colMeans(x, na.rm=TRUE)) but i am getting the following error >Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric can it be done in any other way? and why i am getting this error?? thanks in advance.. elisa [[alternative
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,
2013 Apr 10
3
how to calculate average of each column
Hey All, I have a large dataset and I want to calculate the average of each column then return a new dataset. Here is my question: I dont know if there is a function that can allow me to calculate the average every 60 records of data in the whole dataset, and return a new data frame. Not sure if I have to divide the dataset first for every 60, then do the mean or can i directly do that. thanks
2012 Jul 12
6
read.table with numeric row names
I have a text file like this 2.5 3.6 7.1 7.9 100 3 4 2 3 200 3.1 4 3 3 300 2.2 3.3 2 4 I used "r <- read.table("a.txt", header=T)" The row names becomes X2.5, X3.6... What I need is the row names are numeric, so I can use the row names as numbers on x-axis for plotting. e.g. "plot(colMeans(r)~names(r))",
2013 Jan 04
2
"By" function Frame Conversion (with Multiple Indices)
Hello, I have the following dataset. Please note that there are missing values on records 4 and 5: id,age,weight,height,gender 1,22,180,72,m 2,13,100,67,f 3,5,40,40,f 4,6,42,,f 5,12,98,66, 6,50,255,60,m I'm using the "By" function like this: list1 <- by(dataset[c("weight", "height")], dataset[c("age", "gender")],
2012 Dec 08
3
Mean-Centering Question
Hello, I'm trying to create a custom function that "mean-centers" data and can be applied across many columns. Here is an example dataset, which is similar to my dataset: *Location,TimePeriod,Units,AveragePrice* Los Angeles,5/1/11,61,5.42 Los Angeles,5/8/11,49,4.69 Los Angeles,5/15/11,40,5.05 New York,5/1/11,259,6.4 New York,5/8/11,187,5.3 New York,5/15/11,177,5.7
2012 Aug 30
2
Identifying and Removing NA Columns and factor Columns with more than x Levels
Hi, How do you subset a dataframe so that you only have columns: 1. that contain one or more NAs? 2. that contain factors with greater than or equal to 32 levels? How do you remove from a dataframe columns** 3. with one or more NA's? 4. that contain factors with greater than or equal to 32 levels? ** I know how to remove columns at a basic level but I am trying
2012 Aug 06
2
deleting columns from a dataframe where NA is more than 15 percent of the column length
I have a dataframe of 10 different columns (length of each column is the same). I want to eliminate any column that has 'NA' greater than 15% of the column length. Do i first need to make a function for calculating the percentage of NA for each column and then make another dataframe where i apply the function? Whats the best way to do this.
2013 Feb 21
1
remove rows in data frame by average
Dear all, I have a data frame, which looks like this: Subject | Block | Trial | Feature1 | Feature2 .... 1 | 1 | 1 | ... | ... 1 | 1 | 2 | ... | ... 1 | 2 | 1 | ... | ... 1 | 2 | 2 | ... | ... 1 | 3 | 1 | ... | ... ...| ...| ...| ... | ... Can I remove the "Trial" column by averaging all the rows and without using a "for loop"? At the end my data frame should look like
2009 Jul 15
1
Simulation code error
Dear List, I have some problem with my simulation code. Here is output from R: > sim.sp <- function(data,CM,n,N) + { + C <- matrix(rep(NA,N),ncol=1) + for(i in 1:N) + { + j <- n + xx <- which(colSums(CM[j,])==1) + V <- names(xx) + V <- paste(V, collapse="+") + V <- paste("SBA~", V) + rd <- round(nrow(data)*(2/3)) + d <-
2013 Jan 05
5
Need help on dataframe
Dear R users, I came up to a problem by taking means (or other summary statistics) of a big dataframe. Suppose we do have a dataframe: ID V1 V2 V3 V4 ........................ V71 1 6 5 3 2 ........................ 3 2 3 2 2 1 ........................ 1 3 6 5 3 2 ........................ 3 4 12 15 3 2 ........................ 100
2009 Jul 15
1
Error in simulation R-code
Dear List, I have got error message when I run the R-code. Can anyone has a suggestion? v.code <- df.bm7[,c(10:31)]; v.code[1:3,] names(v.code) CM = v.code # variable binomial code sim.sp <- function(data,CM,n,N) { C <- matrix(rep(NA,N),ncol=1) for(i in 1:N) { j <- n xx <- which(colSums(CM[j,])==1) V <- names(xx) V <- paste(V,
2011 Nov 27
1
Simplifying my code
Hi, I have a pretty simple problem. Here is the code: dat1=complete(dat.mice,1) dat2=complete(dat.mice,2) dat3=complete(dat.mice,3) dat4=complete(dat.mice,4) dat5=complete(dat.mice,5) dat6=complete(dat.mice,6) dat7=complete(dat.mice,7) dat8=complete(dat.mice,8) dat9=complete(dat.mice,9) dat10=complete(dat.mice,10) dat11=complete(dat.mice,11) dat12=complete(dat.mice,12)
2010 Feb 04
2
Filling a logical matrices with values
Hello !! I have this problem: A matrix on True/False and as many numerical vectors as columns, but of different length. What I 'd like to get is this: set.seed(12) > dat <- as.data.frame(matrix(as.logical(sample(T:F, 30, T)),5,6)) > colnames(dat) <- letters[1:6] > rownames(dat) <- paste(letters[1:5],1:5, sep="") > dat a b c d e f a1
2016 Apr 14
3
Unequal column lengths
Hello, I?ve tried several times to learn R, but have never gotten past a particular gate. My data are organized by column in Excel, with column headers in the first row. The columns are of unequal lengths. I export them as CSV, then import the CSV file into R. I wish to summarize the data by column. R inserts NA for missing values, then refuses to operate on columns with NA. R is importing
2012 Oct 12
3
average duplicated rows?
Dear useRs, I have a slightly complicated data structure and am stuck trying to extract what I need. I'm pasting an example of this data below. In some cases, there are duplicates in the "gene_id" column because there are two different "sample 1" values for a given "sample 2" value. Where these duplicates exist, I need to average the corresponding
2012 Mar 08
4
Correlation between 2 matrices but with subset of variables
Dear All, I have two matrices A (40 x 732) and B (40 x 1230) and would like to calculate correlation between them.  I can use: cor(A,B, method="pearson") to calculate correlation between all possible pairs. But the issue is that there is one-many specific mappings between A and B and I just need to calculate correlations for those pairs (not all). Some variables in A (proteins, say p1)
2012 Dec 06
1
tool for cluster analysis
I have Windows XP Professional Version 2002 and the R-Version 2.1.1. I did cluster analysis with the cluster package and the agnes (method = ?ward?). The results are satisfactory. But the dendrogram of agnes is confused to work with the results. Is there a tool, I can get a clear arrangement of the results for the cluster analysis. For example a matrix with different numbers for each group.
2007 Dec 11
1
Query in codebook decoding
Hello Monty, Sorry for the wrong subject title last time. A little more clarification needed. When reading bit-by-bit, there is no MSb/LSb, just 'first bit' and 'last bit'. The Huffman tree is traversed from 'first bit' to last bit'. This is a conceptual layer above the bitpacker; all you need to know is what order the bits come out, which happens to be LSb-first.
2012 Dec 06
2
Design library
Dear friends Hello I'm a PhD student in Edinburgh University and interested in survival analysis. By chance, I found design library in Splus software. I have some questions about it and it's highly appreciated if you can help me. In its help (Design library help) I found the topics(not the commands), which are available in the main software. for instance, survival analysis is