Displaying 20 results from an estimated 5000 matches similar to: "long run time for loop operation & matrix fill"
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 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 12
7
ignoring zeros or converting to NA
Hi everyone,
I have a matrix that has a combination of zeros and NAs. When I perform
certain calculations on the matrix, the zeros generate "Inf" values. Is
there a way to either convert the zeros in the matrix to NAs, or only
perform the calculations if not zero (i.e. like using something similar to
an !all(is.na() construct)?
Thanks,
rcoder
--
View this message in context:
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 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 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 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 Jul 09
2
shifting data in matrix by n rows
Hi everyone,
I have some data in a matrix, and I want to shift it down by one row. The
matrix in question has a date column. Does anyone know of a way to shift the
data by one row, whilst preserving the date column in the matrix - i.e.
shift the data and leave the date column in the current location?
Thanks,
rcoder
--
View this message in context:
2008 Aug 08
1
increment size in for loop
Hi everyone,
Is there a way to vary the increment size in a for loop? For e.g. when
incrementing in steps greater than unity.
Thanks,
rcoder
--
View this message in context: http://www.nabble.com/increment-size-in-for-loop-tp18893893p18893893.html
Sent from the R help mailing list archive at Nabble.com.
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
--
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 02
1
problem with nested loop for regression
Hi everyone,
I'm experiencing difficulty getting the results I want when I use a nested
for loop. I have a data set to which I perform some calculations, and then
try to apply a regression over a rolling window. The code runs, but the
regression results I am getting (intercept and slope) are simply the same,
repeated again and again in the results matrix. The regression does not seem
to be
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
2012 Aug 01
1
Error message: $ operator is invalid for atomic vectors
HI,
The code was working perfectly fine yesterday and today, until half an hour ago.? Couldn't find any problems in the code. Still, I am getting error message.
myMatrix <- data.matrix(read.table(text="
Name??????????? Age
ANTONY??????? 27
IMRAN????????? 30
RAJ????????????????? 22
NAHAS????????? 32
GEO??????????????? 42
", header=TRUE))
MinMaxArray? <- data.frame(MIN =
2008 Aug 24
1
problem running dll in R
Hi everyone,
I've created a dll for a fortran subroutine, and when I call the subroutine
in R (via a wrapped function) a standard program shutdown windows error
prompt immediately pops up: the program has encountered a problem and needs
to be shut down... send message / don't send message to MS... etc.
When I click "Don't send", the R consol does not then shut down, and
2013 Jun 27
3
using "rollapply" to calculate a moving sum or running sum?
#using "rollapply" to calculate a moving sum or running sum?
#I am tryign to use rollapply to calcualte a moving sum? #I tried
rollapply and get the error message
#"Error in seq.default(start.at, NROW(data), by = by) :
# wrong sign in 'by' argument"
#example:
mymatrix <- ( matrix(data=1:100, nrow=5, ncol=20) )
mymatrix_cumsum <- ( matrix(data=NA, nrow=5,
2009 Jul 20
1
S4 method dispatch with inheritance
Hi,
I'm trying to create a new S4 class (myMatrix) which for now just
extends dgCMatrix (from package Matrix). Then I want to use "[" which is
defined in Matrix.
Out of the box with "[" (defined in Matrix) I lose the class information
and the result is an object of class dgCMatrix. If I specify a
"["-method for myMatrix, it is not used because a signature
2005 Jan 21
6
Avoiding a Loop?
Dear R-Helpers,
I have a matrix where the first column is known. The second column is
the result of multiplying this first column with a constant "const". The
third column is the result of multiplying the second column with
"const".....
So far, I did it like this (as a simplified example):
nr.of.columns <- 4
myconstant <- 27.5
mymatrix <- matrix(numeric(0), nrow=5,
2005 Feb 21
3
Sorting a matrix on two columns
Hello,
If a matrix with 5 columns has been defined and the first two columns
need to be sorted in ascending order, how can this be achieved whilst
ensuring the
other 3 columns data are in relative position to the sorted columns?
Glen Jones
[[alternative HTML version deleted]]
2006 Apr 04
2
Selecting out certain values from a MATRIX
I have two objects, one matrix and one vector.
I want to use my vector to subset certain values out of my matrix.
For example:
I want to tell R, to select out all rows in myMatrix into a new myMatrix2 IF
that corresponding row is less than a 0.5 in myVector.
So:
myMatrix = a matrix of 8000 by 20
myVector = vector of 8000
myMatrix2 = a matrix of < 8000 by 20 (based on selection criteria in