Displaying 20 results from an estimated 10000 matches similar to: "how to (combine / recode / merge) two factor."
2011 Feb 14
4
sem problem - did not converge
Someone can help me? I tried several things and always don't converge
# Model
library(sem)
dados40.cov <- cov(dados40,method="spearman")
model.dados40 <- specify.model()
F1 -> Item11, lam11, NA
F1 -> Item31, lam31, NA
F1 -> Item36, lam36, NA
F1 -> Item54, lam54, NA
F1 -> Item63, lam63, NA
F1 -> Item65, lam55, NA
F1 -> Item67, lam67, NA
F1 ->
2006 Aug 29
2
lattice and several groups
Dear R-list,
I would like to use the lattice library to show several groups on
the same graph. Here's my example :
## the data
f1 <- factor(c("mod1","mod2","mod3"),levels=c("mod1","mod2","mod3"))
f1 <- rep(f1,3)
f2 <-
2009 Sep 19
2
Counting observations of a combined factor
#I have a dataset with two factor. I want to combine those factors into
a single factor and count the number of data values for each new factor.
The following gives a comparable dataframe:
a <- rep(c("a", "b"), c(6,6))
b <- rep(c("c", "d"), c(6,6))
df <- data.frame(f1=a, f2=b, d=rnorm(12))
df
# I use the 'interaction' function to combine
2008 May 10
3
Compact Indicator Matrices
An indicator matrix is a binary matrix with orthogonal columns whose
rows sum to 1. A row of this matrix could be [0 1 0 0]. My problem is
to group the similar rows (profiles) so that to create a compact form
of the matrix.
Is there an R function that deals with this problem or do I have to
write it from scratch?
Thanks,
Angelos Markos
Dr. Applied Informatics,
University of Macedonia, Greece
2005 Jan 27
1
Is glm weird or am I?
Hi,
I've written a script that checks all bivariate correlations for
variables in a matrix. I'm now trying to run a logistic regression on
each pair (x,y) where y is a factor with 2 levels. I don't know how (or
whether I want) to try to fathom what's up with glm.
What I wrote is attached. Here's what I get.
*****************************************************
2010 Aug 03
4
REmove level with zero observations
If I have a column with 2 levels, but one level has no remaining
observations. Can I remove the level?
Had intended to do it as listed below, but soon realized that even though
there are no observations, the level is still there.
For instance
summary(dbs3.train.sans.influential.obs$HAC)
yields
0 ,1
4685,0
nlevels(dbs3.train.sans.influential.obs$HAC)
yields
[1] 2
drop.list <- NULL
2010 Jul 02
2
merging plot labels in a lattice plot
Hi, I have a lattice lot conditioned on two variables. Example code is:
library(lattice)
x <- data.frame(d=runif(100),
f1=sample(c('yes', 'no'),100,replace=TRUE),
f2=c(rep('Run1',30),rep('Run2',30),rep('Run3',40)))
histogram(~d | f1 + f2, x)
In the plot, for a given value of f2, there are two panels, one for
'n'
2009 Jun 20
1
how to apply the dummy coding rule in a dataframe with complete factor levels to another dataframe with incomplete factor levels?
Dear R helpers:
Sorry to bother for a basic question about model.matrix.
Basically, I want to apply the dummy coding rule in a dataframe with
complete factor levels to another dataframe with incomplete factor levels.
I used model.matrix, but could not get what I want.
The following is an example.
#Suppose I have two dataframe A and B
2012 Sep 06
2
merge a list of data frames
I have a list of data frames:
> str(data)
List of 4
$ :'data.frame': 700773 obs. of 3 variables:
..$ V1: chr [1:700773] "200130446465779" "200070050127778" "200030633708779" "200010587002779" ...
..$ V2: int [1:700773] 0 0 0 0 0 0 0 0 0 0 ...
..$ V3: num [1:700773] 1 1 1 1 1 ...
$ :'data.frame': 700773 obs. of 3 variables:
..$
2006 Nov 10
1
Combining factors
Hi
I know this is a basic question and I know I have done it before but I
can't find the answer any more.
I have a data set, say:
F1, F2, Value
F1 and F2 are Factors.
I would like to plot
plot(TheCombinationOf(F1, F2), Value)
I remember there was a function for TheCombinationOf() but I don't
remember the name.
I could create a new factor based on F1 and F2, but I would prefer the
2009 May 25
2
inconsistency in ?factor
In the almost current development version (2009-05-22 r48594) and also in
https://svn.r-project.org/R/trunk/src/library/base/man/factor.Rd
?factor contains (compare the formulations marked by ^^^^^^)
\section{Warning}{
The interpretation of a factor depends on both the codes and the
\code{"levels"} attribute. Be careful only to compare factors with
the same set of levels (in
2006 Jul 11
2
Dropping unused levels of a factor that has "NA" as a level
Is this a bug?
> f1 <- factor(c("a", NA), levels = c("a", "NA") )
> f2 <- f1[, drop = TRUE]
> f2
[1] a <NA>
Levels: a <NA>
I would have expected f2 to have only one level, "a". It seems
to me that the code in [.factor does not follow the advice in
help("factor") on how to set factor codes to be
2011 Apr 25
1
average among one factor in a nested dataframe
I have two nested data frames:
a<-rnorm(6)
b<-rnorm(9)
f1<-c("x1","x2","x3"))
f2<-c("y1","y2")
id<-c(1:6)
a_df<-data.frame(cbind(id,f1,"y1",a))
id<-c(1:9)
b_df<-data.frame(cbind(id,f1,"y2",b))
I want to preserve id and f1, but want to collapse f2 and take the
corresponding mean values of a and b.
2008 Apr 28
1
error in summary.Design
Dear list,
after fitting an lrm with the Design package (stored as "mymodel") I
try running a summary, but I get the following error:
dim(mydata)
[1] 235 9
names(mydata)
[1] "id" "VAR1" "VAR2" "VAR3" "VAR4" "VAR5" "VAR6" "VAR7" "VAR8"
summary(mymodel)
Error in `contrasts<-`(`*tmp*`,
2006 Aug 16
1
Specifying Path Model in SEM for CFA
I'm using specify.model for the sem package. I can't figure out how to
represent the residual errors for the observed variables for a CFA
model. (Once I get this working I need to add some further constraints.)
Here is what I've tried:
model.sa <- specify.model()
F1 -> X1,l11, NA
F1 -> X2,l21, NA
F1 -> X3,l31, NA
F1 -> X4,l41, NA
F1 -> X5, NA, 0.20
2005 Aug 22
1
mozilla/firefox search engine AMD64 jre1.5 plugin linux
Hi,
I have a problem with the "help.start()" and the search engine on a AMD64 :
The search engine use the java plugin but the java plugin is not
available for the jre.1.5 ...
I have a linux box : fedora 4 on 64bit and R2.1.1
When I start the search engine, I had the message that the java plugin
was missing.
So I try to install manual the java run time jre-1.5 for the AMD64, but
the
2003 Jan 03
1
Take care with codes()! (was type of representation)
Ahh yes, sorry about that.
Here's the corrected snippet:
# Create an Example Data Frame Containing Car x Color data
carnames <- c("bmw","renault","mercedes","seat")
carcolors <- c("red","white","silver","green")
datavals <- round(rnorm(16, mean=10, sd=4),1)
data <- data.frame(Car=rep(carnames,4),
2008 Apr 18
3
Function redefinition - not urgent, but I am curious
This is just my curiousity working.
Suppose I write:
f1 <- function(x) x + 1
f2 <- function(x) 2 * f1(x)
f2(10)
# 22
f1 <- function(x) x - 1
f2(10)
# 18
This is quite obvious. But is there any way to define f2
in such a way that we "freeze" the definition of f1?
f1 <- function(x) x + 1
f2 <- function(x)
# put something here
2 * f1(x)
# probably put something else here
2004 Jan 20
1
evaluation of discriminant functions+multivariate homosce dasticity
While I don't know anything about Box's M test, I googled around and found a
Matlab M-file that computes it. Below is my straight-forward translation of
the code, without knowing Matlab or the formula (and done in a few minutes).
I hope this demonstrates one of Prof. Ripley's point: If you really want to
shoot yourself in the foot, you can probably program R to do that for you.
[BTW:
2006 Jan 04
1
Difficulty with 'merge'
Dear R-helpers,
Happy New Year to all the helpful members of the list.
Here is the behavior I'm looking for:
> v1 <- c("a","b","c")
> n1 <- c(0, 1, 2)
> v2 <- c("c", "a", "b")
> n2 <- c(0, 1 , 2)
> (f1 <- data.frame(v1, n1))
v1 n1
1 a 0
2 b 1
3 c 2
> (f2 <- data.frame(v2, n2))