Displaying 20 results from an estimated 4000 matches similar to: "speed and looping issues; calculations on big datasets"
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
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 =
2009 May 20
0
function returning the name of an object
Hello R users,
I'm trying to solve an apparently simple problem.
I include a matrix in a model formula, and I want then to extract the related coefficients.
Basically, I want a function func such that:
mymatrix <- cbind(rnorm(10),rnorm(10))
y <- b <- rnorm(10)
model <- lm(y ~ b + mymatrix)
func(mymatrix,model)
which returns only the 3rd and 4th coefficients.
I thought to
2012 Mar 20
1
Remove individual rows from a matrix based upon a list
Dear All,
Thanks in advance for any help. I have a square matrix of measures of
interactions among individuals and would like to calculate a values from a
function (colSums for example) with a single individual (row) excluded in
each instance. That individual would be returned to the matrix before the
next is removed and the function recalculated. I can do this by hand
removing rows based upon
2009 May 09
0
clump of binary pixels on raster
Dear all,
I have a set od 30,000 binary landscapes, which represent habitat and
non-habitat cover.
I need to generate images that identify those neighbour (rule 8) pixels as
one patch ID,
and a different patch ID for each clump of pixels. I coded it using
labcon(adehabitat),
but as some of my landscapes have so many patches, labcon not finish and
entry in
a eternal looping. By other side, I coded
2005 Aug 08
2
computationally singular
Hi,
I have a dataset which has around 138 variables and 30,000 cases. I am
trying to calculate a mahalanobis distance matrix for them and my
procedure is like this:
Suppose my data is stored in mymatrix
> S<-cov(mymatrix) # this is fine
> D<-sapply(1:nrow(mymatrix), function(i) mahalanobis(mymatrix, mymatrix[i,], S))
Error in solve.default(cov, ...) : system is computationally
2011 Aug 17
2
Lattice: problem with setting space between plot and legend
Dear R Users,
I am writing code to present my output data (I'm using Lattice Package).
However, it's essential for me to control space between barchart and legend.
I've read the package's specification, but unfortunately I haven't spot the
information how to do this. Here's the code I've written:
barchart(mymatrix[,1:ncol(mymatrix)],horizontal=FALSE,
2007 Mar 01
1
problem with throwing lines out of matrix
Dear all,
again i have a problem with special case of dropping lines out of a
matrix.
i tried the following, where throwout is a vector of length 18 with
simple id values that should be compared to any
for (k in 1:length(throwout))
{
mymatrix=matrix(mymatrix[-(forfact[k]),],ncol=4)
}
this didnt work and i tried the following to find the error:
mymatrix[,1][mymatrix[,1]==throwout[7]]
2011 Oct 11
2
binding all elements of list (character vectors) to a matrix as rows
dear r-users,
i have got a problem which i am trying to solve:
i have got the following commands:
Mymatrix <- matrix(1:9,ncol=3)
Z <-
list("V1"=c("a","",""),"V2"=c("b","",""),"V3"=c("c","",""),"V4"=c("d","",""))
Mymatrix <-
2012 Jul 19
2
Line chart with a double matrix
Hello,
I have a double matrix that I want to represent in a line chart. Although I
have seen some examples I still don't manage to get it. My data is this (a
double matrix called mymatrix) :
Blogs Wikis Redes Etiq. SPC LMS
Menor de 30 57.14 28.57 14.29 28.57 57.14 28.57
de 31 a 40 63.83 61.70 29.79 17.02 59.57 70.21
de 41 a 50 72.64 70.75 47.17 20.75 55.66 75.47
Mayor de
2002 Nov 04
3
write table and dinnames
I would write in tab-text file a table like this one:
TAB colname1 TAB colname2 TAB TAB... colnameN
rowname1 # # #
rowname2 # # #
rownameM # # #
then I wrote something like:
mymatrix <- matrix(nrow=M,ncol=N,byrow=T)
rownames(mymatrix) <- chvector1
colnames(mymatrix) <- chvector2
2012 Mar 31
1
basic subset question of matrix
Dear list,
I would like to subset a large expression matrix based on rownames.
That is, I have a list (as a txt-file) with gene names that matches
some of the rows in my matrix.
I've loaded my matrix as well as gene list using the read.table() command.
myMatrix <- read.table("name_of_file.txt", header=T, row.names=1)
list_to_keep <- read.table("name_of_file.txt",
2007 Jan 29
1
"Reversal" of Aggregation
Dear all,
given I have a data.frame in a format like this
mydf <- data.frame(age=rep(1:3,5),
year=c(rep(1996,3), rep(1997,3), rep(1998,3),
rep(1999,3), rep(2000,3)),
income=1:15)
mydf
Now I convert it to some 2D-frequency table like this:
mymatrix <- tapply(X=mydf$income, INDEX=list(mydf$age, mydf$year),
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,
2003 Nov 05
1
objects inside curly braces
Hello,
I am running a program in r that calls a function, which calls another
function, which calls another etc. These functions are of the form:
example<- function(x,y,z)
{x, y, and z are defined within curly braces like this}
Here's my question. To start the main function, I input as an initial
parameter a matrix of regressors of the form:
MyMatrix<-cbind(this.one,that.one)
2012 Jun 14
3
Time difference between two dates/timing
Hi,
Here, i have a matrix like this
MyMatrix <-
*DATETIME HEADER1 HEADER2*
1/1/2010 0:10 197.1947 100.0859
1/1/2010 0:20 203.8811 100.1013
1/1/2010 0:30 206.564 100.0433
1/1/2010 0:40 207.9563 99.9393
i want to get the time difference in minutes between two date.
TimeDiff <- MyMatrix[1,1] - MyMatrix[2,1]
TimeDiff
2004 Nov 01
5
make apply() return a list
Hi,
I have a dataframe (say myData) and want to get a list (say myList) that
contains a matrix for each row of the dataframe myData. These matrices are
calculated based on the corresponding row of myData. Using a for()-loop to do
this is very slow. Thus, I tried to use apply(). However, afaik apply() does
only return a list if the matrices have different dimensions, while my
matrices have
2008 Jun 19
1
ANOVA error
Hello,
I have a dataframe named myMatrix with the structure
Treatment Time Cr mIb ...
Being the treatment and time the predictors and Cr, mIb and so on the
response variables. When I call
Cr.aov <- aov(Cr~Treatment, data=myMatrix)
I got this error:
Error in storage.mode(y) <- "double" :
invalid to change the storage mode of a factor
In addition: Warning message:
In
2005 Dec 08
3
Reshaping data
Dear all,
given I have data in a data.frame which indicate the number of people in
a
specific year at a specific age:
n <- 10
mydf <- data.frame(yr=sample(1:10, size=n, replace=FALSE),
age=sample(1:12, size=n, replace=FALSE),
no=sample(1:10, size=n, replace=FALSE))
Now I would like to make a matrix with (in this simple example)
10 columns (for the
2006 Aug 09
3
objects and environments
Dear list,
I have two functions created in the same environment, fun1 and fun2.
fun2 is called by fun1, but fun2 should use an object which is created in fun1
fun1 <- function(x) {
ifelse(somecondition, bb <- "o", bb <- "*")
## mymatrix is created, then
myresult <- apply(mymatrix, 1, fun2)
}
fun2 <- function(idx) {
if (bb == "o) {
#