similar to: Establishing groups using something other than ifelse()

Displaying 20 results from an estimated 30000 matches similar to: "Establishing groups using something other than ifelse()"

2008 Oct 09
2
Bug in ifelse
Hi all, I am quite sure it's not a bug, but I am going nuts about this. I do not possibly understand why I get different results for b1 and b2 as shown below. x=c(183,191,192,193,195,206,207,209,210,211,212,213,214,217,218,221,222,223, 224,225,227,228,229,230) y=c(221,225,228,241,242) z=y[y<max(x)] ##all Ys smaller than the maximum of X a=ifelse(length(z)==0,NA,max(z)) ##assign NA if
2010 Apr 03
2
Using ifelse and grep
Good Morning, I am trying to create a new column of character strings based on the first two letters in a string in another column. I believe that I need to use some combination of ifelse and grep but I am not totally sure how to combine them. I am not totally sure why the command below isn't working. Obviously it isn't finding anything that matches my criteria but I am not sure why. Any
2009 Feb 13
2
extracting parts of words or extraxting letter to use in ifelse-func.
Hello I want to make some variables with the ifelse-function, but i don't know how to do it. I want to make these five variables; b2$PRRSvac <- ifelse(b2$status=='A' | b2$status=='Aa',1,0) b2$PRRSdk <- ifelse(b2$status=='B' | b2$status=='Bb',1,0) b2$sanVac <- ifelse(b2$status=='C' | b2$status=='sanAa',1,0) b2$sanDk <-
2013 May 29
3
bootstrap
Hi, You might need to check library(boot).? I have never used that before.? So, I can't comment much.? It is better to post on R-help list.? I had seen your postings on Nabble in the past.? Unfortunately those postings were not accepted in R-help.? You have to directly post at ? r-help at r-project.org after registering at: https://stat.ethz.ch/mailman/listinfo/r-help ?
2012 Apr 25
1
Create a new Vector based on two columns
Hello, I am trying to get a new vector 'x1' based on the not NA-values in column 'a' and 'b'. I found a way but I am sure this is not the best solution. So any ideas on how to "optimize" this would be great! m <- factor(c("a1", "a1", "a2", "b1", "b2", "b3", "d1", "d1"), ordered
2004 Jun 12
1
optimize linear function
I am attempting to optimize a regression model's parameters to meet a specific target for the sum of positive errors over sum of the dependent variable (minErr below). I see two courses of action , 1) estimate a linear model then iteratively reduce the regressors to achieve the desired positive error threshold (naturally the regressors and predicted values are biased - but this is
2010 Mar 20
2
EM algorithm in R
Please help me in writing the R code for this problem. I've been solving this for 4 days. It was hard for me to solve it. It's a simulation problem in R. The problem is My true model is a normal mixture which is given as 0.5 N(-0.8,1) + 0.5 N(0.8,1). This model has two components. I will get a random sample of size 100 from this model. I will do this 300 times. That means, I will have
2009 Feb 19
2
Use of ifelse for indicating specific rownumber
Hello I have a dataset named "b2" with 1521 rows, in that dataset i have 64 rows containing specific information. the rownumbers with specific info are: + i [1] 22 53 104 127 151 196 235 238 249 250 263 335 344 353 362 370 389 422 458 459 473 492 502 530 561 624 647 651 666 671 [31] 715 784 791 807 813 823 830 841 862 865 1036 1051 1062 1068
2011 Jul 26
2
Big data and column correspondence problem
Greetings, I've been struggling for some time with a problem concerning a big database that i have to deal with. I'll try to exemplify my problem since the database is really big. Suppose I have the following data: AA = c(4,4,4,2,2,6,8,9) A1 = c(3,3,5,5,5,7,11,12) A2 = c(3,3,5,5,5,7,11,12) A = cbind(A, A1, A2) BB = c(2,2,4,6,6) B1 =c(5,11,7,13,NA) B2 =c(3,12,11,NA,NA) B3
2012 Apr 25
1
Create new Vector based on two colums
Hello, I am trying to get a new vector 'x1' based on the not NA-values in column 'a' and 'b'. I found a way but I am sure this is not the best solution. So any ideas on how to "optimize" this would be great! m <- factor(c("a1", "a1", "a2", "b1", "b2", "b3", "d1", "d1"), ordered
2009 Jan 29
4
Text in a character vector to indicate "ifelse" argument
Hello I have a data set that looks like this; > b2 dato chr status PRRSvac PRRSsanVac PRRSsanDk PRRSdk 33 2007-12-03 090432 R?d SPF 34 2007-02-09 090432 R?d SPF+sanDK 35 2002-12-17 090432 R?d SPF+DK 36 2002-11-27 090432 R?d SPF+sanDK 37 2002-07-23
2012 Oct 15
2
fit a "threshold" function with nls
I am trying to model a dependent variable as a threshold function of my independent variable. What I mean is that I want to fit different intercepts to y following 2 breakpoints, but with fixed slopes. I am trying to do this with using ifelse statements in the nls function. Perhaps, this is not an appropriate approach. I have created a very simple example to illustrate what I am trying to do.
2013 Jan 24
3
ifelse to speed up loop?
Hello, I'm not sure how to explain what I'm looking for but essentially I have a test dataset that looks like this: test: V1 1 1 2 1 3 1 4 2 5 2 6 2 7 1 8 1 9 1 10 2 11 2 12 2 And what I want to be able to do is create another column that captures a "grouping" variable that looks like this: test V1 group 1 1 1 2 1 1 3 1 1 4 2 2 5 2
2013 Oct 18
1
crr question‏ in library(cmprsk)
Hi all I do not understand why I am getting the following error message. Can anybody help me with this? Thanks in advance. install.packages("cmprsk") library(cmprsk) result1 <-crr(ftime, fstatus, cov1, failcode=1, cencode=0 ) one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2)) predict.crr(result1,cov1,X=cbind(1,one.z1,one.z2)) Error: could not find function
2013 Apr 13
1
how to add a row vector in a dataframe
Hi, Using S=1000 and simdata <- replicate(S, generate(3000)) #If you want both "m1" and "m0" #here the missing values are 0 res1<-sapply(seq_len(ncol(simdata.psm1)),function(i) {x1<-merge(simdata.psm0[,i],simdata.psm1[,i],all=TRUE); x1[is.na(x1)]<-0; x1}) res1[,997:1000] #????? [,1]???????? [,2]???????? [,3]???????? [,4]??????? #x1??? Numeric,3000 Numeric,3000
2012 Sep 07
6
splitting character vectors into multiple vectors using strsplit
Hi folks, Suppose I create the character vector charvec by > charvec<-c("a1.b1","a2.b2") > charvec [1] "a1.b1" "a2.b2" and then I use strsplit on charvec as follows: > splitlist<-strsplit(charvec,split=".",fixed=TRUE) > splitlist [[1]] [1] "a1" "b1" [[2]] [1] "a2" "b2" I was wondering
2003 Nov 18
1
aov with Error and lme
Hi I searched in the list and only found questions without answers e.g. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/19955.html : Is there a way to get the same results with lme as with aov with Error()? Can anybody reproduce the following results with lme: id<-c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5)
2009 Nov 29
3
Plotting observed vs. Predicted values, change of symbols
Dear Wiz[R]ds, I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun, and others. We are almost there. For whatever reason, I can't change the symbol from a circle to a triangle in the upright posture plots. Any ideas? I have included the problem in full. # tritiated (3H)-Norepinephrine(NE) disappearance from plasma # concentrations supine and upright # supine datasu <-
2013 Sep 26
2
Sums based on values of other matrix
Dear all, I have a big problem: - I got two matrices, A and B - A shows identifies the value of B, however the values of B must be summed - For instance, 1 1 2 2 2 2 1 1 gives matrix a 3 4 2 1 1 1 2 2 gives matrix b Now the result for the value 1 would be 7 4 which are the rowsums of the values of matrix B given that matrix A has the value 1. How can I do this automatically? I
2013 Feb 23
1
how to calculate left kronecker product?
For an application, I have formulas defined in terms of a left Kronecker product of matrices, A,B, meaning A \otimes_L B = {A * B[i,j]} -- matrix on the left multiplies each element on the right. The standard kronecker() function is the right Kronecker product, A \otimes_R B = {A[i,j] * B} -- matrix on the right multiplies each element on the left. The example below shows the result of