Displaying 20 results from an estimated 200 matches similar to: "Losing factor levels when moving variables from one context to another"
2005 Apr 21
2
Deciles and R
Hi everyone,
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
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.
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 Nov 22
1
Efficiently creating/defining new variables transformations
I would like to add an extension to the current name of a variable to create
a new variable that is its sqrt transform. Each piece 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
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
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
2009 Feb 27
1
Large 3d array manipulation
I have a large 3 dimensional array of size (243,246,768)
The 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(
2003 Oct 13
1
AGI solution to Grandstream BT102 call waiting problem
I'm trying to fix a problem with the GrandStream Budgetone 102. I've been reading the source code, mailing lists and other resources. Here's the scenario and the approach I have been pursuing. I'm having some problems with the AGI calls and I hope someone can give me some clarification.
PSTN <---> T1,PRI * <---> Grandstream BT 102 (12)
2012 Jun 27
1
If statement - copying a factor variable to a new variable
I need to look through a dataset with two factor variables, and depending
on certain criteria, create a new variable containing the data from one of
those other variables.
The problem is, R keeps making my new variable an integer and saving the
data as a 1 or 2 (I believe the levels of the factor).
I've tried using as.factor in the IF output statement, but that doesn't
seem to work.
Any
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
I am new to R, but have been using SAS for years. In this transition period,
I am finding myself pulling my hair out to do some of the simplest things.
An example of this is that I need to generate a new variable based on the
outcome of several existing variables in a data row. In other words, if the
variable in all three existing columns are "Yes", then then the new variable
should
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>
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
2005 Apr 14
1
Multiple copies of attached packages
I have noticed that after I ran a batch script multiple times I get
multiple copies of a package's name when I call search(). Is this a
problem?
> search()
[1] ".GlobalEnv" "DF" "DF"
[4] "DF" "DF" "DF"
multiple copies here ...
[13] "DF" "DF"
2008 Aug 21
1
Kruskal.test() on lists
Hi,
I am trying to do a kruskal wallis test on two lists, fVisited and cSN:
fVisited[[1]]
[1] 0.17097623 0.30376141 0.17577266 0.14951855 0.03959753 0.08096217 0.05744888 0.02196257....
....
cSN[[1]]
[1] 0.08557303 0.36477791 0.19601252 0.12981040 0.05351320 0.10385542 0.03539577 0.03106175....
So if I just want to do a test on just one of the entries this is simple enough:
2009 Jun 24
1
"by" question
Hello all
I have a big data frame and I regularly want to break it down into subsets,
calculate some new data, and add it back to the data frame.
At the moment my technique seems a bit ugly and embarrassing. 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...
2011 Oct 29
1
Add col in data.frame
Hello Gurus,
I am still new to R. Here is my issue.
I was trying to add column to data frame that was populated by read.spss().
When I used cbind to add a new variable(column).
library(foreign)
mydf<-read.spss(file="C:/myspss.sav",use.value.labels=FALSE,
to.data.frame=TRUE,use.missings=FALSE)
attr(mydf,"variable.labels")
## it gives you all the labels
2008 Sep 27
1
quantile / centile
I'm wondering if there is a simple way to assign a quantile to a vector in a
data frame, much like one could in Stata using centile. Let's say I want 100
slices in my assignation. I can easily see what the limits of each slice by
using quantile:
quantile(my.df$my.var, probs=seq(0, 1, 0.01))
But how do I assign the appropriate value to each row/record in my data
frame? Clearly the
2009 Feb 24
2
receiving 1st digit from a variable
Hi people!
I want to save the 1st letter from the ${EXTEN} variable. I don't want
to trim it, I want to RESAVE it into a new variable.
Let us assume the ${EXTEN} contains: 0698332977 then I'd love to get the 0
I would thank you for all advises.
Tamer