Displaying 20 results from an estimated 300 matches similar to: "How to add a function to another written code?"
2013 Feb 22
2
How to merge two functions into one?
I am using the code below to calculate the correlation map between two
datasets. This code worked fine.
dir1 <- list.files("D:thly", "*.bin", full.names = TRUE)
dir2 <- list.files("D:002", "*.envi", full.names = TRUE)
file_tot <- array(dim = c(1440, 720, 11, 2))
for(i in 1:length(dir1)) {
file_tot[, , i, 1] <-
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
???
> 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
2017 Jun 29
1
about reading files in order
Thanks for that answer.
I was not aware of gtools::mixedsort
<https://www.rdocumentation.org/packages/gtools/versions/3.5.0/topics/mixedsort>
function.
Jean
On Thu, Jun 29, 2017 at 2:47 PM, Henrik Bengtsson <
henrik.bengtsson at gmail.com> wrote:
> You can use:
>
> > files <- list.files(path = "folder01")
> > files <- gtools::mixedsort(files)
>
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)),
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"),
2017 Jun 29
0
about reading files in order
You can use:
> files <- list.files(path = "folder01")
> files <- gtools::mixedsort(files)
to order the files in a "human-friendly" order rather than
lexicographic order (which sort() provides).
FYI 1; it's preferred to use file.path("folder01", list[i]) rather
than paste('folder01',lists[i],sep='/').
FYI 2; if you use
2011 Mar 10
1
3 dimensional MDS plots
Hi,
I am trying to create 3 mds plots: one with axis 1 vs axis 2, one with axis 2 vs axis 3, and one with axis 1 vs axis 3. When inputting my code, I only end up with one diagram and when inputting
mdsg.mds$dims, the program returns 2 for 2 dimensions. How can I create the other two plots?
Any help would be greatly appreciated,
Calla Carbone
The table I use is number of each taxa on each
2018 Mar 12
7
Equivalent of gtools::mixedsort in R base
Hi,
Searching for functions that would order strings that mix characters and numbers in a "natural" way (ie, "a1 a2 a10" instead of "a1 a10 a2"), I found the mixedsort and mixedorder from the gtools package.
Problems:
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does
2- gtools has not been updated in 2.5
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
2004 Sep 17
1
R-2.0.0 Install problem for package bundle with inter-dependent n amespaces
I have a revised version of the gregmisc package, which I've converted into
a package bundle each of which has a namespace: gplots, gmodels, gdata,
gtoools. Of course, there are interdependencies among these namespaces:
gsun374: /tmp [11]> cd gregmisc/
gsun374: gregmisc [12]> grep import */NAMESPACE
gdata/NAMESPACE:importFrom(gtools, odd, invalid, mixedsort)
2011 Nov 16
0
problem to tunning RandomForest, an unexpected result
Dear Researches,
I am using RF (in regression way) for analize several metrics extract from
image. I am tuning RF setting a loop using different range of mtry, tree
and nodesize using the lower value of MSE-OOB
mtry from 1 to 5
nodesize from1 to 10
tree from 1 to 500
using this paper as refery
Palmer, D. S., O'Boyle, N. M., Glen, R. C., & Mitchell, J. B. O. (2007).
Random Forest Models
2007 Aug 04
2
multiple nls - next fit even after convergence problem
Hello R-gurus,
I'm trying to adjust different growth curves to a rather extensive dataset.
I wrote up a function to go through all of them, but am encountering a problem :
among the more than 1000 curves I have, obviously for some of them I encounter conversion problems.
I'd like for my function to keep going to the next curve and store the fact that for curve number X I had a convergence
2017 Jul 06
0
svm.formula versus svm.default - different results
Dear community,
I'm performing svm-regression with svm at library e1071.
As I wrote in another post: "svm e1071 call - different results", I get different results if I use the svm.default rather than the svm.formula, being better the ones at svm.formula
I've debugged both options.
While debugging the svm.formula, I've seen that when I reach the call:
ret <-
2006 Feb 02
0
crossvalidation in svm regression in e1071 gives incorrect results (PR#8554)
Full_Name: Noel O'Boyle
Version: 2.1.0
OS: Debian GNU/Linux Sarge
Submission from: (NULL) (131.111.8.96)
(1) Description of error
The 10-fold CV option for the svm function in e1071 appears to give incorrect
results for the rmse.
The example code in (3) uses the example regression data in the svm
documentation. The rmse for internal prediction is 0.24. It is expected the
10-fold CV rmse
2012 May 15
0
Indexing in summaryBy
I'm trying to use a self-written function with the summaryBy function (doBy
package).
I have lots of data from Monte Carlo experiments comparing different
estimators across different (combinations of) parameter values, similar to
the following form:
colnames(mydata) <- c("X", "b0", "b1", # parameter combination,
corresponding (true) parameter values
2011 Nov 17
1
tuning random forest. An unexpected result
Dear Researches,
I am using RF (in regression way) for analize several metrics extract from
image. I am tuning RF setting a loop using different range of mtry, tree
and nodesize using the lower value of MSE-OOB
mtry from 1 to 5
nodesize from1 to 10
tree from 1 to 500
using this paper as refery
Palmer, D. S., O'Boyle, N. M., Glen, R. C., & Mitchell, J. B. O. (2007).
Random Forest Models
2006 Feb 02
0
crossvalidation in svm regression in e1071 gives incorre ct results (PR#8554)
1. This is _not_ a bug in R itself. Please don't use R's bug reporting
system for contributed packages.
2. This is _not_ a bug in svm() in `e1071'. I believe you forgot to take
sqrt.
3. You really should use the `tot.MSE' component rather than the mean of
the `MSE' component, but this is only a very small difference.
So, instead of spread[i] <- mean(mysvm$MSE), you
2017 Sep 27
1
need held in r coding.
Need Help in Debugging below script:--------------------------------
dat <- get_majorlandmarks(dat,Dmin,Per)
fit_xts <- xts(dat$fit,order.by = dat$Date,frequency = 365)
close_xts <- xts(dat$Close, order.by = dat$Date, frequency = 365 )
majorlandmarks_xts <-xts(dat$Close[dat$majorlandmarks==TRUE], order.by =
dat$Date[dat$majorlandmarks==TRUE], frequency = 365 )
minorlandmarks_xts
2017 Jul 07
1
Scoring and Ranking Methods
Hi,
I am doing predictive modelling of Multivariate Time series Data of a Motor
in R using various models such as Arima, H2O.Randomforest, glmnet, lm and
few other models.
I created a function to select a model of our choice and do prediction.
Model1 <- function(){
..
return()
}
Model2 <- function(){
...
return()
}
Model3 <- function(){
...
return()
}
main <-