search for: newvar

Displaying 20 results from an estimated 34 matches for "newvar".

Did you mean: newval
2005 Apr 21
2
Deciles and R
...e, I'm a new R user (if this is a really basic question, please do excuse me...) and I'm having some questions regarding a deciles problem. I have a variable which I need to categorize according to its deciles (X). However, this categorization should be made into another variable (call it NewVar). Ex. for the quartiles case (just for the sake of exposition, since I need deciles...), I would like to be able to generate the NewVar variable based on the quantiles of X: X NewVar 1 1 6 2 2 1 4 2 3 1 5 2 12 4 9 3 8 3 10 4 11 4 7 3 Is there a function or a way of doin...
2007 Feb 01
2
Losing factor levels when moving variables from one context to another
...740 10 6 -0.0706713324725649 30 7 1.49001721222926 30 8 2.00587718501980 30 9 0.450576585429981 30 10 2.87120375367357 30 11 2.25575058079324 80 12 2.03471288724508 80 13 2.67432066972984 80 14 1.74102136279177 80 15 2.29827581276955 80 and now: newvar<-(rnorm(15,4)) newdat<-as.data.frame(cbind(newvar, dat$vecs)) newdat R returns: newvar V2 1 4.300788 1 2 5.295951 1 3 5.099849 1 4 3.211045 1 5 3.703554 1 6 3.693826 2 7 5.314679 2 8 4.222270 2 9 3.534515 2 10 4.037401 2 11 4.476808 3 12 4.842449 3 13 3.109677 3...
2012 Nov 22
1
Efficiently creating/defining new variables transformations
...e of the equation below works independently, but the left side definition fails on run. I also tried creating the variable name first, but ended up with an object that toString() did not fix. Better ideas? Example 1 (paste0(emotions[[i]],"_sqrt"))<-sqrt(data[[emotions[i]]]) Example 2 newvar<-toString(paste0(emotions[[i]],"_sqrt")) data$newvar<-sqrt(data[[emotions[i]]]) Example 3 newvar<-toString(paste0(emotions[[i]],"_sqrt")) data$newvar[1]<-sqrt(data[[emotions[i]]]) -- View this message in context: http://r.789695.n4.nabble.com/Efficiently-creating...
2006 May 24
5
Joining variables
Hello, If I have two variables that are factors or characters and I want to create a new variable that is the combination of both what function can I use to accomplish this? Ex. Var1 Var2 SA100055113 19851113 And I want NewVar SA10005511319851113 Thanks in advance. Cameron Guenther, Ph.D. Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 cameron.guenther at myfwc.com
2011 Jan 04
1
Go from CALLINGout to just CALLING
Hello list, how can I go from CALLINGout to just CALLING ? I've tried : exten => s,n,Set(newVAR=${CUT(CALLINGout,,3)}) or exten => s,n,Set(newVAR=$[CUT(CALLINGout,,3)]) But no result : [Jan 4 11:10:12] -- Executing [s at from-S:34] NoOp("SIP/s2-0000003b", "newVAR=") in new stack Asterisk 1.6.10 here. Kind regards, Jonas. -------------- next part ------------...
2003 Oct 15
2
Example of cell means model
This is an example from chapter 11 of the 6th edition of Devore's engineering statistics text. It happens to be a balanced data set in two factors but the calculations will also work for unbalanced data. I create a factor called 'cell' from the text representation of the Variety level and the Density level using '/' as the separator character. The coefficients for the linear
2012 Jun 27
1
If statement - copying a factor variable to a new variable
...NA) v2.factor <- c("D","D","S","S","S","S") test.data <- data.frame(v1.factor,v2.factor) for (i in 1:nrow(test.data) ) { if ( (is.na(v1.factor[i])==TRUE) & (is.na(v2.factor[i])==TRUE)) {test.data$newvar[i] <- NA} else if ( is.na(v1.factor[i])==TRUE & is.na(v2.factor[i])==FALSE) {test.data$newvar[i] <- test.data$v1.factor[i]} else if ( is.na(v1.factor[i])==FALSE & is.na(v2.factor[i])==TRUE) {test.data$newvar[i] <- test.data$v2.f...
2007 Oct 10
1
global object in user defined function
I need an object created in a user defined function to be accessible to another user defined function. I am fairly certain the object is correctly created as it prints when I use the return() function, however the 2nd function seems unable to use it. I am guessing objects created in functions are not globally accessible, is this correct? What is an appropriate way to pass the object to the
2003 Oct 13
1
AGI solution to Grandstream BT102 call waiting problem
...walking the channels to do a strcmp for an exact match. I'm lost to find out what the Sip channel designator should look like. It appears that the ChanIsAvail would be the correct call to make for this purpose. Last, I can't get the options to work with the $AGI->exed('Dial', $newvar , '30,t'); command. It seems to ignore the options, so, I can't tell the dial command how long to ring and to allow the called extension to transfer. TIA, Walker Here are some snips from my conf files and agi script: myagi.agi ... for $i ( split /,/,$ARGV[0] ) { if ( $AGI->exe...
2009 Feb 27
1
Large 3d array manipulation
...first dimension is Rows, second is columns and the third is Time. So for each row and column, I want to calculate the mean of time steps 1:8, 2:9, 3:10 and so on and assign the values to a new array. For this I am using the following script. for(i in 1:243) { for(j in 1:246) { for(k in 1:768) { newVar[i,j,k] <- mean( myVar[i,j,k:k+7]) } } } This works, but needless to mention it take a very long time to loop over all the rows, columns and time periods. I was wondering if there is a simpler way to do this. Thanks Aparna
2005 Apr 14
1
Multiple copies of attached packages
...ype x[i] <- something (*) which works fine, except that then if I look at x[i] and DF$x[i] they are different. So it looks like x was recreated in the Global Environment, which I actually can check by typing .GlobalEnv$x. On the other hand, if I put in my code something like newvar[i] <- something where newvar was never defined, then I get an error. I was hoping that the statement (*) above would assign to the variable DF$x. But it looks like (although that is probably not the correct explanation) that the interpreter somehow "remembers" that once there was a va...
2007 Oct 19
1
X matrix deemed to be singular in counting process coxph
Dear all, I have a question with respect to counting process formulation of the coxph(survival) model. I have two groups of observations for which I have partitioned each observation into two distinct time intervals, namely, entry day till day 13, and day 13 till death or censorship day (of course the latter only for the observations that survived the first 13 day interval), and added a
2012 Jul 31
3
Help with NaN when 0 divided by 0
Hi All, I have some data where I am doing fairly simple calculations, nothing more than adding, subtracting, multiplying and dividing. I’m running into a problem when I divide one variable by another and when they’re both 0 I get NaN. I realize that if you divide a non-zero by 0 then you get Inf, which is, of course, correct. But in my case I never get Inf, just NaN because of the structure
2010 Feb 27
1
New Variable from Several Existing Variables
..."Yes", then then the new variable should also be "Yes", however if any one of the three existing variables is a "No", then then new variable should be a "No". I would then use that new variable as an exclusion for data in a new or existing dataset (i.e., if NewVariable = "No" then delete): Take this: Column1, Column2, Column3 Yes, Yes, Yes Yes, No, Yes No, No, No No, Yes, No Yes, Yes, No Generate this: Column1, Column2, Column3, NewVariable1 Yes, Yes, Yes, Yes Yes, No, Yes, No No, No, No, No No, Yes, No, No Yes, Yes, No, No And end up with this...
2012 Dec 10
3
equivalent of group command of the egen function in Stata
Dear R listers, I am trying to create a new variable that uniquely identifies groups of observations in a dataset. So far I couldn't figure out how to do this in R. In Stata I would simply type: egen newvar = group(dim1, dim2, dim3) Please, find below a quick example to show what I am dealing with: I have a dataset with 4 variables: var <- runif(50) ## a variable that I want to group dim1 <- factor(rep(1:3, length.out= 50), labels = c("x","y","z") ) ## 3 variabl...
2013 May 13
2
reduce three columns to one with the colnames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130513/fe848ce7/attachment.pl>
2006 May 02
0
Enquiry regarding Apply
I want to compute a new variable (newvar) based on the values of two other variables (t1freq, t2freq).The two variables (t1freq,t2freq) are contained in a dataframe - study1dat <- read.csv("c:\\study1rb.csv",header=T) . I gather this computation can be done using Apply and I have run the following example from the help m...
2009 Jun 24
1
"by" question
...ssing. Something like: result <- by(mydata, mydata$some_factor, function (x) { # do something to create a vector v with length(v) == nrow(x) return(v) }) # now result has a big list, argh... how do I put it neatly back into the mydata data frame? for (i in unique(mydata$some_factor) { mydata$newvar[mydata$somefactor ==i] <- result[[i]] } What should I be doing instead of this? David Hugh-Jones Post-doctoral Researcher Max Planck Institute of Economics, Jena http://davidhughjones.googlepages.com [[alternative HTML version deleted]]
2011 Feb 18
3
recoding a data in different way: please help
Dear R users The following question looks simple but I have spend alot of time to solve it. I would highly appeciate your help. I have following dataset from family dataset : Here we have individuals and their two parents and their marker scores (marker1, marker2,....and so on). 0 means that their parent information not available. Individual Parent1 Parent2 mark1 mark2 1 0 0
2004 Aug 11
0
(no subject)
Something like: newVar <- ifelse(group == 1 & diagnosis == 1, 'positive', 'negative') [You might want to coerce that to a factor if you wish.] Andy > From: Shaw, Philip (NIH/NIMH) > > Hi > > A very simple question (from a R novice) > > How do I create a new variable wit...