Displaying 20 results from an estimated 10000 matches similar to: "re-coding variables"
2003 Sep 08
1
problems with categorical variables
Hi All:
I am working on a dataset of a study on healthcare workers. One of the
variables I am studying is a categorical variable (variable name:EDUC,
indicates educational achievement, with 6 levels: "illiterate", "primary",
"junior high school", "high school completed", "undergraduate", and
"postgraduate").
I want to collapse the
2005 Sep 08
5
data manipulation
Dear All,
I would be grateful if you can help me. My problem is the following:
I have a data set like:
ID time X1 X2
1 1 x111 x211
1 2 x112 x212
2 1 x121 x221
2 2 x122 x222
2 3 x123 x223
where X1 and X2 are 2 covariates and "time" is the time of observation and ID indicates the
2006 Oct 23
2
Help with "recode" and "factor" functions
I have a data set with seven inputs. Four of which are categorical. For my
midterm, my professor wants us to scale all the inputs. This means, I
pressume, that I have to use 'recode' or 'factor' to transform the
categorical data in numerical. For example, one input variable is
'race=(b,w,h,o)'. I just want to assign a numerical value to all
'b,w,h,o'. I
2008 Jan 30
4
boxplot and number of observations per box
Dear all,
How can I plot the number of observations per box in a boxplot. Many thanks,
Bernard
---------------------------------
[[alternative HTML version deleted]]
2005 Nov 10
3
Remove levels
Daer All,
I have a factor variable, X with 5 levels. When I type tables(X) it gives me:
table(X)
1 2 3 4 5
10 5 0 0 0
How to drop the levels with zeros such that when I will type:
table(X) it will give me:
table(X)
1 2
10 5
Thank a lot,
Bernard
---------------------------------
[[alternative HTML version deleted]]
2007 Nov 19
4
sequence of vectors
Dear All,
I wonder if there is any R function to generate a sequence of vectors from existing ones. For example:
x 1<- c(1,2,3)
x2 <- c(4,5)
x3 <- c(6,7,8)
The desired output is a list of all 3*2*3 = 18 possible combinations of elements of x1,x2 and x3. One element for example is (1,4,6).
Many thanks in advance,
Bernard
2005 Oct 06
3
Singular matrix
Dear All,
I have written the following programs to find a non-singular (10*10) covariance matrix.
Here is the program:
nitems <- 10
x <- array(rnorm(5*nitems,3,3), c(5,nitems))
sigma <- t(x)%*%x
inverse <- try(solve(sigma), TRUE)
while(inherits(inverse, "try-error"))
{
x <- array(rnorm(5*nitems,3,3), c(5,nitems))
sigma <- t(x)%*%x
inverse <-
2005 Dec 20
2
Time data
Dear All, I wonder how to compute the age from the date of birth and the date of examination. Suppose that have the following data:
df <- as.data.frame(rbind(c(1,"10/08/1950","15/03/1998"), c(1,"10/08/1950","20/07/1998"), c(1,"10/08/1950","23/10/1998")))
names(df) <- c("ID", "date_birth",
2005 Sep 16
3
Replicate
Dear All,
I have a vector x = (1,1,1,2,2,2,3,3,3,3)
I am looking for a function to return a vector containing the distinct elements of x i,e y = (1,2,3)
The following code gives the desired results:
as.numeric(levels(as.factor(x)))
Is there any other elegant way?
Thanks,
B
---------------------------------
[[alternative HTML version deleted]]
2011 Sep 29
1
How to Code Random Nested Variables within Two-way Fixed Model in lmer or lme
Hi All,
I am frustrated by mixed-effects model! I have searched the web for
hours, and found lots on the nested anova, but nothing useful on my
specific case, which is: a random factor (C) is nested within one of the
fixed-factors (A), and a second fixed factor (B) is crossed with the
first fixed factor:
C/A
A
B
A x B
My question: I have a functioning model using the aov command (see
2006 Feb 21
3
Compute a correlation matrix from an existing covariance matrix
Dear All,
I am wondering if there is an R function to convert a covariance matrix to a correlation matrix. I have a covariance matrix sigma and I want to compute the corresponding correlation matrix R from sigma.
Thank you very much,
Bernard
---------------------------------
[[alternative HTML version deleted]]
2005 Sep 21
3
Sort a data frame with respect to more than one variable
Dear All,
How can I sort a data frame with respect to more than one variable?
I know that for one variable X one may use: df[order(df$X), ] where df is the data frame containing X.
Many thanks,
Bernard
---------------------------------
[[alternative HTML version deleted]]
2007 Feb 07
3
generate Binomial (not Binary) data
Dear All,
I am looking for an R function or any other reference to generate a series of correlated Binomial (not a Bernoulli) data. The "bindata" library can do this for the binary not the binomial case.
Thank you,
Bernard
---------------------------------
[[alternative HTML version deleted]]
2005 Oct 20
4
creating a derived variable in a data frame
Hello,
I have read through the manuals and can't seem to find an answer.
I have a categorical, character variable that has hundreds of values. I want to group the existing values of this variable into a new, derived (categorical) variable by applying conditions to the values in the data.
For example, suppose I have a data frame with variables: date, country, x, y, and z.
x,y,z are
2005 May 25
1
Ternary Plots with continuous data
Hello
I have a data base consisting of soil parameters, and tree species
densities. The vcd (visualizing categorical data) package includes the
ternaryplot function which plots the gravitation center of 3 prameters.
I'd like to find a similar function for use with continuous data rather than
categorical.
Does anyone know of a function suitable for this objective?
Thanks
Steve
2005 Sep 21
1
Identical data frames
Dear All,
Is there any R function to test if two data frames, say df1 and df2, having the same row names and the same column names are identiques?
Thanks in advance,
Bernard
---------------------------------
[[alternative HTML version deleted]]
2006 Jun 29
1
specify y axis values
Dear All,
I am looking how to specify the values on the y axis and x axis for a curve function.
example:
curve(2*x + 3, 0,10) gives me a range of x axis in (0,2,4,6,8,10) amd for yaxis (5,10,15,20). How to do in order to have the x axis in (0,1,2,3,4,5,6,7,8,9,10) and y axis in (5,6,7,8,......, 10).
Thanks a lot,
Bernard
---------------------------------
2007 Apr 27
1
bootstrap
Dear All,
I would like to use a nonparametric bootstrap to calculate the confidence intervals for the 5% and 95% quantiles using boot.ci. As you know, boot.ci requires the use of boot to generate bootstrap replicates for my statistic. However this last function doesn't work in my case because I am missing something. Here is an example
y <- rnorm(100)
Quantile <-
2007 Oct 28
1
tree problem
I am trying to use tree to partition a data set. The data set has 3924
observations. Partitioning seems to work for small subsets of the data,
but when I use the entire data set, no partitioning occurs. The
variables are:
RESP respondent to a survey (0 = not a respondent, 1 =
respondent)
AGE_P Age (continuous)
ORIGIN_I Hispanic Ethnicity (1 = Hispanic, 2 = non-Hispanic)
RACRECI2 Race
2024 Jun 03
1
R code for overlapping variables -- count
If they are binary (0/1 dummies), can't you just "&" them as in
table(Female & USA & MidIncome)
(or sum() if you don't care about the number of 0s)
-pd
> On 2 Jun 2024, at 00:31 , Shadee Ashtari <shadee.ashtari at gmail.com> wrote:
>
> Hi!
>
> I am trying to find the code for how to get counts for intersectional
> variables. For example,