One thing you might want to do is an R CMD CHECK with both the development
and released versions of R since CRAN will check it against both:
http://cran.r-project.org/src/contrib/checkSummary.html
On 10/17/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
On 10/17/2006 2:22 AM, Andreas Wittmann
apropos(loess)
help.search(loess)
methods(class = loess)
class?loess # in this case it does not return anything but sometimes it does
RiteSearch(loess)
On 10/17/06, michael watson (IAH-C) [EMAIL PROTECTED] wrote:
When R help simply states something like:
Value:
An object of class
On 10/17/06, Farrel Buchinsky [EMAIL PROTECTED] wrote:
I created a dataframe called OSA
here is what it looks like
no.surgery surgery
00.4 6.9
60.2 0.3
I have also attached it as an R data file
I cannot understand why I am getting the following error.
Using the builtin BOD data set try this:
predict(lm(demand ~., BOD), se.fit = TRUE)
On 10/17/06, Li Zhang [EMAIL PROTECTED] wrote:
Y X Z
42.07.0 33.0
33.04.0 41.0
75.0 16.07.0
28.03.0 49.0
91.0 21.05.0
55.08.0 31.0
Try this:
X - structure(11:15, .Names = letters[1:5])
Y - structure(21:25, .Names = letters[1:5])
rbind(group1 = X, group2 = Y)
tab - rbind(group1 = X, group2 = Y)
tab[,-1] / tab[,1]
On 10/17/06, Leeds, Mark (IED) [EMAIL PROTECTED] wrote:
I have two numeric vectors each of length 17 and each
Sorry there was an extra line in there. It should be:
X - structure(11:15, .Names = letters[1:5])
Y - structure(21:25, .Names = letters[1:5])
tab - rbind(group1 = X, group2 = Y)
tab[,-1] / tab[,1]
On 10/17/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Try this:
X - structure(11:15
Go the R home page (google for R), click on CRAN in left pane, choose
a mirror, click on Task Views in left pane and choose
Cluster.
On 10/17/06, Weiwei Shi [EMAIL PROTECTED] wrote:
hi,
is there some good summary on clustering methods in R? It seems there
are many packages involving it.
And
which can be parsed.
On 10/15/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
In gsubfn I replace matches with strings that represent calls to a function
and then perform paste(eval(parse(text= ...)), collapse = ) on the result.
One user of gsubfn is using it with very long strings (over 20,000
There is also a third way, namely use the missing function
in the code:
f - function(x) if (missing(x)) print(missing) else print(x)
f()
On 10/16/06, Hans-Peter [EMAIL PROTECTED] wrote:
Hi,
I am troubled by the use of NULL or NA to indicate
missing/non-specified function arguments.
In the
Try this:
grep(b|c|d, letters, value = TRUE)
[1] b c d
On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote:
Dear R-users,
is there a way to pass a list of patterns to the grep function? I
vaguely remember something with %in% operator...
Thanks,
Stéphane.
--
La science a
DF - data.frame(pat = letters[1:3])
grep(paste(DF$pat, collapse = |), letters, value = TRUE)
[1] a b c
On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote:
Ooops sorry for html tags... Just forgot to edit the message
before sending it...
So back to my question:
Thx for the hint, but
On 10/16/06, Hans-Peter [EMAIL PROTECTED] wrote:
2006/10/16, Duncan Murdoch [EMAIL PROTECTED]:
As Gabor said, the third way is to give no default, but test missing()
in the code.
I forgot this one, thank you. In my case it is probably not suited as
I just pass the arguments to a C (Pascal)
On 10/16/06, Frank McCown [EMAIL PROTECTED] wrote:
Forgive my ignorance, but shouldn't '\\' be converted into '\' in my
string? In my output (below), you can see that '\\' remains '\\'.
term = mother\'s day
term
[1] mother's day
term = mother\\\'s day
term
[1] mother\\'s day
??
for example:
d - diag(3)
a - A
yacas( d * a )
Thanks,
Cleber Borges
Gabor Grothendieck wrote:
Ryacas is an R interface to the free yacas computer algebra
system. Ryacas allows one to send R expressions,
unprocessed yacas strings and certain other R objects to a
separate yacas
) |
||
| ( 0 ) ( 0 ) ( a ) |
\/
On 10/16/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Its pretty limited right now but you can do this:
library(Ryacas)
d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
a - Sym(a)
a * d
expression(list(list(a, 0, 0
) |
||
| ( 0 ) ( a ) ( 0 ) |
||
| ( 0 ) ( 0 ) ( a ) |
\/
On 10/16/06, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
Its pretty limited right now but you can do this:
library(Ryacas)
d - List(List(1, 0, 0), List(0, 1, 0), List
Try this:
eval(parse(text = pi + 3))
On 10/14/06, Lloyd Lubet [EMAIL PROTECTED] wrote:
I'd like to excute character strings such as z-plot( objects()[1]; eval(z)
and viola I'd have a plot of my first dataframe in the first frame.
Unfortunately this approach no longer works.
Help?
Lloyd
Here is a completely different solution using gplot in sna. We create
an edge matrix, edges, and plot it.
library(sna)
edges - replace(matrix(0, 8, 8), cbind(match(x0, xx), match(x1, xx)), 1)
gplot(edges, coord = cbind(xx, yy), usearrows = FALSE,
vertex.col = c(black, white)[factor(aa)])
On
In gsubfn I replace matches with strings that represent calls to a function
and then perform paste(eval(parse(text= ...)), collapse = ) on the result.
One user of gsubfn is using it with very long strings (over 20,000 characters)
and the parse is giving an input buffer overflow. Here is an
?Ryacas
---
Rob Goedman, goedman at mac dot com
Gabor Grothendieck, ggrothendieck at gmail dot com
Søren Højsgaard, Soren.Hojsgaard at agrsci dot dk
Ayal Pinkus, apinkus at xs4all dot nl
___
R-packages mailing list
R-packages@stat.math.ethz.ch
https
Try this:
table(lapply(my.data, rep, my.data$weight)[1:2])
On 10/14/06, Adrian Dusa [EMAIL PROTECTED] wrote:
Dear all,
This is probably a stupid question for which I have a solution, which
unfortunately is not as straighforward as I'd like. I wonder if there's a
simple way to apply a
On Saturday 14 October 2006 16:00, Gabor Grothendieck wrote:
Try this:
table(lapply(my.data, rep, my.data$weight)[1:2])
On 10/14/06, Adrian Dusa [EMAIL PROTECTED] wrote:
Dear all,
This is probably a stupid question for which I have a solution, which
unfortunately
I missed your second question. See ?cov.wt
On 10/14/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Try this (and round the result to make to it comparable to your calculation):
xtabs(weight ~ var1 + var2, my.data)
On 10/14/06, Adrian Dusa [EMAIL PROTECTED] wrote:
Thanks for this Gabor
Try using OLS starting values:
glm(Y~X,family=gaussian(link=log), start = coef(lm(Y~X)))
On 10/14/06, Michael Dewey [EMAIL PROTECTED] wrote:
At 15:31 13/10/2006, Ronaldo ReisJunior wrote:
Hi,
I have some similar problems. Some times ago this problem dont there existed.
Look this simple
Try this:
f - function(x, y, z) (x + y + z)^2
integrate(f, 0, 1, x = 0, z = 0) # integrate f setting x=z=0
0.333 with absolute error 3.7e-15
On 10/14/06, Lorenzo Isella [EMAIL PROTECTED] wrote:
Dear All,
I am working with functions of several variables, e.g. f(x,y,z).
At some point,
Here is another approach using the same data as in
John Fox's reply. His is probably superior but this
does have the advantage that its very simple. Note
that it gives the same coefficients and R squared
to several decimal places. We just simulate a
data set with the given means and variance
There was a missing line:
On 10/14/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Here is another approach using the same data as in
John Fox's reply. His is probably superior but this
does have the advantage that its very simple. Note
that it gives the same coefficients and R squared
If you are just modifying an S3 method in a package you may not need to reinsert
the method into the package since UseMethod first looks into the
caller environment
for methods anyways and only second does it look for methods in the
package. Thus:
HTML.data.frame - R2HTML:::HTML.data.frame
Here are two ways:
1. Using inner from:
http://tolstoy.newcastle.edu.au/R/help/05/04/3709.html
try:
array(inner(t(X), Y, *), c(4, 21))
2. using model.matrix get all terms and interactions and eliminate the
non-interactions:
model.matrix(~ X * Y - X - Y - 1)
On
read your data frame in all at once and then cut it on x[2] and split
the result, e.g.
split(iris, cut(iris$Sepal.Length, 4:8))
Please provide reproducible code. Without input its not reproducible.
See last line of every message to r-help.
On 10/13/06, Marco Grazzi [EMAIL PROTECTED] wrote:
On Windows you could just put this into sweave.bat, say, and then
place that anywhere in your path (or in the current directory):
set infile=%~sdpn1
set infile=%infile:\=/%
cmd Rcmd Sweave %infile%.Rnw
pdflatex %infile%.tex
start %infile%.pdf
On 10/13/06, Thomas Harte [EMAIL PROTECTED] wrote:
Try this:
class(attributes(x)$row.names)
[1] integer
rownames(x) - as.character(rownames(x))
class(attributes(x)$row.names)
[1] character
On 10/13/06, Hsiu-Khuern Tang [EMAIL PROTECTED] wrote:
Reading the list of changes for R version 2.4.0, I was happy to see that the
row names of
On 10/11/06, Marc Schwartz [EMAIL PROTECTED] wrote:
On Wed, 2006-10-11 at 13:30 -0400, Charles Annis, P.E. wrote:
Greetings:
I've searched the R archives with no luck.
I want to print this to the screen as part of on-screen instructions as an
example:
default.FACTOR.labels -
You can define your own class then define [ to act any way you would like:
[.myobj - function(x, ...) {
y - unclass(x)[...]
attributes(y) - attributes(x)
y
}
tm - structure(1:10, units = sec, class = myobj)
tm
tm[3:4] # still has attributes
On 10/11/06, Michael
That's a windows message which says it can't find the command
you typed anywhere on its path.
If you can't figure it out get Rcmd.bat from batchfiles:
http://cran.r-project.org/contrib/extra/batchfiles/
and place that file anywhere on your path. It will
find R in the registry and run
Because y[1] and y[5] are not the same in Part1 but are in Part2:
# using y from Part1
y[5] - y[1]
[1] 1.110223e-16
You could round your numbers to 2 digits, say:
rank(round(100*y)) # y is from Part1
[1] 3.5 5.0 1.0 2.0 3.5
On 10/10/06, Li Zhang [EMAIL PROTECTED] wrote:
Does anyone know
Your example does not exhibit that behavior when I try it (below).
Can you provide a reproducible example following the style
shown here:
Lines - a 1 2e-4
+ b 2 3e-8
DF - read.table(textConnection(Lines))
str(DF)
'data.frame': 2 obs. of 3 variables:
$ V1: Factor w/ 2 levels a,b: 1 2
$
Here are two ways:
f1 - function(i) weighted.mean(X[i,1], X[i,2])
aggregate(list(wmean = 1:nrow(X)), as.data.frame(X[,3:5]), f1)
f2 - function(x) data.frame(wmean = weighted.mean(x[,1], x[,2]), x[1, 3:5])
do.call(rbind, by(X, as.data.frame(X[,3:5]), f2))
Also you check out the na.rm= argument
As a workaround use evaluate=FALSE argument to update and
evaluate it yourself fetching the environment from the innards
of the lm structure:
f - function() {
DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
lm(y ~ x1, DF)
}
f.lm - f()
e - attr(terms(f.lm), .Environment)
(2, 1, 12), x2 = gl(2,6))
f.lm - lm(y ~ x1, DF)
f.lm$update - function(object = f.lm, ...) update(object, ...)
f.lm
}
f.lm - f()
f.lm$update(formula = y ~ x2)
On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:
Gabor Grothendieck wrote:
As a workaround use evaluate=FALSE argument
Perhaps the evaluate= argument could be extended to
allow an environment or an object for which
environment(object) yields an environment, e.g.
update(y ~ x2, evaluate = formula(f.lm))
On 10/10/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
On 10/10/2006 1:32 PM, Martin C. Martin wrote:
Gabor
Its saying you are trying to pass a list to zoo (a data frame is a list);
however, from ?zoo we see zoo takes a first argument of:
a numeric vector, matrix or a factor.
On 10/10/06, Horace Tso [EMAIL PROTECTED] wrote:
dear list,
I have these hourly price data over a 20 year period. Among other
See ?try or ?tryCatch. The basic idiom is given here:
https://stat.ethz.ch/pipermail/r-help/2005-May/072035.html
On 10/10/06, Warren [EMAIL PROTECTED] wrote:
Hi all,
I am trying to do fitting of large sets of timeseries data, and error
messages derail the process when I encounter a dataset
Or just:
lapply(x, integrate, f = dnorm, upper = Inf)
On 10/11/06, Tobias [EMAIL PROTECTED] wrote:
I think I have figured it out myself, would however like to know the opinion
of more experienced coders. Is this a good way of approaching this:
cumdnorm1 - function(x)
).
This plot was produced with R 2.4 on windows and lattice 0.14-9.
Thanks and regards,
Ritwik.
On 10/9/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Could you explain what does not work means. It seems to produce a
graph with x-y numbers on it in R 2.4.0 on Windows.
At any rate, I
On 10/9/06, hadley wickham [EMAIL PROTECTED] wrote:
Current .Rd documentation has some obvious problems:
- the parser strips comments out of examples when it runs them
- there's no way to put images into the documentation
- the keywords aren't much use
- there's isn't a definition
See:
http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg09925.html
On 10/9/06, Jonathan Williams
[EMAIL PROTECTED] wrote:
Dear R Helpers,
I want to test if a procedure within a loop has produced an error or not.
If the procedure has produced an error, then I want to ignore its result.
Or perhaps its clearer (and saves a bit of space) to use apply...prod
here instead of exp...log:
fft(apply(mvfft(t(cbind(1-p,p,0,0,0))), 1, prod), inverse = TRUE)/5
On 10/7/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
One can get a one-line solution by taking the product of the FFTs
On 10/8/06, Ted Harding [EMAIL PROTECTED] wrote:
On 08-Oct-06 Gabor Grothendieck wrote:
Or perhaps its clearer (and saves a bit of space) to use apply...prod
here instead of exp...log:
fft(apply(mvfft(t(cbind(1-p,p,0,0,0))), 1, prod), inverse = TRUE)/5
Yes, that's neat (in either
On 10/8/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
On 10/8/06, Ted Harding [EMAIL PROTECTED] wrote:
On 08-Oct-06 Gabor Grothendieck wrote:
Or perhaps its clearer (and saves a bit of space) to use apply...prod
here instead of exp...log:
fft(apply(mvfft(t(cbind(1-p,p,0,0,0))), 1
And here is a fourth:
as.numeric(format(dd, %Y)) + (quarters(dd) Q1)
On 10/8/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Here are three alternative ways to get the fiscal year as a numeric
value assuming:
dd - as.Date(x$Date,%d/%m/%Y)
# add one to year if month is past March
The Tinn-R editor on sourceforge can do that.
There is also a useful intro here on setting up Tinn-R:
http://genetics.agrsci.dk/~sorenh/misc/Rlive/index.html
On 10/8/06, Lina Jansen [EMAIL PROTECTED] wrote:
Hello,
a colleague of mine uses R on his Mac and he has quite a nice feature: When
he
Try
read.zoo(myfile, sep = ,, FUN = as.POSIXct)
or
to.chron - function(x) {
s - do.call(rbind, strsplit(format(x), ))
chron(dates(s[,1], format = Y-M-D), times(s[,2]))
}
read.zoo(myfile, sep = ,, FUN = to.chron)
depending on which class you want.
On 10/8/06, Leeds, Mark (IED)
Could you explain what does not work means. It seems to produce a
graph with x-y numbers on it in R 2.4.0 on Windows.
At any rate, I would have done it like this although I think you can
leave off the [1] on subscripts and it will still work.
library(lattice)
library(grid)
xyplot(y1 + y2 ~ x |
Try
n - 1
f - if (n == 1) sin else cos
f(pi)
On 10/7/06, Alberto Vieira Ferreira Monteiro [EMAIL PROTECTED] wrote:
Why this kind of assignment does not work?
n - 1
f - ifelse(n == 1, sin, cos)
f(pi)
this must be rewritten as:
n - 1
f - cos
if (n == 1) f - sin
f(pi)
[oops.
I have noticed that dispatch on functions seems not to work
in another case too. We define + on functions (I have ignored
the niceties of sorting out the environments as we don't really
need it for this example) but when we try to use it, it fails even
though in the second example if we run it
One can get a one-line solution by taking the product of the FFTs.
For example, let p - 1:4/8 be the probabilities. Then the solution is:
fft(exp(rowSums(log(mvfft(t(cbind(1-p,p,0,0,0)), inverse = TRUE)/5
On 10/7/06, Ted Harding [EMAIL PROTECTED] wrote:
Hi again.
I had suspected that
Try this:
run.lm - function(DF, response = names(DF)[1], fo = y~.) {
fo[[2]] - as.name(response)
eval(substitute(lm(fo, DF)))
}
# test
run.lm(iris)
run.lm(iris, Sepal.Width)
Another possibility is to rename the first column:
On 10/7/06, HelponR [EMAIL PROTECTED] wrote:
Here are three alternative ways to get the fiscal year as a numeric
value assuming:
dd - as.Date(x$Date,%d/%m/%Y)
# add one to year if month is past March
as.numeric(format(dd, %Y)) + (format(dd, %m) 03)
# same but using POSIXlt
# (Even though there are no time zones involved I have seen
#
Reparameterize replacing x1 with x2+delta constraining delta
to be positive or else replace x1 with x2 + delta^2 and
no constraint.
On 10/6/06, Felix Eggers [EMAIL PROTECTED] wrote:
I am trying to optimize a likelihood function using constrOptim. I
know from prior research that, e.g. x1x2. Is
Hi, I need installation instructions. library(pmg) seems not to be enough.
Thanks.
library(pmg)
Loading pmg()
Loading required package: gWidgets
Loading required package: gWidgetsRGtk2
Loading required package: RGtk2
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to
There is a generalized inner product here:
http://tolstoy.newcastle.edu.au/R/help/05/04/3709.html
On 10/6/06, Atte Tenkanen [EMAIL PROTECTED] wrote:
Hi,
Can somebody tell me, which is the fastest way to make comparisons between
all rows in a matrix (here A) and put the results to the new
You can get that by using zero width lookahead assertions. They must
match but are not consuming so the next match will not be forced
to start past them. See ?regex and
http://www.regular-expressions.info/lookaround.html
for more.
gregexpr( [a-z](?= [a-z] ), a b c d e f , perl = TRUE)
On
Grouping the data frame by the first two columns, apply colMeans
and then rbind the resulting by-structure together:
do.call(rbind, by(DF, DF[2:1], colMeans, na.rm = TRUE))
On 10/5/06, Greg Tarpinian [EMAIL PROTECTED] wrote:
R 2.3.1, WinXP:
I have a puzzling problem that I suspect may be
On 10/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Also see package caTools.
On 10/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
See:
http://tolstoy.newcastle.edu.au/R/help/04/10/5161.html
On 10/4/06, JOHN VOIKLIS [EMAIL PROTECTED] wrote:
Hello,
I wrote the function
] wrote:
On 9/29/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Here are two possibilities. The first use trellis.focus/trellis/unfocus
to
add text subsequent to drawing the xyplot and the second uses a
custom panel:
xyplot(x ~ x, data = data.frame(x = 1:10))
trellis.focus
There are two places that I find the current way it works to be
less than ideal although its not that bad either:
1 .when one wants to define strings that have quotes then
one must be careful to use double quoted strings to contain
single quotes and single quoted strings to contain double quotes
with parameters are very uncomfortable, but the code you gave me is
great!
Meinhard
On Oct 4, 2006, at 5:25 PM, Gabor Grothendieck wrote:
longfun could just pass a, b and d to each of the individual
functions and each of the individual functions could pass
out back as a return value.
f1 - f2
I seem to have omitted g
library(lattice)
xyplot(x ~ x | g, data = data.frame(x = 1:12, g = gl(3,4)), panel =
function(...) {
panel.xyplot(...)
panel.text(x=2, y=4, labels=which.packet())
})
On 10/5/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
This requires R 2.4.0. Its
Probably the best you can hope for is to cover
most cases. This one uses match.call and handles
a number of cases and perhaps if you spend more time
on it might be able to add some cases where it fails
such as the second L below:
f - function(x) {
if (!is.list(x)) x - list(x)
if
I should have mentioned is that the way it works is that
it uses the name of the list component, if any, otherwise
it uses the name of the function if its given as a number
and otherwise it uses the function itself or possibly the
name of the list.
On 10/5/06, Gabor Grothendieck [EMAIL PROTECTED
I should have mentioned is that the way it works is that
it uses the name of the list component, if any, otherwise
it uses the name of the function if its given as a name
and otherwise it uses the function itself or possibly the
name of the list.
On 10/5/06, Gabor Grothendieck [EMAIL PROTECTED
(match.call()[-1][[1]]))
}
myfun(mean)
myfun(list(mean, sd))
On 10/5/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
I should have mentioned is that the way it works is that
it uses the name of the list component, if any, otherwise
it uses the name of the function if its given as a name
This produces a list whose ith element is matrix Xi :
X4 - replace(matrix(0, 4, 4), cbind(4, 4), 1)
lapply(1:4, function(i) replace(X4, cbind(i,i), 1))
On 10/4/06, Ya-Hsiu Chuang [EMAIL PROTECTED] wrote:
Hi,
I am trying to create matrices X's based on one indicator variable, r.
Given a 4
Here are a few ways:
now - Sys.time()
Epoch - now - as.numeric(now)
i + Epoch
structure(i, class = c(POSIXt, POSIXct))
class(i) - c(POSIXt, POSIXct)
On 10/4/06, paul sorenson [EMAIL PROTECTED] wrote:
What is the recommended way to convert/coerce and integer to a POSIXct
please?
d -
longfun could just pass a, b and d to each of the individual
functions and each of the individual functions could pass
out back as a return value.
f1 - f2 - function(a, b, d) a+b+d
longfun1 - function() {
a - b - d - 1
out - f1(a, b, d)
out - f2(a, b, d) + out
out
}
longfun1() # 6
Try this:
replace(BOD, TRUE, lapply(BOD, factor))
On 10/4/06, Weiwei Shi [EMAIL PROTECTED] wrote:
Hi,
I use apply
apply(x, 2, factor)
but it does not work. please help. thanks.
--
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.
Did you always know?
No, I did not. But I
Is the idea here to have the NA entries be a factor level? Try this:
table(format(EthnicCode))
with appropriate mods if you want to rearrange the levels.
On 10/4/06, David Scott [EMAIL PROTECTED] wrote:
I think this is one for Gabor. I don't seem to be able to find my way to
an answer
Just one small point on this. This may not matter to you but
just in case it does, if L - lapply(BOD, factor) then
replace(BOD, TRUE, L)
data.frame(L)
are not exactly the same in the case that BOD has additional
attributes (which in this case it does). The first one will
preserve the
See:
http://tolstoy.newcastle.edu.au/R/help/04/10/5161.html
On 10/4/06, JOHN VOIKLIS [EMAIL PROTECTED] wrote:
Hello,
I wrote the function, below, in the hope of _quickly_ generating a
sliding-window time series of the mean, sd, median, and mad values
from a matrix of data. The script below
Also see package caTools.
On 10/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
See:
http://tolstoy.newcastle.edu.au/R/help/04/10/5161.html
On 10/4/06, JOHN VOIKLIS [EMAIL PROTECTED] wrote:
Hello,
I wrote the function, below, in the hope of _quickly_ generating a
sliding-window
As indicated in ?rollmean there are only ts and zoo methods
for rollapply. Try
rollapply(zoo(1:10), 3, mean)
Also note that as indicated in ?rollmean, rollmean does
have a default method:
rollmean(1:10, 3)
On 10/3/06, Horace Tso [EMAIL PROTECTED] wrote:
Hi list,
I'm a little confused
See ?mean and note the na.rm= argument:
aggregate(frame[-1], frame[1:2], mean, na.rm = TRUE)
On 10/1/06, Frank [EMAIL PROTECTED] wrote:
Dear r-help reader,
I have some problems with the aggregate function.
My datframe looks like
frame
Day Time V1 V2
1 M0 3 NA
2 M0 4
That's note the only problem. The point (B, 14) is plotted at (C, 14).
Your problem is that:
factor(letters)[2:3, drop = TRUE]
[1] b c
Levels: b c
so now b has level 1 and c has level 2 so if you try to plot b from the
original factors where it was 2 it will show up above c and c will not
Here are 4 approaches in order from most compact
to least. #1 only works for numeric matrices, # 2 is
a shorter versio of your solution using rep.vec and # 3
is from Alex's post and is likely what I would
use in practice.
m - matrix(1:4, 2) # test matrix
# 1 - m must be numeric for this one to
Check out ?dput
On 9/30/06, Ritwik Sinha [EMAIL PROTECTED] wrote:
Hi,
I would like to write a list to an ascii file.
I tried the following
y - list(a = 1, b = c(TRUE,FALSE), c = oops)
save(y, file=y.data, ascii=TRUE)
# Not satisfactory
print does not have a file= option
cat cannot
For the last line you could also consider the print.data.frame method:
data.frame(Symbol = symbols, dolVol = dolVol.pretty)
or
data.frame(row.names = symbols, dolVol = dolVol.pretty)
capture.output or sink could be used if you want to direct it to a file.
On 9/30/06, BBands [EMAIL
it does is
looping through
each row(or col) , which would be slow for large matrix, right ?
cheers
- Original Message -
From: Gabor Grothendieck [EMAIL PROTECTED]
Date: Saturday, September 30, 2006 4:54 am
Subject: Re: [R] How to repeat vectors ?
To: Tong Wang [EMAIL PROTECTED]
Cc
Try:
mapply(%*%, mylist1, mylist2, SIMPLIFY = FALSE)
Please provide self-contained examples as requested on
the last line of every message to r-help. That means the
data for X1, X2, Y1, Y2 should be included so one can
run the code you post.
On 10/1/06, Tong Wang [EMAIL PROTECTED] wrote:
Hi,
On 9/29/06, hadley wickham [EMAIL PROTECTED] wrote:
But doesn't R has a rather limited force of lazy evaluation? - you
have no control over it, apart from that arguments are evaluated
lazily. This rather limited compared to other languages (no lazy
lists etc)
You do have more
Here are two possibilities. The first use trellis.focus/trellis/unfocus to
add text subsequent to drawing the xyplot and the second uses a
custom panel:
xyplot(x ~ x, data = data.frame(x = 1:10))
trellis.focus(panel, 1, 1)
panel.text(x=2, y=4, labels=Text)
trellis.unfocus()
xyplot(x ~ x, data =
Try this:
f - function(x,xlab) truehist(x, xlab = xlab)
mapply(f, as.data.frame(X), colnames(X))
On 9/29/06, Ravi Varadhan [EMAIL PROTECTED] wrote:
Hi,
I have a simple problem that I would appreciate getting some tips. I am
using the truehist function within an apply call to plot
Try:
as.dist(mymatrix)
On 9/29/06, Deming Mi [EMAIL PROTECTED] wrote:
Dear R users,
I have computed a diagonal distance matrix and it's in a matrix format (I
did not use the dist() function). However hclust() does not take my
distance matrix as correct input object. It seems that hclust()
Here is one way that does not require explicit assignment of tzone:
rbind(data.frame(x=xx), data.frame(x=xx[1] - 60), data.frame(x=xx[2] + 60))[[1]]
With xx from the post we get:
rbind(data.frame(x=xx), data.frame(x=xx[1] - 60), data.frame(x=xx[2] +
60))[[1]]
[1] 2006-09-26 12:00:00 GMT
If Comparison and Candidates each have no duplicated rows (which
is the situation in the example) then try this:
tail(!duplicated(rbind(Comparison, Candidates)), nrow(Candidates))
On 9/28/06, Dirk Eddelbuettel [EMAIL PROTECTED] wrote:
Dear useRs,
I am having a hard time coming up with a
See ?SafePrediction for how it works in R.
Also the example here:
http://www.mayin.org/ajayshah/KB/R/html/o9.html
On 9/28/06, Spencer Jones [EMAIL PROTECTED] wrote:
I am fitting a regression model with a bs term and then making predictions
based on the model. According to some info on the
foo2 could be written:
foo3 - function(x, y = x) { force(y); x - 0; y }
to make it clear that evaluation of y is being forced. See ?force
On 9/28/06, Ulrich Keller [EMAIL PROTECTED] wrote:
Hello,
and sorry if this is already explained somewhere. I couldn't find anything.
R (2.3.1,
See:
http://tolstoy.newcastle.edu.au/R/help/06/02/21556.html
On 9/28/06, Charles Annis, P.E.
[EMAIL PROTECTED] wrote:
Greetings R-ians:
Searching the Searchable Mail Archives I discovered that ctrl L will clear
the Rgui screen, which is what I'd like to do from a print (or some similar)
On 27 Sep 2006 10:57:15 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote:
Tong Wang [EMAIL PROTECTED] writes:
Hi,
I am writing a function and need to pass a function expression as an
argument, for instance,
myfun - function( express) {
x- c(1,2,3)
# using this test data
set.seed(1)
x - 1:20/20
y - exp(2 + 3 * x) + rnorm(20)
# if its ok to fit logs so that its linear
exp(fitted(lm(log(y) ~ x)))
1 2 3 4 5 6 7 8
8.55615 9.94692 11.56376 13.44340 15.62857 18.16894
801 - 900 of 3333 matches
Mail list logo