search for: a12

Displaying 20 results from an estimated 101 matches for "a12".

Did you mean: 12
2011 Feb 20
2
concatenate vector after strsplit()
...aracter vectors created by strsplit() I want to concatenate the 1st 4 character elements of each list item as a new vector called file. I admit to being confused about list syntax even after numerous readings. Here's what I tried: ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "µm"), c("Focused", "10k", "A12", "t08.tif", "+", "µm"), c("Focused", "10k", "A12", "t12.tif", "+", "µm"), c("Focused&q...
2017 Dec 13
3
match and new columns
Hi all, I have a data frame tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE) I want match tdat$B with tdat$A and populate the column values of tdat$A ( col A and Col B) in the newly created columns (col D and col E). please find my attempt and the desired output belo...
2017 Dec 14
1
match and new columns
Hi Bill, I put stringsAsFactors = FALSE still did not work. tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE ,stringsAsFactors = FALSE) tdat$D <- 0 tdat$E <- 0 tdat$D <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0)) tdat$E <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0)) tdat I got this,...
2017 Dec 13
2
match and new columns
Thank you Rui, I did not get the desired result. Here is the output from your script A B C Y D E 1 A12 B03 C04 0.70 0 0 2 A23 B05 C06 0.05 0 0 3 A14 B06 C07 1.20 0 0 4 A25 A23 A12 3.51 1 1 5 A16 A25 A14 2,16 4 4 On Wed, Dec 13, 2017 at 4:36 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote: > Hello, > > Here is one way. > > tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B...
2001 Dec 03
3
beginner's questions about lme, fixed and random effects
...amples in the nlme package. My first attempt was to try doing a t-test in lme. This is very similar to the Rail example that comes with nlme, but it has two groups instead of five. So I try a1 <- 1:10 a2 <- 7:16 t.test(a2,a1) getting t(18)=4.43, p=.0003224. Then I try to do it with lme: a12 <- c(a1,a2) grp <- factor(rep(1:2,c(10,10))) Now, at this point, I think I should be able to do something like this: lme(a12~grp) or lme(a12~1|grp) but I keep getting an error message, "Invalid formula for groups." So I tried making a groupedData object: data1 <- as.data.frame...
2009 Dec 17
1
CORRECTION - Generation of Random numbers in a loop
Dear R helpers, please ignore my earlier mail. Here is the corrected mail. Please forgive me for the lapses on my part. Extremely sorry.   Here is the corrected mail.     Dear R helpers   I am having following data   Name           Numbers A11                  12 A12                  17  A13                   0 A11                  11  A12                   6 A13                   0 A11                   8 A12                   4 A13                   3   CONDITIONS   If Name is A11, min_val = 1.05, max_val = 1.30 If Name is A12, min_val = 1.30, max_val = 1...
2017 Dec 14
0
match and new columns
...ame - factors are getting in your way here. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Dec 13, 2017 at 3:02 PM, Val <valkremk at gmail.com> wrote: > Thank you Rui, > I did not get the desired result. Here is the output from your script > > A B C Y D E > 1 A12 B03 C04 0.70 0 0 > 2 A23 B05 C06 0.05 0 0 > 3 A14 B06 C07 1.20 0 0 > 4 A25 A23 A12 3.51 1 1 > 5 A16 A25 A14 2,16 4 4 > > > On Wed, Dec 13, 2017 at 4:36 PM, Rui Barradas <ruipbarradas at sapo.pt> > wrote: > > > Hello, > > > > Here is one way. > &...
2017 Dec 13
0
match and new columns
...ne way. tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0) tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0) Hope this helps, Rui Barradas On 12/13/2017 9:36 PM, Val wrote: > Hi all, > > I have a data frame > tdat <- read.table(textConnection("A B C Y > A12 B03 C04 0.70 > A23 B05 C06 0.05 > A14 B06 C07 1.20 > A25 A23 A12 3.51 > A16 A25 A14 2,16"),header = TRUE) > > I want match tdat$B with tdat$A and populate the column values of tdat$A > ( col A and Col B) in the newly created columns (col D and col E). please > fin...
2008 Jan 20
3
Logical test and look up table
...uld like to associate each name with a particular Type (coded as 1,2,3,4,H or H1) in a second column. Is it possible to do a lookup table of associations (i.e. A23 is of type 1, A13 is of type 3 ...) so as to fill up automatically the $Type column. df() $Source $Type A23 A24 A9 A32 A25 A14 A10 A12 A11 A13 G Alternative solutions are also welcome. Thanks in advance P.S. I found a discussion mentioning match() and %in% but it does not seem adapted. -- Nikola Markov Inserm U 846 Stem cells and brain research institute 18 av Du Doyen Lepine 69500 Bron France
2011 Oct 01
1
[LLVMdev] Tablegen: RegisterInfoEmitter.cpp
...he idea behind compare_numeric() is to compare strings containing digits in a special way: Do a normal string-compare up to the point where both string elemnts are numerical. Find then an outcome based on the number of consecutive digits in the strings while disregarding the value of the digits, eg a12b < a123. I guess then this order should hold: a12 == a22 < a1b, for these strings. Looking at StringRef::compare_numeric(StringRef RHS), the problem is, for a12 and a1b, Data[1]==RHS.Data[1], and the continue is reached. Data[2] is then less than RHS.Data[2], so a12 < a1b. But in the ca...
2011 Aug 05
2
R compare cells in one matrix
...[,1] [,2] [,3] [,4] [,5] [1,] 277.4 276.24 275.62 276.55 278.05 [2,] 277.4 276.24 275.55 276.42 277.72 [3,] 277.4 276.24 275.50 276.22 277.39 [4,] 277.4 276.24 275.42 276.02 277.02 [5,] 277.4 276.22 275.37 275.82 276.64 And I want to *compare*its cells like this: a11 and a12; a11 and a21; a11 and a22. then a12 and a22; a12 and a13; a12 and a23. and so on in a cycle. *Is there a function or a package that can be used for comparation?* Thank you! -- View this message in context: http://r.789695.n4.nabble.com/R-compare-cells-in-one-matrix-tp3720854p3720854.html Sent...
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
??? > y <- sort( c("a1","a2","a10","a12","a100")) > y [1] "a1" "a10" "a100" "a12" "a2" > mixedsort(y) [1] "a1" "a2" "a10" "a12" "a100" **Please read the docs!** They say that mixedsort() and mixedorder() bo...
2010 Apr 19
1
BRugs
Hi. I am new here, and I am writing this Winbugs code with BRugs. n=length(bi.bmi) Lagegp=13 Lgen=2 Lrace=5 Lstra=15 Lpsu=2 #model gen x race bi.bmi.model=function(){ # likelihood for (i in 1:n){ bi.bmi[i]~ dbern(p[i]) logit(p[i])<- a0 + a1[agegp[i]]+a2[gen[i]]+a3[race[i]] + a12[agegp[i], gen[i]] + gam[stra[i]]+ u[psu[i],stra[i]] } # constraints for a1, a2, a3, a12 a1[1]<-0.0 a2[1]<-0.0 a3[1]<-0.0 a12[1,1]<-0.0 # for(k in 2:Lgen){ a12[1,k]<-0.0} for(j in 2:13){ a12[j,1]<-0.0} # priors a0~ dnorm(0.0, 1.0E-4) for(i in 2:13){a1[i]~dnorm(0.0, 1.0E-4)}...
2007 Mar 16
1
ideas to speed up code: converting a matrix of integers to a matrix of normally distributed values
...s example to see what I'm talking about above make.effects <- function(x,mn=0,var=1,cov=.5){ set.seed(x) return(mvrnorm(1,mu=c(mn,mn),Sigma=matrix(c(var,cov,cov,var),nrow=2),empirical=FALSE))} (alleles <- matrix(c(5400,3309,2080,1080,2080,1111,389,9362,6372,3787,2798,1009),ncol=4)) a12 <- array(sapply(alleles,make.effects),dim=c(2,nrow(alleles),ncol(alleles))) (a1 <- a12[1,,]) (a2 <- a12[2,,]) #I've set the population correlation = .5; empirical corr=.4635 cor(as.vector(a1),as.vector(a2)) ##run this to see that the code begins to get pretty slow with even a 3000x4...
2018 Mar 12
1
Equivalent of gtools::mixedsort in R base
x <- c( "a1", "a10", "a2" ) y <- c( "b10", "b2", "a12", "ca1" ) DF <- expand.grid( x = x, y = y ) # randomize set.seed( 42 ) DF <- DF[ sample( nrow( DF ) ), ] # missing from gtools mixedrank <- function( x ) { seq.int( length( x ) )[ gtools::mixedorder(x) ] } o <- do.call( order, lapply( DF, mixedrank ) ) DF[ o, ] # o...
2004 Jul 03
2
DSTEIN error (PR#7047)
...ements of a block ## diagonal matrix when the matrix is treated as a vector. m <- n*2 s <- integer(0) for (i in seq(1, m-1, by = 2)) s <- c(s, rep(i:(i+1),2)) block.indices <- m * rep(0:(m-1), each = 2) + s A[block.indices] <- block return(A) } A12 <- function(lambda, mu, sigma, n) { A <- matrix(0, nrow = n, ncol = n * 2) block <- c(-1/(2 * mu), (2*lambda)/(mu * sigma)) block.indices <- n * 0:(2*n-1) + rep(1:n, each = 2) A[block.indices] <- block return(A) } I.exp <- function(A11,A12,A22...
2013 Feb 01
2
Nested loop and output help
...mat1 <- cbind(X,Y) dev1 <- sample(-40:40, 1, replace=T) cut1 <- mean(X) + dev1 dev2 <- sample(12:54, 1, replace=T) cut2 <- mean(X) + dev1 + dev2 X2 <- X-cut1 Y2 <- Y-cut2 c3 <- cor(X2,Y2) mat2 <-cbind(X2,Y2) a11 <- ifelse( X < cut1 & Y < cut2, 1, 0) a12 <- ifelse( X < cut1 & Y >= cut2, 1, 0) a21 <- ifelse( X >= cut1 & Y < cut2, 1, 0) a22 <- ifelse( X >= cut1 & Y >= cut2, 1, 0) mat3 <-matrix(c(sum(a11),sum(a21), sum(a12),sum(a22)), nrow = 2) mat4 <-matrix(c(sum(a11),sum(a22), sum(a12),sum(a21)), nrow...
2012 Mar 28
6
How to get all possible combinations?
Dear all, suppose I have a vector with elements as: Vec <- c(2,3,4,5,6) Now I want to have all possible combination of length 3 using those elements and without any repetition. Like, I want to have 1 possibility like 2-3-4 but not 3-2-4. Can somebody guide me how to achieve that in R? Thanks for your help.
2005 Nov 09
8
Element-by-element multiplication operator?
Is there an element-by-element multiplication in R, like the .* operator in Matlab? eg: A (2x3) B (2x3) C=A.*B C (2x3) C = [[a11*b11 a12*b12 a13*b13]; [a21*b21 a22*b22 a23*b23]] I can't find one... Thanks -Mike Gates
2009 Dec 17
1
Random Number Generation in a Loop
...ers in teh range (1.05-1.30) followed by 3 random numbers in the range (1.30-1.60) and so on.   # ___________________________________________________    Here is the R code I have tried   ONS <- read.table(textConnection("name number                  A11    12                               A12    17                               A13     0                                   A11    11                                A12      6                                 A13      0                                 A11      8 A12      4                                 A13      3"), header = TRUE...