Displaying 20 results from an estimated 1000 matches similar to: "Return dimension index from array with n-dimensions"
2010 Aug 09
1
build.pl in building library with Rtools211
Dear all,
As I couldn't find any thread on the internet I hope the help-list might help me out.
I've tried to update Rtools from R210 used in combination with R2.9.1 to R211 in combination with R2.11.1. However, I do not succeed.
I have R2.11.1 running, as well as Inno Setup 5, HTML help and MikTex. A version of Perl is installed too. Environment variable paths are set to link to these
2012 Dec 13
3
Repeat elements of matrix based on vector counts
I have two dataframes (df) that share a column header ("plot.id"). In the
1st df, "plot.id" records are repeated a variable number of times based on
the number of trees monitored within each plot. The 2nd df only has a
single record for each "plot.id", and contains a variable named "load" that
is collected at the plot-level and is only listed once per plot
2012 Jan 02
1
Display warning when embedded data file is loaded
Dear all,
I would like to show a warning when a data file, that is embedded in the package, is loaded. I have so far not been able to find any manual or mailing list going on about that.
In code example:
library("myPackage")
data("myData")
# Now I want a warning containing info about this loaded 'myData' file
It would be great if someone could indicate if this is
2012 Mar 21
1
nlme error on dimensions in multiplication
Hello R users,
When trying to fit a nonlinear mixed model to a respiration time series,
I get the following error message:
Error in recalc.varFunc(object[[i]], conLin) :
dims [product 30] do not match the length of object [34]
In addition: Warning message:
In conLin$Xy * varWeights(object) :
longer object length is not a multiple of shorter object length
Below is an example that generates
2017 Jun 01
0
Reversing one dimension of an array, in a generalized case
??
> z <- array(1:24,dim=2:4)
> all.equal(f(z,3),f2(z,3))
[1] "Attributes: < Component ?dim?: Mean relative difference: 0.4444444 >"
[2] "Mean relative difference: 0.6109091"
In fact,
> dim(f(z,3))
[1] 2 3 4
> dim(f2(z,3))
[1] 3 4 2
Have I made some sort of stupid error here? Or have I misunderstood
what was wanted?
Cheers,
Bert
Bert Gunter
2017 Jun 01
3
Reversing one dimension of an array, in a generalized case
Here is an alternative approach using apply(). Note that with apply() you are reversing rows or columns not indices of rows or columns so apply(junk, 2, rev) reverses the values in each column not the column indices. We actually need to use rev() on everything but the index we are interested in reversing:
f2 <- function(a, wh) {
dims <- seq_len(length(dim(a)))
dims <-
2017 Jun 01
0
Reversing one dimension of an array, in a generalized case
On the off chance that anyone is still interested, here is the corrected function using aperm():
z <- array(1:120,dim=2:5)
f2 <- function(a, wh) {
idx <- seq_len(length(dim(a)))
dims <- setdiff(idx, wh)
idx <- append(idx[-1], idx[1], wh-1)
aperm(apply(a, dims, rev), idx)
}
all.equal(f(z, 1), f2(z, 1))
# [1] TRUE
all.equal(f(z, 2), f2(z, 2))
# [1] TRUE
2017 Jun 01
0
Reversing one dimension of an array, in a generalized case
Thanks to all for responses/. There was a question of exactly what was wanted. It is the generalization of the obvious example I gave,
>>> junk1 <- junk[, rev(seq_len(10), ]
so that
junk[1,1,1 ] = junk1[1,10,1]
junk[1,2,1] = junk1[1,9,1]
etc.
The genesis of this is the program is downloading data from a variety of sources on (time, altitude, lat, lon) coordinates, but all
2017 Jun 01
2
Reversing one dimension of an array, in a generalized case
My error. Clearly I did not do enough testing.
z <- array(1:24,dim=2:4)
> all.equal(f(z,1),f2(z,1))
[1] TRUE
> all.equal(f(z,2),f2(z,2))
[1] TRUE
> all.equal(f(z,3),f2(z,3))
[1] "Attributes: < Component ?dim?: Mean relative difference: 0.4444444 >"
[2] "Mean relative difference: 0.6109091"
# Your earlier example
> z <- array(1:120, dim=2:5)
>
2017 Jun 01
1
Reversing one dimension of an array, in a generalized case
Thanks again. I am going to try the different versions. But I probably won't be able to get to it till next week.
This is probably at the point where anything further should be sent to me privately.
-Roy
> On Jun 1, 2017, at 1:56 PM, David L Carlson <dcarlson at tamu.edu> wrote:
>
> On the off chance that anyone is still interested, here is the corrected function using
2006 Jan 10
2
Correct way to test for exact dimensions of matrix or array
Dear R Users,
I want to test the dimensions of an incoming vector, matrix or array safely
and succinctly. Specifically I want to check if the unknown object has
exactly 2 dimensions with a specified number of rows and columns.
I thought that the following would work:
> obj=matrix(1,nrow=3,ncol=5)
> identical( dim( obj) , c(3,5) )
[1] FALSE
But it doesn't because c(3,5) is numeric
2008 Jul 11
1
Subsetting an array by a vector of dimensions
Hi
Is it possible to subset an n-dimensional array by a vector of n dimensions? E.g. assume I have
> x <- array(1:24, dim=2:4)
> x[1,1,2]
[1] 7
> dims <- c(1,1,2)
I would like a function that I can supply x and dims as parameters to, and have it return 7. Also, I would like to do something like:
> x[1,1,]
[1] 1 7 13 19
> dims2<- c(1,1,NA)
And have a function of x and
2000 Aug 29
1
Making a share visible only to members of a group
Hi,
> I want a shared directory to be visible only to the members of a group, and
> to no one else. Instead, a shared directory is either visible to everyone
I tried to realize this by using include like: #include smb.conf.%G
But it did not work correctly. Sometimes the share was visible,
sometimes it wasnt,
and if it was visible, network path wasnt found afterwards.
> I have worked
2017 Jun 01
3
Reversing one dimension of an array, in a generalized case
> On 1 Jun 2017, at 22:42, Roy Mendelssohn - NOAA Federal <roy.mendelssohn at noaa.gov> wrote:
>
> Thanks to all for responses/. There was a question of exactly what was wanted. It is the generalization of the obvious example I gave,
>
>>>> junk1 <- junk[, rev(seq_len(10), ]
>
>
> so that
>
> junk[1,1,1 ] = junk1[1,10,1]
> junk[1,2,1] =
1998 Sep 04
0
Linux SMB Mount utils patch
Hi,
I'm sure that you are all aware that the mount utilities that ship
with samba are designed to compile and run only with Linux 2.1 series
development kernels.
I'll _try_ keep this short and sweet while doing my best to
explain what I have done, since I have a tendancy to ramble on. I
have two boxes, one Linux with libc5, and another with Linux and Glibc2
(aka libc6). The Samba
2017 Jun 01
0
Reversing one dimension of an array, in a generalized case
How about this:
f <- function(a,wh){ ## a is the array; wh is the index to be reversed
l<- lapply(dim(a),seq_len)
l[[wh]]<- rev(l[[wh]])
do.call(`[`,c(list(a),l))
}
## test
z <- array(1:120,dim=2:5)
## I omit the printouts
f(z,2)
f(z,3)
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into
2017 Jun 01
5
Reversing one dimension of an array, in a generalized case
Hi All:
I have been looking for an elegant way to do the following, but haven't found it, I have never had a good understanding of any of the "apply" functions.
A simplified idea is I have an array, say:
junk(5, 10, 3)
where (5, 10, 3) give the dimension sizes, and I want to reverse the second dimension, so I could do:
junk1 <- junk[, rev(seq_len(10), ]
but what I am
2012 Nov 15
1
bug with mapply() on an S4 object
Hi,
Starting with ordinary vectors, so we know what to expect:
> mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2))
[1] 101 204 309 104 210 318
> mapply(function(x, y) {x * y}, 101:106, 1:3)
[1] 101 204 309 104 210 318
Now with an S4 object:
setClass("A", representation(aa="integer"))
a <- new("A", aa=101:106)
> length(a)
2012 May 09
0
Error in outer() : dimension mismatch
Dear R users,
I am a new R user and have some difficulty
understanding the functioning of “outer”, where my question is from. I have
read the posts related to the questions on the outer function, but
unfortunately could not figure out where my mistake is.
I have a function with two variables and
three parameters (a density function that is not standard) and I want to draw
the contourplot along
2006 Apr 07
4
reading mpeg4 dimensions and flv dimension using ruby
Hey guyz,
Well basically what i am trying to do is get ruby to read my video files
in so that i can get the dimensions of the video and then place the
dimension sizes in my view. The two formats i need to do this with are
mpeg4 (h.264) and FLV. Is there anyway i can get rails to access the
metadata of these formats and pull the dimensions from the metadata? Any
help would be greatly