If DF is a data frame containing the rows then:
unique(t(apply(DF, 1, function(x) as.numeric(factor(x, levels = unique(x))
On 10/19/06, Tony Long <[EMAIL PROTECTED]> wrote:
> All:
>
> I have a matrix, X, with a LARGE number of rows. Consider the
> following three rows of that matrix:
>
> 1
One variation of this is:
"?" <- function(...) invisible(0)
?"this command illstrates blah, blah"
sin(pi)
rm("?")
On 10/19/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> On 10/19/2006 6:16 PM, Yurii Aulchenko wrote:
> > Dear All,
> >
> > I am programming a demo for an R package (say, the name
f <- function(f1, ...) {
args <- list(...)
lapply(args, print)
f1(...)
}
f(sin, pi)
On 10/19/06, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> how do i assign "1" or "2" to some destination variable?
> i mean, how do i use something to represent ... in
Try this:
f <- function(f1, ...) f1(...)
f(sin, 1)
f(max, 1, 2)
On 10/19/06, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a function like this:
>
> f <- function(f1) { ...}
>
> f1 is a function name itself.
> I have two candidates for f1, and each of them have different numbers
> of ar
ss I must be even
> dumber than I previously thought!
>
> Any help would still be welcome.
>
>
> On 10/19/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > Check out these packages:
> > - Ryacas (on omegahat) -- sockets between R and yacas
> >
Check out these packages:
- Ryacas (on omegahat) -- sockets between R and yacas
- mimR (on CRAN) -- sockets between R and mim (Windows only)
On 10/19/06, Grateful Frog <[EMAIL PROTECTED]> wrote:
> Hello R-helpers!
>
> I am new to R, but having a rough time with the socketConnection function. I
>
For your second question:
x <- chron(1)
x <- chron(x, out.format = ddmm)
using the ddmm from below.
On 10/19/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> As discussed the Help Desk article in R News 4/1, the 2 vs 4 year
> length is controlled by the chron.yea
As discussed the Help Desk article in R News 4/1, the 2 vs 4 year
length is controlled by the chron.year.abb option, e.g.
options(chron.year.abb = FALSE)
chron(20)
however, as also discussed there its not really recommended that
you use this option so try this instead:
ddmm <- func
Make sure that the Date column is actually of class "Date":
DF$Date <- as.Date(DF$Date, "%d-%b-%y")
plot(DF)
See ?as.Date . Also read the Help Desk article in R News 4/1 to
learn more about dates.
On 10/18/06, tom soyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have the following data in two colum
There is a new version, 0.2-9, of the Windows XP batchfiles
distribution. It is a zip file containing a set of Windows
XP batch scripts useful in conjunction with R.
The latest release adds sweave.bat which will 1. run sweave,
2. run pdflatex and then 3. view the pdf in sequence. If
sweave or pd
"(8.01,Inf]")
# 1
library(gsubfn)
colMeans(strapply(rn, "[^\][(),]+", as.numeric, simplify = TRUE))
# 2
library(gsubfn)
strapply(rn, "^.([^,]+), *(.+).$",
~ (as.numeric(x) + as.numeric(y))/2, backref = -2, simplify = TRUE)
# 3
with(read.table(textConnection(
Either 1. in your old workspace create a separate file using save that
contains only the variables you want to transfer (see ?save) and then
load that or
2. load the whole thing into an environment
e <- new.env()
load("myspace.rda", e)
and then copy out all the variables you want and delete e (th
Here are three solutions:
# Assume rn holds the rownames of the table
# rn <- rownames(my.table)
rn <- c("[-11.9,-10.6]", "(-10.6,-9.3]", "(-9.3,-8.01]", "(-8.01,-6.73]")
# 1
library(gsubfn)
colMeans(strapply(rn, "[-.0-9]+", as.numeric, simplify = TRUE))
# 2
library(gsubfn)
strapply(rn, "([-.0
May this:
gsub("\n", "", "
X:/level1/level2
/level3/level4/
level5/level6
")
On 10/18/06, Erik Chang <[EMAIL PROTECTED]> wrote:
> Dear R experts,
>
> I wonder how can one input a string variable in multiple lines in a R
> script. I've seen solution to the command line continuation in the
> non-st
Please use an informative subject for sake of the archives.
Here are several solutions:
aggregate(DF[4:8], DF[2], mean)
library(doBy)
summaryBy(x1 + x2 + x3 + x4 + x5 ~ name, DF, FUN = mean)
# if Exp, name and id columns are factors then this can be reduced to
library(doBy)
summaryBy(. ~ name,
rings 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 us
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.
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:
>
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 e
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
>
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.
>
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
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 w
Just one other comment. If you want to try running Linux over Windows
you might want to check out how the AndLinux project (google to find)
is progressing. I had tried it about a year ago and it was much faster
than VMware although at that time it was still a bit immature.
On 10/17/06, Gabor
Maybe there are timing problems using that setup with sockets? I once tried
VMware (not with Ryacas but just to try it out) and found it slow as can
be expected with an emulated environment. Since you have Windows XP just
use the Windows version of Ryacas directly.
On 10/17/06, Simon Blomberg <[E
> 0 , 1 ) )
>
>
>
> Thanks for your attention!
>
>
> Cleber Borges
>
>
>
>
> >Here is a slightly shorter way to do it although it
> involves passing
> >a yacas string directly:
> >
> >>yacas("a * Identity(3)")
> >
> >expression(list(list(a,
|
| ( 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), Li
econdly,
> Is there a way to send R'objects (variables) to yacas and make
> symbolic
> operations??
> for example:
>
> d <- diag(3)
> a <- "A"
>
> yacas( d * a )
>
> Thanks,
> Cleber Borges
>
>
> Gabor Grothendieck wrote:
>
> &
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]
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
> 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 f
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.
>
>
>
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 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
artif
?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
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)])
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.
>
> He
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
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 co
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 som
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
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
y.data$var1, my.data$var2))
> round(unweighted*total$weight, 0)
>
>
> Yet another question: how would the weight variable be applied to correlate
> two numerical variables?
>
> Best,
> Adrian
>
> On Saturday 14 October 2006 16:00, Gabor Grothendieck wrote:
> &g
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 ap
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
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:
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:
>
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)
O
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
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 Rcmd.ex
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
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.FAC
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) {integrat
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 datase
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
You need to substitute it into yourself. Also note that
displaying a function will display its source attribute
which may get unsynchronized with the actual function
if the function was constructed yourself so NULL it out
to be sure what you are seeing is what the unction
actually is:
# g is the
tin wrote:
> >
> > Gabor Grothendieck wrote:
> >> 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
12, x1 = gl(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:
&g
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")
eva
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
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"
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 k
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 resu
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 de
l there should be two lines, but this
> has just one (group lost).
>
> 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 &quo
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
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, M
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
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/
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...l
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 =
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
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 se
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:
>
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
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 exp
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
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)
O
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
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 lo
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. x1>x2.
ist(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 giv
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 &
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 PROTEC
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 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.
longfun3 work perfect for my "very
> untypical" problem. As I have many local variables, usual functions
> 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:
>
> > lo
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
o
> On 9/29/06, Deepayan Sarkar <[EMAIL PROTECTED]> 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 x
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,
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
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,
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
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 attribute
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
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 n
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(
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
> pleas
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.
>
> Give
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 confu
801 - 900 of 3469 matches
Mail list logo