search for: nrows

Displaying 20 results from an estimated 6335 matches for "nrows".

Did you mean: rows
2010 Dec 24
3
selection of outputs from the function
Hi Dear All, This is a function which contains Covariance Ratio and Likelihood Distance values (CVRi, LDi). i want to compute the all row's values, that is run this function for nrow(X) times. The X and Y matrices are;
2011 May 19
3
problem with optim()
Dear R-users, I would like to maximize the function g above which depends on 4 parameters (2 vectors, 1 real number, and 1 matrix) using optim() and BFGS method. Here is my code: # fonction to maximize g=function(x) { x1 = x[1:ncol(X)] x2 = x[(ncol(X)+1)] x3 = matrix(x[(ncol(X)+2):(ncol(X)+1+ncol(X)*ncol(Y))],nrow=ncol(X),ncol=ncol(Y)) x4 = x[(ncol(X)+1+ncol(X)*ncol(Y)+1):length(x)]
2013 Sep 02
3
Product of certain rows in a matrix
Hi, You could try: A<- matrix(unlist(read.table(text=" 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 ",sep="",header=FALSE)),ncol=3,byrow=FALSE,dimnames=NULL) library(matrixStats) ?res1<-t(sapply(split(as.data.frame(A),as.numeric(gl(nrow(A),2,6))),colProds)) ?res1 #? [,1] [,2] [,3] #1??? 4?? 10?? 18 #2?? 63?? 64?? 63 #3?? 18?? 10??? 4
2012 Oct 08
1
Any better way of optimizing time for calculating distances in the mentioned scenario??
Dear All, I'm dealing with a case, where 'manhattan' distance of each of 100 vectors is calculated from 10000 other vectors. For achieving this, following 4 scenarios are tested: 1) scenario 1: > x<-read.table("query.vec") > v<-read.table("query.vec2") > d<-matrix(nrow=nrow(v),ncol=nrow(x)) > for (i in 1:nrow(v)){ + d[i,]<-
2009 Apr 14
1
mean fold change issues and p values
I am new to R and have two scripts written slightly different but should to relatively the same thing but my lack of experience with the program I can not figure out the what I need to do to correct it. The first script gives me a consistent mean fold change values with every run but can generate negative p values for some. For the second version of the script, the fold changes seem to be very
2010 Jul 25
0
Redefine NROW and NCOL to be compatible with nrow and ncol for S3 classes with own dim function?
Dear R-developers, I am currently trying to develop a package with some customized container classes and found an issue with the functions NROW and NCOL. I guess that I can simply work around the problem by redefining these functions in my own package (Yet, I do not know whether that will work cleanly everywhere). Nevertheless, I thought that perhaps one might think about to redefine these
2008 Apr 05
2
Adding a Matrix Exponentiation Operator
...nentiation by squaring. Is there a way to cut down on the number of copies I am making here (I am assuming that the lhs and rhs of matprod() must be different instances). Any feedback appreciated ! Thanks Rory <snip> /* Convenience function */ static void copyMatrixData(SEXP a, SEXP b, int nrows, int ncols, int mode) { for (int i=0; i < ncols; ++i) for (int j=0; j < nrows; ++j) REAL(b)[i * nrows + j] = REAL(a)[i * nrows + j]; } SEXP do_matexp(SEXP call, SEXP op, SEXP args, SEXP rho) { int nrows, ncols; SEXP matrix, tmp, dims, dims2; SEXP x, y, x_, x__;...
2009 May 26
1
Bug in "$<-.data.frame" yields corrupt data frame (PR#13724)
...lt;-.data.frame" ) A single object matching '$<-.data.frame' was found It was found in the following places package:base registered S3 method for $<- from namespace base namespace:base with value function (x, i, value) { cl <- oldClass(x) class(x) <- NULL nrows <- .row_names_info(x, 2L) if (!is.null(value)) { N <- NROW(value) if (N > nrows) stop(gettextf("replacement has %d rows, data has %d", N, nrows), domain = NA) if (N < nrows && N > 0L) if (nrows%%...
2006 Oct 23
2
getting the by() function to work properly
Hola everyone, Solving this issue would be a huge time saver for analyzing my thesis data, so I'll try to be as concise as possible and hope that someone can give me a hand. I am trying to run a function that I created, which works fine until I try to use it with the by function. That function is listed at the bottom (f3) just in case that might be the issue. Essentially I have compiled a
2013 Feb 07
1
Merging data in arrays
Dear All, Here is a hypothetical sample (sorry for the clumsy code): A1 <- matrix(1:5, nrow=5, ncol=1) A2 <- matrix(6:10, nrow=5, ncol=1) A3 <- matrix(11:15, nrow=5, ncol=1) A4 <- matrix(16:20, nrow=5, ncol=1) A5 <- matrix(21:25, nrow=5, ncol=1) A6 <- matrix(26:30, nrow=5, ncol=1) B1 <- matrix(c(A1, A2, A3), nrow=5, ncol=3) B2 <- matrix(c(A2, A3, A4), nrow=5, ncol=3) B3
2009 Aug 10
3
how use cat() function?
i  want to print in the console and to have an excel file like this no_GWP                NbOfPolicyClass1[0-1000]     NbOfPolicyClass2[1000-3000]        NbOfPolicyClass3[> 3000] No_GWPMax=8    NbpolicyClass1=5                   NbpolicyClass2=4                            NbpolicyClass3 =3              i have do it like this:!!! data1 <-
2011 Sep 20
2
How to transfer variable names to column names?
Hello R users, I have a set of data frames for which I am tallying row numbers, as shown below. > nrow(mC_Explant) [1] 14480 > nrow(mC_Callus) [1] 23320 > nrow(mC_RegenPlant) [1] 8108 etc. I want to create a new data frame which has the variable names as column headings, and then a single row with the nrow tallies. My first step was this: dfIntron <- c(nrow(mC_Explant),
2010 Apr 17
4
how to remove one row at a time from a matrix keeping its nrow consistent
After some headache with debugging my script, I finally isolated the problem taht I am going to illustrate in the following example. I expected matrix nrow to decrease consistently till 1. Instead, when the matrix is left with one row only, its nrow jumps to 2 because the matrix gets transposed. How come ? Thank you, Maura > B <- c(1,2) > B <- rbind(B,c(3,4)) > B <-
2018 Apr 08
2
Doubt_merging data
Hello, I gather data from 5 objects and 5 data. frames and would like to join information. join: pb_SM + pb_T + pb_P + pb_F + pb_SJ = total_pb join: sdmdata_SM + sdmdata_T + sdmdata_P + sdmdata_F + sdmdata_SJ =total_sdmdata code: rbind, merge? total_pb<- ?? total_sdmdata<- ?? 1 absvals_SM <- extract(grid_present_SM, absences_10000) presvals_SM <-
2002 Apr 09
6
matrix dimension and for loop
Dear all, My questions are that if I have > x<-rnorm(50) > dim(x)<-c(10,5) > y=1:5 > Z<-matrix(0,NROW(x),NROW(y)) > for (j in 1:NROW(y)) Z[,j]<-x[,j]*y[j] 1. Is there any other way to write this without 'for' loop? 2. and if I don't know the dimension of x, which could be only 1 column, how could I write the command without using if (NCOL(x)==1), or
2010 Oct 13
1
(no subject)
Dear all, I have just sent an email with my problem, but I think no one can see the red part, beacuse it is black. So, i am writing again the codes: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N <- 200 I <- 5 taus <- c(0.480:0.520) h <-
2017 Jul 05
4
expand gridded matrix to higher resolution
Hi all, (if me email goes out as html, than my email client don't do as told, and I apologies already.) We need to downscale climate data and therefore first need to expand the climate from 0.5deg to the higher resolution 10min, before we can add high resolution deviations. We basically need to have the original data at each gridcell replicated into 3x3 gridcells. A simple for loop can do
2010 Nov 10
2
Parallel code runs slower!
My parallel code is running slower than my non-parallel code! Can someone pls advise what am I doing wrong here? t and tTA are simple matrices of equal dimensions. #NON PARALLEL CODE nCols=ncol(t) nRows=nrow(t) tTA = matrix(nrow=nRows,ncol=nCols) require(TTR) system.time( for (i in 1:nCols) { x = t[,i] xROC = ROC(x) tTA[,i]=xROC } ) user system elapsed 123.24 0.07 123.47 # PARALLEL CODE nCols=ncol(t) nRows=nrow(t) tTA = matrix(nrow=nRows,ncol=nCols) require(doSMP) workers &l...
2011 Jul 29
4
finding a faster way to run lm on rows of predictor matrix
Hi, everyone. I need to run lm with the same response vector but with varying predictor vectors. (i.e. 1 response vector on each individual 6,000 predictor vectors) After looking through the R archive, I found roughly 3 methods that has been suggested. Unfortunately, I need to run this task multiple times(~ 5,000 times) and would like to find a faster way than the existing methods. All three
2009 Jan 20
1
Creating a Sparse Matrix from a Sparse Vector
Hello, I am working with a sparse matrix that is approx. 13,900 by 14,100. My goal is to select a row out of the matrix and create a new matrix with that row repeated 13,900 times without having to do any looping. Example: Starting Matrix: exampleMatrix 3 x 4 sparse Matrix of class "dgCMatrix" [1,] 1 . . . [2,] . 1 . 0.5 [3,] . . 1 .. New Matrix:.. newExampleMatrix 3 x 4 sparse