Displaying 20 results from an estimated 4248 matches for "dim".
Did you mean:
did
2014 Nov 15
1
Error "promise already under evaluation ..." with function(x, dim=dim(x))
I've meant to ask the following for several years now. I understand why:
> foo <- function(x, dim=dim) { dim }
> foo(1)
Error in foo(1) :
promise already under evaluation: recursive default argument
reference or earlier problems?
gives an error, but why wouldn't/couldn't the following work?
> foo <- function(x, dim=dim(x)) { dim }
> foo(1)
Error in foo(1) :
promise alr...
2014 Nov 24
1
Error "promise already under evaluation ..." with function(x, dim=dim(x))
On Sat, Nov 15, 2014 at 1:47 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
>
> On 14/11/2014, 9:06 PM, Henrik Bengtsson wrote:
> > I've meant to ask the following for several years now. I understand why:
> >
> >> foo <- function(x, dim=dim) { dim }
> >> foo(1)
> > Error in foo(1) :
> > promise already under evaluation: recursive default argument
> > reference or earlier problems?
> >
> > gives an error, but why wouldn't/couldn't the following work?
> >
> >> foo <-...
2008 Jul 30
1
model mix problem. FALSE CONVERGENCE
...############################### Manipulation sur le fichier de
donn?es
titi <- read.table(Fic[2],header=T,sep="\t") # Lecture du fichier
Protocole
indiv <- as.character(titi[,1]) #Identifiant des
individus
Subject <- as.factor(titi[,1])
n <- dim(titi)[1] #Nb individus
toto1 <- read.table(Fic[1],header=T,sep="\t") # Lecture du fichier de
donn?es
ions <- as.character(toto1[,1]) #Identifiant des ions
## La matrice des Intensit?s
if (sum(para$checks1==c(T,F))==2) {
toto <- lo...
2023 Oct 29
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hello,
the fix of PR18612 (https://bugs.r-project.org/show_bug.cgi?id=18612)
in r85380 (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803)
caused a change in `dim<-()`. Specifically, in the past, any
`dim<-()` assignment would _always_ remove "dimnames" and "names"
attributes per help("dim"):
The replacement method changes the "dim" attribute (provided the
new value is compatible) and removes any "dimn...
2023 Oct 30
2
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
...gt;> on Sun, 29 Oct 2023 10:42:19 -0700 writes:
> Hello,
> the fix of PR18612
> (https://bugs.r-project.org/show_bug.cgi?id=18612) in
> r85380
> (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803)
> caused a change in `dim<-()`. Specifically, in the past,
> any `dim<-()` assignment would _always_ remove "dimnames"
> and "names" attributes per help("dim"):
> The replacement method changes the "dim" attribute
> (provided the new value is c...
2023 Oct 31
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hi Martin, Henrik,
I actually like this change.
Makes a lot of sense IMO that dim(x) <- dim(x) be a no-op, or, more
generally, that foo(x) <- foo(x) be a no-op for any setter/getter combo.
FWIW S4Arrays::set_dim() does that too. It also preserves the dimnames
if the right value is only adding or dropping outermost (ineffective)
dimensions:
??? > x <- array(1:6,...
2004 Oct 01
2
multiple dimensional diag()
Hi
I have two arbitrarily dimensioned arrays, "a" and "b", with
length(dim(a))==length(dim(b)). I want to form a sort of
"corner-to-corner" version of abind(), or a multidimensional version
of blockdiag().
In the case of matrices, the function is easy to write and if
a=matrix(1,3,4) and b=matrix(...
2006 Jul 27
2
Vector extracted from a matrix. How can I specify dimensions in as.matrix?
...is that uses every line (vector) of a matrix in
a loop. In the model, I need to transpose those vectors that are extracted
from a matrix.
Using simple vectors (no matrix involved) the transpose function works fine:
simplevector <-matrix(1:3,3,1)
tsimplevector <-t(simplevector) #transposed
dim(simplevector) #3x1 matrix (vector)
dim(tsimplevector)#1x3
PROBLEM: However, when the vector is extracted from a matrix, its dimension
is NULL. In this case the transposed dimension is correct, but you'll see
the next example, that if a row was extracted, the dimension would be wrong:
initi...
2005 Apr 21
2
apply vs sapply vs loop - lm() call appl(y)ied on array
...call appl(y)ied on array
Dear useRs
(Code of the now mentioned small example is below)
I have 7 * 8 * 9 = 504 series of data (each length 5). For each of
theses series I want to compute a lm(), where the designmatrx X is the
same for all these computations.
The 504 series are in an array of dimension d.dim <- c(5, 7, 8, 9)
means, the first dimension holds the data-series.
The lm computation needs performance optimization, since in fact the
dimensions are much larger. I compared the following approaches:
using a for-loop. using apply, and using sapply. All of these require
roughly t...
1999 Mar 25
1
Question about Structure
Hello,
Perhaps I am missing something here about the function structure() (Platfrm etc.
in the end?
> structure(1:6, dim= 2:3)
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
> structure(1:6, dim= 3:2)
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> structure(1:2, dim= 1:2)
[,1] [,2]
[1,] 1 2
> structure(1:2, dim= 2:1)
[,1]
[1,] 1
[2,] 2
> structure(1:3, dim...
2006 Jun 10
3
sparse matrix, rnorm, malloc
...answer to my question below.
I'm trying to generate very large sparse matrices (< 1% non-zero
entries per row). I have a sparse matrix function below which works
well until the row/col count exceeds 10,000. This is being run on a
machine with 32G memory:
sparse_matrix <- function(dims,rnd,p) {
ptm <- proc.time()
x <- round(rnorm(dims*dims),rnd)
x[((abs(x) - p) < 0)] <- 0
y <- matrix(x,nrow=dims,ncol=dims)
proc.time() - ptm
}
When trying to generate the matrix around 20,000 rows/cols on a
machine with 32G of memory,...
2005 Jan 21
6
dim vs length for vectors
Hi all,
I'm not sure if this is a feature or a bug (and I did read the
FAQ and the posting guide, but am still not sure). Some of my
students have been complaining and I thought I just might ask:
Let K be a vector of length k. If one types dim(K), you get
NULL rather than [1] k. Is this logical?
Here's the way I explain it (and maybe someone can provide a
more accurate explanation of what's going on): R has several
types of scalar (atomic) values, the most common of which are
numeric, integer, logical, and character values...
2005 Jul 07
2
Brewer colours
...ette and per number of
colours. Interpolating to more colours will loose the
distinction.
The code:
# www.colorbrewer.org
brewerSequential.PuBu <- array(data = c(
255,255,255,
255,247,251,
236,231,242,
208,209,230,
166,189,219,
116,169,207,
54,144,192,
5,112,176,
4,90,141,
2,56,88),
dim = c(3, 10))
brewerSequential.YlGnBl <- array(data = c(
255,255,255,
255,255,217,
237,248,177,
199,233,180,
127,205,187,
65,182,196,
29,145,192,
34,94,168,
37,52,148,
8,29,88),
dim = c(3, 10))
brewerSequential.GnBu <- array(data = c(
255,255,255,
247,252,240,
224,243,219,
204,235,197,
168,22...
2005 May 07
4
how to add method to .Primitive function
Hi,
I tried to write the dim method for the list class, but R doesn't seem
to dispatch to it:
> dim.list = function(x) c(length(x[[1]]), length(x))
> dim(list(1))
NULL
> dim.list(list(1))
[1] 1 1
What is the correct way of registering dim.list with .Primitive("dim")?
Thanks,
Vadim
[[alternative...
2012 Oct 23
1
[LLVMdev] Clang fails to compile template with dependendent Non type template parameter.
Hi All,
I'm trying to compile the following code on clang-
template <int dim> class X {};
template <class T> struct Y {
static const unsigned int dim = 1 ;
template <class U> X<Y<T>::dim> f();
};
template <class T> template <class U>
X<Y<T>::dim> Y<T>::f() { return X<dim>(); }
int main()
{
Y<int>()...
2010 Oct 21
4
Efficient nested loops
Dear R community,
I am working with huge arrays, so I spend a lot of time computing. This is
my code:
for (x in 1:dim(variable)[1]){
for (y in 1:dim(variable)[2]){
for (z in 1:dim(variable)[3]){
result <- max(variable[x,y,z,])
}
}
}
Is there a more efficient procedure to do this task?
Thanks in advance!
[[alternative HTML version deleted]]
2012 Oct 16
2
Penalty function constrained optimization
Hi All,
I am trying to use optim() to minimize a function with a penalty function
term. This is a simple model bioeconomic model of a fishery. The penalty
function constrains the amount of effort (f) at 9. This works fine. The code
is:
**********
nfleets<-2
M<-1
M<-array(M,dim=c(nfleets))
N<-1000
cost<-c(30,30)
cost<-array(cost,dim=c(nfleets))
Price<-2
Price<-array(Price,dim=c(nfleets))
q<-array(0.1,dim=c(nfleets))
f<-1
f<-array(f,dim=c(nfleets))
f1<-f[1]
f2<-f[2]
init.eff<-array(8,dim=c(nfleets))
OF<-c(q*f)
F<- sum(q*f)
Z<-M+F
C...
2017 Feb 09
2
[Release-testers] [4.0.0 Release] Release Candidate 2 has been tagged
On Thu, Feb 9, 2017 at 2:23 PM, Dimitry Andric <dimitry at andric.com> wrote:
> On 9 Feb 2017, at 01:33, Hans Wennborg via Release-testers <release-testers at lists.llvm.org> wrote:
>>
>> 4.0.0-rc2 was just tagged from the branch at r294535.
>
> Building on FreeBSD 10 at least didn't crash this ti...
2018 Aug 31
2
Argument 'dim' misspelled in error message
Hi,
The following error message misspells the name of
the 'dim' argument:
> array(integer(0), dim=integer(0))
Error in array(integer(0), dim = integer(0)) :
'dims' cannot be of length 0
The name of the argument is 'dim' not 'dims':
> args(array)
function (data = NA, dim = length(data), dimnames = NULL)
N...
2008 Sep 10
1
Return dimension index from array with n-dimensions
Hi,
I have been dealing with some problems finding a fast way of getting to
know in what dimension a specific value is located out of an array (like
the 'which' function for a vector returns its position).
Unable to find anything about this on the internet I wrote a function
myself.
Could you please comment if such a function already exists, and if not,
please feel free to commen...