similar to: Creating ordered colors for ordered factors

Displaying 20 results from an estimated 30000 matches similar to: "Creating ordered colors for ordered factors"

2011 Feb 10
1
highest and second highest value in row for each combination
Dear R-List, I have a dataframe area<-c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10)) type<-c(rep(1:10,5)) a<-rnorm(50) b<-rnorm(50) c<-rnorm(50) d<-rnorm(50) df<-cbind(area,type,a,b,c,d) df area type a b c d [1,] 1 1 0.45608192 0.240378547 2.05208079 -1.18827462 [2,] 1 2 -0.12119506 -0.028078577
2011 Sep 26
1
producing an aggregate table of top 3 by cost
Help-Rs   As someone who is newer to R and trying to make the transition from Access into R, there is a frequetnly used function that I'd like to try and duplicate in the R world.  It involved creating an aggregate table of the top (n)  orders for an item by sum of cost over a select period of time.   So, take the following example :   group <- c(rep(1,10), rep(2,10), rep(3,10)) product
2009 Aug 09
1
help with a loop (coefficients with lmList)
Hi R-helpers. #I start with the reproducible example: firm<-c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10)) year<-c(rep(1998:2007,5)) industry<-c(rep(1,20),rep(5,10),rep(7,10),rep(9,10)) X1<-rnorm(50) X2<-rnorm(50,mean=0.5,sd=0.1) Y<-rnorm(50,mean=0,sd=0.5) data<-data.frame(firm, industry,year,X1,X2,Y) data #I need to calculate for all the industries the following
2011 Dec 03
1
Reading multiple text files and then combining into a dataframe
I have a multiple text files, separated by a single space, that I need to combine into a single data.frame. Below is the track I'm on using list.files to capture the names of the files and then lapply with read.table. But I run into problems making a usable dataframe out of the data. #Creating example data in similar format to data I have sub <- rep(1,10) trial <- seq(1,10,1) size
2010 Aug 01
3
remove extreme values or winsorize – loop - dataframe
Hi everyone! #I need a loop or a function that creates a X2 variable that is X1 without the extreme values (or X1 winsorized) by industry and year. #My reproducible example: firm<-sort(rep(1:1000,10),decreasing=F) year<-rep(1998:2007,1000) industry<-rep(c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10),rep(6,10),rep(7,10),rep(8,10),rep(9,10), rep(10,10)),1000) X1<-rnorm(10000)
1999 Dec 13
3
t.test inside function (PR#373)
Full_Name: Bill Simpson Version: 65.1 OS: linux Submission from: (NULL) (193.62.250.209) Try this code as separate lines entered interactively, then try doit() doit<-function() { x<-seq(1,10) y1<-x+rnorm(10,1,1.5) y2<-x+rnorm(10,1,1) t.test(x,y1,paired=TRUE) t.test(x,y2,paired=TRUE) } doit() apparently executes only the last of a series of t.test()s. Maybe this is no bug,
2009 May 27
2
boxplot
Hi gues,   Is there any function in R for boxplot with different time points? t1 <- c(rep(1,20),rep(2,20)) t2 <- c(rep(1,10),rep(2,10),rep(1,10),rep(2,10)) x <- rnorm(40,5,1) dat <- data.frame(t1,t2,x) boxplot(x~t1,t2) Many thanks, Amor [[alternative HTML version deleted]]
2011 May 25
1
Subtracting rows by id
Dear R users, I have two datasets: id1 <- c(rep(1,10), rep(2,10), rep(3,10)) value1 <- sample(1:100, 30, replace=TRUE) dataset1 <- cbind(id1,value1) id2 <- c(1,2,3) subtract.value <- c(1,3,5) dataset2 <- cbind(id2, subtract.value) I want to subtract the number of rows in the subtract.value that corresponds to the id value in dataset1. So for the 1 in id1, I want to
2012 Dec 06
2
lme4 glmer general help wanted - code included
Hi guys, I'm very new to R and have been teaching myself over the past few months - it's a great tool and I'm hoping to use it to analyse my PhD data.As I'm a bit of a newb, I'd really appreciate any feedback and/or guidance with regards to the following questions that relate to generalized linearmixed modelling (or, at least, I think they do!)(if there is a 'better',
2010 Nov 30
1
Zooming in to a ggplot (a sort of ylim, but ylim won't do)
Dear Helpers, I wonder whether you might be able to help me. I have a plot composed of ggplot (and a follow on geom_smooth call). I would like to restrict the display range of the y axis to a smaller range, a sort of zooming onto a region. I attempted to use ylim, but it will effect the range (i.e. effect the geom_smooth call). Is there any way that I can save the results up to geom_smooth call
2004 Nov 15
2
argument rationalization
Hi I am writing a bunch of functions that take two, three or four arguments. These functions operate on vectors of the same length; but I want the function to behave sensibly if one or more arguments are scalars. "+" does this for two arguments: "+"(1:10,3) # interpreted as "+"(1:10,rep(3,10)) But my functions can take more arguments. Say f() takes three:
2011 Dec 22
1
large data set (matrix) using image()
When I use the image() function for a relatively small matrix it works perfectly, eg.x <- 1:100 > z <- matrix(rnorm(10^4),10^2,10^2) > image(x=x,y=x,z=z,col=rainbow(3))but when I want to plot a larger matrix, it doesn't really work. Most of the times, it just plot a few intermitent points.x <- 1:1000 z <- matrix(rnorm(10^6),10^3,10^3) image(x=x,y=x,z=z,col=rainbow(3))
2007 Aug 30
2
Assigning line colors in xyplot
Hi, I have a dataframe containing data from individuals 1, ..., 12 (grouping variable "g" in the data frame below), which belong either to "A" or "B" (grouping variable "f"): set.seed(1) tmp <- data.frame(
2010 Sep 07
1
average columns of data frame corresponding to replicates
Hi Group, I have a data frame below. Within this data frame there are samples (columns) that are measured more than once. Samples are indicated by "idx". So "id1" is present in columns 1, 3, and 5. Not every id is repeated. I would like to create a new data frame so that the repeated ids are averaged. For example, in the new data frame, columns 1, 3, and 5 of the original
2007 Apr 17
2
background color
hi, I want to add different colors on the background of a classical plot. Each color is associated to an interval of the x axis. example: the background is red on the interval [1,10], blue on [11,20]. I try the rect function but it isn't appropriate for the background. Can any one can help me please? best regards. --------------------------------- [[alternative
2011 Nov 07
2
help with formula for clogit
I would like to know if clogit function can be used as below clogit(group~., data=dataframe) When I try to use in above format it takes a long time, I would appreciate some pointers to get multiple combinations tested. set.seed(100) d=data.frame(x=rnorm(20)+5, x1=rnorm(20)+5, x2=rnorm(20)+5, x3=rnorm(20)+5, x4=rnorm(20)+5, x5=rnorm(20)+5, x6=rnorm(20)+5, x7=rnorm(20)+5, x8=rnorm(20)+5,
2003 Feb 11
1
mean function on correlation matrices (PR#2540)
Full_Name: Raymond Salvador Version: R 1.6.2 OS: Windows ME Submission from: (NULL) (131.111.93.195) The mean function applied on individual components of several correlation matrices gives a wrong result (gives the first value instead of the mean). Here there is a simple example x1 <- rnorm(10,1,1) y1 <- rnorm(10,1,1) z1 <- cbind(x1,y1) w1 <- cor(z1) x2 <- rnorm(10,1,1) y2
2002 Oct 17
4
Multiple colors in plots/lookup function
Hello, I'd like to do something like: n<-100 zz<-cbind(rnorm(n),rnorm(n),floor(runif(n)*3+1)) colors<-c("red","green","blue") plot(zz,col=colors(zz[3])) and have a matrix of scatterplots colored by class. The above does not work, of course, but I'm not sure exactly what function I'm looking for. Thank you for your time, Dave, -- Dave
2005 Aug 03
1
abline and linearity over groups
Dear R users, please can you help me understand the behaviour of abline using function lm. I'm trying to learn linearity over groups. So I make three groups with 10 values each: test=data.frame(cbind( l=c(rnorm(10,0,30),rnorm(10,100,30),rnorm(10,200,30)), t = c(rep(0,10), rep(1,10), rep(2,10)) )) when I do: plot(test$l~test$t) abline(lm(test$l~test$t)) the abline is a straight line
2007 Jul 03
1
xyplot and autokey, maintaining colors specified via "col" in key
All, When specifying colors to xyplot w/ a groups argument, using auto.key no longer maintains the colors properly. I've searched the docs and help but haven't found exactly what I need ... I saw a few examples in the archives involving par.settings but that doesn't seem to do it. I also saw some people using key instead of auto.key, but that didn't seem consistent. Is there a