Hi,
I seem to be unable to get a mixed legend that has lines *or* polygons
(not both). For example:
ppi - seq(0,2*pi,length.out=21)[-21]
frame()
plot.window(ylim=c(-5,5),xlim=c(-5,5),asp=1)
polygon(cos(ppi)*4+rnorm(20,sd=.2),sin(ppi)*4+rnorm(20,sd=.2),
col=green,border=FALSE)
Hi all,
I'm usually comfortable using the *apply functions for vectorizing loops
in R. However, my particular problem now is using it in a sequential
operation, which uses values evaluated in an offset of the loop vector.
Here is my example using a for loop approach:
dat -
Those numbers look like ... well, numbers. You want characters! Try
converting the integer to a character before trying to do a string
parse, e.g.:
ymd.int - c(20050104, 20050105, 20050106, 20050107, 20050110, 20050111,
20050113, 20050114)
ymd - as.Date(as.character(ymd.int),%Y%m%d)
As far as
[1] 20050104 20050105 20050106 20050107 20050110 20050111 20050113
20050114
ymd - as.Date(as.character(ymd.int),%Y%m%d)
ymd
[1] 2005-01-04 2005-01-05 2005-01-06 2005-01-07 2005-01-10
[6] 2005-01-11 2005-01-13 2005-01-14
class(ymd)
[1] Date
While the variable ymd is actually of class
Sadly, I don't know of any tutorials or much help on the web for R ...
that doesn't mean it doesn't exist ... you might just have to look
around for it (www.rseek.org is a good place to start)
I've learned almost everything I know through:
?strptime
Also check out the methods for the classes,
I apologize if I don't fully understand your question, but the pdf
device has a MediaBox, which is equivalent to the BoundingBox in EPS
file. The PDFs from R are defined nicely using height/width dimensions,
and work well with embedding in pdflatex, etc. For example:
Your are so close ... you just need to specify that you want your
histograms to show density, not percent. I've only edited one line of
your script, the rest is good and plots nicely:
histogram(~ resp | group, col=steelblue,type=density,
__
You might also want to try density, since it can theoretically have
non-zero bins, since it doesn't use bins. For example, take a Weibull
distribution, which could look better with a log y-axis:
x - rweibull(1000,1,5)
par(mfrow=c(2,1))
plot(density(x,from=0))
rug(x)
e.g. dat
[,1]dat[,2]
[1,]300 20060101
[2,]257 20060102
[3,]320 20060103
[4,]311 20060104
[5,]297
How about turning them into a native date-time class, then re-formatting it.
For example, say you have some American dates in a character vector:
American.datechar - c(5/15/1976,2/15/1970,1/9/2006)
# parse this:
American.date - strptime(American.datechar,%m/%d/%Y)
# reformat:
Part of the problem is that alpha is a new and undocumented feature
(note to developers: add this info into the pdf and rgb documentation).
It only works in PDFs (maybe on quartz on Macs?), so you need to write
to a PDF file:
pdf(out.pdf,version=1.4)
In R 2.5.0 (r40806), one of the change is to allow partial matching of
name in the attr function. However, how can I tell if I have an exact
match or not?
For example, checking to see if an object has a name attribute, then
giving it one if it doesn't:
dat - data.frame(x=1:10,y=rnorm(10))
Another way is to use an indexed list, which is far more tidier than
your method. If you mean about 100 as in an irregular number, then a
list is your friend (i.e., a ragged array, that can have sometimes 97
samples, sometime 105 samples, etc.). Similar to your example:
dat -
Hi,
I have a question regarding setting options that use a list. There are
none that I'm aware of in R-base, however, it can make sense for some
custom situations. For example:
options(myoptions=list(lwd=1,density=NULL,angle=45,col=green))
Getting values is simple:
getOption(myoptions)$col
Log y-axis on histograms are conceptually wrong, but aren't a bad idea
either. It is conceptually safer to show this using density. Consider
an exponential distribution, which could look better with a log y-axis:
x - rexp(1,.1)
xd - density(x,from=0)
par(mfrow=c(2,1))
plot(xd)
Hi,
I have questions about object attributes, and how they are handled when
subsetted. My examples will use:
tm - (1:10)/10
ds - (1:10)^2
attr(tm,units) - sec
attr(ds,units) - cm
dat - data.frame(tm=tm,ds=ds)
attr(dat,id) - test1
When a primitive class object (numeric, character, etc.) is
Here is a patch to improve documentation for finding useful, yet newish,
functions: 'findInterval' and 'colorRamp'. I think that it is worthwhile
to mention these in the 'seealso' section of the similar 'match' and
'palette' documents. I had difficulty finding these functions at first,
as they
17 matches
Mail list logo