showIntegral <- function (f, xmin, xmax, n = 16, fractionFromLeft = 0.5)
{
stopifnot(fractionFromLeft >= 0, fractionFromLeft <= 1, n >=
1)
curve(f(x), from = xmin, to = xmax, lwd = 2, col = "blue")
abline(h = 0)
dx <- (xmax - xmin)/n
right <- xmin + (1:n) * dx
left
You can use capture.output(xmlParseOutput) to make a character vector with
one string per line of printed R output and send that back to Spotfire
for display.
You will need to consult with Spotfire experts (at TIBCO support or
community.tibco.com) to figure out the best way to display this in
It looks like you are calling TERR from Spotfire. The Spotfire/TERR interface
can only pass TERR data.frames (eq. to Spotfire tables) back to Spotfire and
XMLInternalDocuments cannot be columns of data.frames (in neither TERR nor
R).
You should contact TIBCO support and/or participate in the
Your code works in TERR under Spotfire, but since Spotfire deals with
rectangular data sets the glue code between them puts your objects in
a data.frame, which is not legal.
What do you hope to do with the XMLInteralDocument object in Spotfire?
Such objects depend on R internal pointers and
You did not show the structure of your datasets (with, e.g.,
dump(c("datafile1","datafile2"),file=stdout())) nor what your call to
merge() was. However, it may be that you did not use the by.x and by.y
arguments to merge() to specify which columns to match.
txt1 <- "date1
By the way, here is an example where the advice in FAQ 7.10 (change the
factor
columns to numeric) would give incorrect results. The incorrect header
setting
in the call to read.table causes an extra row of non-numeric data to appear
at the
start of the imported data.
> txt <- "ColA ColB\n101
You may have read in your data incorrectly - a column you expected to be
numeric was not recognized as such so it was read in a character and then
converted to a 'factor'.
FAQ 7.10 tells how to work around the problem
Since you only want the diagonal of the correlation matrix, the following
will probably
do the job using less memory. The mapply versions works on the data.frames
you supplied, but will not work on matrices - be careful not to conflate
the two classes of data objects.
> vapply(colnames(df1),
You can fit a spline to the points and evaluate the derivative
of the fitted spline where you want. The built-in splines package
has functions for this, as do other packages on CRAN.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Dec 18, 2015 at 1:09 AM, BARLAS Marios 247554
Have you considered thin plate splines, which are a natural
extension of one-dimensional splines to higher dimensional
spaces, but are not piecewise polynomials? The Tps function
in the fields package will fit a thin plate spline to irregularly
spaced data.
Bill Dunlap
TIBCO Software
wdunlap
Do you know what sort of S+ objects do not survive the
dump-from-S+-source-into-R procedure unscathed? E.g., do you have S4
classes that don't make it or certain classes
of data objects?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sat, Dec 26, 2015 at 3:17 AM, Kim Pilegaard
by(dataFrame, groupId, FUN) applies FUN a bunch of data.frames (row subsets
of the dataFrame input). mean() returns NA for data.frames. You could use
FUN=colMeans if you wanted column means or FUN=function(x)mean(colMeans(x))
or FUN=function(x)mean(unlist(x)) if you wanted some version of a
What do you hope to do with this data while it is in R?
E.g., do you want to plot it, fit a model to it, to select a few
rows or columns from it, sort it, summarize lots of small subsets
of it, or something else?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Dec 28, 2015 at 1:39 PM, Mark
sapply's FUN argument must be a function (or a character string naming
a function) and sqrt(var(x)) evaluates to a number, not a function.
mySD <- function(x) {sapply(x,function(x)sqrt(var(x)))}
would work, but I like to make it
mySD <- function(x) {sapply(x,function(xi)sqrt(var(xi)))}
to make
What answer do you want for the following data?
x <- c(2,2,3,4,4,4,4,5,5,5,3,1,1,0,0,0,1,1,1)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Dec 22, 2015 at 11:34 PM, Makram Belhaj Fraj <
belhajfraj.mak...@gmail.com> wrote:
> Dear colleagues
> i need your generous help to solve the
I left out the example:
> set.seed(1)
> df <- data.frame(x1 = rpois(1000,4), x2 = rpois(1000,8))
> helper_fun <- function(x) {
+ cut(x, breaks = unique(quantile(x, seq(0, 1, 1/10), na.rm = TRUE)),
+ include.lowest = TRUE)
+ }
> df2 <- data.frame(lapply(df, helper_fun))
>
> getwd()
[1] "/Users/johnbeyer"
> dir
function (path = ".", pattern = NULL, all.files = FALSE, full.names =
FALSE,
recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE,
Note what a difference the parentheses after the function name make. With
parentheses,
often with
Is the following function, myFormula(), what you are looking for?
myFormula <- function(stem, env = parent.frame()) {
eval(bquote(.(as.name(paste0("Disch.",stem))) ~
.(as.name(paste0("Base.",stem))),
list(stem=as.name("rolling"))), envir=env)
}
str(myFormula("myStem"))
#Class "formula"
I don't know what you mean by "without having to use any special
interfaces", but "reference classes" will do what I think you want. E.g.,
the following makes a class called 'SortedNumeric' that only sorts the
vector when you want to get its value, not when you append values. It
stores the
>It is easy in a loop but that will take ages. Is there any vectorised
>apply-like solution to this?
If you showed the loop that takes ages, along with small inputs for
it (and an indication of how to expand those small inputs to big ones),
someone might be able to show you some code that does
>In fact, I learned most of them the hard way
>by trial and error and realized that it’s difficult to separate time and
>date using POSIXct and POSIXlt.
It is difficult to separate time from data in real life as well. The most
common problem is when your time zone switches between 'daylight
Finally I applied lapply in this way:
df_snow_day$snow <- lapply(df_snow_day$day, function(x)
round(mean(df_snow$snow[df_snow$day == x], na.rm=T))
This does not work. I do not understand why the class of df_snow_day$snow
is of type list either:
lapply()'s output is always a list.
I
Your log showed that g++ was given the flag -std=c++0x. It should be
-std=c++11 so the 'using typename = blahblah' syntax works. Either
your feather/src/Makevars is missing the line CXX_STD=CXX11 or your
version of R is lacking support for CXX_STD.
> g++ -m32 -std=c++0x
>The bit about the decimal leading to a shift in the decimal place
>pointed out by Bill is a bit obscure, though it to is mentioned in the
help file.
I don't think that is how real Fortran formats work. My memory is that
you only put a dot in the format if there were no dots in your data file
Just to be clear, do you really want your 'condition' groups to be be
subsets
of one another? Most (all?) of the *ply functions assume you want
non-overlapping groups so they do a split-summarize-combine sequence.
You would have to replace the split part of that.
Bill Dunlap
TIBCO Software
>If you want to drop levels, use droplevels() either on the factor or on
the >subset of your data frame. Example:
>droplevels(f[1]) #One element, only one level
Calling factor() on a factor, as the OP did, also drops any unused levels,
as the examples showed.
>
It has been a while since I used Fortran formatted input, but the following,
without dots in the format, works:
> txt <- "1950. .614350 .026834 .087227 .006821 .180001 4.56E-2"
> print(read.fortran(textConnection(txt), c("f5", "6f8")), digits=10)
V1 V2 V3 V4 V5 V6
Does using zz<-bxp(boxplot(data,plot=FALSE)) do what you want? E.g.,
d <- transform(data.frame(t=1:15), x = sin(t)+log2(t), group =
paste("Group", t%/%4))
groupedX <- with(d, split(x, group))
zz <- bxp(boxplot(groupedX, plot=FALSE)) # bxp returns the x positions of
the boxes
points(col="blue",
You did not change df$quant - you made a new object called 'subdf'
containing a column called 'quant' that had only one level. Changing
subdf has no effect on df.
> df <- data.frame(quant=factor(letters))
> str(df)
'data.frame': 26 obs. of 1 variable:
$ quant: Factor w/ 26 levels
>>rm(curl) # release the curl! (does this end the session???)
Try adding a call to gc() immediately after this removal. That will force
an
immediate run of any finalizer associated with the object just removed.
With the call to gc(), the garbage collector will be called some time in the
You could remove all non-digits from the strings with
> gsub("[^[:digit:]]+", "", x)
[1] "0122" "" "" "89963" "1" "8"
and then count the number of characters remaining with nchar
> x[nchar(gsub("[^[:digit:]]+", "", x)) <= 1]
[1] "RTG" "GF TYHH" "KFTR1" "RT 8"
Or you
The default row.names on a data.frame made by the core-R data.frame
function are of the the form c(NA, -NROW(dataFrame)). The dplyr package
has a 'data_frame' function that uses c(NA, +NROW(dataFrame)) instead. The
tibble package also has a data_frame function, but it uses the negative
length.
I think there is a bug in raster::removeTmpFiles(). Near the end it has
f <- f[dif > h]
if (length(f) > 1) {
unlink(f, recursive = TRUE)
}
so it only tries to remove the files listed in 'f' if there is more than
one of them.
Perhaps the author meant to use '>='
> 1: .Fortran("dataxy", n = as.integer(n), tmax = as.integer(tmax),
alpha = as.double(alpha), beta = as.double(beta), x = as.double(0,
length = n), y = as.double(0, length = n), tau = as.integer(0,
length = n))
Are you expecting that
as.integer(0, length=n)
and
as.double(0, length =
>With the call to gc(), the garbage collector will be called some time in
the
>future and the finalizers will be run then.
Typo: that initial 'With' should be 'Without'.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Jun 15, 2016 at 12:57 PM, William Dunlap wrote:
>
help(ar) should tell you how to get the coefficients. If, like me, you
don't
read help files, you can use str() to look at the structure of ar's output.
> str(a <- ar(sin(1:30), aic=TRUE))
List of 14
$ order : int 2
$ ar : num [1:2] 1.011 -0.918
$ var.pred: num 0.0654
$
Is part of the issue that in common parlance "NA" or "N/A" may
mean either "not available" or "not applicable" (e.g., isPregnant
for a male) but in R NA means only "not available"?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Jun 24, 2016 at 8:37 AM, Bert Gunter
You can make a step-number variable with cumsum(grepl("^Step ", ...)) and
use it as the splitting variable in split. E.g.,
> dat <- read.table(yourFile, stringsAsFactors=FALSE, sep="|",
colClasses=c("NULL", "character", "character", "character"),
col.names=c("Junk","Date","Time","Type"))
> dat
The following shows how to get different colors for most features of a
scatterplot:
plot(1:11,log(1:11),ann=FALSE,axes=FALSE,col="pink",pch=16)
box(col="gray")
title(xlab="X Axis Label", col.lab="light blue")
title(ylab="Y Axis Label", col.lab="light green")
axis(side=1, at=c(2,3,5,7,11),
I tend to use bquote, as in
x_label <- bquote(bold(species) ~ (italic(N1)))
plot(1:10,main=bquote("This is the expression for" ~ .(x_label) * "!"))
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Jan 11, 2016 at 7:59 AM, Evan Cooch wrote:
> Suppose I've
Don't use vapply() here - use lapply() instead and then leave cut's output
alone.
vapply() will combine its outputs to create a character matrix and
data.frame will pull apart the character matrix into its columns. Skipping
the matrix intermediary solves
lots of issues.
Bill Dunlap
TIBCO
Try this one:
myBox <- function (which = c("plot", "figure"), ...) {
# draw filled rectangle where box() would draw open rectangle
which <- match.arg(which)
oldXpd <- par("xpd")
on.exit(par(oldXpd))
if (which == "plot") {
do.call("rect", c(as.list(par("usr")[c(1, 3, 2,
I tried the following but it does not work:
data <- lapply(
paste(("C:/Research3/simulation1/second_gen/pheno_
1000ind_4000m_add_h70_prog_",[1:2],"_",[2:3],".csv",sep=''),
read.csv, header=TRUE, sep=',' )
names(data) <- paste("d", LETTERS[1:3], sep='')
I tried that and R
R's subscripting operators do not "guess" the value of a missing
argument: a missing k'th subscript means seq_len(dim(x)[k]).
I bet that you use syntax like x[,1] (the entire first column of x)
all the time and that you don't want this syntax to go away.
Some languages use a placeholder like '.'
If 'tab' is a data.frame then new.tab <- tab[[mvar]] is a column from that
data.frame, not a data.frame with one column. new.tab <- tab[ , mvar,
drop=FALSE ] will give you a data.frame that you can add to with either of
nvar <- "newName"
new.tab[ , nvar] <- newColumn
new.tab[[nvar]]
> y
[1] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 "
> gsub("$", "", y)
[1] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 “ #
no change. Why?
"$" as a regular expression means "end of string", which has zero length -
replacing "end
of string" with
Most of the mass of that distribution is within 3e-100 of 2.
You have to be pretty lucky to have a point in sequence
land there. (You will get at most one point there because
the difference between 2 and its nearest neightbors is on
the order of 1e-16.)
seq(-2,4,len=101), as used by default in
The "missingness" of an argument gets passed down through nested function
calls. E.g.,
fOuter <- function(x) c(outerMissing=missing(x), innerMissing=fInner(x))
fInner <- function(x) missing(x)
fInner()
#[1] TRUE
fOuter()
#outerMissing innerMissing
# TRUE TRUE
It is only
In addition to the other fine answers, you might find it convenient
to represent the points as complex numbers and use the Arg function
to get the angle (and abs() or Mod() the distance).
> z <- complex(real=0.8660254, imaginary=0.5)
> Arg(z) / base::pi * 180
[1] 30
> Arg(-z) / base::pi *
Did you somehow get a copy of the Splus par function into your
R workspace?
Use the conflicts() function to see if you have something masking par.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Jan 27, 2016 at 1:56 AM, Kim Pilegaard wrote:
> I have a function that calls
You could start by sorting the components, by lambda (size) or by mu (mean)
since, if you don't supply starting values, the order of the components is
random. You could use the following to sort normalmixEM's output:
sort.mixEM <- function (x, decreasing = FALSE, ..., by = "lambda")
{
Perhaps you can try clustering the output of the Hough transform.
PET::hough() will compute it, given a matrix like
gplots::hist2d(1/temp[,1],temp[,2])$hData. I do not have much experience
here.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Feb 2, 2016 at 3:35 AM, PIKAL Petr
If your start/end pairs are not overlapping you can use findInterval() to
do this
pretty quickly. E.g.,
isInABound <- function (x, low, high)
{
stopifnot(length(low) == length(high))
bounds <- rep(low, each = 2)
bounds[seq(2, length(bounds), by = 2)] <- high
You can do things like
while ( !is.nan( r <- randomFunction(x) )) {}
# r will be a non-NaN value of randomFunction(x) now
or
for(i in seq_len(1000)) {
if (!is.nan( r <- randomFunction(x))) {
break
}
if (i == 1000) {
stop("no good values of
Using column names where you used column numbers would work:
example <- data.frame(
check.names = FALSE,
Nuclei = c(133L, 96L, 62L, 60L),
`Positive Nuclei` = c(96L, 70L, 52L, 50L),
Slide = factor(c("A1", "A1", "A2", "A2"), levels = c("A1", "A2")))
aggregate(example["Nuclei"],
Note that the expression
x[1] <- 10
is equivalent not to
`[<-`(x, 1, value=10)
but to
x <- `[<-`(x, 1, value=10)
so there is no conflict between your two expressions.
Saying
c(1,2,3) <- `[<-`(c(1,2,3), 1, value=10)
is not allowed because there is no name to assign something to.
There
> 28 PiB. Storing such a large matrix even on file is not possible.
The ads for Amazon Red Shift say it is possible. E.g.,
Amazon Redshift is a fast, fully managed, petabyte-scale data
warehouse that makes it simple and cost-effective to analyze
all your data using your existing business
You can add the argument na.print=" " to print() to make
the missing values print as " " instead of as NA. Some,
but not all print methods support this. E.g.,
> print(c(1,2,NA,4,5,NA), na.print="-")
[1] 1 2 - 4 5 -
> print(matrix(c(1,2,NA,4,5,NA),2), na.print="-")
[,1] [,2] [,3]
[1,]
> mod_c <- aov(dv ~ myfactor_c + Error(subject/myfactor_c), data=mydata_c)
>
> summary.lm(mod_c)
> Error in if (p == 0) { : argument is of length zero>
You called the lm method for summary() on an object of class c("aovlist",
"listof"). You should not expect a method for one class to work on an
dnew...@dcn.davis.ca.us>
> wrote:
>
>> The "end of string" special meaning only applies when the dollar sign is
>> at the right end of the string (as it was in the OP attempt). That is, it
>> is NOT generally necessary to wrap it in brackets to remove the special
>> meaning unl
You could try pulling some of the repeated subscripting operations,
especially the insertions, out of the loop. E.g.,
values <- observations[,"values"];
date <- observations[,"date"] ;
groups$average <- vapply(seq_len(NROW(groups)), function(i)
mean(values[date >= groups[i, "start"]
it
> is NOT generally necessary to wrap it in brackets to remove the special
> meaning unless it would otherwise be at the end of the pattern string.
> --
> Sent from my phone. Please excuse my brevity.
>
> On February 10, 2016 10:10:40 PM PST, William Dunlap via R-help <
> r-h
One technique for dealing with this is called 'multiple imputation'.
Google for 'multiple imputation in R' to find R packages that implement
it (e.g., the 'mi' package).
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 15, 2016 at 8:14 AM, Lorenzo Isella
wrote:
I would suggesting using "" instead of NULL for rz, throughout this code.
(I would also suggest making sure the code can be copied into R without
causing a syntax error before posting the request for help.)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Mar 11, 2016 at 9:10 AM, Adams,
How much do you care about dealing with misformatted date strings, like
"111-Oct"
or "12-Mai"? Flagging those may be more important than milliseconds of CPU
time.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Mar 9, 2016 at 5:24 PM, Dalthorp, Daniel wrote:
> How
Using the print.level=2 argument to nlm can help track this down.
Also, set options(warn=1) before calling nlm so warnings get printed
as soon as they are generated.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Mar 28, 2016 at 3:32 PM, Rolf Turner
wrote:
> On
You said you specified frequency=96 when you constructed the time
series, but when I do that the decomposition looks reasonable:
> time <- seq(0,9,by=1/96) # 15-minute intervals, assuming time unit is day
> measurement <- sqrt(time) + 1/(1.2+sin(time*2*pi)) +
rnorm(length(time),0,.3)
>
decompose wants frequency(Y) to be more than 1 - it really wants an integer
frequency
so it can return a vector of that length containing the repeating pattern
(the "figure").
frequency(Y) is 1/3600 so you get the error (which might be better worded):
> plot(decompose(Y))
Error in
Use all.equal instead of identical if you want to gloss over
integer/numeric class differences and minor floating point differences (and
a host of others).
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Apr 11, 2016 at 5:25 PM, Paulson, Ariel wrote:
> Hi Jeff,
>
>
> We
I think the worst aspect of this restriction in poly() is that when
you use poly in the formula of a model-fitting function you cannot
have any missing values in the data, even if you supply
na.action=na.exclude.
> d <- transform(data.frame(y=c(-1,1:10)), x=log(y))
Warning message:
In
I don't know what is in R's poly(), but if it is like S+'s or TERR's then
one could do
if (anyNA(x)) {
nax <- na.exclude(x)
px <- poly(x = nax, degree = degree, coefs = coefs, raw =
raw, simple = simple)
px <-
quot;matrix"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Mar 24, 2016 at 4:54 AM, Martin Maechler <maech...@stat.math.ethz.ch
> wrote:
> >>>>> William Dunlap via R-help <r-help@r-project.org>
> >>>>> on Wed, 23 Mar 2016 13:56:35 -0700
%=>% would have precendence ('order of operations') problems also.
A + B %=>% C
is equivalent to
A + ( B %=>% C)
and I don't think that is what you want.
as.list(quote(A + B %=>% C)) shows the first branch in the parse tree. The
following function, str.language, shows the entire parse
> i <- seq_len(length(x)-1)
> split(x, cumsum(c(TRUE, (x[i]==0) != (x[i+1]==0
$`1`
[1] 0.144872972504 0.850797178400
$`2`
[1] 0 0 0
$`3`
[1] 0.199304859380 2.063609410700 0.939393760782 0.838781367540
$`4`
[1] 0 0 0 0 0
$`5`
[1] 0.374688091264 0.488423999452 0.783034615362 0.626990428900
table converts its non-factor arguments to factors using the exclude
argument that you supply. If you want the arguments to be handled
differently, then convert them to factors
yourself, in the way you want. E.g.,
> with(df, table(x=factor(x, exclude=1), y))
y
x 1 2 3
2 0 1 0
3 1 0 0
>
You could use transform() instead of [[<- to add columns to your data.frame
so the new columns get transformed they way they do when given to the
data.frame function itself. E.g.,
> dd <- data.frame(X=1:5, Y=11:15)
> str(transform(dd, Z=matrix(X+Y,ncol=1,dimnames=list(NULL, "NewZ"
Your code looks fine to me. What did t2pd look like?
I tried reproducing the problem in R-3.2.4(Revised) and everything worked
(although the output of str() looked a bit different - perhaps you have an
old version of R)
> df <- data.frame(TE=1:10, TR=101:110,
> dt1[ vapply(dt1, FUN=is.numeric, FUN.VALUE=NA) ]
a c
1 1 1.1
2 2 1.0
...
10 10 0.2
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Apr 29, 2016 at 9:19 AM, Carl Sutton via R-help <
r-help@r-project.org> wrote:
> Good morning RGuru's
> I have a data frame of 575 columns. I
I think you are seeing the Moire (interference) pattern arising from
the interaction of lty=4 (dotted/dashed lines) and closely spaced
parallel lines. Use lty=1 (solid lines) to see this.
[BTW, your script did not work because you changed the capitalization
of top and bottom halfway through it.]
The following usage of stopifnot seems reasonable to me and it
would be nice if the 2nd call caused the message 'is.data.frame(df) is not
TRUE'.
f <- function(df) {
stopifnot(is.data.frame(df), is.integer(df$ID))
range(df$ID)
}
f(data.frame(ID=4:7))
# [1] 4 7
f(4:7)
# Error in df$ID : $
If you really want to return all the objects in a function, I think it
is better to return as.list(environment()), perhaps adding the
all.names=TRUE argument to capture names starting with a dot.
I only have done this while debugging a function and then I
find it is more convenient to return just
Does this do what you want?
z <- data.frame(Name=c("One","Three","Twelve","Eleven"), Count=c(1,3,12,11))
with(z, barplot(Count, names=Name, horiz=TRUE))
with(z, barplot(Count, names=Name, horiz=TRUE, las=1))
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, May 12, 2016 at 10:19 AM,
You can also use match(code, unique(code)), as in
transform(dd.2, codex2 = paste0("Person", match(code, unique(code
It is not guaranteed that x!=y implies digest(x)!=digest(y), but it is
extremely
unlikely to fail. This match idiom guarantees that.
Bill Dunlap
TIBCO Software
wdunlap
ave() encapsulates the split/lapply/unsplit stuff so
transform(mydf, v1.mod = ave(v1, blocks, FUN=mynorm))
also gives what you got above.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, May 13, 2016 at 7:44 AM, Massimo Bressan <
massimo.bres...@arpa.veneto.it> wrote:
> yes, thanks
>
>
ave(A, i, FUN=cummax) loops but is faster than your aggregate-based
solution. E.g.,
> i <- rep(1:1, sample(0:210, replace=TRUE, size=1))
> length(i)
[1] 1056119
> a <- sample(-50:50, replace=TRUE, size=length(i))
> system.time( vAve <- ave(a, i, FUN=cummax) )
user system elapsed
See if you can use is.nan() to figure out which values of B, Bmax, ...,
cause
the result to be NaN (not a number). One possibility is if B were always
negative so abs(B)/max(B) could be negative: (negative)^(non-integer power)
is NaN.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, May 3,
The following base R code does roughly what Bert suggests. It does
no checking that the data is in the format you describe. The
split-by-cumsum
trick is a handy idiom.
# lines <- readLines(yourFile), or, for this example:
lines <- c("#One","X Y Z","1 2 3","4 5 6","",
"#Two", "X
You could install and load the 'lubridate' package, which has month()
and month<-() functions so you can do the following:
> z <- as.Date(c("2015-01-29", "2016-01-29", "2016-05-07", "2016-12-25"))
> z
[1] "2015-01-29" "2016-01-29" "2016-05-07" "2016-12-25"
> month(z) <- month(z) + 1
> z
[1] NA
For starters, use 'pmin' (parallel min) instead of 'min'.
substitute(MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))),
list(MIN=quote(pmin), K14=quote(VaR), ABS=quote(abs),
EXP=quote(exp), LN=quote(log), H14=quote(Bmax),
omega=quote(w2)))
# pmin(psi/VaR,
No matter how expert you are at writing regular expressions,
it is important to list which sorts of strings you want matched
and which you do not want matched. Saying you want to match
"age" but not "age2" leads to lots of possibilities. Saying how
you want to categorize each string in a vector
Since you only have 3 predictors, each categorical with a small number of
categories, you can use expand.grid to make a data.frame containing all
possible combinations and give that the predict method for your model to
get all possible predictions.
Something like the following untested code.
> That didn't work Jim!
It always helps to say how the suggestion did not work. Jim's
function had a typo in it - was that the problem? Or did you not
change the call to ddply to use that function. Here is something
that might "work" for you:
library(plyr)
data <-
Can you show us a self-contained example, along with the output of
running conflicts()?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 19, 2016 at 8:57 AM, Michael Artz
wrote:
> HI that did not work for me either. The value I got returned from that
> function
t;> is an expression that evaluates to a character string:
>> >> "round(quantile(x,.25),0) - round(quantile(x,0.75),0)"
>> >>
>> >> no matter what the argument of your function, x. Hence
>> >>
>> >> return(paste(...)) will return th
Since these are color strings, you can use functions in the grDevices
package (other others) to manipulate them. E.g., you can convert them
to various color spaces and perhaps use the mean in one of those
spaces as your 'average color'.
> myColors <-
This is not a solution but your lsfit attempt
#Error in lsfit(A, b) : only 3 cases, but 4 variables
lsfit(A,b)
gave that error because lsfit adds a column of 1 to
its first argument unless you use intercept=FALSE.
Then it will give you an answer (but I think it converts
your sparse matrix
I think as.POSIXct will just pass through a POSIXct object without any
changes. E.g.,
> dput(as.POSIXct( structure( list(quote(foo)),
class=c("POSIXct","POSIXt"
structure(list(foo), class = c("POSIXct", "POSIXt"))
If as.POSIXct( POSIXctObject, tz="ZONE") changed the time zone then a fair
Why are you predicting from tr_m$finalModel instead of from tr_m?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, May 9, 2016 at 11:46 AM, Muhammad Bilal <
muhammad2.bi...@live.uwe.ac.uk> wrote:
> Please find the sample dataset attached along with R code pasted below to
> reproduce the
approx() has a 'rule' argument that controls how it deals with
extrapolation. Run help(approx) and read about the details.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Jul 22, 2016 at 8:29 AM, lily li wrote:
> Thanks, Ismail.
> For the gaps before 2009-01-05 and
Your original mail said
Example of date - 05-30-16
To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y")
but by showing us the actual code I see you reversed the m and d and
capitalized the Y in your first attempt, causing NA's since your data was
not in that format.
The big
1 - 100 of 485 matches
Mail list logo