similar to: keeping original order in factor()

Displaying 20 results from an estimated 20000 matches similar to: "keeping original order in factor()"

2008 Dec 11
5
Row order in plot
I'm new to R so forgive me if this seems like a simple question: So I have table where the row titles are string variables. When I plot the data with rows along the x-axis, the data is ordered alphabetically as opposed to the order of the table. How can I preserve the row order of the table in the plot? Thanks in advance. -- View this message in context:
2008 Apr 30
2
ordering a factor in boxplot output
I'm sure I'm missing something obvious in the documentation... I'm generating a boxplot boxplot(CleanValue~ApptCategory*ReportingCode,data=newfile) where ApptCategory is a factor with possible values ("New","Established") Problem is, the output orders those factors alphabetically, and I'd really rather see New come first. I'm apparently confused by the
2011 Aug 31
2
stumped on how to reorder factors
I am trying to reorder a factor data type so that when I plot stats associated with the factor, the ordering makes sense. For instance, if I have a factor entered as follows ... A = as.factor(c("1", "10", "3", "3", "10", "10")) levels(A) ... the ordering does not really make sense (assuming I want the factor ordered by integer
2011 Oct 31
3
Plot two matrices and keeping the record of row names
Dear all, I have two data frames- x1 and y1 with same row names and column names(actually the names of the patients). x1 a b c d e a 1.0000000 0.4730679 0.6226994 0.6036036 0.6433333 b 0.4730679 1.0000000 0.6227273 0.6303855 0.5730858 c 0.6226994 0.6227273 1.0000000 0.7290503 0.6900585 d 0.6036036 0.6303855 0.7290503 1.0000000
2010 Aug 16
2
re-order the rows of a data frame accroding to a specified order of some column
Dear all, I have a data frame with several columns, and I have the specified order of a given column. How can I re-order the rows of my data frame accroding to this specified order? for example, x = data.frame( num = 1:26, alpha = letters[1:26], stringsAsFactors=FALSE) z = sample(x$alpha, replace=FALSE) Can I re-order x accroding to z ? Thanks, Leon [[alternative HTML version
2008 Jun 16
2
in axis() suppressing axis line but keeping tick marks
I've been trying to figure out a parameter that will let you separately adjust the parameters for the axis line from the tick mark. In the following example, I would like to suppress the axis line, but keep the tick marks. Thanks, Andrew foo <- data.frame(x=1:3, y=4:6) plot(foo$x, foo$y, type="n", axes=F) points(foo$x, foo$y) axis(side=1, at=foo$x, lty=0) #would like to figure
2008 Dec 16
1
renaming factor-labels / add factors etc.
Hi, how can I change a defined factor-variable? Like adding levels, renaming existing levels or merge several levels of a factor to one level? For example; following factor-variable is given: x <- factor(c("xyz1", "abc1", "xyz2", "abc2")) How can I add the level fgh? And how can I merge "xyz1" and "xyz2" to one level? And
2011 Jan 26
1
Find the empty element in a factor array
Hi all, I have a factor array, and some of the elements are empty. How would I return the index number of the empty elements. For example, test<-factor(c('A','','B','C','E')) > test [1] A B C E Levels: A B C E I would like the result equal to 2. Thank you, Wendy -- View this message in context:
2004 Oct 28
3
ifelse() question
Hi I have a data.frame with dim = 18638 (rows) 6 (cols) names(dat) [1] "id" "long" "lat" "species" "type" "size" Variable "species" and "type" are factors. Species has 5 levels "BOV" "CAP" "CER" "OVI" "POR" Variable "type" has 11 levels
2003 Oct 09
1
Scoping rules
Dear List members: I'm using R1.7.1 (Windows 2000) and having difficulty with scoping. I've studied the FAQ and on-line manuals and think I have identified the source of my difficulty, but cannot work out the solution. For the purposes of illustration. I have three functions as defined below: fnA <- function(my.x) { list(first=as.character(substitute(my.x)), second=sqrt(my.x)) }
2008 Apr 13
3
Matched pairs with two data frames
Hi, I have a frame "treat" and want to find matched pairs in the data frame "control". In the matched (combined) data frame there should be two variables (0/1),indicating the "source" of the data (treat or control), so that it is possibe to set a "filter" (extraxt/select data). #Here are the dataframes (my real data frames have many variables) treat <-
2009 May 14
1
Supplying NA or Zeros in dataframe for missing factor combinations
Hi there, I am not getting anywhere near a solution, so here is my question. I have searched the archives and didn't find a solution, but maybe my search didn't use the right words. So here it is: I have a dataframe with the following structure factor1 factor2 value In the (rather large) dataset I have to work on, there are some factor combinations missing, e.g. factor1 <-
2004 Dec 01
2
unbalanced design
Hi all, I'm new to R and have the following problem: I have a 2 factor design (a has 2 levels, b has 3 levels). I have an object kidney.aov which is an aov(y ~ a*b), and when I ask for model.tables(kidney.avo, se=T) I get the following message along with the table of effects: Design is unbalanced - use se.contrast() for se's but the design is NOT unbalanced... each fator level
2007 Aug 28
6
Factor levels
Dear R-users, I have found this not-so-recent post in the archives - http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html - while I was looking for a particular way to reorder factor levels. The question addressed by the author was to know if the read.table function could be modified to order the levels of newly created factors "according to the order that they appear in the data
2008 Apr 22
4
how to convert non numeric data into numeric?
I am having the following error in my function function(theta,reqdIRR) { theta1<-theta[1] theta2<-theta[2] n<-length(reqdIRR) constant<- n*(theta1+theta2) sum1<-lapply(reqdIRR*exp(theta1),FUN = sum) sum2<-lapply(exp(theta2 - reqdIRR*exp(theta1)),FUN = sum) sum = sum1 + sum2 log.fcn = constant - as.numeric(sum) result = - log.fcn return(result) } *error :
2007 Aug 16
3
multiple colors within same line of text
Hi, I'm interested in using mtext(), but with the option of having multiple colors in the same line of text. For example, creating a line of text where: Red is red and blue is blue How do you create a text argument that lets you do this within mtext()? Thanks, Andrew MGH Cancer Center [[alternative HTML version deleted]]
2012 Dec 21
2
how to recode an ordered factor
Dear R helpers, I'm trying to recode an ordered factor to reverse its scale, but I can't figure out how to make it. I am using the Recode function provided by the Car package. I've created an ordered variable: data$o.var1 <- ordered(data$var1, levels=c(1,2,3,4), labels =c("very satisfied", "fairly satisfied", "not very satisfied", "not at all
2008 May 11
1
Finding unmatched data between two dataframe using several factors
Hi R users I am trying to find unmatched data from two dataframes. I would like to find unmatched data based on several factors. For the following data: dat1 <- data.frame(x = paste("A", 1:6, sep=""), y = c("andy","bob","ciaran","dan", "eion", "fred")) dat1 dat2
2002 Oct 25
1
merge: How to preserve the original order?
I tried: x.vals <- data.frame( id = c( 'A1', 'C2', 'B3' ) , ref = c( 'Ref1', 'Ref2' ,'Ref1' ) , val = c( 1.11, 2.22, 3.33 ) ) x.labels <- data.frame( ref = c( 'Ref1', 'Ref2' ) , label = c( 'Label01', 'Label02' ) ) merge( x.vals, x.labels,
2009 Apr 02
2
Scatter plot
Hi. How do I plot the straight line and r? in a scatter plot using a simple file x~y? Sueli Rodrigues Eng. Agr?noma - UNESP Mestranda - USP/ESALQ PPG-Solos e Nutri??o de Plantas Fones (19)93442981 (19)33719762