similar to: Efficient swapping

Displaying 20 results from an estimated 20000 matches similar to: "Efficient swapping"

2017 Jul 06
3
Efficient swapping
Thanks a lot, Ista! I really appreciate it. How about a slightly different case as the following: set.seed(1) (tmp <- data.frame(x = 1:10, R1 = sample(LETTERS[1:5], 10, replace = TRUE), R2 = sample(LETTERS[2:6], 10, replace = TRUE))) x R1 R2 1 C B 2 B B 3 C E 4 E C 5 E B 6 D E 7 E E 8 D F 9 C D 10 A E Notice that the factor levels between
2017 Jul 06
0
Efficient swapping
Untested, but I expect that setting the levels to be the same across the two factors levels(tmp$R1) <- levels(tmp$R2) <- LETTERS[1:6] and proceeding as before should be fine. Best, Ista On Jul 6, 2017 6:54 PM, "Gang Chen" <gangchen6 at gmail.com> wrote: Thanks a lot, Ista! I really appreciate it. How about a slightly different case as the following: set.seed(1) (tmp
2017 Jul 06
0
Efficient swapping
How about foo <- with(list(r1 = tmp$R1, r2 = tmp$R2, swapme = (as.numeric(tmp$R1) - as.numeric(tmp$R2)) %% 2 != 0), { tmp[swapme, "R1"] <- r2[swapme] tmp[swapme, "R2"] <- r1[swapme] tmp }) Best, Ista On Thu, Jul 6, 2017 at 4:06 PM, Gang Chen <gangchen6 at gmail.com> wrote: > Suppose that we have the following
2009 Jan 06
5
Using apply for two datasets
I can run one-sample t-test on an array, for example a matrix myData1, with the following apply(myData1, 2, t.test) Is there a similar fashion using apply() or something else to run 2-sample t-test with datasets from two groups, myData1 and myData2, without looping? TIA, Gang
2005 Apr 28
3
have to point it out again: a distribution question
Stock returns and other financial data have often found to be heavy-tailed. Even Cauchy distributions (without even a first absolute moment) have been entertained as models. Your qq function subtracts numbers on the scale of a normal (0,1) distribution from the input data. When the input data are scaled so that they are insignificant compared to 1, say, then you get essentially the
2011 Mar 10
3
A question about data frame
A very simple question. With a data frame like this: > n = c(2, 3, 5) > s = c("aa", "bb", "cc") > df = data.frame(n, s) I want df$s[1] or df[1,2], but how can I get rid of the extra line in the output about the factor levels: > df$s[1] [1] aa Levels: aa bb cc Thanks, Gang
2012 Feb 07
6
Setting up infile for R CMD BATCH
Suppose I create an R program called myTest.R with only one line like the following: type <- as.integer(readline("input type (1: type1; 2: type2)? ")) Then I'd like to run myTest.R in batch mode by constructing an input file called answers.R with the following: source("myTest.R") 1 When I ran the following at the terminal: R CMD BATCH answer.R output.Rout it failed
2010 Mar 27
3
Calculate variance/covariance with complex numbers
Anybody knows what functions can be used to calculate variance/covariance with complex numbers? var and cov don't seem to work: > a 1 V1 0.00810014+0.00169366i V2 0.00813054+0.00158251i V3 0.00805489+0.00163295i V4 0.00809141+0.00159533i V5 0.00813976+0.00161850i > var(a) 1 1 1.141556e-09 Warning message: In var(a) : imaginary parts discarded in
2013 Dec 14
2
Change factor levels
Suppose I have a dataframe 'd' defined as L3 <- LETTERS[1:3] d0 <- data.frame(cbind(x = 1, y = 1:10), fac = sample(L3, 10, replace = TRUE)) (d <- d0[d0$fac %in% c('A', 'B'),]) x y fac 2 1 2 B 3 1 3 A 4 1 4 A 5 1 5 A 6 1 6 B 8 1 8 A Even though factor 'fac' in 'd' only has 2 levels, but it seems to bear the birthmark
2010 Feb 05
3
metafor package: effect sizes are not fully independent
In a classical meta analysis model y_i = X_i * beta_i + e_i, data {y_i} are assumed to be independent effect sizes. However, I'm encountering the following two scenarios: (1) Each source has multiple effect sizes, thus {y_i} are not fully independent with each other. (2) Each source has multiple effect sizes, each of the effect size from a source can be categorized as one of a factor levels
2008 Apr 07
3
Extract values from a named array
Sorry for this dumb question. Suppose I have a named array ww defined as ww <- 1:5 names(ww) <- c("a", "b", "c", "d", "e") How can I extract the whole array of numbers without the names? ww[1:5] does not work while ww[[1]] can only extract one number at a time. Thanks, Gang
2011 Jan 21
11
[PATCH]x86:x2apic: Disable x2apic on x86-32 permanently
x86:x2apic: Disable x2apic on x86-32 permanently x2apic initialization on x86_32 uses vcpu pointer before it is initialized. As x2apic is unlikely to be used on x86_32, this patch disables x2apic permanently on x86_32. It also asserts the sanity of vcpu pointer before dereference to prevent further misuse. Signed-off-by: Fengzhe Zhang <fengzhe.zhang@intel.com> diff -r 02c0af2bf280
2008 Mar 06
2
Array arithmetic
I have two arrays A and B with dimensions of (L, M, N, P) and (L, M, N), and I want to do for (i in 1:L) { for (j in 1:M) { for (k in 1:N) { if (abs(B[i, j, k]) > 10e-5) C[i, j, k,] <- A[i, j, k,]/B[i, j, k] else C[i, j, k,] <- 0 } } } How can I get C more efficiently than looping? Thanks, Gang
2013 Oct 09
2
[LLVMdev] Question about anti-dependence breaker
hi, I have few question about breaking anti-dependence of postRAScheduler in LLVM. when I use command line "clang -target arm -mcpu=cortex-a8 -O2 -integrated-as -c test.c -o test.o" and get objdump file as follows: ldrr1, [r0,#16]----(1 str r1, [r0,#32]----(2 ldr r1, [r0,#12]----(3 str r1, [r0,#36]----(4 ldr r1, [r0,#08]----(5 str r1, [r0,#40]----(6 However, I expect that instruction
2011 May 22
2
Convert dataframe with two factors from wide to long format
I know how to convert a simple dataframe from wide to long format with one varying factor. However, for a dataset with two factors like the following, Subj T1_Cond1 T1_Cond2 T2_Cond1 T2_Cond2 1 0.125869 4.108232 1.099392 5.556614 2 1.427940 2.170026 0.120748 1.176353 How to elegantly convert to a long form as Subj Time Cond Value 1 1 1 0.125869 1
2013 Oct 09
0
[LLVMdev] Question about anti-dependence breaker
----- Original Message ----- > > > > hi, > I have few question about breaking anti-dependence of postRAScheduler > in LLVM. > when I use command line "clang -target arm -mcpu=cortex-a8 -O2 > -integrated-as -c test.c -o test.o" > and get objdump file as follows: > ldr r1, [r0,#16]----(1 > str r1, [r0,#32]----(2 > ldr r1, [r0,#12]----(3 > str r1,
2003 Mar 06
1
Virtual servers for 2 workgroup
Hi My config: Samba 2.2.3 & Linux Debian Testing kernel 2.4.20 There are two network cards on my pc : -one links to the network R1 (138.231.121.12) -one links to the network R2 (192.168.0.1) I would like to open two shares: -the first one on R1 in the workgroup wkgrp1 -the second one on R2 in the workgroup wkgrp2 I read that, thanks to the directives "netbios
2010 Feb 15
2
[LLVMdev] Incorrect execution of global constructor with JIT on ARM
Hello, llvm developers! I am running LLVM with JIT on ARM. For simple programs it runs ok, but for lager code I have stumbled upon some issues. See following C++ code to which I have reduced the problem: #include <stdio.h> struct Global { typedef unsigned char ArrayType[4]; ArrayType value; Global(const ArrayType& arg) { for (int i = 0; i < 4; i++) this->value[i] =
2010 Feb 17
0
[LLVMdev] Incorrect execution of global constructor with JIT on ARM
On 15 February 2010 14:49, Martins Mozeiko <49640f8a at gmail.com> wrote: > #include <stdio.h> > struct Global { >  typedef unsigned char ArrayType[4]; >  ArrayType value; >  Global(const ArrayType& arg) { >    for (int i = 0; i < 4; i++) this->value[i] = arg[i]; >  } > }; > static const unsigned char arr[] = { 1, 2, 3, 4 }; > static const Global
2018 Feb 20
3
Take the maximum of every 12 columns
This is what I was looking for. Thank you everyone! Sincerely, Milu <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Mail priva di virus. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>