similar to: How to generate factor levels with unequal numbers?

Displaying 20 results from an estimated 20000 matches similar to: "How to generate factor levels with unequal numbers?"

2013 Feb 17
1
addition in the initial question
Dear Elisa, Try this: vec1<-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45) vec2<-vec1[1:26] names(vec2)<-LETTERS[1:26] label1<-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x) x),SIMPLIFY=FALSE),function(i)
2013 Apr 18
1
vectors with equal values
Hi, Try: ?vec1<-c(1,1,1,1,1,1,1,1,1) if(all(vec1==1)) "xxxxxxxxx" else? "yyyyyyyyyyy" #[1] "xxxxxxxxx" ?vec2<-c(rep(1,4),2) ?if(all(vec2==1)) "xxxxxxxxx" else? "yyyyyyyyyyy" #[1] "yyyyyyyyyyy" #or if(length(unique(vec1))==1) "xxxxxxxxx" else? "yyyyyyyyyyy" #[1] "xxxxxxxxx" ? if(length(unique(vec2))==1)
2007 Feb 01
2
Losing factor levels when moving variables from one context to another
Hi, there I'm currently trying to figure out how to keep my "factor" levels for a variable when moving it from one data frame or matrix to another. Example below: vec1<-(rep("10",5)) vec2<-(rep("30",5)) vec3<-(rep("80",5)) vecs<-c(vec1, vec2, vec3) resp<-rnorm(2,15) dat<-as.data.frame(cbind(resp, vecs))
2009 Dec 08
1
Printing 'k' levels of factors 'n' times each, but 'n' is unequal for all levels ?
Dear List, I need to print out each of 'k' levels of a factor 'n' times each, where 'n' is the number of elements belonging to each factor. I know that this can normally be done using the gl() command, but in my case, each level 'k' has an unequal number of elements. Example with code is as below: vc<-read.table("P:\\Transit\\CORRECT
2001 Nov 01
1
Erratic behaviour of sammon()
I'm not sure this list is the right place for this thing. I noticed some erratic behaviour in sammon(). Running sammon on two nearly identical sets of data results in very different results. Below is an example. I create an initial configuration with cmdscale() and store it into 'vec1'. I write this to file, and read it back in again to 'vec2'. According to cor() on the three
2007 Aug 23
0
indexing and regression testing
Dear all, It was a pleasure to meet you at Iowa State University. Two days ago I submitted two experimental packages to CRAN (hope it will be there soon): rindex: quick indexing of large objects (currently only character, see ?index) regtest: some first support for automated regression testing (heavily used in \dontshow{} section of ?index) With rindex you can for example i <-
2009 Jul 27
1
how to use do.call together with cbind and get inside a function
Dear R-helpers: I have a question related to using do.call to call cbind and get. #the following works vec1 <- c(1,2) vec2 <- c(3,4) ColNameVec <- c('vec1','vec2') mat <- do.call("cbind",lapply(ColNameVec,get)) mat #put code above into a function then it does not work #before doing so, first remove vec1 and vec2 from global environment rm(vec1,vec2) test
2008 Dec 30
2
[LLVMdev] Folding vector instructions
Hello. Sorry I am not sure this question should go to llvm or mesa3d-dev mailing list, so I post it to both. I am writing a llvm backend for a modern graphics processor which has a ISA very similar to that of Direct 3D. I am reading the code in Gallium-3D driver in a mesa3d branch, which converts the shader programs (TGSI tokens) to LLVM IR. For the shader instruction also found in LLVM IR,
2004 May 25
1
cor and missing values. Bug?
There seems to be an issue in computing rank correlations with missing values present. I think this comes from the way rank() function works but I am not sure how to go about this. Rank function places missing values at the end by default thus skewing the rank relationship between two vectors: Example: R : Copyright 2003, The R Foundation for Statistical Computing Version 1.8.1 (2003-11-21),
2011 Jun 03
2
Arules: R Crashes when running eclat with tidLists=TRUE
Hello, I'm using the eclat function of the arules package (1.0-6) for the identification of frequent itemsets. I need the tidLists, but if I set in the function tidLists=TRUE R crashes (Windows XP Professional SP3, 32 bit, R version 2.12.1 (2010-12-16), reproducible on two different computers) with two different error messages or non at all. Minimum examples are: library(arules)
2008 May 12
1
lexicographic comparison of two vectors
Is there any built-in way to lexicographically compare two vectors of the same length in R? The textbook algorithm could be coded as follows: lex.cmp <- function (vec1,vec2) { for (j in 1:length(vec1)) { if (vec1[j] < vec2[j]) { return(-1) } if (vec1[j] > vec2[j]) { return(1) } } return(0) } Thanks, Gabriel
2011 Apr 14
1
nesting multiple for loops
Hi everyone. I am quite frustrated that this doesn't work, as all the functions within work fine by themselves. I'd also like any pointers to how to avoid 'for' loops in my code. I understand it's less than desirable, but I'm still quite new and use them a lot. I have a few wide datasets (90 to 120) with long column names, each name contains a number of different
2008 Dec 30
2
[LLVMdev] [Mesa3d-dev] Folding vector instructions
Alex wrote: > Hello. > > Sorry I am not sure this question should go to llvm or mesa3d-dev mailing > list, so I post it to both. > > I am writing a llvm backend for a modern graphics processor which has a ISA > very similar to that of Direct 3D. > > I am reading the code in Gallium-3D driver in a mesa3d branch, which > converts the shader programs (TGSI tokens) to
2010 Jul 12
2
findInterval and data resolution
Hello Wise Ones... I need a clever way around a problem with findInterval. Consider: vec1 <- 1:10 vec2 <- seq(1, 10, by = 0.1) x1 <- c(2:3) a1 <- findInterval(x1, vec1); a1 # example 1 a2 <- findInterval(x1, vec2); a2 # example 2 In the problem I'm working on, vec* may be either integer or numeric, like vec1 and vec2. I need to remove one or more sections of this vector;
2008 Sep 20
1
lower and upper limits in integrate as vectors
Dear R useRs, i try to integrate the following function for many values "integrand" <- function(z) { return(z * z) } i do this with a for-loop for(i in 2:4) { z <- integrate(integrand, i-1, i)$value cat("z", z, "\n") } to speed up the computation for many values i tried vectors in integrate to do this. vec1<-1:3 vec2<-2:4
2013 Mar 22
2
A question on function return
Hello again, Let say I have following user defined function: fn <- function(x, y) { Vec1 <- letters[1:6] Vec2 <- 1:5 return(list(ifelse(x > 0, Vec1, NA), ifelse(y > 0, Vec2, NA))) } Now I have following calculation: > fn(-3, -3) [[1]] [1] NA [[2]] [1] NA > fn(3, -3) [[1]] [1] "a" [[2]] [1] NA Here I can not understand why in the second case, I get
2004 Jul 09
3
Problem with bwplot
Try factor(vec2) in your bwplot() call. -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Ernesto Jardim Sent: Friday, July 09, 2004 9:41 AM To: Mailing List R Subject: [R] Problem with bwplot Hi, I'm ploting some box-and-whisker plots with bwplot but I'm not getting any box-and-whiskers ... just dots.
2005 Jun 09
1
Subassignments involving NAs in data frames
I'm seeing some inconsistent behavior when re-assigning values in a data frame. The first assignment turns all of the 0s in my data frame to 2s, the second fails to do so. > df1 <- data.frame(a = c(NA, 0, 3, 4)) > df2 <- data.frame(a = c(NA, 0, 0, 4)) > df1[df1 == 0] <- 2 ## Works > df2[df2 == 0] <- 2 Error: NAs are not allowed in subscripted assignments Checking an
2010 Aug 24
3
multiple assignments ?
Simple one, have read and googled, still no luck! I want to create several empty vectors all of the same length. I would like multiple empty vectors (vec1, vec2, vec3) and want to create them all in one line. I've tried vec1,vec2,vec3 <- vector(length=5) and c(vec1,vec2,vec3) <- vector(length=5) and several other attempts but nothing seems to work ... suggestions? Thanks Jim
2011 Jun 29
3
4D data acsess
Hi, I have a 4D data file from MATLAB, call it X, that I want to analyze in R. The first 3 dimensions are x y z coordinates and the forth is a value in time. If you took a sample vector in matlab it would look like vec1 = X(x1, y1, z1, :) vec2 = X( x2, y2, z2, :) this would give you all values (I have 300 of them) corresponding to this (x1,y1,z1) point of X. Now I read the MATLAB datafile 4D