Displaying 20 results from an estimated 50000 matches similar to: "Question about NA's"
2007 Nov 21
2
matrix elementwise average with NA's
Hello fellow R users,
I have a matrix computation that I imagine should be relatively easy to do, however I cannot figure out a nice way to do it. I have two matrices, for example
mat1 <- matrix(c(1:5,rep(NA,5), 6:10), nrow=3, byrow=T)
mat2 <- matrix(c(2:6, 6:10, rep(NA,5)), nrow=3, byrow=T)
I'd like to compute the element-wise average for non-NA entries. Of course
(mat1+mat2)/2
2007 May 20
2
Number of NA's in every second column
Hi R-users,
How do I calculate a number of NA's in a row of every second column in my
data frame?
As a starting point:
dfr <- data.frame(sapply(x, function(x) sample(0:x, 6, replace = TRUE)))
dfr[dfr==0] <- NA
So, I would like to count the number of NA in row one, two, three etc. of
columns X1, X3, X5 etc.
Thanks in advance
Lauri
[[alternative HTML version deleted]]
2005 Feb 21
5
Compare rows of two matrices
Hello,
#I have two matrices, eg.:
y <- matrix( c(20, NA, NA, 45, 50, 19, 32, 101, 10, 22, NA, NA, 80, 49, 61, 190), ncol=4 )
x <- matrix( c(20, NA, NA, NA, 50, 19, 32, 101, 10, 22, NA, NA, 80, 49, 61, 190), ncol=4 )
#Whereas x contains all NA?s from y plus some additional NA?s.
#I want to find the index of these additional NA?s. I think, there must be a very
2005 Feb 21
0
AW: Compare rows of two matrices
Excellent. That was very helpful. Now I have full control about my NA?s :-)
Thank you very much!!!
Matthias
>
> Here is an another way
>
> count <- is.na(x) + is.na(y)
> which( count == 1, arr.ind=TRUE )
>
> 'count' gives you the number of missing values at for each
> row and column. Then you can find out how many occurances of
> both missing,
2008 Oct 03
1
NA's in segmented
I am trying to fit a very simple broken stick model using the package
"segmented" but I have hit a roadblock.
> str(data)
'data.frame': 18 obs. of 2 variables:
$ Bin : num 0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25 4.75 ...
$ LnFREQ: num 5.06 4.23 3.50 3.47 2.83 ...
I fit the lm easily:
> fit.lm<-lm(LnFREQ~Bin, data=id07)
But I keep getting an error
2012 Jul 23
2
help with element-by-element sum with NA
Hi,
I have three matrices which could be, for example:
A = 0, NA
NA, 3
B = 1, NA
0, NA
C = 1, NA
1, 1
(The point is that they all may have NA's in some cells)
QUESTION: How do I perform a element-by-element sum of the elements of
these three matrices (A + B + C), ignoring NA's, to obtain:
D = 2, NA
1, 4
2005 Mar 31
4
NA's?
Your message doesn't help us very much. You haven't said what kind of
calculation it is you want to do, and that certainly matters. For
example, for some kinds of computations the solution you started below
would work fine:
> M <- matrix(1:16, 4, 4)
> is.na(diag(M)) <- TRUE
> M
[,1] [,2] [,3] [,4]
[1,] NA 5 9 13
[2,] 2 NA 10 14
[3,] 3 7 NA
2005 Aug 12
6
evaluating string variables
Hello!!!
I have a folder (C:/R/) with matrix files, named by number, i.e.
0.mat, 1.mat,...,1250.mat. In this case, they are 5x5 simetric
matrices. I would like to compute a property for each matrix and put
calculated values into a data frame for posterior ploting and
printing. Below there is an example for 7 matrices (0.mat..6.mat)
#define data frame
L <- data.frame(frame=numeric(7),
2003 Oct 30
0
dist() objects with NA's don't print them (PR#4866)
The print.dist() method in the mva package currently prints the
triangular distance matrices with the ``trick'' of setting the
(diagonal and) upper triangular part to NA, and then uses
print(mat, na = "") to print that matrix.
This is very much undesired if there are true NAs.
Reproducible example code:
(x <- cbind(c(1,NA,2,3), c(NA,2,NA,1)))
(d <- dist(x)) ## does not
2024 Feb 28
1
[EXT] Initializing vector and matrices
Hi Steven,
It's not entirely clear what you actually want to achieve in the end.
As soon as you "know" x1, and assuming that the different "xi" do not
differ in length in the real application, you know the length of the
target vector.
Instead of the loop, you can use 'Reduce' without having to initialize a
starting vector.
# generate sample vectors, put them in
2006 Oct 16
5
Re : Generate a random bistochastic matrix
Thanks, I tried someting like this, but computation takes times for large matrices
btransf <- function(y,X=length(y)^4) {
N <- length(y)
bm <- matrix(rep(1/N,N^2),N,N)
for(j in 1:X){
coord <- sample(1:N,4,replace=T)
d <- runif(1,0,min(bm[coord[1],coord[2]],bm[coord[3],coord[4]]))
2009 Feb 16
1
[LLVMdev] Invalid call generated on 64-bit linux when calling native C function from IR
Hi,
when I try to generate LLVM-IR which calls back to native C functions the
jit compiler generates invalid code on 64-bit linux. The same code works
fine on 32-bit linux, 32-bit OS X and 64-bit OS X. A reproduction case is
attached to this mail. It is a simple modification of the "How to use jit"
example adding a call to a native function.
I am currently using EE->addGlobalMapping
2008 Jun 04
4
sum of unknown number of matrices
Hi R,
I have a list of matrices. I need to get the sum of all the matrices in
the list.
Example:
a=b=c=d=matrix(1:4,2,2)
l=list(a,b,c,d)
I need:
> a+b+c+d
[,1] [,2]
[1,] 4 12
[2,] 8 16
Something like do.call("+",l) is not working...why is this?
I may not be knowing the number of matrices in the list...
Thanks, Shubha
This e-mail
2004 Sep 03
0
Inconsistencies in subassignment with NA index. (PR#7210)
Apart from the inconsistencies, there are two clear bugs here:
1) miscalculating the number of values needed, in the matrix case. E.g.
> AA[idx, 1] <- B[1:4]
Error in "[<-"(`*tmp*`, idx, 1, value = B[1:4]) :
number of items to replace is not a multiple of replacement length
although only 4 values are replaced by AA[idx, 1] <- B.
2) the behaviour of the 3D case.
2007 May 04
2
Get the difference between two matrices with different length
Hello,
I have got two matrices with different length. The matrices have 3
columuns. The first two are coordinates. The third is a measurement.
Now I want to get a subtraction between every single value of the
third column (between matrix1 and matrix2), but only if the two
first coordinates in matrix1 and matrix2 are the same.
I tried "FUN=?" in aggregate and ave, but I don't know
2011 Jan 12
1
vector or list of matrices corresponding to an observation
Dear all,
I observe for each observation several joint distributions of two
multinomial random variables (5x5 matrices). Right now, data are
arranged so that I have 20 columns for each joint distribution by
observation, which is not practical.
I would like to work with matrices that would be indexed by
observation, just as I work with vectors and matrices for regression
like analysis.
How
2011 Jun 15
1
Reshaping data with xtabs reorders my rows
Dear,
I have a data frame melted from a list of matrices (melt from reshape
package), then I impute some missing values and then want to tabulate
the data again to the array (or list, doesn't matter) of matrices form.
However when using xtabs function it orders my rows alphabetically and
apparently doesn't take "reorder = FALSE" option or anything like it.
Is there anything I
2011 Aug 05
1
jagged array (matrices of different dimensions)
Dear all,
I am having trouble creating a "jagged array" in R. I have found no commentary on how to do it in the help files, but maybe I am misunderstanding the purpose of some of the array functions (e.g. tapply).
I am using a longitudinal dataset where each individual has a different number of time points (observations). I need to create correlation structures for each
2005 Apr 13
5
Binary Matrices
I'm wanting to perform analysis (e.g. using eigen()) of binary matrices - i.e. matrices comprising 0s and 1s.
For example:
n<-1000
test.mat<-matrix(round(runif(n^2)),n,n)
eigen(test.mat,only.values=T)
Is there a more efficient way of setting up test.mat, as each cell only requires a binary digit? I imagine R is setting up a structure which could contain n^2 floats.
Thanks in advance
2005 Jan 04
1
Don't receive the prefix
Hello,
I had installed several asterisk, but I every time had a problem with
callerID.
On each phones I don't reveive the first digit.
For example:
Caller 0672083516 called an IP Phone 0123456789. The IP Phone see 672083516
as callerID.
I think there is a patch for it, but I don't know where to find it out.
Thanks.
-------------- next part --------------
An HTML attachment was