I'm not sure if this is correct behavior or not, but it seems counterintuitive
to me:
dat <- data.frame(id=1:5, let=letters[1:5])
# A. omits the first row
dat[- 1, ]
# B. unexpectedly omits ALL rows
dat[- integer(0), ]
It would be less surprising if there were no rows omitted in the (B) case.
I have some large-ish files that are the output of save() from R 2.15.1, which
that version can load() just fine. After upgrading to 2.15.2, load() no longer
works on these files. Is this a known issue?
__
R-help@r-project.org mailing list
https://stat.e
The following three calls all produce the same result (my machine is in EST):
> as.POSIXct(0, tz="", origin=ISOdatetime(1970,1,1,10,0,0))
[1] "1970-01-01 10:00:00 EST"
> as.POSIXct(0, tz="EST", origin=ISOdatetime(1970,1,1,10,0,0))
[1] "1970-01-01 10:00:00 EST"
> as.POSIXct(0, tz="GMT", origin=IS
This version of my code makes the R process consume unreasonable amounts of RAM:
datf <- rbind(lapply(mylist, function(item) {
with(item, data.frame(col1, col2, col3))
}))
This version works fine:
datf <- lapply(mylist, function(item) {
with(item, data.frame(col1, col2, col3)
Bob O'Hara gmail.com> writes:
>
> On 4 April 2012 05:35, Jack Tanner hotmail.com> wrote:
>
> > samplesBgr("beta") # crash
> > samplesBgr("beta", plot=FALSE) # also crash
> >
> > Have you plotted your histories? I haven't u
Melrose2012 stonybrook.edu> writes:
>
> alive <- (fflies$living)
> dead <- (fflies$living[1]-alive)
> glm.fit <- glm(cbind(alive,dead)~fflies$day,family="binomial")
> summary(glm.fit)
Your call to glm() is not doing what you think it's doing. What you want to do
is probably closer to
glm.fit
(Using BRugs 0.7-5, R 2.14.2 32-bit on 64-bit Windows 7, OpenBUGS 3.2.1)
1. BRugs crashes R for me as follows. Sorry about the lack of detail; please let
me know if / how to supply a more useful bug report on this issue.
fit <- BRugsFit(...)
# BRugs and OpenBUGS runs fine, the parameter estimates
David Winsemius comcast.net> writes:
> sapply(tz, function(ttt) as.POSIXct(x=x, tz=ttt,
> origin="1960-01-01"),simplify=FALSE)
Sure, there's no end of workarounds. It would just be consistent to treat both
the x and the tz arguments as vectors.
__
R
x <- 1472562988 + 1:10; tz <- rep("EST",10)
# Case 1: Works as documented
ct <- as.POSIXct(x, tz=tz[1], origin="1960-01-01")
# Case 2: Fails
ct <- as.POSIXct(x, tz=tz, origin="1960-01-01")
If case 2 worked, it'd be a little easier to process paired (time, time zone)
vectors from different time z
jim holtman gmail.com> writes:
> > match(f, names(z))
> [1] 2 3
Jim, thanks so much, that's right on.
Patrick, thanks to you too, but yours is not the same as what I asked:
> z <- c(3,4,5,4)
> names(z)<- c("a","b","c","b")
> z[f]
b c
4 5
Yours returns the actual values in z, not the indexes
I have a named vector:
> z <- c(1, 2, 3, 2)
> names(z) <- c("a","b","c","b")
> f <- c("b","c")
I want to know the index in z of the first occurrence of each of the values in
f.
One implementation is
> sapply(f, function(x) which(names(z)==x)[1])
b c
2 3
Is which() smart enough to stop when i
I've got a sparse term list of the form
term1 doc1
term2 doc1
term3 doc2
etc.
I'd like to load this into a Corpus, as defined in the tm package. I was
thinking that one way to do this is to iterate over the list building up the i,
j, v vectors for a simple_triplet_matrix, and then to use that as
Jack Tanner hotmail.com> writes:
> > b = quote(b==3)
>
> Now I want to append "&& x > 2" to the value of b. How do I do that?
Never mind, I figured it out:
substitute(b && x > 2, list(b=b))
__
R-help@
AjayT googlemail.com> writes:
> The data looks like this,
>
> Id=1 time=2011-03-27 19:23:40 start=1.4018 end=1.4017
> Id=2 time=2011-03-27 19:23:40 start=1.8046 end=1.8047
Something like this would do:
lines = scan(file, nlines=1, ...)
fields = strsplit(lines[1], "\s+", perl=TR
I have a variable of mode "call":
> b = quote(b==3)
> b
b == 3
Now I want to append "&& x > 2" to the value of b. How do I do that?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http:
Wainscott, Robert LT cvn74.navy.mil> writes:
> I want to split dataset "ZIDL", into individual datasets based on the
> string content of variable "Dept".
There are many, many ways to do this, depending on what you're really after.
Here's one:
depts = levels(factor(zidl$dept))
for (i in 1:length
I have a data structure that is fast to dput(), but very slow to dget(). On
disk, the file is about 35MB.
> system.time(dget("r.txt"))
user system elapsed
142.931.27 192.84
The same data structure is fast to save() and fast to load(). The .RData file on
disk is about 12MB.
> system.t
[Apologies in advance if this is too "statistics" and not enough "R".]
I've got an experiment with two sets of treatments. Each subject either received
all treatments from set A or all treatments from set B.
I can compute the N pairwise correlations for all treatments in either set using
cor().
I'm writing SQL queries, and it's very handy to be able to use sQuote for string
parameter values. It makes me wish that I could use an sQuote-like function for
enclosing column names and other identifiers in backticks, i.e., select `foo`
from `table`. Obviously I can do this with paste(), I'm just
About 2 years ago, Tobias Verbeke asked:
"I am looking for a way to capture the binary string that in normal use of
graphics devices will bewritten to (most commonly) a file connection... Is
there a way of capturing the binary `jpeg string'
[generated by jpeg()]?"
http://tolstoy.newcastle.edu.
Szabolcs Horvát gmail.com> writes:
> You could use the modulo operator.
> >
> > # additional examples of what I want
> > seq(from=2, length.out=4, rlimit=3)
> > [1] 2 3 1 2
>
> seq(from=1, length.out=4) %% 3 + 1
Ah, that's so slick. You're off to a great start! Huge thanks to you and
everyone
Henrique Dallazuanna gmail.com> writes:
> Try rep:
>
> rep(2:4, length.out = 3, times = 10)
That's close, but it doesn't wrap to start at 1.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting
I'd like to have something like seq() where I can pass in a length of the
desired sequence and a right limit so that the sequence goes up to the limit and
then starts again from 1.
# works now
seq(from=2, length.out=3)
[1] 2 3 4
# what I want
seq(from=2, length.out=3, rlimit=3)
[1] 2 3 1
# addit
Apologies for the noob question. I need to split setting up a plot and drawing
it into two functions. One determines the properties of a plot (data, axis,
labels, etc.), and the other plots it (using a preferred device, image
dimensions, etc.).
get.props = function() {
list(x=x, y=y, xlab="foo",
Gabor Grothendieck gmail.com> writes:
> URLdecode.vec <- Vectorize(URLdecode)
>
> On Sat, Aug 29, 2009 at 10:31 AM, Jack Tanner hotmail.com> wrote:
> >
> > Could URLdecode be modified to actually process all elements of the vector,
> > not just the first?
Using R 2.9.2 on Windows XP SP3.
1. Edit ~/Rconsole, and set
font = TT Bitstream Vera Sans Mono
2. Start Rgui.exe
3. Go to Edit, GUI Preferfences
4. Rgui.exe crashes
Rgui.exe does not crash if I do not access GUI Preferences (i.e., if I just use
R), and it does correctly use Bitstream Vera Sans
In R 2.9.2,
> URLdecode(c("a%20b", "b%20c"))
[1] "a b"
Warning message:
In charToRaw(URL) : argument should be a character vector of length 1
all but the first element will be ignored
Could URLdecode be modified to actually process all elements of the vector, not
just the first?
Thanks in advanc
There's a funny inconsistency in how t.test handles paired=T or paired=F. If x
and y parameters are lists, paired=F works, but paired=T doesn't.
> lg=read.csv("my.csv")
> a = subset(lg, condition=="a")["score"]
> b = subset(lg, condition=="b")["score"]
> t.test(a,b)
> t.test(a,b, paired=TRUE)
Erro
28 matches
Mail list logo