Displaying 20 results from an estimated 30000 matches similar to: "ignoring zeros or converting to NA"
2008 Aug 13
2
missing TRUE/FALSE error in conditional construct
Hi everyone,
I posted something similar to this in reply to another post, but there seems
to be a problem getting it onto the board, so I'm starting a new post.
I am trying to use conditional formatting to select non-zero and non-NaN
values from a matrix and pass them into another matrix. The problem is that
I keep encountering an error message indicating the ":missing value where
2008 Jul 27
4
product of successive rows
Hi everyone,
I want to perform an operation on a matrx that outputs the product of
successive pairs of rows. For example: calculating the product between rows
1 & 2; 3 & 4; 5 & 6...etc.
Does anyone know of any readily available functions that can do this?
Thanks,
rcoder
--
View this message in context: http://www.nabble.com/product-of-successive-rows-tp18681259p18681259.html
2008 Jul 31
1
rollapply() to portions of a matrix
Hi everyone,
I have a rollapply statement that applies a function, in steps, over a data
matrix as follows:
#Code start
testm<-rollapply(mat, 100, by=100, min, na.rm=F)
#Code end
This moves down matrix 'mat' and calculates the minimum value over a 100 row
range, every 100 rows (i.e. no overlaps). NAs are not removed.
I want to modify this statement somehow so that the rollapply()
2008 Aug 13
3
conditional IF with AND
Hi everyone,
I'm trying to create an "if" conditional statement with two conditions,
whereby the statement is true when condition 1 AND condition 2 are met:
code structure:
if ?AND? (a[x,y] <condition1>, a[x,y] <condition2>)
I've trawled through the help files, but I cannot find an example of the
syntax for incorporating an AND in a conditional IF statement.
2008 Aug 13
2
merging data sets to match data to date
Hi everyone,
I want to extract data from a data set according to dates specified in a
vector. I have created a blank matrix with row names (dates) that I want to
extract from the full data set. I have then performed a merge to try to o/p
rows corresponding to common dates to a results matrix, but the operation
did not fill the results matrix. Coulc anyone offer any advice to assist
with this
2008 Jul 29
1
rolling regression between adjacent columns
Hi everyone,
I am trying to apply linear regression to adjacent columns in a matrix (i.e.
col1~col2; col3~col4; etc.). The columns in my matrix come with identifiers
at the top of each column, but when I try to use these identifiers to
reference the columns in the regression function using rollapply(), the
columns are not recognised and the regression breaks down. Is there a more
robust way to
2008 Jul 29
1
correlation between matrices - both with some NAs
Hi everyone,
I'm having trouble applying the Cor() function to two matrices, both of
which contain NAs. I am doing the following:
a<-cor(m1, m2, use="complete.obs")
... and I get the following error message:
Error in cor(m1, m2, use = "complete.obs") :
no complete element pairs
Does anyone know how I can apply a correlation, ignoring any NAs?
Thanks,
rcoder
--
2006 Mar 03
1
NA in eigen()
Hi,
I am using eigen to get an eigen decomposition of a square, symmetric
matrix. For some reason, I am getting a column in my eigen vectors (the
52nd column out of 601) that is a column of all NAs. I am using the option,
symmetric=T for eigen. I just discovered that I do not get this behavior
when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is
(up to rounding error) a
2009 Jun 12
3
replacing zeros by NAs
something like ...
> x<-c(1,2,3,0,5,6,0)
> is.na(x[x==0])<-T
> x
[1] 1 2 3 NA 5 6 NA
~~~~~~~~~~~~~~~~
Robert Kinley
~~~~~~~~~~~~~~~~
[[alternative HTML version deleted]]
2008 Aug 15
2
cor() btwn columns in two matrices - no complete element pairs
Hi everyone,
I'm trying to calculate correlation coefficients between corresponding
columns in two matrices with identical dimensions but different data. The
problem is that the matrices contain NAs in different locations. I am using
the following code to try to calculate correlations between complete sets of
data:
#Code start
maxcol<-ncol(mat1)
for (i in 1:maxcol)
{
2008 Aug 06
1
using acf() for multiple columns
Hi everyone,
I'm trying to use the acf() function to calculate the autocorrelation of
each column in a matrix. The trouble is that I can only seem to get the
function to work if I extract the data in the column into a separate matrix
and then apply the acf() function to this column.
I have something like this: acf(mat,lag.max=10,na.action=na.pass)
...but I would really like to apply the
2010 Mar 30
4
Code is too slow: mean-centering variables in a data frame by subgroup
Dear R-ers,
I have a large data frame (several thousands of rows and about 2.5
thousand columns). One variable ("group") is a grouping variable with
over 30 levels. And I have a lot of NAs.
For each variable, I need to divide each value by variable mean - by
subgroup. I have the code but it's way too slow - takes me about 1.5
hours.
Below is a data example and my code that is too
2008 Aug 07
1
long run time for loop operation & matrix fill
Hi everyone,
I'm running some code containing an outer and inner loop, to fill cells in a
2500x1500 results matrix. I left my program running overnight, and it was
still running when I checked 17 hours later. I have tested the operation on
a smaller matrix and it executes fine, so I believe there is nothing wrong
with the code. I was just wondering if this is normal program execution
speed
2012 May 21
3
Prevent calculation when only NA
Hi everybody,
I have a small question about R.
I'm doing some correlation matrices between my files. These files contains
each 4 columns of data.
These data files contains missing data too. It could happen sometimes that
in one file, one of the 4 columns contains only missing data NA. As I'm
doing correlations between the same columns of each files, I get a
correlation matrix with a
2009 Nov 21
1
how to ignore NA when using cumsum WHILE retaining NAs?
I would like to cumulatively sum rows in a matrix, in which each row has 1
NA value, which I do NOT want to treat as 0s. The NAs are placeholders
where there is actually no data, which is not the same as a 0. The usual
"na.rm=TRUE" does not seem to work with the command cumsum. Is there
another way to ignore the NAs or do I need to figure out a different way to
do this?
Here's an
2008 Feb 14
5
Removing columns that are all NA from a matrix
Hi,
I guess this might be a FAQ or something, and there's probably a nice
simple way to do it, but I can't think of it:
Given a matrix, I want to remove columns that are _entirely_ filled with
NAs (partial NAs are fine).
How please?
Thanks,
Martin
2009 Jun 15
2
NA as a result of using GLM
Hi all!
Maybe someone could help me with the following. I know this hasn't directly to do with ecology but I'm also using glm.
I have a list of 16 genes and 10 samples. The samples are of two types, 4 Ctrl and 6 Diseased. If,
labelInd<-as.factor(c(rep("0",4),rep("1",6)))
genes.glm<-glm(labelInd ~ ., family=binomial, data=mat)
beeing "mat" the 10x16
2005 Jan 14
5
Replacing NAs in a data frame using is.na() fails if there are no NAs
Hi
This is a difference between the way matrices and data frames work I
guess. I want to replace the NA values in a data frame by 0, and the
code works as long as the data frame in question actually includes an NA
value. If it doesn't, there is an error:
df <- data.frame(c1=c(1,1,1),c2=c(2,2,NA))
df[is.na(df)] <- 0
df
df <- data.frame(c1=c(1,1,1),c2=c(2,2,2))
df[is.na(df)] <-
2006 Oct 03
3
Linking R with Fortran 90: make: m2c: Command not found
Following the setup in Prof.Duncan Murdoch's page, I have successfully compiled the DLL for one Fortran 95 program using Gfortran and got 300 times speed boost. For the second set of fortran programs, However, I have this error message
R CMD SHLIB -o jiangang kdtree2.f90 jian.f90 gang.f90
m2c -o jian.o jian.mod
make: m2c: Command not found
make: *** [jian.o] Error 127
Can anyone
2012 May 03
2
add an automatized linear regression in a function
Dear R users,
For the moment, I have a script and a function which calculates correlation
matrices between all my data files. Then, it chooses the best correlation
for each data and take it in order to fill missing data in the analysed file
(so the data from the best correlation file is put automatically into the
missing data gaps of the first file (because my files are containing missing
values