Dear list,
I'm trying to use the reshape package to perform a merging operation
on a list of data.frames as illustrated below,
a <- 1:10
example <- list( data.frame(a=a, b=sin(a)), data.frame(a=a,
b=cos(a)) )
melt(example, id = a)
this produces the desired result, where the data.fram
Given that I cannot arbitrarily change the data to make "a" an
integer, can I still use "a" as a grouping variable?
I tried melt(example, id = factor(a)) but it does not work either.
Must this change from numeric values to factors be done before
applying melt?
Thanks,
baptiste
On 25 Jul
On 26 Jul 2008, at 02:52, hadley wickham wrote:
On Fri, Jul 25, 2008 at 8:50 PM, hadley wickham
<[EMAIL PROTECTED]> wrote:
On Fri, Jul 25, 2008 at 9:49 AM, baptiste auguie
<[EMAIL PROTECTED]> wrote:
Dear list,
I'm trying to use the reshape package to perform a merging
Here is my attempt at this (taking a specific understanding of the ill-
defined "equivalence" relation),
unletter <- function(word){
word.broken <- strsplit(word, NULL)
set.of.numbers <- sapply(word.broken[[1]], function(let) which(let ==
letters))
paste(set.of.numbe
10:47, (Ted Harding) wrote:
On 28-Jul-08 09:29:22, baptiste auguie wrote:
Here is my attempt at this (taking a specific understanding of the
ill-
defined "equivalence" relation),
unletter <- function(word){
word.broken <- strsplit(word, NULL)
set.of.numbers <
Dear list,
I'm writing a long document (thesis) and as much as I would like to
use only ggplot2 for the graphics, some features are still a bit
undocumented so I often end up choosing either ggplot2, lattice, or
base plots (which i know better) depending on the particular graph to
produc
It seems to me that the reshape package should do the job,
library(reshape) # note that you need to fix the method to melt lists
in the current version ( passing ... to the method for data.frames, as
discussed here last week)
cast(data=melt(dat), fun.aggregate = function(.x) rle(.x)$length[
Dear list,
I've had this problem for a while and I'm looking for a more general
and robust technique than I've been able to imagine myself. I need to
find N (typically N= 3 to 5) zeros in a function that is not a
polynomial in a specified interval.
The code below illustrates this, by cre
Hi list,
This is a very basic question about lattice: I wish to add some
vertical lines in each panel of a xyplot as demonstrated in this
example:
library(lattice)
xx <- seq(1, 10, length=100)
x <- rep(xx, 4)
y <- c(cos(xx), sin(xx), xx, xx^2/10)
fact <- factor(rep(c("cos", "sin", "id", "
2008 at 11:54 AM, baptiste auguie
<[EMAIL PROTECTED]> wrote:
Hi list,
This is a very basic question about lattice: I wish to add some
vertical
lines in each panel of a xyplot as demonstrated in this example:
library(lattice)
xx <- seq(1, 10, length=100)
x <- rep(xx, 4)
y <- c(cos(
d not find a clean way to implement it.
Any thoughts welcome! I feel like I've overlooked an obvious trick.
Many thanks,
baptiste
On 7 Aug 2008, at 11:49, baptiste auguie wrote:
Dear list,
I've had this problem for a while and I'm looking for a more general
and robust technique
3) once a zero is found, look for zeros on both sides, etc... this
quickly makes a complicated decision tree when the number of zeros
grows and I could not find a clean way to implement it.
Any thoughts welcome! I feel like I've overlooked an obvious trick.
Many thanks,
baptiste
On 7 Aug 2
Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
] On
Behalf Of baptiste auguie
Sent: Friday, August 08, 2008 1:25 PM
To: Hans W. Borchers
Cc: r-help@r-project.org
Subject: Re: [R] re cursive root finding
On 8 Aug 2008, at 16:44, Hans W. Borchers wrote:
As your curve is def
Dear list,
I have the following example, from which I am hoping to retrieve
numeric values of the factor levels (that is, without the brackets):
x <- seq(1, 15, length=100)
y <- sin(x)
my.cuts <- cut(which(abs(y) < 1e-1), 3)
levels(my.cuts)
hist() does not suit me for this, as it does n
ind a clean way to implement it.
Any thoughts welcome! I feel like I've overlooked an obvious trick.
Many thanks,
baptiste
On 7 Aug 2008, at 11:49, baptiste auguie wrote:
Dear list,
I've had this problem for a while and I'm looking for a more general
and robust technique than I
# function(...)
as.numeric(c(...)),backref=-2,simplify=TRUE))
lims
}
cutIntervals(1:5, 3)
Many thanks,
baptiste
On 9 Aug 2008, at 11:12, Prof Brian Ripley wrote:
On Sat, 9 Aug 2008, baptiste auguie wrote:
Dear list,
I have the foll
Dear all,
I'm routinely using lattice and ggplot2, I wish to create a lattice
theme that looks not too dissimilar to ggplot's defaults so I can
include both graphs in a document with a consistent look.
To illustrate my questions, consider the following example:
library(ggplot2)
library(l
Hi,
I find convenient to use a custom function for this:
sample.df <-
function (df, N = 1000, ...)
{
df[sample(nrow(df), N, ...), ]
}
sample.df(daf1,1000)
Hope this helps,
baptiste
On 25 Aug 2008, at 12:31, Martin Hvidberg wrote:
I have a data frame (daf1), that holds +8 record
Hi
I think you want something like,
with(ds, tapply(yn, drank1group, rank) )
also, the reshape package should do this sort of thing neatly.
Hope this helps,
baptiste
On 25 Aug 2008, at 16:10, ivo welch wrote:
Dear R wizards: First, thanks for the notes on SQL. These pointers
will make
Brilliant! I've just ordered your book to learn more about lattice as
its use is quite gripping despite a steep learning curve.
Many thanks,
baptiste
On 25 Aug 2008, at 23:07, Deepayan Sarkar wrote:
On Mon, Aug 25, 2008 at 4:47 AM, baptiste auguie
<[EMAIL PROTECTED]> wrote
Hi,
I'm not sure I understand what you want, but perhaps:
x <- 1:9
y <- x
plot(x, y, ann=F, xaxt="n")
axis(1, lab=F) -> positions
mtext(paste(positions), side = 1, line = 1, outer = F, at = test,
cex=1:length(positions))
HTH,
baptiste
On 27 Aug 2008, at 18:36, Dani Valverde wrote:
Hel
Aug 2008, at 18:51, baptiste auguie wrote:
Hi,
I'm not sure I understand what you want, but perhaps:
x <- 1:9
y <- x
plot(x, y, ann=F, xaxt="n")
axis(1, lab=F) -> positions
mtext(paste(positions), side = 1, line = 1, outer = F, at = test,
cex=1:length(positions))
HTH
I had a similar problem recently where I used the following code:
v <- factor(letters[1:3])
all.cases <- expand.grid(v, v)
all.cases[as.numeric(all.cases[, 2]) >= as.numeric(all.cases[, 1]), ]
I'm not sure how to extend it cleanly to an arbitrary number of
vectors, though.
Baptiste
On 31
Hi,
Try this,
layout(matrix(c(1,1,2,3), ncol=2, byrow=T))
hist(1:10)
plot.new()# empty space
plot(1:10)
HTH,
baptiste
2009/8/16 RAVI KAPOOR :
> Hi
>
> Can any one explain how i can divide the graphic window
>
> into two rows and two columns -- allocate figure 1 all of row 1 and
> allocate fi
Hi,
If you have a data.frame, perhaps this can help,
tc = textConnection("carat cut color clarity depth table price x y z
1 0.23 Ideal E SI2 61.555 326 3.95 3.98 2.43
2 0.21 Premium E SI1 59.861 326 3.89 3.84 2.31
3 0.23 Good E VS1 56.965
I'm facing a similar challenge with a grid.table function (see example
below). I envisaged two routes,
1- rather than assigning a list of properties for each cell, I would
define a matrix for each property. For instance, the default could be,
fill = matrix("grey90", nrow(values), ncol(values)) #
Try this,
a[ ,as.logical(colSums(a))]
mind an unfortunate logical vs integer indexing trap:
isTRUE(all.equal( a[ ,!!colSums(a)] , a[ ,colSums(a)] ))
[1] FALSE
HTH,
baptiste
2009/8/18 Alberto Lora M :
> Hi Everbody
>
> Could somebody help me.?
>
> I need to remove the columns where the sum o
Try this,
print(p+ opts(plot.background= theme_rect(fill=NA)))
HTH,
baptiste
2009/8/19 rajesh j :
> Hi,
> I plotted a histogram using ggplot2 and saved it as a pdf.However, the
> portions outside the histogram dont appear transparent when I use a
> non-white bg colour in my latex document.What
Hi,
One way using ggplot2,
library(ggplot2)
ggplot(data=myda, mapping=aes(x=traits, y=..density..)) +
stat_density(aes(fill=factor), alpha=0.5, col=NA, position = 'identity') +
stat_density(aes(colour = factor), geom="path", position = 'identity', size=2)
HTH,
baptiste
2009/8/19 Mao Jianfeng
I believe you want "x.intersp",
txt <- c("Setosa Petals", "Versicolor Sepals")
plot(1,1,t="n")
legend("top", txt, text.col=1:2, cex=0.7,
inset=c(0,1/3))
legend("center", txt, text.col=1:2, cex=0.7,
x.intersp = -0.5)
HTH,
baptiste
2009/8/19 Stefan Grosse :
> On Wed, 19 Aug 2009 10:20:03 +0200
plot(1:10,ylab=expression("temperature "*delta*t))
2009/8/19 e-letter :
> On 18/08/2009, Gavin Simpson wrote:
>> On Tue, 2009-08-18 at 13:06 +0100, e-letter wrote:
>>> On 17/08/2009, Michael Knudsen wrote:
>>> > On Mon, Aug 17, 2009 at 12:51 PM, e-letter wrote:
>>> >
>>> >> I have tried to add
the short answer is to add [[i]] in your loop,
file_list[[i]] <- paste(index$month[i], index$year[i], sep='')
yet a shorter answer would be,
file_list = apply(index, 1, paste, collapse="")
HTH,
baptiste
2009/8/20 Steve Murray :
>
> Dear R Users,
>
> I have 120 objects stored in R's memory and
Try this,
mat <- replicate(4, matrix(rnorm(25), 5), simpl=F)
mat
vect <- rnorm(4)
mapply( `*` , mat, vect, SIMPLIFY=F)
HTH,
baptiste
PS: I see someone replied already, but you might find replicate useful too
2009/8/21 RON70 :
>
> Suppose I have following list :
>
> mat <- vector("list")
> fo
Hi,
Say you have the following data and functions that you want to reuse,
d = data.frame(1:10)
foo = function(x,y , ...){
plot(x,y, type="l", ...)
}
You may save the code in a file "testing.r", noting that in general
data may find a convenient storage format using save(d, file=
"mydata.
geom_path in ggplot2 is another option, see two examples on this page:
http://had.co.nz/ggplot2/geom_path.html
HTH,
baptiste
2009/8/21 Jim Lemon :
> Gonçalo Graça wrote:
>>
>> Hi! I'm not experienced very experienced with R and i'm looking for a way
>> doing plots like in this example
>> http:
Try this,
mystr <-"c==1"
subset(foo, eval(parse(text = mystr)) )
library(fortunes)
fortune("parse") # try several times
# I prefer this, but there is probably a better way
mycond<- quote(c==1)
subset(foo, eval(bquote(.(mycond))) )
HTH,
baptiste
2009/8/21 Sebastien Bihorel :
> Dear R-users,
>
That's right, however the bquote construct may be useful when
combining several conditions,
subset(foo, eval(bquote(.(mycond) & a < 5)) )
baptiste
2009/8/22 Vitalie S. :
> On Fri, 21 Aug 2009 22:38:09 +0200, baptiste auguie
> wrote:
>
>> Try this,
>>
>> m
Hi,
Have you checked that you have the latest version of ggplot2 and plyr?
Please post your sessionInfo()
HTH,
baptiste
2009/8/28 romunov
> Dear R-Help subsribers,
>
> upon running into a wonderful ggplot2 package by accident, I abruptly
> encountered another problem. Almost every command ru
2009/8/31 David Scott
>
>
> I think this discussion is valuable, and have previously asked about style
> which I think is very important. Base R does suffer from very inconsistent
> naming and as I think Duncan said it makes it very difficult sometimes to
> remember names when you have variations
Murdoch
> baptiste auguie wrote:
>
>> 2009/8/31 David Scott
>>
>>
>>
>>> I think this discussion is valuable, and have previously asked about
>>> style
>>> which I think is very important. Base R does suffer from very
>>> i
Hi,
I think you want %in% instead of ==
see ?"%in%"
HTH,
baptiste
2009/8/31 AllenL
>
> Dear R-list,
> Seems simple but have tried multiple approaches, no luck.
>
> I have a list of column names:
>
> >names.species.bio.18=c("Achimillb","Agrosmitb","Amorcaneb","Andrgerab","Ascltubeb","Elymcana
Hi,
Try this,
library(grid)
value <- c(0.1)
lab <- c("test",
expression(bquote(paste(.(value[1]*100), " and percentiles1",
sep=""))),
bquote(expression(.(value[1]*100)*" and percentiles2")),
bquote(paste(.(value[1]*100), " and percentiles3", sep="")) )
grid.newpage
Hi,
Try this,
myplot <- function(subject) { plot(subject,
main=deparse(substitute(subject))) }
s1 <- c(200,200,190,180)
myplot(s1)
see ?deparse
HTH,
baptiste
2009/9/2 Marianne Promberger
> Dear list,
>
> I've written a function that plots subjects. Something like:
>
> myplot <- functi
asy way to bullet proof the code: use as.expression when building lab
>
> Thanks
>
> baptiste auguie wrote:
>
>> Hi,
>>
>> Try this,
>>
>>
>> library(grid)
>>
>> value <- c(0.1)
>>
>> lab <- c("test",
>>
Hi,
You may find some inspiration here:
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:ggplot2theme_inbase
HTH,
baptiste
2009/9/3 RINNER Heinrich
> Dear R-community,
>
> using R.2.9.1, how do you put reference lines or grids into the
> _background_ of a plot?
> For example:
Hi,
This may come close to what you want,
x <- data.frame(ID=rep(letters[1:5],2), A1=rep(10:14,2), A2=rep(2:6,2),
A3=c(101:105,95:99), A4=c(-60, rep(c(0, 3), length=9)))
# basic conditions
cond1 <- quote(ID == "a" & A2 >1)
cond2 <- quote(A1 < 10)
cond3 <- quote(A1 == 10) # note t
it's documented as "unexpected"
?diag
Note
Using diag(x) can have unexpected effects if x is a vector that could be of
length one. Use diag(x, nrow = length(x)) for consistent behaviour.
And the result follows from this part,
else if (length(x) == 1L && nargs() == 1L) {
n <- as.int
Hi,
I think you've got a problem with environments,
testA<-function(input=1)
{
dat <- data.frame(A=seq(input,5), B=seq(6,10))
vec.names<- c("a", "b")
env <- new.env()
for(i in 1:ncol(dat))
{
tab<- dat[,i]-1
assign(vec.names[i], tab, env=env)
}
Hi,
Try this,
x = 10
noquote(dQuote(x))
noquote(sQuote(x))
HTH,
baptiste
2009/9/4 sailu Yellaboina
> I want to print a variable with in double quotes.
> For example
>
> x = 10 ;
> x ;#prints 10
> "x" ; #prints x
> \"x\" ; # Error: unexpected input in "\"
>
> I want to the out put
Hi,
you have two problems in your first scenario,
1- Wrong operator precedence. For example,
> 1 == 2 | 3
[1] TRUE
where 1==2 is tested as FALSE, but 1 is not tested against 3 for equality as
it would be using,
> 1 == 2 | 1 == 3
[1] FALSE
or using %in% 2:3
Instead, R evaluates "FALSE | 3", a
Hi,
Try this,
myFUN <- function(FUN) {
return(deparse(substitute(FUN)))
}
HTH,
baptiste
2009/9/7 Rainer M Krug
> Hi
>
> I have the following function which should return the name of FUN:
>
> myFUN <- function(FUN) {
> return( THE_NAME_OF_FUN(FUN))
> }
>
> Is it possible? What do I have tio
Hi,
It's not enough to create a string with your instructions, it also needs to
be evaluated as such.
If you really wanted to evaluate your string, you'd need something like,
a <- b <- cc <- 1 # dummy example
eval(parse(text = "cbind(a, b, cc)"))
#library(fortunes)
#fortune("parse")
but fortune
Hi,
Something like this perhaps,
p <- xyplot(y ~ x | names,
layout = c(1, 3),
panel = function(...,type="p") {
if (panel.number() == 1) {
panel.xyplot(...,type = "h")
} else {
panel.xyplot(...,type = type)
}
})
plot(p)
HTH,
baptiste
200
Hi,
See if this helps,
polygon.regular <- # return a matrix of xy coordinates for a regular
polygon centered about (0,0)
function (sides = 5)
{
n <- sides
if (n < 3)
n <- 3
if (n > 8)
n <- 50
th <- pi * 2/n
costh <- cos(th)
sinth <- sin(th)
Hi,
It's probably easiest with the pdf (or postscript) device,
pdf("all.pdf")
for(ii in 1:27)
plot(rnorm(10), main=paste("plot", ii))
dev.off()
Bitmap-based devices can generate sequential filenames (Rplot1.png,
Rplot2.png, ...) that you could combine in a single document using external
tools
Hi,
Using ggplot2, you could do something like this,
library(ggplot2)
myplot <- function(x, y, data, geom="point"){
ggplot(data=data, map=aes_string(x=x, y=y, colour = "treatment") ) +
layer(geom=geom) +
scale_colour_manual(values=c("red", "blue"))
}
d = data.frame(Xmeas=rnorm(10), Ymeas=rn
Hi,
try this,
rowMeans(as.data.frame(Coefs))
# or apply(as.data.frame(Coefs), 1, mean)
HTH,
baptiste
2009/9/14 Masca, N.
> Dear All,
>
> I have a problem which *should* be pretty straightforward to resolve - but
> I can't work out how!
>
> I have a list of 3 coefficient estimates for 4 diffe
Hi,
tail(x,2)
or
x[seq(nrow(x)-1, nrow(x)), ]
HTH,
baptiste
2009/9/14 Peng Yu
> Hi,
>
> x=matrix(1:60,nr=6)
>
> I can refer the last 2 rows by
> x[5:6,]
>
> If I don't know the total number of rows is 6, is there a way to refer
> the last 2 rows?
>
> Regards,
> Peng
>
> _
alternatively, use aes_string,
p <- ggplot(bmm, aes_string(x="age", y="bm", colour="pp", group="pp"))
p <- p + geom_line()
p
HTH,
baptiste
2009/9/14 smu
> hey,
>
> On Mon, Sep 14, 2009 at 07:51:42AM -0700, John Kane wrote:
> > p <- ggplot(bmm, aes(x="age", y="bm", colour="pp", group="pp"))
Of course if w9zd9_1, w9zd9_2, w9zd9_3 were elements of a data.frame (or
even a list), you could use indexing,
w9zd9 = data.frame(w9zd9_1 = 1:10, w9zd9_2 = 1:10, w9zd9_3 = -2*1:10)
average = function(numbers=1, w9zd9){
if(numbers == 1L) return(w9zd9[ ,1]) # vector case fails with rowMeans
rowM
Try this,
marco2 = matrix(rnorm(4), nrow=2, ncol=2)
marco3 = 2.12
i =1
plot.new()
mtext(bquote(R^2*.(round(marco2[1,i],digits=3))*" N° of
proteins:"*.(marco3[i])),side=4,cex=.6)
HTH,
baptiste
2009/9/16 Marco Chiapello
> /Dear all,///
> /I am very thankful, if you could tell what is the righ
?Reduce
maybe
HTH,
baptiste
2009/9/16 OKB (not okblacke)
>Is there anything like cumsum and cumprod but which allows you to
> apply an arbitrary function instead of sum and product? In other words,
> I want a function cumfunc(x, f) that returns a vector, so that for all n
> up to the
Hi,
for basic tables (e.g. display a data.frame without fancy formatting),
you could try the textplot() function from the gplots package, or this
rough function for Grid graphics,
source("http://gridextra.googlecode.com/svn/trunk/R/tableGrob.r";)
# install.packages("gridextra", repos="http://R-Fo
Try this,
sapply(Mabslim , my_gamma, alpha=-1, xstar = -21, xmax = -27)
or wrap it with ?Vectorize,
vmy_gamma = Vectorize(my_gamma, vectorize.args = "xlim")
vmy_gamma(alpha=-1, xstar = -21, xlim= Mabslim, xmax = -27)
HTH,
baptiste
2009/9/17 Maurizio Paolillo :
> Dear R users,
> I'm trying t
I don't understand your question.
Where does your data come from in the first place? Is it stored in a
file, or is it a result of a previous operation in R, or is it
something you need to copy and paste in your script, or ...?
the textConnection() construct is often used to make for
self-containe
No box is easy,
bwplot(y~x, data=data.frame(y=rnorm(10),x=sample(letters[1:3],10,repl=T)),
par.settings=list(axis.line=list(col=NA)))
but that seems to remove all axis lines and ticks as well. You may
have to define a custom panel.axis() function.
An alternative is to use grid.remove() to remove
it might be possible to set up a particular mode before copying the history,
### start example ###
email = function(op){
if(!missing(op)) {
options(op) } else {
op <- options()
options("prompt" = " ")
options("continue" = " ")
op
}
}
op = email()
a = 1:10
a
email(op)
a = 1:10
a
Dear list,
As a minimal test of a more complex grid layout, I'm trying to find a
clean and efficient way to arrange text grobs in a rectangular layout.
The labels may be expressions, or text with a fontsize different of
the default, which means that the cell sizes should probably be
calculated usi
Neat!
What if, instead, one wanted to format his/her code in the console
before sending it by email? Any tips for that?
(I proposed something like options("prompt"=" ") above, but got stuck
with adding a comment # to printed results)
Thanks,
baptiste
2009/9/19 Gabor Grothendieck :
> Combini
A few amendments might make this improved code more readable,
e = expression(alpha,"testing very large width", hat(beta),
integral(f(x)*dx, a, b))
library(grid)
rowMax.units <- function(u, nrow){ # rowMax with a fake matrix of units
matrix.indices <- matrix(seq_along(u), nrow=nrow)
do.call(uni
Hi,
What about this,
eval(parse(text=expr))
(no print)
HTH,
baptiste
2009/9/19 Nick Matzke :
> Hi,
>
> I have a script which I source, which evaluates a changing expression call
> hundreds of times. It works, but it prints to screen each time, which is
> annoying. There must be simple way
Hi,
Not exactly answering your question, but latticeExtra provides a
function useOuterStrips that you could use to have a single S11 strip
on the left instead.
HTH,
baptiste
2009/9/20 di jianing :
> Hello R helpers,
>
> I am producing a figure with dual strips, i.e., x~y | S1 + S2, where S1 an
Hi,
>From what I understand, I would suggest the following strategy,
1- combine all data in a single data.frame (see merge, rbind, reshape
package, etc.)
2- plot all data at once using a formula like this,
boxplot(d~f,data=df)
HTH,
baptiste
2009/9/20 Sam Player :
> # I have a dataframe with
Dear all,
I'm trying to follow an old document to use Grid frames,
Creating Tables of Text Using grid
Paul Murrell
July 9, 2003
As a minimal example, I wrote this,
gf <- grid.frame(layout = grid.layout(1, 1), draw = TRUE)
label1 <- textGrob("test", x = 0, just = "left", name="test")
gf=place
Hi,
Maybe the textplot() function in the gplots package?
HTH,
baptiste
2009/9/21 Sergey Goriatchev :
> Hello everyone,
>
> I have a plot and I want to but a (formatted) box containing text and
> numbers, say:
> Mean: 0.1
> St.Deviation: 1.1
> Skewness: 1.1
> Kurtosis: 0.5
>
> I know there is a
ordinates in text() function.
> No, there must be another function somewhere that produces these text boxes.
>
> Best,
> Sergey
>
> On Mon, Sep 21, 2009 at 11:49, baptiste auguie
> wrote:
>> Hi,
>>
>> Maybe the textplot() function in the gplots package?
>>
plot(0, xlab=bquote(theta *" = "* .(x)))
?substitute
?bquote
HTH,
baptiste
2009/9/21 Jarrod Hadfield :
> Hi,
>
> I want to have a legend that is a mixture of numbers and symbols, and have
> found no way of achieving this.
>
> For example, if I want theta="x" or theta=2 this is easily achieved.
Dear list,
I think I'm being dense, but I can't get combn or expand.grid to give
me this result. I need to generate a matrix of all 16 possible
sequences of 4 boolean elements,
0001
0010
0011
0100
.
(in the end I'll have to assign NA to the 0s and some value to the 1s
but let's kee
I knew I was missing the obvious. And to think it's only Monday...
Thanks everyone!
baptiste
2009/9/21 Henrique Dallazuanna :
> Try this:
>
> do.call(expand.grid, rep(list(0:1), 4))
>
> On Mon, Sep 21, 2009 at 2:04 PM, baptiste auguie
> wrote:
>> Dear list,
>>
Hi,
The short answer would be ?paste (as in paste(year, ".csv", sep="") ),
but I'd suggest you try this instead,
lf <- list.files(pattern = ".csv")
lf
# [1] "2003.csv" "2004.csv" "2005.csv"
ln <- gsub(".csv", "", lf)
ln
# [1] "2003" "2004" "2005"
length(ln)
lapply(lf, read.csv)
?list.files
yet another way,
> x <- read.table(textConnection("Category Value
+ b1
+ b2
+ a7
+ a1"), header=TRUE)
> y = transform(x, Category = relevel(Category, c("b")))
> str(y)
'data.frame': 4 obs. of 2 variables:
$ Category: Facto
Hi,
It's trivial with ggplot2,
library(ggplot2)
qplot(tp,dp, geom="line") + scale_y_reverse()
HTH,
baptiste
2009/9/23 David Winsemius :
>
> On Sep 23, 2009, at 7:58 AM, FMH wrote:
>
>> Dear All,
>>
>> Let:
>> dp: depth of the river
>> tp: temperature with respect to depth
>>
>> We can have a s
Try this,
d <- na.omit(data.frame(tp,dp))
plot(d, t="l", ylim=rev(range(d$dp)))
?na.omit
HTH,
baptiste
2009/9/23 FMH :
> Thank you for the code. I found that the coding does not work if there is an
> NA in dp variable. For instance;
>
> #
> dp <- c(1,4,NA,2,5,7,9,8,9,2)
>
Hi,
You could try the grid.grab() function in R devel if your graphics use
the Grid package. It will read the graphical output as a bitmap which
you can then export in a multipage pdf. It may not be really
flattening per se but that would definitely help with the viewing
speed.
HTH,
baptiste
O
Hi,
On 11 February 2010 22:14, Paul Murrell wrote:
> Hi
>
>
> baptiste auguie wrote:
>>
>> Hi,
>>
>> You could try the grid.grab() function in R devel if your graphics use
>> the Grid package. It will read the graphical output as a bitmap which
>
>
Hi,
Try with bquote,
plot.new()
myText <- "some text"
text(.5, .5, bquote(bold(.(myText
basically, bquote( .(myText) ) performs the substitution before
applying bold() (see ?bquote).
HTH,
baptiste
On 14 February 2010 17:36, Mark Heckmann wrote:
> # I want to plot bold text. The text sh
Hi,
it's hard to tell what's wrong without a reproducible example, but I
noted two things:
- AFAIK there is no plot method for ggplot2. You probably meant print(p) instead
- if you map x to factor(month), I think it will be incompatible with
your xlim values range(month).
HTH,
baptiste
On 14
Hi,
I believe it's lazy evaluation. See ?force
HTH,
baptiste
On 14 February 2010 20:32, Jyotirmoy Bhattacharya
wrote:
> I want to use lapply and a function returning a function in order to build a
> list of functions.
>
>> genr1 <- function(k) {function() {k}}
>> l1 <- lapply(1:2,genr1)
>> l1[
Hi,
Try this,
unlist(test)
or
do.call(c, test)
HTH,
baptiste
On 19 February 2010 15:19, statquant wrote:
>
> Hello all
> I am new in R and so easy stuff are difficult...
> let say that I have a list
> test <- list(a=c("x","v"),b=c("n","m"))
> how can I without a loop get test$a bind with te
Hi,
just to make sure, you didn't forget to close the device with dev.off() ?
baptiste
On 21 February 2010 20:48, Karthik wrote:
> Hello Tal,
> This is the code.
>
>
>> hist(rnorm(100))
>> jpeg("histogram.jpeg")
> ---
>
> Even when I decrease the qua
Hi,
If you are curious you might like to try a highly experimental Grid
function I wrote some time ago,
library(grid)
source("http://gridextra.googlecode.com/svn/trunk/R/patternGrob.r";)
grid.newpage()
grid.pattern(x=seq(1/6, 5/6, length=6), width=unit(1/8,"npc"),
height=unit(0.5,"npc"),
Hi,
A minimalist example using Grid graphics,
library(RGraphics)
bwImage <- function(m, cols=c("white", "black"),
draw=TRUE, gp=gpar()){
g <- imageGrob(nrow(m), ncol(m),
cols=cols[m+1], gp=gp)
if(draw)
grid.draw(g)
return(g)
}
m <- matrix(rnorm(200) > 0,
On 26 February 2010 11:12, Lorenzo Isella wrote:
> Thanks Augustine and Jim for the prompt reply.
> You both answered my question. To avoid another post, I would simply like to
> know if something along these lines is doable also with ggplot2.
> Many thanks
>
> Lorenzo
>
Augustine???
Anyhow, wi
Hi,
I think I would follow this approach too, using updatelist() from the
reshape package,
updatelist <- function (x, y)
{
common <- intersect(names(x), names(y))
x[common] <- y[common]
x
}
myfunction=function(list1=NULL, list2=NULL, list3=NULL){
list1=updatelist(list(variable1=1
Point well taken --- grid::gpar() is also a good example; I'll make
use of your suggestion in my future coding.
Best,
baptiste
On 27 February 2010 15:02, Barry Rowlingson
wrote:
> On Sat, Feb 27, 2010 at 11:29 AM, Gabor Grothendieck
> wrote:
>> Or use modifyList which is in the core of R.
>
>
Hi,
The 3 packages I load most often are my own; typically I make a new
package for every new job. It automatically loads other packages as
dependencies (top-ranked are ggplot2, reshape, plyr) as well as my
data and functions I'm currently working with.
If some functions evolve further towards a
c(x <- 1:5, rev(x[-length(x)]))
On 5 March 2010 07:04, kensuguro wrote:
>
> I'm just beginning R, with book Using R for Introductory Statistics, and one
> of the early questions has me baffled. The question is, create the
> sequence: 1,2,3,4,5,4,3,2,1 using seq() and rep().
>
> Now, as a progr
Hi,
try this,
data.frame(x,as.numeric(x %in% y))
HTH,
baptiste
On 7 March 2010 21:06, joseph wrote:
> hello
>
> can you show me how to create a data.frame from two factors x and y. column 1
> should be equal to x and column 2 is 1 if it is common to y and 0 if it is
> not.
>
> x=factor(c("A
Hi,
it's generally considered a bad practice but try this,
eval(parse(text=AA))
library(fortunes)
fortune(106)
HTH,
baptiste
On 10 March 2010 07:46, jq81 wrote:
>
> My question is represented by the following example.
>
> For example, I have a character string a, which is defined as
>
> AA="
Dear all,
I'm trying to write tabular data to a text file, these data will be
the input of a Fortran program. The format needs to be
"(i7,2x,7(e15.7,2x))". I have not been able to find a clean way of
producing this output with write.table. I searched for a
"write.fortran" function similar to read.
1 - 100 of 738 matches
Mail list logo