Displaying 20 results from an estimated 34 matches for "cat2".
Did you mean:
cat
2012 Feb 28
1
group calculations with other columns for the ride
Hello,
I can get the median for each factor, but I'd like another column to go
with each factor. The nm column is a long name for the lvls column. So
unique work except for the order can get messed up.
Example:
x =
data.frame(val=1:10,lvls=c('cat2',rep("cat1",4),rep("cat2",4),'cat1'),nm=c('longname2',rep("longname1",4),rep("longname2",4),'longname1'))
x
val lvls nm
1 1 cat2 longname2
2 2 cat1 longname1
3 3 cat1 longname1
4 4 cat1 longname1
5 5 cat1 lon...
2010 Apr 12
2
Interpreting factor*numeric interaction coefficients
...o interact.
An example of such a model follows at the bottom of this message, but here
is a section of its summary table:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.220186 0.539475 2.262 0.0237 *
var1 0.028182 0.050850 0.554 0.5794
cat2 -0.112454 0.781137 -0.144 0.8855
cat3 0.339589 0.672828 0.505 0.6138
var1:cat2 0.007091 0.068072 0.104 0.9170
var1:cat3 -0.027248 0.064468 -0.423 0.6725
I am having trouble interpreting this output.
I think I understand that...
2011 Jan 17
2
matrix manipulations
...6 categories, and the other some other of the 6 categories (and not necessarily exclusive).
So let's built some results after i used the table function.
m1 <- matrix(c(32, 35, 36, 12, 15, 16), nrow = 2, ncol = 3, byrow = TRUE, dimnames = list(c("land", "water"), c("cat2", "cat5", "cat6")))
> m1
cat2 cat5 cat6
land 32 35 36
water 12 15 16
m2 <- matrix(c(45, 46, 47, 48, 21, 22, 23, 24), nrow = 2, ncol = 4, byrow = TRUE, dimnames = list(c("land", "water"), c("cat1", "cat2", "c...
2011 Aug 06
1
help with predict for cr model using rms package
...redicted mean (or fitted) ordinal response values using the
predict function. I have a feeling I'm missing something simple,
however I haven't been able to determine what that is. Thanks in
advance for your help.
Adam
dd <- datadist(all.data2.stand)
options(datadist='dd')
bp.cat2 <- all.data2.stand$bp.cat2
u <- cr.setup(bp.cat2)
u
b.mean <-rep(all.data2.stand$b.mean, u$reps)
r.mean <-rep(all.data2.stand$r.mean, u$reps)
mean.ova.energy <- rep(all.data2.stand$mean.ova.energy, u$reps)
y <- (u$y) # constructed binary response
cohort <- u$cohort
attach(al...
2007 Jul 30
4
how to combine data of several csv-files
Hello,
I'm looking for a solution for the following problem:
1) I have a folder with several csv files; each contains a set of
measurement values
2) The measurements of each file belong to a position in a two
dimensional matrix (lets say "B02.csv" belongs to position 2,2
3) The size of the matrix is fix
4) I cannot assure to have a csv file for each position
5) Each position
2009 Dec 02
1
Lattice: multiple data sets on same plot
...00, 500))
cat<-(runif(2000)<=.5)+0
for(i in 1:length(cat)){
if(cat[i] == 0){
pop[i,"cat1"] = "this"
}
else{
pop[i,"cat1"] = "that"
}
}
cat<-(runif(2000)<=.5)+0
for(i in 1:length(cat)){
if(cat[i] == 0){
pop[i,"cat2"] = "here"
}
else{
pop[i,"cat2"] = "there"
}
}
#Extract sample
sam <- pop[sample(1:2000,50),]
#Combine data sets
x <- make.groups(pop, sam)
#Create trellis display
densityplot(~var1 + var2 | cat1 * cat2, data=x, groups=which,
plot.points=FA...
2006 Aug 24
1
Using a 'for' loop : there should be a better way in R
...a brute force "for" loop approach
which seems okay as it is a small dataset. It looks
a bit inelegant and given all the warnings in the
Intro to R, etc, about using loops I wondered if
anyone could suggest something a bit simpler or more
efficent?
Example:
cat1 <- c( 1,1,6,1,1,5)
cat2 <- c( 1,2,3,4,5,6)
cat3 <- c( 5,4,6,7,8,8)
cat4 <- c( 1,2,1,2,1,2)
years <- c( 'year1', 'year2', 'year3', 'year3',
'year1', 'year1')
id <- c('a','a','b','c','c','a')
df1 <- data.frame...
2007 Dec 19
3
median of binned values
...r categories (or bins), and I need to find the median category.
Trivial to do by hand, but I was wondering if there is a means to do it
in R in an elegant way.
The obvious medioan(vector) returns the median frequency for the binns,
and that is not what I want. i.e,:
freq
cat1 1
cat2 10
cat3 100
cat4 1000
cat5 10000
I want it to return cat5, instead of cat3.
Thanks a lot
Martin
2010 Jul 14
1
Dot Plot with Confidence Limits
Hi,
I have the following dataset and I would like to create a dotplot with
confidence limits:
CAT1 CAT2 MEAN Lower
Upper
1 1 1 0.619 0.392
0.845
2 1 10 1.774 1.030
2.518
3 1 100 7.700...
2012 Dec 12
1
ggplot: geom_line with only pairs of points connected
...one
between B and C) not be there.
What I've come up with is this (instead using geom_segment):
df <- data.frame(cat=LETTERS[1:4],num=rnorm(4))
dfdf <-cbind(df[seq(from=1,by=2,along.with=df),],df[seq(from=2,by=2,along.with=df),])
names(dfdf) <- c("cat","num","cat2","num2")
ggplot(df, aes(x=cat, y=num)) + geom_point() +
geom_segment(aes(x=cat,xend=cat2,y=num,yend=num2),data=dfdf)
Hoewever, in a more extended example (where df is more complex and
also contains factors used for grouping and faceting) this becomes a
bit cumbersome.
Is there a b...
2010 Jun 09
2
cbind with vectors of different lengths?
Hello R help
I have a dataframe, with 71 samples (rows) and 30 variables. I got linear models for some of the variables,? and I want to join fitted and residuals of these models to the data frame. Sometimes, these vectors have the same length of the dependant variable, but in a few cases, NA values can be found on my data, and therefore, both fitted and residuals have a few rows less than the
2010 Sep 29
0
R Graphic - Tellis as a potential
Hello all,
I have been meaning to learn R for a while and have just subscribed to this
list. I am planning to give R a shot at one of my live projects. I am looking
to explore graphical features of R on my data below.
Sample Data:
Cat1 - Cat2 - Cat3 - Cat4 - NumPeople - Salary
H - L - H - L - 100 - 50000
L - L - L - L - 40 - 30000
- H - H - - 100 - 45000
Cat1 through Cat4 are categorical variables containing High, Medium, Low or
Blank values and the last two variables are continuous.
1. Is there a good way of graphically represen...
2011 Apr 12
2
Converting a categorical variable to multiple dichotemous variables
I have a categorical variable in a dataframe similar to the following...
cat
1
1
3
2
4
I need to convert it to 4 dichotemous variables for each observations like...
cat1 cat2 cat3 cat4
1 0 0 0
1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1
Thanks in advance!
Shane
2006 Mar 25
2
acts_as_tree wierdness with children.count and children.size
i am making a category tree and i iterate over the category using my
counter_cache however it would show a different number than what was
actually being represetned in the tree.
Here is an example
cat.children = [cat2, cat3]
puts cat.children.size 2
puts cat.children_count 2
cat4.parent_id = cat.id
cat4.save
puts cat.children.size 2
puts cat.children_count 2
however cat.children.count produces the correct...
2006 Jun 19
10
Trying to delete from a unordered list using ajax
I have a controller method as such:
def delete
@category = Category.find_by_name(params[:name])
@element_id = @category.name
Category.delete_all(["name = ?", @category.name])
end
(For the purpose of this exercise, category names are unique)
I have the corresponding delete.rjs file:
if @element_id
page.remove :id => @element_id
page.visual_effect :highlight,
2003 Dec 16
2
Fw: [S] plot stacked bar chart in R
...;s-news at wubios.wustl.edu>
Sent: Tuesday, December 16, 2003 2:04 PM
Subject: [S] plot stacked bar chart in R
> Hi,
> I am trying to plot a stacked bar chart in R but am not able to find the
> documentation.
>
> The input data format is like the following
>
>
> CAT1 CAT2 Count
> A a 234
> A b 758
> A c 156
> B a 753
> B b 568
> B c 684
> C a 356
> C b 564
> C c 256
> D a 123
> D b 165
> D c 754
>
> please advice.
>
>
> thanks,
>
>
> Yun-Fang
>
>
> --------------------------------...
2010 Oct 23
1
Summarizing For Values with Multiple categories
Hi all,
I have some data as follows.
Cat1 Cat2 Cat3 COG Counts
A B C COG1 10
B D COG2 20
C COG3 30
D COG4 40
I would like to sum all the counts for each category:
A B C D
10 30 40 60
>CAT2COG<-
list(A="COG1",B=c("COG1","COG2"),C=c("CO...
2012 Nov 27
1
For-loop,string variables, and the $-operator
...lumn represents
a category and the individual data points in each category are binary
responses (in this case they are actually 1's and 0's). What I want to
extract are the counts for each category and put them in a vector. To do
that I used the following:
cats<-c("cat1","cat2", "cat3", ...)
c()->counts
for(j in cats){
append(counts, sum(data$j)) -> counts
}
However, the 'counts' object only contains 0's after the script runs:
counts
[1] 0, 0, 0, ....
After replacing various elements in the sc...
2013 Jan 01
1
Order variables automatically
Hi,
I have a dataset with 6 categorical variables. I have used this following code to make the variables u1-u6 ordered factors and this works well.
cat1cat2 cat3 cat4 cat5 cat6
? 0 ? ?? 1 ? ? 1????? 0 ??? 0? ?? 1
? 1 ? ?? 1 ? ? 0 ? ?? 0 ? ? 0 ? ? 0
.......
....
############
data<-read,table("example.txt")
data <- as.data.frame(lapply(data, ordered))
############
Now, suppose I have bigger dataset where some variables are categori...
2007 Jul 04
10
A More efficient method?
Dear Rhelpers,
Is there a faster way than below to set a vector based on values from
another vector? I'd like to call a pre-existing function for this, but one
which can also handle an arbitrarily large number of categories. Any ideas?
Cat=c('a','a','a','b','b','b','a','a','b') # Categorical variable