I'd like to plot a given time series in a primary color but highlight
a segment of it in a different color. Is there an elegant way to do
it?
A+
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the postin
I have a dataframe with many rows like this:
> df
X1 X2 X3 X4 X5 X6 X7 week d
sim1 FALSE TRUE TRUE TRUE TRUE TRUE TRUE1 0.3064985
sim1 is the rowname, X1..X7,week,d are the column names. X1..X7 are factors,
booleans in this case.
I need to add another r
How do I apply a function to every row of a dataframe most naturally?
Specifically, I'd like to filter out any row which contains an Inf in any
column. Since all columns are numeric, I guess max should work on a row...
-- Alexy
__
R-help@r-project.or
On Mar 3, 2011, at 4:22 AM, antujsrv wrote:
>
> I wish to develop a web crawler in R.
As Rex said, there are faster languages, but R string processing got better due
to the stringr package (R Journal 2010-2). When Hadley is done with it, it
will be like having it all in R!
-- Alexy
_
This is really a statistics problem, so I wonder which R packages can be
employed best to solve and visualize it.
I run a lot of simulations to approach the truth. The truth is a result of
very complex computations, and is a real number. The closer it is to 0, the
truthier it is.
Each simula
On Sun, Dec 6, 2009 at 3:04 PM, Duncan Murdoch wrote:
> Does that directory exist? .libPaths("foobar") silently does nothing,
> because (on my system) "foobar" is not a directory. (This is documented
> behaviour, though it would perhaps be friendlier if it gave a warning when
> it dropped a reque
I have the .libPaths() defined in my .Rprofile, and it stopped having any
effect. Even if I try to do it in the REPL, as:
> x <-
> paste(Sys.getenv("HOME"),"/Library/R/",paste(R.version$major,as.integer(R.version$minor),sep='.'),"/library",sep='')
> x
[1] "/Users/alexyk/Library/R/2.10/library"
I used to have the following in my .Rprofile:
if (length(.libPaths())==1)
.libPaths(paste(Sys.getenv("HOME"),"/Library/R/",paste(R.version$major,as.integer(R.version$minor),sep='.'),"/library",sep=''))
-- and it added my user-defined library directory. Then I installed
packages there, so during
How can I make R separate thousands, millions, etc., on the plot axes,
with commas?
Cheers,
Alexy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.h
I need to fit a graph into a column of a 2-column paper. I found that
just specifying width and height parameters (3.2in x 3.5in) to plot
doesn't decrease the fonts of the main title, axis titles, and
labeling numbers, and tick sizes. So I have to add cex to all labels
and titles and manage ticks
When trying to remember what did I do in the session, especially after
coming back to it after a few days, I'd like to mimic Unix's ls -ltrh
-- does R retain the timing a certain variable is created? If not,
would it make a useful addition, to have ls with an option to sort by
creation tim
I want to produce a dataframe with integer columns for elements of
string pairs:
pairs <- c("10 21","23 45")
pairs.split <- lapply(pairs,function(x)strsplit(x," "))
pdf <- as.data.frame(pairs.split)
names(pdf) <- c("p","q")
-- at this point things look good, except the columns are factors, as
res <- lapply(1:length(L),do.one)
Actually, I do
res <- lapply(:length(L),function(x)do.one(L[x]))
-- this is the price of needing the element's name, so I have to both
make do.one extract the name and the meat separately inside, and
lapply becomes ugly. Yet the obvious alternatives -- ex
Sometimes I'm iterating over a list where names are keys into another
data structure, e.g. a related list. Then I can't use lapply as it
does [[]] and loses the name. Then I do something like this:
do.one <- function(ldf) { # list-dataframe item
key <- names(ldf)
meat <- ldf[[1]]
mydf
I'm growing a large dataframe by composing new rows and then doing
row <- compute.new.row.somehow(...)
d <- rbind(d,row)
Is this a fast/preferred way?
Cheers,
Alexy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEA
I've had a very long file written out by R with write.table, with
fields of time values, converted from POSIXlt as.numeric. Among 2.5
million values, very few had 6 trailing zeroes, and those were output
in scientific notation as in the subject. Is this the default
behavior for long integ
On Jan 26, 2009, at 2:12 PM, Duncan Murdoch wrote:
df[get("colname", parent.frame()) == value,]
Actually, what I propose is a special search rule which simply
looks at the enclosing dataframe.name[...] outside the brackets
and looks up the columns first.
Yes, I understood that, and I ex
On 1/26/2009 1:46 PM, Alexy Khrabrov wrote:
Every time I have to prefix a dataframe column inside the indexing
brackets with the dataframe name, e.g.
df[df$colname==value,]
-- I am wondering, why isn't there an R scoping rule that search
starts with the dataframe names, as if we
Every time I have to prefix a dataframe column inside the indexing
brackets with the dataframe name, e.g.
df[df$colname==value,]
-- I am wondering, why isn't there an R scoping rule that search
starts with the dataframe names, as if we'd said
with(df, df[colname==value,])
-- wouldn't that
I found there's a very good functional set of operations in R, such as
apply family, Hadley Wickham's lovely plyr, etc. There's even a
Reduce (a.k.a. fold). Now I wonder how can we do pattern-matching?
E.g., now I split dimensions like this:
m <- dim(V)[1] # R
n <- dim(V)[2
On Oct 12, 2008, at 2:26 AM, Prof Brian Ripley wrote:
You need to use substitute() on the call. Something like
sapply(1:5,function(i)
eval(substitute(svm(person_oid ~ ., data=zrr[1:N,]),
list(N=100*i))
)
Thanks!
On Sun, 12 Oct 2008, Alexy Khrabrov wrote:
I want to train
I want to train svm models on increasingly large training data subsets
of some zrr as follows:
> m <- sapply(1:5,function(i)
svm(person_oid~.,data=zrr[1:100*i,]))# (*)
However, when I inspect m[1], it literally shows
> m[1]
[[1]]
svm(formula = person_oid ~ ., data = zrr[1:N, ])
-- as
Is there a way to select a subset of a dataframe consisting of all
those rows with rownames *except* from a subset of rownames to be
excluded? Example:
> a <- data.frame(x=1:10,y=10:1)
> a <- a[order(a$y),] # to make rownames differ visually
> a[8,]
x y
3 3 8
> a["8",]
x y
8 8 3
> a[-
Did anyone try to write R extensions in OCaml? What would it entail
to enable it?
Cheers,
Alexy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide
2008 at 11:03 AM, Alexy Khrabrov
<[EMAIL PROTECTED]> wrote:
I'd like to control my namespace thoroughly, separated by task. Is
there a
way, in R session, to introduce namespaces for tasks dynamically
and switch
them as needed? Or, is there a combination of load/save worksp
I'd like to control my namespace thoroughly, separated by task. Is
there a way, in R session, to introduce namespaces for tasks
dynamically and switch them as needed? Or, is there a combination of
load/save workspace steps which can facilitate this?
Cheers,
Alexy
I have two pairs of time intervals: coarse- and fine-grained. They're
components of their respective dataframes, looking like,
coarse:endtimestarttime
1t1_end t1_start
2 t2_end t2_start
...
fine: is the same, except that i
Greetings -- I'd like to present R to our university research group as
a viable platform to do machine learning applications for human
behavior modeling. The actual research will be further specialized,
but general activities -- acquiring/interfacing with the data,
specifying/learning a mo
quot;col1","Col2","COL3")
--- On Wed, 17/9/08, Alexy Khrabrov <[EMAIL PROTECTED]> wrote:
From: Alexy Khrabrov <[EMAIL PROTECTED]>
Subject: [R] creating horizontal dataframes with column names
To: [EMAIL PROTECTED]
Received: Wednesday, 17 September, 2008, 1:52
Greetings -- in order to write back to SQL databases, one needs to
create a dataframe with values. I can get column names of an existing
table with sqlColumns. Say I have a vector of values (if they're all
the same type), or a list (if different). How do I create a dataframe
with column
Greetings -- I have a dataframe a with one element a vector, time, of
POSIXct values. What's a good way to split the data frame into
periods of a$time, e.g. days, and apply a function, e.g. mean, to some
other column of the dataframe, e.g. a$value?
Cheers,
Alexy
__
Is there a way to associate descriptions with the objects in the
workspace, and later retrieve them to know what the object was created
for?
Thanks,
Alexy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do r
Certain timeseries I have had outliers, which I removed by assigning
NA to their positions. Now acf() refuses to go to work. What's the
right way to remove outliers from ts objects, and what are teh
standard ways to interpolate NAs in them?
Cheers,
Alexy
_
Greetings -- I've got some sensor data of the form
t1_1, t1_2
t2_1, t2_2
...
tN_1,tN_2
-- time intervals measuring starts and stops of sensor activity. I'd
like to see whether there's any regularity in it. Seems natural to
consider these data timeseries -- except most of the timeseries
p
On May 6, 2008, at 10:30 PM, Prof Brian Ripley wrote:
What were H & W? For png() they are (by default) in pixels, for
pdf() in inches.
You haven't told us your OS, but I guess Mac OS. Please update to R
2.7.0: that offers you two new png() devices for higher-quality
plots, and various o
I've used to have a script with a barplot command it in, preceded by a
png:
png(graph.file,height=H,width=W)
barplot(t,names.arg=breaks[2:(length(t)+1)],tck=gridlines)
-- worked before R 2.6.2. When I tried it in R 2.6.2, which I have
for a while but didn't run with that script, it complain
I've read in Phil Spector's new book that it's a good idea to
preallocate a big matrix, like
u <- matrix(0,nrow,ncol) # (1)
Now, I read contents of a huge matrix from a Fortran binary dump.
u <- readBin(con,what="double",n=nrow*ncol) # (2)
If I do (1) and then (2), u is a vector, obviously it
Greetings -- I'd like to avoid converting a Fortran array of floats
into ASCII and back reading it in R. Furthermore it's much faster to
dump large arrays in binary, as they take up much less space with full
precision -- many decimal points take up many bytes in ASCII versus
four or eight
Using wk <- with(d, split(word, kind)), I get the following class table:
wk$`1`
[1] "a" "bra" ... # (*)
wk$`10`
"ca" "dabra" ...
Now I need to export it in the following format:
classnum_members examples
1 23 a bra ...
104 ca
I'm trying to read a file in Windows CP1251 encoding (8-byte
Cyrillics). My Mac's iconv understands it fine under that alias.
Alas, I get an error, invalid multibyte string when trying to read
it. When I convert it to UTF-8 with iconv and read without
encoding=, all is well. However, I'
On Nov 24, 2007, at 2:07 PM, Chuck Cleland wrote:
> with(d, split(word, kind))
>
> # OR
>
> with(d, split(as.character(word), kind))
Awesome! Scoping: how do I get the result back to the top level?
> with(d, wk <- split(word,kind))
> wk
Error: object "wk" not found
-- trying to create it at
I wonder what's the right way in R to do the following -- placing
objects of the same kind together in subarrays of varying length.
Here's what I mean:
> word <- c("a","b","c","d","e","f","g","h","i","j")
> kind <- c(1,1,1,2,3,4,5,5,7,7)
> d <- data.frame(word,kind)
> d
word kind
1
What are idioms for taking a head or a tail of a vector, either up to
an index, or from an index to the end? Also -- is it necessary to
use length(v) to refer to the last element? E.g., Python has
v[:3] # indices 0,1,2
v[3:] # indices 3,4,...
v[-1] # the last element of v
v[:-1] # all but las
I'm running rle() on a long vector, and get a result which looks like
> uc
Run Length Encoding
lengths: int [1:16753] 1 1 1 1 1 1 1 1 1 1 ...
values : int [1:16753] 29462748 22596107 18322820 14323315
12684505 9909036 7296916 6857692 5884755 5883697 ...
I can print uc$names or uc$levels
Is there an R analog of the Unix command uniq -c:
http://en.wikipedia.org/wiki/Uniq
Given an array x, uniq -c replaces each contiguous subsequence of
identical numbers with a tuple (count, number). E.g.
$ cat > usample
10
10
9
8
8
7
7
7
6
3
1
1
1
0
$ uniq -c usample
2 10
1 9
On Nov 21, 2007, at 1:24 PM, Thibaut Jombart wrote:
> Alexy Khrabrov wrote:
>
>> I get tables with millions of rows. For plotting to a screen-size
>> jpg, obviously just about 1000 points are enough. Instead of feeding
>> plot() the original millions of rows, I'
I get tables with millions of rows. For plotting to a screen-size
jpg, obviously just about 1000 points are enough. Instead of feeding
plot() the original millions of rows, I'd rather shrink the original
dataframe, using some kind of the following interpolation:
-- split dataframe into chu
I have a graph which looks like hyperbole. I'd like to fit a
straight line to the lower segment going to infinity, approaching the
X axis -- I'm interested in the angle. If I'd do it manually, I'd
cut off a certain initial part of the range, [0..x_min], and then do
an lm with the rest. Y
xy.coords can have a log="xy" parameter which then plot interprets to
use log scale.
I wonder whether plot can be instructed in a similar way to use log10
scale instead of natural logs.
Cheers,
Alexy
On Nov 20, 2007, at 7:01 PM, Duncan Murdoch wrote:
> On 11/20/2007 10:41 AM, A
Is there a way to teach xy.coords, when given log="xy", or just "x"
or "y" separately, to do a decimal log10 instead of the natural log?
Cheers,
Alexy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the
n")
>
> Naturally, this could all be "functionized" and the various text
> arguments
> passed as arguments to the function (see ?plot.default or its
> code); or they
> could be components of a list, or ...
>
>
> Bert Gunter
> Genentech Nonclinical Statistics
&
quot; | R --vanilla --slave
Wonder if there's a way to have a single file which is a stand-alone
command script, and can be source()'d in R.
Cheers,
Alexy
On Nov 20, 2007, at 4:03 AM, Marc Schwartz wrote:
>
> On Tue, 2007-11-20 at 03:32 +0300, Alexy Khrabrov wrote:
>> What
What's the idiom of assigning a default value to a variable if it's
not set? In Ruby one can say
v ||= default
-- that's an or-assign, which triggers the assignment only if v is
not set already. Is there an R shorthand?
Cheers,
Alexy
__
R-help@r
I'd like to produce graphs with titles, axis labels, and legend as
parameters read from a separate text file. Moreover, I'd like to use
the legend for a short summary of the data -- not necessarily for
describing the line colors per se. How do we do this?
Cheers,
Alexy
___
I need a vector with sums of vectors up to each position in the
original. The imperative version is simple:
# running sum: the traditional imperative way
sumr.1 <- function(x) {
s <- c()
ss <- 0
for (i in 1:length(x)) {
ss <- ss + x[i]
s[i] <- ss
}
s
}
Yet I want a f
With all due respect to the great book -- of which I own 2 copies I
bought new -- it's not an "O'Reilly Programming in " book. The
idea of a programming book like that is to thoroughly treat the
language from a programmer's standpoint, in a fairly standard way,
such as Ruby or Python.
As
On Nov 7, 2007, at 4:13 PM, Duncan Murdoch wrote:
>> And, still no option processing as in GNU long options, or python
>> or ruby's optparse.
>> What's the semantics of parameter passing -- by value or by
>> reference?
>
> By value.
Thanks Duncan! So if I have a huge table t, and the idea w
Greetings -- coming from Python/Ruby perspective, I'm wondering about
certain features of R as a programming language.
Say I have a huge table t of the form
run ord unitwords new
1 1 69391013641
1 2 275 1001518
1 3 33141008
58 matches
Mail list logo