search for: wh

Displaying 20 results from an estimated 253 matches for "wh".

Did you mean: hw
2004 Sep 24
3
Error with repeat lines() in function
...xecute 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 function(x,annot,rat1,rat2,rf,...) { par(las=2) wh <- which(annot[,5]==x) xmax <- max(annot[wh,4]) xmin <- min(annot[wh,3]) chr <- annot[wh,2][1] wh.rf <- rf$chrom==as.character(chr) & rf$txStart>xmin & rf$txEnd<xmax par(mfrow=c(2,1)) plot(annot[wh,3],rat1[wh],type="l",xlab=&quo...
2012 Dec 14
1
format.pval () and printCoefmat ()
...gives me the desired results, but coerces the character string into NAs for the two character variables, because my object is a data frame, not a matrix. Please see the first output below: contrast_level1 contrast_level2). Is there a way I could have avoid printing the NAs in the character fields when using the format.pval () and printCoefmat () on the data frame? I would appreciate receiving your help. Thanks, Pradip setwd ("F:/PR1/R_PR1") load (file = "sigtests_overall_withid.rdata") #format.pval(tt$p.value, eps=0.0001) # keep only selected columns from the above da...
2008 Jul 11
1
Suggestion: 20% speed up of which() with two-character mod
Hi, by replacing 'll' with 'wh' in the source code for base::which() one gets ~20% speed up for *named logical vectors*. CURRENT CODE: which <- function(x, arr.ind = FALSE) { if(!is.logical(x)) stop("argument to 'which' is not logical") wh <- seq_along(x)[ll <- x & !is.na(x)] m &...
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,}', as.character(netw[,i])) res[i] <- substring(as.character(netw[,i]), wh, wh + attr(wh,'match.length')-1) }   the problem is that I cannot manage to extr...
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...
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 example seems to imply that > a and b must be of the same...
2017 Aug 06
2
data frame question
Dear All, wonder if you have thoughts on the following: let us say we have: df<-data.frame(a=c(1,2,3,4,5,1,2,3,4,5,6,7,8),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7)) I would like to rewrite values in column name "a" based on values in column name "b", where based on a certain value of column "b" the next value of column 'a' is prompted, in other words would like to have this as a result: df<-data.frame(a=c(1,1,1,1,1,2,2,2,2,2,2,2,2),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7)) where at the value of 0 in column 'b' the number in...
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 which(names(somevar) == "somestring") with 0 I'll get Error in length(...
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 (arr.ind &amp...
2017 Jun 01
3
Reversing one dimension of an array, in a generalized case
...ch 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 <- setdiff(dims, wh) apply(apply(a, dims, rev), dims, t) } # Your example j1 <- junk[ , rev(1:10), ] j2 <- f2(junk, 2) all.equal(j1, j2) # [1] TRUE # Bert's example z1 <- f(z, 2) z2 <- f2(z, 2) all.equal(z1, z2) # [1] TRUE...
2005 Nov 12
3
net rpc vampire - cannot login to migrated computer accounts
...main, login works. (But this is not an option for our ~500 maschines...) I have looked at the computer account of one maschine after the migration and after I rejoined the domain manually. There's a difference: after "net rpc vampire" migration: dn: uid=BIT59$,ou=computers,dc=uni-wh,dc=de objectClass: top objectClass: inetOrgPerson objectClass: posixAccount objectClass: sambaSamAccount cn: BIT59$ sn: BIT59$ uid: BIT59$ uidNumber: 22693 gidNumber: 515 homeDirectory: /dev/null loginShell: /bin/false description: Computer gecos: Computer structuralObjectClass: inetOrgPerson entry...
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...
1999 Jul 15
1
which() does not handle NAs in named vectors. (PR#226)
...is2.6 system = sparc, solaris2.6 status = status.rev = 0 major = 0 minor = 64.2 year = 1999 month = July day = 3 language = R -- It is unclear to me that the handling of NAs is desirable, and it has problems with names: > z <- c(T,T,NA,F,T) > names(z) <- letters[1:5] > which(z) Error: names attribute must be the same length as the vector (Why do the vector and its names have different subscripts? And while you are correcting this, Arguments: x: a logical vector or array. `NA's are allowed an omitted. has a typo, and the logic can b...
2017 Jun 01
0
Reversing one dimension of an array, in a generalized case
...ual(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 "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 Thu, Jun 1, 2017 at 11:34 AM, David L Carlson <dcarlson at...
2006 Aug 22
1
Total (un)standardized effects in SEM?
Hi there, as a student sociology, I'm starting to learn about SEM. The course I follow is based on LISREL, but I want to use the SEM-package on R parallel to it. Using LISREL, I found it to be very usable to be able to see the total direct and total indirect effects (standardized and unstandardized) in the output. Can I create these effects using R? I know how to calculate them
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 to ask such questions. R is open source, so just look! > which function (x, arr.ind = FALSE, useNames = TRUE) { wh <- .Internal(which(x)) ## C code if (arr.ind && !is.null...
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 all.equal(f(z, 3), f2(z, 3)) # [1] TRUE all.equal(f(z, 4), f2(z...
2007 Nov 19
5
Howto modify samba printer ACLs without Windows?
Hi all, I would like to limit access to our samba shared printers to certain user groups by commandline without using Windows. Is this possible? Thanks! Christoph
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 after is a general function that will do that where the array could be two, three or four dimensions, and I pass to the function which dimension...
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] = junk1[1,9,1] > > etc. > > The genesis of this is the program is do...