similar to: Newbie: colSums() compared with Matlab's sum()

Displaying 20 results from an estimated 1000 matches similar to: "Newbie: colSums() compared with Matlab's sum()"

2009 Dec 28
2
2D array of strings
Sorry for the dumb question, but I couldn't figure this out myself. Consider the following: > str <- c("abc","def") > array(str, c(2,1)) [,1] [1,] "abc" [2,] "def" How can i obtain the outcome of the second instruction without specifying the number of rows? Thank you in advance, Francesco.
2009 May 27
3
Neural Network resource
Hi All, I am trying to learn Neural Networks. I found that R has packages which can help build Neural Nets - the popular one being AMORE package. Is there any book / resource available which guides us in this subject using the AMORE package? Any help will be much appreciated. Thanks, Indrajit
2008 Jun 05
2
Securities earning covariance
Good morning, I am a new R user and I am trying to learn how to use it. I am trying to solve this problem. I have a dataframe df of daily securities (for a year) earnings as follows: SEC_ID DAY EARNING IT0000001 20070101 5.467 IT0000001 20070102 5.456 IT0000001 20070103 4.954 IT0000001 20070104 3.456 .......................... IT0000002 20070101 1.456 IT0000002 20070102 1.345
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi, I have a matrix, say m=matrix(c( 983,679,134, 383,416,84, 2892,2625,570 ),nrow=3 ) i can find its row/col sum by rowSums(m) colSums(m) How do I divide each row/column by its rowSum/colSums and still return in the matrix form? (i.e. the new rowSums/colSums =1) Thanks. Casper -- View this message in context:
2005 Apr 21
1
colSums and rowSums with arrays - different classes and dim ?
Hi, I'm using colSums and rowSums to sum the first dimensions of arrays. It works ok but the resulting object is different. See > a3d <- array(rnorm(120, mean=2), dim=c(20,6,1)) > dim(colSums(a3d)) [1] 6 1 > dim(rowSums(a3d)) NULL > class(colSums(a3d)) [1] "matrix" > class(rowSums(a3d)) [1] "numeric" I was expecting rowSums to preserve the array
2009 Nov 30
2
command similar to colSums for rowSums?
Working with an NxMxO sized matrix, currently I can do this in my code: if (max(colSums(array)) >= number) But to get an equivalent result using rowSums, I have to do: for (i in 1:10) { if (max(rowSums(array[,,i])) >= number) } I'm running both in a much larger loop that loops millions of times, so speed and such is quite a big factor for me. Currently, the colSums line uses about
2002 Jan 07
0
New package: colSums
I've uploaded a package colSums_1.0.tar.gz to CRAN /src/contrib/Devel. It contains functions colSums, colMeans, colVars, colStdevs, rowSums, rowMeans, rowVars, and rowStdevs. These do simple, fast arithmetic on columns/rows of a matrix, or more generally across dimensions of an array, e.g. colSums(m) = apply(m, 2, sum) but faster. They should be compatible with the corresponding S-Plus
2001 Jul 18
1
colSums
As best I understand it, colSums (and associated functions) in S+ 6 are optimized functions (calling special C routines) for doing simple matrix math. For example, it seems like (in S+): all.equal(colSums(m), apply(m, 2, sum)) should be TRUE for any matrix m. It also seems like colSums (and its brethren) are very fast. My question: Are there equivalents to colSums in R? Thanks, Dave Kane
2003 Feb 13
1
colSums etc. documentation (PR#2545)
For your consideration: > z [,1] [,2] [1,] 1 NA [2,] 2 NA [3,] 3 NA > colSums(z) [1] 6 NA Correct, according to the documentation > colSums(z,na.rm=T) [1] 6 0 Surprising to me, but, as documented, correctly consistent with apply() and >sum(NULL) [1] 0 The documentation for sum() explicitly notes that the sum of an empty set is 0 by definition, so that users
2003 Sep 14
1
Documentation of colSums et. al (PR#4154)
Full_Name: Doug Grove Version: 1.7.0 OS: Linux Submission from: (NULL) (209.31.211.56) Hi, Minor mistake in the documentation on the colSums page. In the ARGUMENTS section it states for 'dims' that: For `col*', the sum or mean is over dimensions `dims+1, ...'; for `row*' it is over dimensions `1:dims'. These two are reversed. Thanks, Doug Grove
2005 Jun 24
3
Counterpart for Matlab's 'feval'?
Hi! I've just begun writing a program that searches for the minimum of a function with golden section search. In order to do this in a nice way I need a function that takes a function name and an argument and returns the function value for that argument, i .e just like Matlab's 'feval'. Is there any? Thanks before hand! Best regards, Fredrik Thuring, Codan Insurance A/S
2001 Dec 14
2
colSums in C
Hi, all! My project today is to write a speedy colSums(), which is a function available in S-Plus to add the columns of a matrix. Here are 4 ways to do it, with the time it took (elapsed, best of 3 trials) in both R and S-Plus: m <- matrix(1, 400, 40000) x1 <- apply(m, 2, sum) ## R=16.55 S=52.39 x2 <- as.vector(rep(1,nrow(m)) %*% m) ## R= 2.39 S= 8.52 x3 <-
2007 May 07
1
looking for equivalent of matlab's medfilt1 function
Dear all, I have several files with Matlab code, which I am translating to R. For the zero-level approach, I took the very old shell script from R-help archives, which has made some obvious leg-work such as replacement of "=" with "<-". Now I am translating indexing, matrix operations and function call using this table http://37mm.no/mpy/octave-r.html The problem is, I
2009 Mar 10
2
R equivalent to MATLAB's "whos" Command?
  By any chance is there an R equivalent to MATLAB's "whos" command?   I tried searching R and R-seek, but didn't really come up with anything.    There are several items I would like to make sure are stored in the workspace and check their values.   Thank you again for your help and any feedback.     > ?workspace No documentation for 'workspace' in specified
2006 Jun 12
1
r's optim vs. matlab's fminsearch
Hi, I'm having a problem converting a Matlab program into R. The R code works almost all the time, but about 4% of the time R's optim function gets stuck on a local minimum whereas matlab's fminsearch function does not (or at least fminsearch finds a better minimum than optim). My understanding is that both functions default to Nelder-Mead optimization, but what's different about
2020 Oct 09
1
Help using the exclude option in the neuralnet package
Good Morning, I am using the neuralnet package in R, and am able to produce some basic neural nets, and use the output. I would like to exclude some of the weights and biases from the iteration process and fix their values. However I do not seem to be able to correctly define the exclude and constant.weights vectors. Question: Can someone point me to an example where exclude and
2007 Sep 07
2
Matlab's lsqnonlin
Hi! I'm translating some code from Matlab to R and I found a problem. I need to translate Matlab's function 'lsqnonlin' (http://www-ccs.ucsd.edu/matlab/toolbox/optim/lsqnonlin.html) into R, and at the beginning I thought it would be the same as R's 'optim'. But then I looked at the definition of 'lsqnonlin' and I don't quite see how to make
2001 Sep 22
2
Finding a 3D convex hull in R
Dear List Members, I'm presently carrying out morphological analysis of a data set of neuronal structures. These are essentially 3D binary trees. In due course I will be trying to use discriminant analysis or other methods to classify these neurons based on morphological variables such as total tree length, segment number etc. I would like to calculate a 3D convex hull for a set of X,Y,Z
2012 Mar 01
3
how to change or copy to another the names of models
Hi I would like to know how I can change the name of a model for each trainning cycle of a model. I work with the RSNNS package and to build a neural network, I used : for (i in 5:30) .... model_ANN <- mlp(X, Y, size=n,....) # where size is the number of neurons in the hidden layer but I need to save each time that the model that is build (the end of each cycle), e.g., when i = 5, I need to
2012 Dec 22
4
Does R have an equivalent for Matlab's cell array?
Hi I have a time series of measurements: every 10 min. a value was logged. The data look like: 20100914 08:01 3.74 20100914 08:11 3.74 20100914 08:21 3.71 20100914 08:31 4.39 20100914 08:41 3.74 This data spans several months. I would like to group the data per day. In Matlab it is fairly easy to obtain a cell array, of which the first column contains the date of each