similar to: Equivalent of gtools::mixedsort in R base

Displaying 20 results from an estimated 3000 matches similar to: "Equivalent of gtools::mixedsort in R base"

2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
??? > y <- sort( c("a1","a2","a10","a12","a100")) > y [1] "a1" "a10" "a100" "a12" "a2" > mixedsort(y) [1] "a1" "a2" "a10" "a12" "a100" **Please read the docs!** They say that mixedsort() and mixedorder() both take a **single
2018 Mar 12
1
Equivalent of gtools::mixedsort in R base
x <- c( "a1", "a10", "a2" ) y <- c( "b10", "b2", "a12", "ca1" ) DF <- expand.grid( x = x, y = y ) # randomize set.seed( 42 ) DF <- DF[ sample( nrow( DF ) ), ] # missing from gtools mixedrank <- function( x ) { seq.int( length( x ) )[ gtools::mixedorder(x) ] } o <- do.call( order, lapply( DF, mixedrank ) )
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does This is tangential, but do.call(order, mydataframe) is not safe to use in a general purpose function either - you need to remove the names from the second argument: > d <- data.frame(method=c("New","New","Old","Old","Old"),
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
split any mixed columns into letter and number columns and then order can be used on that: DF <- data.frame(x = c("a10", "a2", "a1")) o <- do.call("order", transform(DF, let = gsub("\\d", "", x), no = as.numeric(gsub("\\D", "", x)),
2010 Jul 17
4
sort file names in numerical order
Hello, I get some file names by list.files(). These names are in alphabetical order. I want to change it to logical numeric order. Example: > fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10") > sort(fileNames) [1] "A1" "A10" "A2" "B1" "B10" "B2" I want to have:
2009 Jul 10
3
strange strsplit gsub problem 0 is this a bug or a string length limitation?
I was working with the rmetrics portfolioBacktesting function and dug into the code to try to find why my formula with 113 items, i.e. A1 thru A113, was being truncated and I only get 85 items, not 113. Is it due to a string length limitation in R or is it a bug in the strsplit or gsub functions, or in my string? I'd very much appreciate any suggestions ============Input script:
2012 Feb 28
2
Error: could not find function "hier.part"
Error: could not find function "hier.part" things I have tried: 1. reinstall R (lastest version, on windows XP) 2. install package "gtools" 3. include: library(gtools) require(gtools) 4. how I call this function: hier.part(c$Y, xdata, fam = "gaussian", gof = "Rsqu") 5.when I try to check what's in the package "gtools", I get (hier.part is
2012 May 28
1
Why R order files as 1 10 100 not 1 2 3 ?
The code given below worked well. However, the problem is that when I typed dir1 to see the results I found that R order the files as: [1] "data1.flt" "data10.flt" "data100.flt" "data101.flt" [5] "data102.flt" "data103.flt" "data104.flt" "data105.flt" [9] "data106.flt" "data107.flt"
2018 Apr 09
3
Question about subset
Hi, The help page for subset states "subset: logical expression indicating elements or rows to keep: missing values are taken as false." Before I try to re-invent the wheel, I would like to know if one of the base or recommended packages would contain a variant of the subset function that would consider missing values as true. Thanks
2009 May 14
1
Problem with viewports, print.trellis and more/newpage
Dear R-users, I have got the following problem. I need to create 4x2 arrays of xyplot's on several pages. The plots are created within a loop and plotted using the print function. It seems that I cannot find the proper grid syntax with my viewports, and the more/newpage arguments. The following script is a simplification but hopefully will suffice to illustrate my problem. Any suggestion
2009 Apr 28
1
Understanding padding in lattice
Dear R-users, I am trying to understand what the different padding arguments in trellis.par.set are exactly controlling the space around lattice plots. I have used the following code as a basis for testing but it did not really help me to visualize how the value of each argument changes the margins and the plotting area. I guess a better way to visualize the effects of these padding items
2009 Feb 03
2
Numeric class and sasxport.get
Dear R-users, The sasxport.get function (from the Hmisc package) automatically defines the class of imported variables. I have noticed that the class of theoretically numeric variables is simply "labelled", although character variables might end up been defined as "labelled" "Date" or "labelled" "factor". Is there a way to tell sasxport.get to
2018 Apr 09
0
Question about subset
Sent from my iPhone > On Apr 8, 2018, at 9:06 PM, Sebastien Bihorel <sebastien.bihorel at cognigencorp.com> wrote: > > Hi, > > The help page for subset states "subset: logical expression indicating elements or rows to keep: missing values are taken as false." > > Before I try to re-invent the wheel, I would like to know if one of the base or recommended
2009 Apr 20
3
How to force axis to have the same range
Dear R-users, I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted.. Thank you in advance for your help
2009 Sep 02
2
combining grid.text, expression and variables
Dear R-users, I am trying to use the grid.text and expression functions to display several character strings and plotmath text on a viewport. Some strings can include a variable portion (PI.limits in the following example), which I thought could be implemented by combining the bquote and the expression functions. Unfortunately, my expressions do not seem to be evaluated. I would greatly
2009 Aug 21
2
Problem with passing a string to subset
Dear R-users, The following question bothered me for the whole afternoon: how can one pass a string as the conditioning argument to subset? I tried plain mystr, eval(mystr), expression(mystr), etc... I don't to be able to find the correct syntax > foo <- data.frame(a=1:10,b=10:1,c=rep(1:2,5)) > mystr<-"c==1" > subset(foo,c==1) a b c 1 1 10 1 3 3 8 1 5 5 6
2018 May 03
1
Calling the curve function with a character object converted into an expression
Typo: should be NULL not NUL of course An alternative approach closer to your original attempt is to use do.call() to explicitly evaluate the expr argument: w <- "1 + x^2" do.call(curve, list(expr = parse(text = w), ylab ="y")) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus
2018 May 03
2
Calling the curve function with a character object converted into an expression
Hi, Down a cascade of function calls, I want to use the curve function with an expression that is a variable. For various reason, this variable must be a character object and cannot be an expression as required by the curve function. How do I convert my variable into a expression that is accepted by curve? Thanks in advance for your help. ## The following attempts do not work myf <-
2009 Jun 27
1
Multiple parking lots use default park positions
Hello, all. I'm having a deeply frustrating time getting multiple parking lots to work and am wondering what I am doing wrong. I am using Asterisk 1.6.1.1. I defined two separate parking lots in features.conf as follows: [parkinglot_a100] ; SSI context => a100-parking parkpos => 900-920 findslot => next [parkinglot_a10] ; EBC context => a10-parking parkpos => 800-820
2008 Jan 20
3
Logical test and look up table
Dear R users, I have a data frame with one column (4000 rows) containing name codes (factor with 63 levels). I would like to associate each name with a particular Type (coded as 1,2,3,4,H or H1) in a second column. Is it possible to do a lookup table of associations (i.e. A23 is of type 1, A13 is of type 3 ...) so as to fill up automatically the $Type column. df() $Source $Type A23 A24 A9 A32