Displaying 20 results from an estimated 26 matches for "myfactor".
Did you mean:
mfactor
2011 Apr 07
1
Assigning a larger number of levels to a factor that has fewer levels
Hello!
I have larger and a smaller data frame with 1 factor in each - it's
the same factor:
large.frame<-data.frame(myfactor=LETTERS[1:10])
small.frame<-data.frame(myfactor=LETTERS[c(9,7,5,3,1)])
levels(large.frame$myfactor)
levels(small.frame$myfactor)
table(large.frame$myfactor)
table(small.frame$myfactor)
myfactor has 10 levels in large.frame and 5 levels in small.frame. All
5 levels in small.frame are present in...
2009 May 06
4
tapply changing order of factor levels?
..."IN0019800021","IN0020020064")
>
mydata<-c("IN0020020155","IN0019800021","IN0020020064","IN0020020155","IN0019800021","IN0019800021","IN0020020064","IN0020020064","IN0019800021")
> myfactor<-factor(mydata,levels=mylevels)
> myfactor
[1] IN0020020155 IN0019800021 IN0020020064 IN0020020155 IN0019800021
IN0019800021 IN0020020064 IN0020020064 IN0019800021
Levels: IN0020020155 IN0019800021 IN0020020064
> summary(myfactor)
IN0020020155 IN0019800021 IN0020020064
2...
2012 Jan 18
1
drop rare factors
I have a data frame with some factor columns.
I want to drop the rows with rare factor values
(and remove the factor values from the factors).
E.g., frame$MyFactor takes values
A 1,000 times,
B 2,000 times,
C 30 times and
D 4 times.
I want to remove all rows which assume rare values (<1%), i.e., C and D.
i.e.,
frame <- frame[[! (frame$MyFactor %in% c("A","B"))]]
except that I probably got the syntax wrong
and I want c("A",&...
2012 Mar 28
1
discrepancy between paired t test and glht on lme models
...a mocked up data (one that I
found online) here.
require(nlme)
require(multcomp)
dv <- c(1,3,2,2,2,5,3,4,3,5)
subject <- factor(c("s1","s1","s2","s2","s3","s3","s4","s4","s5","s5"))
myfactor <- factor(c("f1","f2","f1","f2","f1","f2","f1","f2","f1","f2"))
mydata <- data.frame(dv, subject, myfactor)
rm(subject,myfactor,dv)
attach(mydata)
# paired t test (H0: f2-f1 = 0)
t.test(...
2010 Jul 05
2
repeated measures with missing data
...ng data issue as follows:
tmtA <- c(20,26, 16,29,22,NA)
tmtB <- c(12,24,17,21,NA,17)
require(lme4)
dv <- c(20,12,26,24,16,17,29,21,22,17)
subject <- rep(c("s1","s2","s3","s4","s5","s6"),each=2)
subject <- subject[-c(10,11)]
myfactor <- rep(c("f1","f2"), 6)
myfactor <- myfactor[-c(10,11)]
mydata <- data.frame(dv, subject, myfactor)
am2 <- lmer(dv ~ myfactor + (1|subject)), data = mydata)
summary(am2)
anova(am2)
subject <- subject[-c(10,11)]
Any help would be greatly appreciated. Thank you,...
2012 Nov 24
1
Adding a new variable to each element of a list
...e data
dv <- c(1,3,4,2,2,3,2,5,6,3,4,4,3,5,6)
subject <- factor(c("s1","s1","s1","s2","s2","s2","s3","s3","s3",
"s4","s4","s4","s5","s5","s5"))
myfactor <- factor(c("f1","f2","f3","f1","f2","f3","f1","f2","f3",
"f1","f2","f3","f1","f2","f3"))
mydata <- data.frame(dv, subject, myfactor)
### Do t...
2006 Apr 29
1
splitting and saving a large dataframe
Hi,
I searched for this in the mailing list, but found no results.
I have a large dataframe ( dim(mydata)= 1297059 16, object.size(mydata=
145280576) ) , and I want to perform some calculations which can be done by
a factor's levels, say, mydata$myfactor. So what I want is to split this
dataframe into nlevels(mydata$myfactor) = 80 levels. But I must do this
efficiently, that is, I can't actually split the dataframe and then save the
resulting 80 smaller ones, as I would run out of memory. I don't know how to
do it though.
So, can anyone gi...
2011 Mar 30
2
summing values by week - based on daily dates - but with some dates missing
...group.1 2009-01-12 1.362
...
group.2 2008-12-29 2.250
group.2 2009-01-05 1.4057
group.2 2009-01-12 3.4411
...
Thanks a lot for your suggestions! The code is below:
Dimitri
### Creating example data set:
mydates<-rep(seq(as.Date("2008-12-29"), length = 43, by = "day"),2)
myfactor<-c(rep("group.1",43),rep("group.2",43))
set.seed(123)
myvalues<-runif(86,0,1)
myframe<-data.frame(dates=mydates,group=myfactor,value=myvalues)
(myframe)
dim(myframe)
## Removing same rows (dates) unsystematically:
set.seed(123)
removed.group1<-sample(1:43,size=11,re...
2007 Dec 09
2
adjusting "levels" after subset a table
Um texto embutido e sem conjunto de caracteres especificado associado...
Nome: n?o dispon?vel
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20071208/5409f1a7/attachment.pl
2009 Mar 03
1
repeated measures anova, sphericity, epsilon, etc
...measures anova. This time around
teaching it, we are using R for all of our computations. We are starting by
covering the univariate approach to repeated measures anova.
Doing a basic repeated measures anova (univariate approach) using aov()
seems straightforward (e.g.:
+> myModel<-aov(myDV~myFactor+Error(Subjects/myFactor),data=myData)
+> summary(myModel)
Where I am currently stuck is how best to deal with the issue of the
assumption of homogeneity of treatment differences (in other words, the
sphericity assumption) - both how to test it in R and how to compute
corrected df for the F-test...
2011 Nov 04
2
Efficiency of factor objects
...0.03 0.00 0.04
> system.time(replicate(1e4,{q1<-c1[100:200];1}))
user system elapsed
0.04 0.00 0.04
> system.time(replicate(1e4,{q1<-f1[100:200];1}))
user system elapsed
0.67 0.00 0.68
Putting the levels vector in an environment speeds up subsetting:
myfactor <- function(...) {
f <- factor(...)
g <- unclass(f)
class(g) <- "myfactor"
attr(g,"mylevels") <- as.environment(list(levels=attr(f,"mylevels")))
g }
`[.myfactor` <-
function (x, ...)
{
y <- NextMethod("[")...
2006 May 24
3
How to make attributes persist after indexing?
Dear All!
For descriptive purposes I would like to add attributes to objects. These
attributes should be kept, even if by indexing only part of the object is
used.
I noted that some attributes like levels and class of a factor exist also
after indexing, while others, like comment or label vanish.
Is there a way to make an arbitrary attribute to be kept after indexing?
This would be especially
2011 Nov 10
1
Errors in SIAR
Help!
model1 <- siarmcmcdirichletv4(data, source, tef, concdep=0, 500000, 50000)
Error in matrix(1, ncol = (numsources + numiso) * numgroups, nrow =
(siardata$iterations - :
invalid 'ncol' value (too large or NA)
In addition: Warning message:
In Ops.ordered((numsources + numiso), numgroups) :
'*' is not meaningful for ordered factors
Previous message, but more
2003 Jun 04
2
convert factor to numeric
Hi R-experts!
Every once in a while I need to convert a factor to a vector of numeric
values. as.numeric(myfactor) of course returns a nice numeric vector of
the indexes of the levels which is usually not what I had in mind:
> v <- c(25, 3.78, 16.5, 37, 109)
> f <- factor(v)
> f
[1] 25 3.78 16.5 37 109
Levels: 3.78 16.5 25 37 109
> as.numeric(f)
[1] 3 1 2 4 5
>
What I really want is...
2010 Sep 05
0
cov.unscaled in NLS - how to define cov.scaled to make comparable to SAS proc NLIN output - and theoretically WHY are they different
...ed from R's NLS to a correlation and compare it to
SAS's correlation. They are identical;
e.g., cov2cor(summary.nls.L$cov.unscaled)
I have even written a function to convert an NLS object into a "cov.scaled"
element that is equivalent to SAS:
scaledCOV = function (nlsObject)
{
myFactor = nlsObject$cov.unscaled[1,1]/(nlsObject$coefficients[1,2]^2);
myScaled = nlsObject$cov.unscaled/myFactor;
myScaled;
}
so with this function I can determine the factor difference between R and
SAS (which is different with each data run of NLS and NLIN). This factor is
based on the same standard...
2006 Oct 18
1
Schmera: a question on R software
Dear All,
I would like to run a generalized linear mixed model with the software R (one categorical predictor, one random factor, the distribution of the dependent variable is binomial, and the link is logit). Thereafter, I would like to perform multiple comparisons (post hoc test) among the groups of the categorical predictor.
Is it possible with the software R?
Are traditional methods of
2008 Aug 29
1
R graphical question
I'm trying to create a graph using plot() with an axis that I
essentially want to plot the categories in the reverse alphanumeric
order - opposite of the typical R fashion. Is there a function to do
this?
In other words, I have categories "a", "c", "g", "z" which is the
order they'll be plotted, but I want to plot them as "z",
2003 Jun 27
3
dropping factor levels in subset
Dear all,
I've taken a subset of data from a data frame using
crb<-subset(all.raw, creek %in% c("CR") & year %in% c(2000,2001) & substrate
%in% ("b"))
this works fine, except that all of the original factor levels are
maintained. This results in NA's for these empty levels when I try to do
summaries based on factors using by(). Is there a simple way to drop
2011 Mar 16
2
Numeric vector converted mysteriously to characters in data frame?
Dear R Help,
I would be very grateful if somebody could explain why this is happening. I
am trying to plot a lattice barchart of a vector of numbers with age
bandings that I have brought together into a data frame. When I plot the
variables in their raw vector form, it works. When I try to plot them in
the df, R labels the numeric axis with default factor values and treats the
numeric vector
2003 Nov 13
5
xlims of barplot
I would like to create a family of barplots with the same xlimits. Is
there a way to "read" the xlimits from the first graph so I can apply it to
the subsequent ones?
I have tried just taking the min and max of the x data and the plot doesn't
show.
cheers
[[alternative HTML version deleted]]