Displaying 20 results from an estimated 35 matches for "ndim".
Did you mean:
dim
2005 Nov 23
4
x[1,], x[1,,], x[1,,,], ...
Hi,
is there a function in R already doing what I try to do below:
# Let 'x' be an array with *any* number of dimensions (>=1).
x <- array(1:24, dim=c(2,2,3,2))
...
x <- array(1:24, dim=c(4,3,2))
i <- 2:3
ndim <- length(dim(x))
if (ndim == 1)
y <- x[i]
else if (ndim == 2)
y <- x[i,]
else if (ndim == 3)
y <- x[i,,]
else ...
and so on. My current solution is
ndim <- length(dim(x))
args <- rep(",", ndim)
args[1] <- "i"
args <- paste(args, collapse=&quo...
2007 Oct 29
1
meaning of lenwrk value in adapt function
R-listers,
In using the adapt function, I am getting the following warning:
Ifail=2, lenwrk was too small. -- fix adapt() !
Check the returned relerr! in: adapt(ndim = 2, lower = lower.limit,
upper = upper.limit, functn = pr.set,
Would someone explain what the 'lenwrk' value indicates in order to help
diagnose this issue.
Also, what are the possible codes for Ifail, so I can set some traps in
my code to handle them correctly.
I apologize for not i...
2007 Nov 02
0
applying duplicated, unique and match to lists?
...tion(i)identical(z[i],zt[pos[i]])))})
rm(x)
}
duplicated.matrix <- duplicated.array <-
function (x, incomparables = FALSE, fromLast = FALSE, MARGIN = 1, hashFUN=list, ...)
{
if (!is.logical(incomparables) || incomparables)
.NotYetUsed("incomparables != FALSE")
ndim <- length(dim(x))
if (length(MARGIN) > ndim || any(MARGIN > ndim))
stop("MARGIN = ", MARGIN, " is invalid for dim = ", dim(x))
temp <- apply(x, MARGIN, hashFUN)
d <- dim(temp)
dn <- dimnames(temp)
dim(temp) <- NULL # we had as.v...
2013 Oct 18
1
crr question in library(cmprsk)
Hi all
I do not understand why I am getting the following error message. Can
anybody help me with this? Thanks in advance.
install.packages("cmprsk")
library(cmprsk)
result1 <-crr(ftime, fstatus, cov1, failcode=1, cencode=0 )
one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2))
predict.crr(result1,cov1,X=cbind(1,one.z1,one.z2))
Error: could not find function
2002 May 30
1
problem of compile fortran program
...uot;,x,phi,n)
[[1]]
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
[[2]]
[1] 0.75
[[3]]
[1] 20
What's wrong? I don't know how to deal with it.
Any suggestions would be great appreciated.
Thanks in advance.
-------FORTRAN CODE: prog.f-------
SUBROUTINE ARSIM_(X,NDIM,PHI)
INTEGER NDIM
REAL X(NDIM),PHI
IF(NDIM.GT.1)THEN
DO 10 I=2,NDIM
X(I) = PHI*X(I-1)+X(I)
10 CONTINUE
ENDIF
RETURN
END
----------------------------
> R.version
_
platform i386-pc-mingw32
arch i386
os...
2004 May 27
1
R-1.9.0: Error in paste(ncomp, "LV's") : Argument "ncomp" is missing, with no default
Is it just my installation or bug in 1.9.0 ?
The same thing works fine in 1.8.1
Best regards,
Ryszard
# R-1.9.0
library(pls.pcr)
nr <- 8; ndim <- 2
x <- matrix(rnorm(nr*ndim), nrow=nr)
y <- as.matrix(x[,1])
for (i in 2:ndim) y <- y + x[,i]
y <- y + rnorm(length(y))
m <- pls(x,y,validation='CV')
# Error in paste(ncomp, "LV's") : Argument "ncomp" is missing, with no
default
2011 Mar 27
1
run function on subsets of matrix
I was wondering if it is possible to do the following in a smarter way.
I want get the mean value across the columns of a matrix, but I want
to do this on subrows of the matrix, given by some vector(same length
as the the number of rows). Something like
nObs<- 6
nDim <- 4
m <- matrix(rnorm(nObs*nDim),ncol=nDim)
fac<-sample(1:(nObs/2),nObs,rep=T)
##loop trough different 'factor' levels
for (i in unique(fac))
print(apply(m[fac==i,],2,mean))
Now, the problem is that if a value in 'fac' only occurs once, the
'apply' fun...
2012 Aug 28
4
[ncdf4] error converting GEIA data to netCDF
...t(global.emis.mx),
> + start=c(1, 1, 1),
> + count=c(-1,-1, 1)) # -1 -> all data
When I try to *pull* the data *from* the netCDF I created,
> > target.data <- ncvar_get(
> + nc=netcdf.file,
> + varid=emis.var,
> + # read all the data
> + start=rep(1, emis.var$ndims),
> + # count=rep(-1, emis.var$ndims))
I get
> Error in if (nc$var[[li]]$hasAddOffset) addOffset = nc$var[[li]]$addOffset else addOffset = 0 :
> argument is of length zero
And I get the same error if I try the minor variation(s)
> target.data <- ncvar_get(
+ nc=netcdf.file...
2008 Mar 12
1
Problem when calling FORTRAN subroutine (dll)
...hanks in advance for any help I can receive. I am not god with FORTRAN - very very infrequent FORTRAN user. I am using R 2.4.0.
Regards
Krishna.
> rm(list=ls(all=TRUE))
> dyn.load("c:/smooth.dll")
> is.loaded("smooth")
[1] TRUE
> NROW<-4
> NCOL<-4
> NDIM<-4
> NCYCLE<-5
> X<-array(c(0.05,0.2,0.35,0.43,0.09,0.29,0.41,0.55,0.2,0.33,0.55,0.7,0.33,0.48,0.6,0.8))
> W<-array(rep(1.0,length(X)))
> X<-matrix(X,nrow=4,ncol=4)
> X<-t(X)
> W<-matrix(W,nrow=4,ncol=4)
> A<-array(0,dim=c(NROW,NCOL,4))
> B<-array(...
2011 Dec 15
3
From Distance Matrix to 2D coordinates
Dear All,
I am struggling with the following problem: I am given a NxN symmetric
matrix P ( P[i,i]=0, i=1...N and P[i,j]>0 for i!=j) which stands for the
relative distances of N points.
I would like use it to get the coordinates of the N points in a 2D
plane. Of course, the solution is not unique (given one solution, I can
translate or rotate all the points by the same amount and generate
2012 Jan 05
1
[ncdf] programmatically copying a netCDF file
How to programmatically (i.e., without no or minimal handcoding) copy
a netCDF file? (Without calling
> system("cp whatever wherever")
:-) Why I ask:
I need to "do surgery" on a large netCDF file (technically an I/O API
file which uses netCDF). My group believes a data-assimilation error
caused a data variable to be corrupted in a certain way, so I'm going
to
2009 Sep 27
3
Teach me how to transpose in R
...excel is 16383, this cvs file doesn't show
all data. Obviously, I need to transpose the matrix..
I tried to use transpose function but failed.
> bbb=t(data2)
Error in t.default(data2) : argument is not a matrix
> ccc=t(hyo)
> ccc
[1] "file has dimensions:"
Error in if (nc$ndims > 0) for (i in 1:nc$ndims) { :
argument is of length zero
Teach me how to deal with this problem.
Thank you very much.
-Hyo
[[alternative HTML version deleted]]
2007 Mar 28
1
warnings on adapt
...why it is giving the following warnings:
At the beginning:
Warning: a final empty element has been omitted
the part of the args list of 'c' being evaluated was:
(paste("Ifail=2, lenwrk was too small. -- fix adapt() !\n", "Check the
returned relerr!"), "Ifail=3: ndim > 20 -- rewrite the fortran code ;-)
!", "Ifail=4, minpts > maxpts; should not happen!", "Ifail=5, internal
non-convergence; should not happen!", )
When it finishes:
Warning messages:
1: Ifail=2, lenwrk was too small. -- fix adapt() !
Check the returned relerr! in:...
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
Hi,
The man page for base::unique.matrix() and base::unique.array() says
that MARGIN is expected to be a single integer. OTOH the code in charge
of checking the user supplied MARGIN is:
if (length(MARGIN) > ndim || any(MARGIN > ndim))
stop(gettextf("MARGIN = %d is invalid for dim = %d",
MARGIN, dx), domain = NA)
which doesn't really make sense.
As a consequence the user gets an obscure error message when specifying
a MARGIN that satisfies the above check but is in f...
2008 Oct 19
1
multivariate integral with ADAPT when the parameter is close to boundary
Dear All,
There is one problem I encountered when I used ADAPT to compute some
2-D integral w.r.t beta density.
For example, when I try to run the following comments:
fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))}
int.fun2<-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4)
It seems it will take very long time to run. Acturally, I stopped the
program after it was running for like 20 minutes.
I thought this might be due to the inclusion of the lower and upper in
to the integral computation, so I tried to change the...
2008 Jul 09
1
netCDF to TIFF
...cdf(nc=tg.ncdf,varid="latitude") # ditto
timearr = get.var.ncdf(nc=tg.ncdf,varid="time") # reads entire time array
targettime = julian(x=1, d=1, y=2002, origin=c(month = 1, day = 1,
year = 1950))
inds = (1:dim(timearr))
tind = inds[targettime == timearr]
ndims = tg.ncdf$var[['data']]$ndims
varsize = tg.ncdf$var[['data']]$varsize
start = c( 1, 1, tind)
count = c(varsize[1], varsize[2], 1)
# Read in data slice:
tg.data = get.var.ncdf(nc=tg.ncdf,varid="data",start,count)
tg.data[tg.data == -9999] = NA...
2003 Jul 30
6
reverse array indexing
Hi,
Suppose I have a multidimensional array:
tmp <- array(1:8, c(2,2,2))
is there a function out there that, given a one-dimensional array index,
will
return the separate indices for each array dimension?
for instance, tmp[8] is equivalent to tmp[2,2,2]. I'd like to derive the
vector (2,2,2)
from the index 8.
thanks,
Brad Buchsbaum
2011 Jul 01
4
Access only part of last dimension of table/matrix
I would like to do some operations inside a function using only one
value for the last dimension of a table/matrix:
tabfn <- function (dfrm, facvec, YN ="event"){
return( Etbl <- do.call(table, dfrm[ , c(facvec,
"event") ]) )
# just want Etbl[,,,"TRUE"] or Etbl[,, "TRUE"] or
Etbl[,"TRUE"]
}
2011 Oct 07
1
Strange behaviour with the Homals Package
...using Homals to perform categorical PCA on some survey data. The
documentation is a bit obscure, however, I followed the examples.
X is a matrix with ordinal 1-5 Likert scale entries on 24 questions from
about 2500 respondents.
So I run
X.nlpc = homals(X, rank = 1, level = "ordinal", ndim = 10)
to get the first 10 pc's (the number of dimensions is irrelevant to my
problem).
I happen to get eigenvalues in nondecreasing order and I am not sure how to
interpret this. Can someone help me?
By the way, I would also be interested in knowing if someone has ever
compared the homals so...
2004 Aug 19
0
suggesting a new feature for unique()
...62 ----
}
unique.matrix <- unique.array <-
! function(x, incomparables = FALSE , MARGIN = 1, index=FALSE, ...)
{
if(!is.logical(incomparables) || incomparables)
.NotYetUsed("incomparables != FALSE")
***************
*** 66,70 ****
args <- rep(alist(a=), ndim)
names(args) <- NULL
args[[MARGIN]] <- !duplicated(as.vector(temp))
! do.call("[", c(list(x=x), args, list(drop=FALSE)))
}
--- 67,76 ----
args <- rep(alist(a=), ndim)
names(args) <- NULL
args[[MARGIN]] <- !duplicated(as.vector(temp))
!...