Displaying 20 results from an estimated 900 matches similar to: "Suggestion: 20% speed up of which() with two-character mod"
2012 Dec 14
1
format.pval () and printCoefmat ()
Hi List,
My goal is to force R not to print in scientific notation in the sixth column (rel_diff - for the p-value) of my data frame (not a matrix).
I have used the format.pval () and printCoefmat () functions on the data frame. The R script is appended below.
This issue is that use of the format.pval () and printCoefmat () functions on the data frame gives me the desired results, but coerces
2004 Sep 24
3
Error with repeat lines() in function
I have a function that does some plotting. I then add lines to the
plot. If executed one line at a time, there is not a problem. If I
execute the function, though, I get:
Error in ans[[1]] : subscript out of bounds
This always occurs after the second lines command, and doesn't happen
with all of my data points (some do not have errors). Any ideas?
Thanks,
Sean
2017 Aug 06
0
data frame question
Your specification is a bit unclear to me, so I'm not sure the below
is really what you want. For example, your example seems to imply that
a and b must be of the same length, but I do not see that your
description requires this. So the following may not be what you want
exactly, but one way to do this(there may be cleverer ones!) is to
make use of ?rep. Everything else is just fussy detail.
2017 Aug 06
1
data frame question
Hi Andreas,
assuming that the increment is always indicated by the same value (in your
example 0), this could work:
df$a <- cumsum(seq_along(df$b) %in% which(df$b == 0))
df
HTH,
Ulrik
On Sun, 6 Aug 2017 at 18:06 Bert Gunter <bgunter.4567 at gmail.com> wrote:
> Your specification is a bit unclear to me, so I'm not sure the below
> is really what you want. For example, your
2013 Jan 13
3
extracting character values
Dear all,
I have a dataframe of names (netw), with each cell including last name and initials of an author; some cells have NA. I would like to extract only the last name from each cell; this new dataframe is calle 'res'
Here is what I do:
res <- data.frame(matrix(NA, nrow=dim(netw)[1], ncol=dim(netw)[2]))
for (i in 1:x)
{
wh <- regexpr('[a-z]{3,}',
2012 Nov 15
3
how to view source code of a function inside a package?
Dear list,
I am trying to look at the function inside a package. I know that
methods() would do the trick, but what if the function is hidden? I have a
problem displaying the hidden function.
Say, for example the MCMC package. How do you view the code of that
function?
something like this:
> which
function (x, arr.ind = FALSE, useNames = TRUE)
{
wh <- .Internal(which(x))
if
2005 Nov 12
3
net rpc vampire - cannot login to migrated computer accounts
Hello experts,
I've migrated our NT4 domain to sambe 3.0.20b/ldap backend with "net rpc
vampire", and nearly everything works as expected. But one big problem
remains: it's not possible to login to the domains member maschines now,
because "the domain is not available at the moment" (translated from
german). After the maschine rejoined the samba domain, login
2008 Jul 03
0
[LLVMdev] Plans considering first class structs and multiple return values
> For example, this:
>
> %t0 = insertvalue { i32, i32 } undef, i32 %a, 0
> %t1 = insertvalue { i32, i32 } %t0, i32 %b, 1
>
> creates the value with %a and %b as member values.
Is there anyway to do it using the C++ API? It seems I need an
instance of the aggregate type to pass into InsertValueInst::Create().
What is the API equivalent of "undef"?
Marc
On Wed,
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
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 Aug 24
5
functions from 'base' package are not accessible
Hi all!
The following code (executed in console)...
somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 = 16:20);
somevar %>% gather(key = var, value = val, which(names(somevar) == "somestring"):length(somevar)) %>% head(2);
throws...
Error in which(names(somevar) == "somestring") :
could not find function "which"
if I change
2020 Oct 14
0
which() vs. just logical selection in df
Inline.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Wed, Oct 14, 2020 at 3:23 PM 1/k^c <kchamberln at gmail.com> wrote:
Is which() invoking c-level code by chance, making it slightly faster
> on average?
>
You do not need
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 Aug 24
0
functions from 'base' package are not accessible
Try putting !!! (three exclamation symbols) in front of which(...)==....
The non-standard evaluation in the tidyverse can cause confusion.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Aug 24, 2017 at 4:32 AM, Eugeny Melamud <
Eugeny.Melamud at lanit-tercom.com> wrote:
> Hi all!
>
> The following code (executed in console)...
> somevar <- data.frame(v1 = 1: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
2008 Jul 02
3
[LLVMdev] Plans considering first class structs and multiple return values
Hello,
The basic infrastructure is in place. You can create first-class
structs/arrays using sequences of insertvalue.
For example, this:
%t0 = insertvalue { i32, i32 } undef, i32 %a, 0
%t1 = insertvalue { i32, i32 } %t0, i32 %b, 1
creates the value with %a and %b as member values. Other ways to
produce aggregate values are loads, function arguments, function
return values, and literal
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)
>
2007 Oct 23
2
winbind nss info = rfc2307 doesn't work when users not in "Users" Container?
Hi all,
we have been using a samba setup with samba being an AD member, idmap
backend = ad and winbind nss info = rfc2307 for several month without
problems yet.
But it turns out now that we cannot move useraccounts in AD from the
original location
"CN=Users,dc=uni-wh,dc=de"
to a newly created OU
"OU=uwhusers,dc=uni-wh,dc=de"
because winbind doesn't get correct values
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