I knew I had seen this in action! But as you mention, most pages only
display ~~RDOC~~ at the moment.
I second the idea of using the wiki for such collaborative work. If the
current (r-devel) version of all help pages could be automatically
copied to the wiki, users would have a convenient way t
Kenny Larsen wrote:
Hi,
A fairly basic problem I think, here although searching the inetrnet doesn't
seem to reveal a solution. I have a dataset with two columns of real
numbers. It is read in via read.table. I simply need to square the data in
the second column and then plot it. I have tried ex
Paul Murrell wrote:
Hi
The bug is now fixed in the development version
(thanks to Duncan for the diagnosis and suggested fix).
Paul
Thank you both for your help and dedication!
Best regards,
baptiste
--
_
Baptiste Auguié
School of Physics
University of Exe
jim holtman wrote:
try this:
Oh well, i spent the time writing this so i might as well post my
(almost identical) solution,
x<-c(1:3, 6: 7, 10:13)
breaks = c(TRUE, diff(x) != 1)
data.frame(start = x[breaks], length = tabulate(cumsum(breaks)))
Hoping this works,
baptiste
x
[1
Dear list,
I'm quite surprised by this,
unit(1:5,"char")[-c(1:2)]
#4char 3char # what's going on??
while I expected something like,
c(1:5)[-c(1:2)]
# 3 4 5
Note that,
unit(1:5,"char")[c(1:2)]
# 1char 2char # fine
?unit warns about unit.c for concatenating, but also says,
It is possible
Marie Sivertsen wrote:
Dear list,
I have a vector of elements which I want to combined each with each, but
none with itself. For example,
v <- c("a", "b", "c")
and I need a function 'combine' such that
combine(v)
[[1]]
[1] "a" "b"
[[2]]
[1] "a" "b"
[[3]]
[1] "b" "c"
I a
Ben Bolker wrote:
amor Gandhi wrote:
Hi,
I have gote the following data
x1 <- c(rep(1,6),rep(4,7),rep(6,10))
x2 <- rnorm(length(x1),6,1)
data <- data.frame(x1,x2)
and I would like to compute the mean of the x2 for each individual of x1,
i. e. x1=1,4 and 6?
You'll probably get sev
Jonathan Williams wrote:
Dear R-helpers,
I have been trying to figure out how to plot a graph with an axis label
consisting of a mixture of Latin, Greek and subscript characters.
Specifically, I need to write A[beta]{1-42}, where A is Latin script A,
[beta] is Greek lower case beta and {1-42} is
Dear all,
I feel like I've been reinventing the wheel with this code (implementing
type = 'b' for Grid graphics),
http://econum.umh.ac.be/rwiki/doku.php?id=tips:graphics-grid:linesandpointsgrob
Has anyone here attempted this with success before? I found suggestions
of overlapping large white
Perfect, thank you!
Thanks also to Gabor G. for the links.
baptiste
On 2 Jun 2009, at 01:30, Paul Murrell wrote:
Hi
baptiste auguie wrote:
Dear all,
I'm trying to access and modify grobs in a ggplot2 plot. The basic
idea
for raw Grid objects I understand from Paul Murrell's
of course, this only applies if you have,
getOption("OutDec") == "."
In any case, follow David's suggestions.
baptiste
On 1 Jun 2009, at 23:20, baptiste auguie wrote:
your data *seems* to have an unusual decimal separator. That would
explain why the two-step co
your data *seems* to have an unusual decimal separator. That would
explain why the two-step conversion to numeric fails, while the brute
conversion to numeric always gives the factor integer codes.
I don't know where your data comes from (str() would be helpful in any
case), but if you read
H,
baptiste
On 1 Jun 2009, at 22:30, Andre Nathan wrote:
> On Mon, 2009-06-01 at 22:24 +0200, baptiste auguie wrote:
>> you can use title() with the sub argument,
>>
>> title(sub="x label", outer=T) # you might want to play around with
>> line argument
&
you can use title() with the sub argument,
title(sub="x label", outer=T) # you might want to play around with
line argument
baptiste
On 1 Jun 2009, at 22:03, Andre Nathan wrote:
Hello
On Wed, 2009-05-27 at 13:38 -0600, Greg Snow wrote:
Create an outer margin (see ?par), then use mtext to
I'm not sure it's currently possible with ggplot2 (lattice and
latticeExtra offer some workarounds for this).
Perhaps you can try this,
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-ggplot2:sharelegend
(neater here: )
http://learnr.wordpress.com/2009/05/26/ggplot2-two-or-more-plo
Dear all,
I'm trying to access and modify grobs in a ggplot2 plot. The basic
idea for raw Grid objects I understand from Paul Murrell's R graphics
book, or this page of examples,
http://www.stat.auckland.ac.nz/~paul/grid/copygrob/copygrobs.R
However I can't figure out how to apply this to
recycling rule: repeat the shorter element as many times as necessary,
all.equal(1:2 + 1:10 , rep(1:2, length=10) + 1:10)
# TRUE
HTH,
baptiste
On 28 May 2009, at 22:00, bogaso.christofer wrote:
I have following addition :
1:2 + 1:10
[1] 2 4 4 6 6 8 8 10 10 12
I could not unde
Try this and see if it helps (if not, please help improving it),
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:legendoutside
HTH,
baptiste
On 27 May 2009, at 20:31, Wade Wall wrote:
Hi all,
I have been trying to figure out how to place a legend beside a plot,
rather than w
Hi,
Perhaps you can try this,
seq.weave <- function(froms, by, length, ... ){
c(
matrix(c(sapply(froms, seq, by=by, length = length/2, ...)),
nrow=length(froms), byrow=T)
)
}
seq.weave(c(2, 3), by=3, length=8)
seq.weave(c(2, 3, 4), by=
Dear list,
This might be a topic for r-devel but i may be missing something
obvious.
I don't understand the rationale in the absolute sizes of the point
symbols, and I couldn't find it documented. The example below uses
Grid to check the size of the symbols against a square of 10mm x 10mm
I'd suggest you first combine the 12 data.frames into one, using
melt() from the reshape package.
makeDummy <- function(.){ # since you don't provide a reproducible
example
data.frame(x=letters[1:10], y=rnorm(10))
}
listOf12DataFrames <- lapply(1:12, makeDummy)
library(re
If you're desperate for a workaround, you might want to try this
example using pgfSweave,
http://ggplot2.wik.is/Mathematical_annotations
On a similar vein, you could try psfrag replacements with a postscript
device (there is some code for this on the list archives).
Feel free to comment /
On 15 May 2009, at 10:01, Prof Brian Ripley wrote:
On Fri, 15 May 2009, Dieter Menne wrote:
Stats Wolf gmail.com> writes:
Postscript, however, does not have to be what I need for two
reasons.
First, it does not accept some special characters from foreign
languages (exactly like PDF).
'
Alternatively,
signif(c(pi,exp(1)), 3)
?signif # and others in that page
HTH,
baptiste
On 14 May 2009, at 13:47, jim holtman wrote:
Depending on what you want to do, use 'sprintf':
x <- 1.23456789
x
[1] 1.234568
as.character(x)
[1] "1.23456789"
sprintf("%.1f %.3f %.5f", x,x,x)
[1]
I'd first try plyr and see if it's efficient enough,
library(plyr)
listOfFiles <- list.files(pattern= ".txt")
d <- ldply(listOfFiles, read.table)
str(d)
alternatively,
d <- do.call(rbind, lapply(listOfFiles, read.table))
HTH,
baptiste
On 13 May 2009, at 12:45, SYKES, Jennifer wrote:
Depending on the nature of your pdf file, it may be possible to use
the grImport package. I've never used it before, but a quick test
seems promising,
> # create a test picture
> colorStrip <-
> function (colors, draw = T)
> {
> x <- seq(0, 1 - 1/ncol(colors), length = ncol(colors))
>
Hi,
I once made this function (essentially the same as Romain),
assignFiles <-
function (pattern = "csv", strip = "(_|.csv|-| )", ...) # strip is
any pattern you want to remove from the filenames
{
listFiles <- list.files(pattern = pattern, all.files = FALSE,
full.names = FALSE,
good point, i forgot about head (!),
library(plyr)
ddply(d, .(block, trial), head, 2)
block trial x y
1 1 1 605 150
2 1 1 603 148
3 1 2 607 148
4 1 2 605 152
On 11 May 2009, at 14:04, Gabor Grothendieck wrote:
Try this:
do.call(rbind, by(DF, DF[1:2], he
try this,
library(plyr)
ddply(d, .(block, trial), function(.d) .d[1:2, ])
block trial x y
1 1 1 605 150
2 1 1 603 148
3 1 2 607 148
4 1 2 605 152
HTH,
baptiste
On 11 May 2009, at 13:49, Jens Bölte wrote:
Hello,
I have been struggling for quite some
try this:
with(fp, Frequenz[which.max(AmpNorm)])
baptiste
On 8 May 2009, at 14:49, Jonas Stein wrote:
Hi,
fp is a data frame like this
,[ fp ]
|Frequenz AmpNorm
| 1 3322 0.0379490639
| 2 3061 0.0476033058
| 3 2833 0.0592954124
| 4 2242 0.1275510204
`
i
X formulas.
Best wishes,
baptiste
On 7 May 2009, at 14:39, Dieter Menne wrote:
Lasse Bombien phonetik.uni-muenchen.de> writes:
Am Mittwoch, den 06.05.2009, 16:08 +0200 schrieb baptiste auguie:
I think the pgfSweave project on R-forge is working on this (as
far as
i know it currently r
I think the pgfSweave project on R-forge is working on this (as far as
i know it currently relies on eps2pgf)
http://r-forge.r-project.org/R/?group_id=331
HTH,
Baptiste
On 6 May 2009, at 15:37, Lasse Bombien wrote:
Hi all,
I saw a thread from 2007 about the possible implementation of a PG
On 5 May 2009, at 19:28, Duncan Murdoch wrote:
On 5/5/2009 1:05 PM, Markus Loecher wrote:
Dear R users,
while I enjoy the built-in log argument to the plot() function, I
wished it
would be as easy to create more general custom transformed axes
such as
sqrt(), logit, etc...
for example, i
your code is missing a closing bracket for the text labels,
legend(1,4, c("Simulation", "Observation"), lty=1:2, col=2:3)
baptiste
On 4 May 2009, at 20:46, Steve Murray wrote:
Dear all,
I'm attempting to insert a legend into a line graph. I've sorted out
the positioning, but I'm unable t
Try this,
# d <- read.table(pipe("pbpaste"), head=T) # read your data
table(d)
# library(reshape)
cast(as.data.frame(table(d)), .~Firm, fun=sum)
HTH,
baptiste
On 4 May 2009, at 13:19, Cecilia Carmo wrote:
Hi everyone:
I need to count the number of banks of each firm in my
data. The firm
Try this,
items <- c(list(col=2),list(pch=2))
par(mfrow=c(2, 1))
for (ii in seq(2)) {
do.call(function(x, y, ... ) plot(1:10, ...), items[ii])
}
?do.call
HTH,
baptiste
On 29 Apr 2009, at 19:30, Sebastien Bihorel wrote:
Dear R-users,
I would like to know if is it possible to set a fun
Hi,
Here's one approach that I find perhaps more elegant than sweeping
through the columns by their index,
library(ggplot2)
data(economics)
str(economics)
# library(reshape)
d <- melt(economics, id="date")
foo <- function(var="pop", d, smooth=FALSE, ... ) {
p <- qplot( data=subs
Try this,
a = matrix(rnorm(10*10),ncol=10)
a[, seq(1,ncol(a),by=2)]
baptiste
On 29 Apr 2009, at 09:28, Umesh Srinivasan wrote:
Hi all,
If I have a huge matrix/ dataframe and I want to create a new matrix/
dataframe with every second (or third, or fourth etc.) row of the
original
mat
ER TABLE JOIN IN R
(Gabor Grothendieck)
12. Re: THE EQUIVALENT OF SQL INNER TABLE JOIN IN R (Peter Dalgaard)
13. Re: 3 questions regarding matrix copy/shuffle/compares (Esmail)
14. Re: Conditional plot labels (baptiste auguie)
15. Re: Scatterplot of two groups side-by-side? (baptiste auguie)
I'm not sure I'm following you but have you tried,
identical(matrix(c(1,1,1,1),ncol=2), matrix(c(1,1,1,1),ncol=2))
?all.equal
?isTRUE
?identical
and possibly the compare package,
compare(matrix(c(1,1,1,1),ncol=2),matrix(c(1,1,1,1),ncol=2))
HTH,
baptiste
On 26 Apr 2009, at 18:02, Esmail wro
Hi,
You could do this very easily using ggplot2,
#install.packages("ggplot2", dep=TRUE)
library(ggplot2)
c <- ggplot(mtcars, aes(y=wt, x=mpg)) + facet_grid(. ~ cyl)
c + stat_smooth(method=lm) + geom_point()
See more examples on Hadley's website: http://had.co.nz/ggplot2/
Hope this helps
Hi,
Have you considered using high-level plotting functions provided by
the ggplot2 or lattice package? Here's a dummy example,
x <- seq(0, 10, length=100)
y1 <- sin(x)
y2 <- cos(x)
y3 <- x^2/100
y4 <- 1/x
d <- data.frame(x, y1, y2, y3, y4)
library(reshape)
dm <- melt(d, id="x")
dm$type1
on suitable devices, you could consider transparency,
plot(f,col=alpha("grey",0.8),pch=19)
baptiste
On 24 Apr 2009, at 14:09, Knut Krueger wrote:
f<- data.frame("x"=c(1,3,5,6,1),"y"=c(1,2,3,4,1))
plot(f)
__
R-help@r-project.org mailing list
http
>
>
> -Messaggio originale-
> Da: Duncan Murdoch [mailto:murd...@stats.uwo.ca]
> Inviato: gio 23/04/2009 14.21
> A: mau...@alice.it
> Cc: baptiste auguie; r-help Help
> Oggetto: Re: [R] R: R: how to split and handle a big R program into
> multiple files
>
It is an R command (package utils), see ?package.skeleton
baptiste
On 23 Apr 2009, at 10:51, mau...@alice.it wrote:
>
> Is that an R command ?
> I browswd for the on-line hlp about such a command but could not
> find it.
> Thank you.
> maura
>
>
> -Messaggio or
If most of the functions are quite stable (you don't change them too
often), you could also consider creating a R package with
package.skeleton.
baptiste
On 23 Apr 2009, at 10:39, jgar...@ija.csic.es wrote:
source() and the use of functions
...
Javier
---
I am working on a program to
if it hasn't been suggested already:
ggplot2 also has a book and a website: http://had.co.nz/ggplot2/
I would recommend any newcomer to have a look as it provides a clear,
consistent and elegant syntax to produce very nice plots.
baptiste
On 22 Apr 2009, at 03:14, Erik Iverson wrote:
In add
I vaguely recall thinking with such convoluted constructs when
switching from Matlab to R. The lack of generic data structures such
as lists makes you define variable names that you can identify and
manipulate. There are structures in Matlab, but I think they are much
less used than lists i
Perhaps try the pgfSweave package on r-forge?
http://r-forge.r-project.org/projects/pgfsweave/
HTH,
baptiste
On 19 Apr 2009, at 22:15, Jonas Stein wrote:
Hi,
i use Sweave to put plots in my .tex Documents. (pdflatex)
Is there a nice solution for this:
a) get a real LaTeX formula in the plo
The grImport package seems to provide such possibility for vector
graphics,
http://www.stat.auckland.ac.nz/~paul/Talks/gddg.pdf
imageJ is another open-source option.
baptiste
On 16 Apr 2009, at 16:44, Shubha Vishwanath Karanth wrote:
Hi R,
Wanted to check if there are any packages avail
Perhaps,
apply(combn(letters[1:4],2), 2, paste,collapse="")
Hope this helps,
baptiste
On 16 Apr 2009, at 17:33, Juergen Rose wrote:
Am Donnerstag, den 16.04.2009, 10:59 -0400 schrieb David Winsemius:
Thanks David,
is there also a shorter way to get the columns names of the new data
frames?
at 12:11, rajesh j wrote:
> multigraph has several graphs in 1 layout.I'm drawing a large graph
> and plotting small portions of it below.I'm drawing lines from the
> large graph to the smaller ones to show which part of the large
> graph it is.
>
> On Thu, Apr 16, 20
Hi,
You should give a minimal reproducible example so that we know more
precisely what you want to do (what's a "multigraph"?).
Perhaps you can get inspiration from Paul Murrell's R graphics book,
in particular Figure 5.22,
http://www.stat.auckland.ac.nz/~paul/RGraphics/customgrid-lattice
Do you want abind?
http://cran.r-project.org/web/packages/abind/index.html
baptiste
On 15 Apr 2009, at 19:33, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI
wrote:
I have a multidimensional array "a", for example,
a
, , 1
[,1] [,2]
[1,]13
[2,]24
, , 2
[,1] [,2]
[1,]
I think you want to have a look at the plyr or doBy packages.
It would be easier to give a precise answer with a minimal example.
HTH,
baptiste
On 15 Apr 2009, at 18:03, Lane, Jim wrote:
Hi, All
Forgive me if this is a stupid newbie question. I'm having no luck
googling an answer to this, p
?assign
(but are you sure you really want to name all these objects
separately? Usually in R you would put them together in a list or a
data.frame, it is much more convenient for later manipulations)
On 14 Apr 2009, at 18:32, Zachary Patterson wrote:
I am new to R. I would like to automat
glad it was helpful.
%in% is a logical operator, so you can use "!" to negate the result
(with parentheses),
! ( 4 %in% 1:3)
Alternatively, define a new operator,
`%ni%` <- Negate(`%in%`)
1 %ni% c(2,1)
Next time you ask a follow-up question please send it to the r-help
list so others ca
Is this what you want?
plotNames <- c("plot1", "plot2", "plot3") # plot is probably best
left as the name of the base function
full.data[full.data$PLOTID %in% plotNames, ] # note the comma
HTH,
baptiste
On 14 Apr 2009, at 15:20, zack holden wrote:
Dear List,
I'm stuck on what seems
Try this,
numbers <- c("one","two","three","four")
values <- c(10,20,30,40)
v <- list(sample(numbers,3),sample(numbers,2))
v
sapply(v,function(.l) values[match(.l, numbers)] )
HTH,
baptiste
On 14 Apr 2009, at 13:01, Manoel Silva wrote:
Dear All,
Here's my problem. I have two lists:
v
[[
Hi,
Two thoughts I'd like to share on this subject:
1) Something really cool for conversions between units is the Google
search bar: type in " 3 inches in cm" and you get,
3 inches = 7.62 centimeters
or, " 3 £ in dollar",
3 UK£ = 4.4007 U.S. dollars
or "12 cubic meters to pi
try this,
do.call(rbind, resample2)
#or simply,
replicate(1000, Cusum(sample(lambs,replace=F)))
you could also look at the plyr package.
Hope this helps,
baptiste
On 10 Apr 2009, at 09:03, Melissa2k9 wrote:
Hi,
I have used this command :
resamples<-lapply(1:1000,function(i) sample(lam
panel.xyplot(x,y,...)
grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")}
)
baptiste auguie-2 wrote:
with ggplot2,
d <- melt(df2,id="year")
qplot(year,value,data=d,colour=variable,geom=c("line","point"))
with ggplot2,
d <- melt(df2,id="year")
qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
geom_text(data= subset(d, variable == "cars"), aes(label=value))
with lattice, my best guess would be to use grid.text in a custom
panel function.
Hope this helps,
baptiste
On 8 Apr 2
with base graphics,
par(bg=NA)
see ?par
Hope this helps,
baptiste
On 8 Apr 2009, at 12:54, Gundala Viswanath wrote:
Is there a way to do it in R?
Especially generating plot in EPS/PDF format.
By transparent I mean clear (not white) background.
I want to attached it to dark PPT slides.
-
On 8 Apr 2009, at 11:44, Duncan Murdoch wrote:
Mark Heckmann wrote:
Dear Duncan,
Thanks for the reply. This works, but unfortunately I need a
different
solution.
My script is supposed to run completely automated and the graphics
I produce
vary in size each time I run the script. But I wan
clr <-
function ()
rm(list = ls(pos = .GlobalEnv), pos = .GlobalEnv)
this works for me
HTH,
baptiste
On 8 Apr 2009, at 10:50, Taraxacum88 wrote:
why
rm(list=ls(all=TRUE),envir=globalenv())
is ok but
ca<-function() rm(list=ls(all=TRUE),envir=globalenv())
ca()
does not work?
Thank yo
Hi,
I think it's a FAQ (== vs all.equal to test for equality), and not
related to expand.grid. See ?all.equal and ?"=="
You don't need which, gridd[gridd[,2]=="0.6" , ] would work fine, or
more elegantly (imho),
gridd <- expand.grid(x=x,y=y )
subset(gridd, factor(x) == "0.6")
Hope
Here's one attempt with plyr, hopefully Hadley will give you a better
solution ( I could not get cast() to do it either)
test <-
data
.frame
(a=c("A","A","A","A","B","B","B"),b=c(1,1,2,2,1,1,1),c=sample(1:7))
ddply(test,.(a,b),.fun=function(.) paste(.)[3])
a b V1
1 A 1c(2, 4
Hi,
Have you looked at the compare package? It might do what you want (I
just remember seeing its description on R News recently but I've never
used it),
d <- data.frame(x=1:10,y=sin(1:10),z=factor(letters[1:10]))
d1 <- d
d1$x[2:3] <- jitter(d$x[2:3] )
d2 <- subset(d1, !(z %in% c("a","g")
Hi,
It seems to me that you could write a generic function myplot() and
have different methods for each class of object (like plot does).
Either S3 or S4 classes would do I think. Then it is only a matter of
making each method work separately. In particular, the method for a
formula coul
I had a similar need for conversions in optics. I put together several
functions and data on r-forge, where it does not clutter CRAN but can
still be shared conveniently with others.
baptiste
On 3 Apr 2009, at 19:27, Duncan Murdoch wrote:
stephen sefick wrote:
I am starting to use R fo
of course!
Thanks,
baptiste
On 3 Apr 2009, at 14:48, hadley wickham wrote:
On Fri, Apr 3, 2009 at 8:43 AM, baptiste auguie
wrote:
That makes sense, so I can do something like,
count <- function(x){
as.integer(unclass(table(x)))
}
count(d$user_id)
ddply(d, .(user_id), transf
hoo 935 1
4 25 facebook 1015 1
5 61 google 940 1
Have I missed a built-in function to obtain this result?
Thanks,
baptiste
On 3 Apr 2009, at 14:16, hadley wickham wrote:
On Fri, Apr 3, 2009 at 4:43 AM, baptiste auguie
wrote:
Dear all,
I'm puzzled by the f
Excellent!
I felt it was fairly trivial but i can be quite dense on Friday
mornings.
I really like the generalisation.
Many thanks,
baptiste
On 3 Apr 2009, at 12:11, Wacek Kusnierczyk wrote:
baptiste auguie wrote:
Dear list,
I often need to convert several variables from numeric or
Dear list,
I often need to convert several variables from numeric or integer into
factors (before plotting, for instance), as in the following example,
d <- data.frame(
x = seq(1, 10),
y = seq(1, 10),
z = rnorm(10),
a = letters[1:10])
d2 <-
within(d,
Hi,
Is this what you want?
d <- data.frame(density.AL = seq(1, 10),
density.AK = seq(1, 10), # many others...
Date=letters[1:10]) # dummy example
library(reshape)
melt(subset(d, Date == "b"), id="Date")
BTW, I spotted a few awkward things in your code,
st <- c("AL",
Dear all,
I'm puzzled by the following example inspired by a recent question on
R-help,
cc <- textConnection("user_id website time
20google0930
21yahoo0935
20facebook1000
25facebook1015
61google
just for curiosity,
`%ni%` <- Negate(`%in%`)
> 1 %ni% c(2,1)
[1] FALSE
d1[id %ni% c(1,4), ]
baptiste
On 2 Apr 2009, at 22:17, gina patel wrote:
I have another question, if I now want to remove multiple id's e.g.
id=1 or 4 is there a simple OR command I can use?
I tried d2<-(d1[id != 1 |
try this,
d = read.table(textConnection("USER NAME
12 admin
12 admin
10 admin
10 advertising
61 process
17snapshot
61ticket
61ticket
30snapshot
10advertising
10advertising
10advertising
10advertising
"),head=T)
str(d) # note that NAME is a fact
perhaps,
unlist(d, use.names=F)
baptiste
On 1 Apr 2009, at 22:15, oscar linares wrote:
Dear Rxperts
I have a data.frame as follows
ABCD
14 710
25 811
36 912
I want to convert it to a data frame with a single row (i.e., stack
the
columns w
Not exactly the output you asked for, but perhaps you can consider,
library(doBy)
> summaryBy(x3~x2+x1,data=x,FUN=mean)
x2 x1 x3.mean
1 1 A 1.5
2 1 B 2.0
3 1 C 3.5
4 2 A 4.0
5 2 B 5.5
6 2 C 6.0
the plyr package also provides similar functionality, as do t
may i suggest the following,
a <- do.call(rbind, lapply(cust1_files, read.table))
(i believe expanding objects in a for loop belong to the R Inferno)
baptiste
On 30 Mar 2009, at 12:58, Mike Lawrence wrote:
cust1_files =
list.files(path=path_to_my_files,pattern='cust1',full.names=TRUE)
a
yet another attempt,
colours <- as.character(paste(letters,colours(),"stuff",LETTERS))
target <- c("red","blue","green","gray")
matches <- melt(sapply(target, grep, x=colours))
colours[matches$value] <- matches$L1
(probably a worse idea than a straight for loop, though)
baptiste
On 2
The variable name in your call to assign should vary within the for
loop, otherwise you're always assigning the value to the same variable.
Consider the following example,
listOfNames <- c("a", "b", "c")
listOfVariables <- c("vara", "varb", "varc")
for(index in seq_along(listOfNames)){
3699 8375 19200 36563 83993 123167
$ X6 : int 248 730 3056 2327 4092 8905 15931 37895 84565
Thanks
baptiste auguie schrieb:
the result of read.table is a data.frame, not a matrix as you first
suggested. Can you copy the result of str(b) so we know what your
data
is made of?
I'
wing
columns with vectors.
apply(b[,-1], 2, plot, x= b[,1])
Also all columns have the same length, [R] states that the length are
different.
Can you help me?
baptiste auguie schrieb:
Something like this perhaps,
a <- matrix(rnorm(5*49), ncol=49)
pdf(width=15, height=15)
par(mfrow= c(8,6))
ap
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
I need to discriminate shading level accordingly to the abundance
value
(level).
I don't know how to proceed.
Paulo E. Cardoso
-Mensagem original-
De: baptiste auguie [mailto:ba...@exeter.ac.uk]
Enviada: sexta-feira,
?colorRamp
Hope this helps,
baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of c
Something like this perhaps,
a <- matrix(rnorm(5*49), ncol=49)
pdf(width=15, height=15)
par(mfrow= c(8,6))
apply(a[,-1], 2, plot, x= a[,1])
dev.off()
HTH,
baptiste
On 27 Mar 2009, at 11:05, skrug wrote:
Hi evrybody,
in a matrix consisting of 49 columns, I would like to plot all column
Hi,
If your directory contains only files you want to load anyway, then
list.files() is your friend,
list.files(pattern = "comp") # or pattern =".asc" for example
If you do need to create the names manually, then you could create the
combinations with expand.grid, as in,
do.call(paste
-0.25873225
>
> However, we would still have this, which is expected (same as
> d[1:2] ):
>
>> `[.data.frame`(d, i=1:2)
>x y
> 1 0.45141341 0.03943654
> 2 -0.87954548 1.83690210
> 3 -0.91083710 0.22758584
> 4 0.06924279 1.26799176
> 5 -
thanks to some off-list replies, I got this to work,
On 25 Mar 2009, at 18:56, baptiste auguie wrote:
Dear all,
Trying to extract a few rows for each element of a list of
data.frames, I'm puzzled by the following behaviour,
d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y
Dear all,
Trying to extract a few rows for each element of a list of
data.frames, I'm puzzled by the following behaviour,
d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5)))
str(d)
lapply(d, "[", i= c(1)) # fine, this extracts the first columns
lapply(d, "[", j= c(1, 3)) #
well, the literal answer is that paste("arunoff_",table_year,"_temp")
is a character vector of length 1 so your indexing cannot work. What
you want is to index the data that corresponds to this variable name,
?get
But I should stress that this manipulation with assign and get seems
complete
(a <- replicate(5,rnorm(10)))
colMeans(a)
should get you started.
HTH,
baptiste
On 23 Mar 2009, at 18:29, pfc_ivan wrote:
I tried using the for (i..) to make 1000 differents sets of numbers,
but then
I dont know how to get the mean value of all of them... because I
dont even
think 1000
On 23 Mar 2009, at 17:39, Jason Rupert wrote:
I would like to replace a few varaibles within a data frame.
For example, in the dataframe below (contrived) I would like to
replace the current housesize value only if the Location is HSV.
However, I would like to leave the other values int
You need only one loop,
year <- 1951:2000
filelist <- paste("C:\\Documents and Settings\\Data\
\table_",year,".txt", sep="")
filelist
for (ii in seq_along(year)) {
assign(paste("table_", year[ii], sep=""),
read.table(file=ifile[ii], header=TRUE,
sep
On 23 Mar 2009, at 11:52, johnhj wrote:
I have still the same problem... As you said I tried with
par(mfrow=c(2,1))
and par(mfrow=c(1,2)) but without success. Could R compiler be the
problem ?
Why not? But may I suggest you try first the following example I sent
you yesterday,
pn
I'm not sure I understood your problem (can you provide an
reproducible example?), but perhaps you can try useOuterStrips() in
the latticeExtra package (the formatting becomes similar to that of
the ggplot2 package, perhaps another option to consider)
Hope this helps,
baptiste
On 23 Mar
conditional. I think the result
is it just overwrites the previous answer so my final results is not
as large as I would expect.
Thanks again in advance.
Mark
-Original Message-
From: baptiste auguie [mailto:ba...@exeter.ac.uk]
Sent: Fri 3/20/2009 4:32 AM
To: Altaweel, Mark R.
Cc: r-help
501 - 600 of 738 matches
Mail list logo