Displaying 7 results from an estimated 7 matches for "nfdisco".
Did you mean:
disco
2011 Nov 01
4
building a subscript programatically
Hi,
On ocasion, you need to subscript an array that has an arbitrary
(ie. not known in advance) number of dimensions. How do you deal with
these situations?
It appears that it is not possible use a list as an index, for
instance this fails:
> x <- array(NA, c(2,2,2))
> x[list(TRUE,TRUE,2)]
Error in x[list(TRUE, TRUE, 2)] : invalid subscript type 'list'
The only way I know is
2011 Nov 23
1
how to stack a list of arrays
Hello,
I have this list of 2-d arrays:
$`0`
k d
[1,] 0.2011962 4.019537
[2,] 0.2020706 5.722719
[3,] 0.2029451 7.959612
$`1`
k d
[1,] 0.3148325 2.606903
[2,] 0.3160287 3.806665
[3,] 0.3172249 5.419222
$`2`
k d
[1,] 0.2332536 4.949390
[2,] 0.2342188 7.115258
[3,] 0.2351840 9.955909
which I need to transform into a data frame like this
2012 Feb 08
3
R equivalent of Python str()?
Hi,
I was wondering if there's a function in R that is meant to return a
string representation of an object. Basically, it's like print() but
it doesn't print anything, it only returns a string.
I know there's a str() function but it's not quite the same. I mean a
function that returns the same string that print() would display.
--
Bye,
Ernest
2012 Jan 31
1
dimensions dropped on assignment
Hi there,
This is a problem I've run into and do not know how to avoid. It
happens when I make an assignment using the dimension names as the
subscript of the array. The end result is a dimenensionless array
(i.e. a vector) which I don't want. See:
> out <- array(0, 5, list(1:5))
> dim(out)
[1] 5
> out[names(out)] <- 1
> dim(out)
NULL
I tried to include a
2011 Aug 15
1
accumulative grouping of time series
HI there,
Consider a data set like this:
> x <- data.frame(a=1:10, b=11:20, t=c(1,1,1,2,2,2,3,3,3,3))
> x
a b t
1 1 11 1
2 2 12 1
3 3 13 1
4 4 14 2
5 5 15 2
6 6 16 2
7 7 17 3
8 8 18 3
9 9 19 3
10 10 20 3
Here x$t is a vector of integers that represent a moment
in time. I would like to calculate a function of a & b at
each moment (t0), but using the rows
2011 Feb 03
3
get caller's name
Hi,
Suppose a function that checks an object:
stop.if.dims <- function(x) {
if (! is.null(dim(x))) {
stop("cannot handle dimensional data")
}
}
This would be used by other functions that can only work with
dimensionless objects. The problem is the error message would need to
include the name of the function that called stop.if.dims, so that the
user knows which function got
2011 Jan 28
3
sapply puzzlement
Hi,
I have this data.frame with two variables in it,
> z
V1 V2
1 10 8
2 NA 18
3 9 7
4 3 NA
5 NA 10
6 11 12
7 13 9
8 12 11
and a vector of means,
> means <- apply(z, 2, function (col) mean(na.omit(col)))
> means
V1 V2
9.666667 10.714286
My intention was substracting means from z, so instictively I tried
> z-means
V1 V2
1 0.3333333