Displaying 20 results from an estimated 30000 matches similar to: "suggestion for ?factor"
2009 Feb 05
3
"open-ended" plot limits?
Hi Folks,
Maybe I've missed it already being available somehow,
but if the following isn't available I'd like to suggest it.
If you're happy to let plot() choose its own limits,
then of course plot(x,y) will do it.
If you know what limits you want, then
plot(x,y,xlim=c(x0,x1),ylim(y0,y1)
will do it.
But sometimes one would like to
a) make sure that (e.g.) the y-axis has a
2010 Sep 08
6
'par mfrow' and not filling horizontally
Greetings, Folks.
I'd appreciate being shown the way out of this one!
I've been round the documentation in ever-drecreasing
circles, and along other paths, without stumbling on
the answer.
The background to the question can be exemplified by
the example (no graphics window open to start with):
set.seed(54321)
X0 <- rnorm(50) ; Y0 <- rnorm(50)
2008 Oct 20
3
? extended rep()
Hi Folks,
I'm wondering if there's a compact way to achieve the
following. The "dream" is that, by analogy with
rep(c(0,1),times=c(3,4))
# [1] 0 0 0 1 1 1 1
one could write
rep(c(0,1),times=c(3,4,5,6))
which would produce
# [1] 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1
in effect "recycling" x through 'times'.
The objective is to produce a vector of
2008 Mar 12
1
[follow-up] "Longitudinal" with binary covariates and outcome
Hi again!
Following up my previous posting below (to which no response
as yet), I have located a report which situates this type
of question in a longitudinal modelling context.
http://www4.stat.ncsu.edu/~dzhang2/paper/glm.ps
Generalized Linear Models with Longitudinal Covariates
Daowen Zhang & Xihong Lin
(This work seems to originally date from around 1999).
They consider an outcome Y,
2009 May 17
2
Output of binary representation
I am interested in studying the binary representation of numerics
(doubles) in R, so am looking for possibilities of output of the
internal binary representations. sprintf() with format "a" or "A"
is halfway there:
sprintf("%A",pi)
# [1] "0X1.921FB54442D18P+1"
but it is in hex.
The following illustrate the sort of thing I want:
1.1001 0010 0001 1111
2008 Oct 11
2
R vs SPSS contrasts
Hi Folks,
I'm comparing some output from R with output from SPSS.
The coefficients of the independent variables (which are
all factors, each at 2 levels) are identical.
However, R's Intercept (using default contr.treatment)
differs from SPSS's 'constant'. It seems that the contrasts
were set in SPSS using
/CONTRAST (varname)=Simple(1)
I can get R's Intercept to match
2008 Oct 12
1
png(): Linux vs Windows
Hi Folks,
Quick question. I have the following line in an R code file
which runs fine on Linux:
if(PNG) png(GraphName,width=12,height=15,units="cm",res=200)
I learn that, when the same code was run on a Windows machine,
there was the following error:
Error in png(GraphName,width=12,height=15,units="cm",res=200):
unused argument(s) (units = "cm")
Sorry to
2009 Mar 31
2
"digits" in round()
Hi Folks,
Compare
print(1234567890,digits=4)
# [1] 1.235e+09
print(1234567890,digits=5)
# [1] 1234567890
Granted that
digits: a non-null value for 'digits' specifies the minimum
number of significant digits to be printed in values.
how does R decide to switch from the "1.235e+09" (rounded to
4 digits, i.e. the minumum, in "e" notation) to
2010 May 12
6
A primitive OO in R -- where next?
Greetings All,
Out of curiosity, I've just done a very primitive experiment:
Obj <- list(Fun=sum, Dat=c(1,2,3,4))
Obj$Fun(Obj$Dat)
# [1] 10
That sort of thing (much more sophisticated) must be documented
mind-blowingly somewhere. Where?
Where I stand right now: The above (and its immediately obvious
generalisations, like Obj$Fun<-cos) is all I know about it so far.
Ted.
2008 Apr 27
2
Deb-4.0 Etch and sources.list for R
Hi Folks,
I'm running Debian-4.0 Etch, installed last September
from a DVD, and regularly updated as things arise.
I have R version 2.4.0 Patched (2006-11-25 r39997)
installed (initially at the time of first installation
of Debian, as provided by Debian), along with a variety
of packages.
I'd like to be able to connect to the CRAN repositories
for Debian R, for updates etc.
When I visit
2008 May 20
1
contr.treatments query
Hi Folks,
I'm a bit puzzled by the following (example):
N<-factor(sample(c(1,2,3),1000,replace=TRUE))
unique(N)
# [1] 3 2 1
# Levels: 1 2 3
So far so good. Now:
contrasts(N)<-contr.treatment(3, base=1, contrasts=FALSE)
contrasts(N)
# 1 2
# 1 1 0
# 2 0 1
# 3 0 0
whereas:
contr.treatment(3, base=1, contrasts=FALSE)
# 1 2 3
# 1 1 0 0
# 2 0 1 0
# 3 0 0 1
contr.treatment(3, base=1,
2008 Jun 01
2
Eliminating "[...]" from print
Hi Folks,
This must be easy but I've not managed to locate the solution!
Basically: I'm using sink() to save successively obtained
results, e.g. I construct a set of regression coefficients
etc. with names rows and columne (I want to see the names
in the output) as an object (say "Object"), and then I
emit it with
print(Object)
So far so good. But I also want to print a
2009 Oct 22
1
contour() & contourLines()
Hi Folks,
I have been using contour() to produce some contour plots
(of a spatially-smooted density produced by kde2d()), with
very satisfactory results.
I now want access to the coordinates of the points on the
contours, and it would seem that contour() does not return a
value, so there is nothing from which these could be extracted.
However, apparently contourLines() does, and it seems to be
2009 Sep 01
2
Function for all 2^N subsets of N
Greetings all!
I have been searching the Site for a function, say "subsets",
such that for instance
subsets(10)
would return a (say) matrix of indices to the 2^10 subsets of
N items -- perhaps in the form of 2^10 rows each of which is
10 entries each either TRUE or FALSE. Or 1 or 0. Or ...
I can of course write my own, using good old looping technology
or similar, but it would be
2007 Nov 30
2
Organising tick-marks in plot()
Hi Folks,
I'm advising someone who's a beginner with R,
and therefore wants the simplest answer possible.
The issue is to produce a plot using
plot(x,y,...)
where, on the X-axis, the tick-marks should be
on the lines of:
-- Range of X-axis: 0:1000
-- tick-marks labelled "0","200",...,"800","1000"
-- unlabelled tick-marks every 50 from 0 to
2010 Jun 07
1
Test
Greetings Moderators!
I moderated the message below just now (one of two identical
test messages). I rejected it, with a covering note to the
author (John Munroe <munddr at gmail.com>, who does not appear
to be subscribed to the list) that I was doing so because
approving it would serve no useful purpose, and pointing out
that it had been held because the message headers matched a
filter
2009 Nov 22
1
contour(): lines & labels in different colours?
Greetings, All!
I want to draw contour lines in red, using contour(), but also
have the contour labels (for the level-values) in black so that
they will stand out against a coloured background already generated
using filled.contour() (the background shades from green at low
levels of "risk" to red at high levels).
In any case, contour labels in red are already somewhat inconspicuous
2007 Dec 09
2
Adding info from summary(lm(...)) to plot
Hi Folks,
Say I have 2 continuous variables X,Y.
I can of course plot (X,Y) with
plot(X,Y,pch="+",col="blue")
say, and add the regression line from lm(Y~X)
by extracting the coefficients 'a' of Intercept
and 'b' of X from Y.lm <- lm(Y~X).
Now, however, I want to have not only a general
explanatory title such as
main="Plot of Y against X"
2008 Mar 02
5
[OT] "normal" (as in "Guassian")
Hi Folks,
Apologies to anyone who'd prefer not to see this query
on this list; but I'm asking because it is probably the
forum where I'm most likely to get a good answer!
I'm interested in the provenance of the name "normal
distribution" (for what I'd really prefer to call the
"Gaussian" distribution).
According to Wikipedia, "The name "normal
2009 Oct 22
2
Simple extraction of level,x,y from contourLines()
A follow-up to my previous query.
Say one of the results returned by contourLines() is
C.W <- contourLines(....)
Then C.W is a list of (in this case 28) lists,
each of which is a list with components $level (a single number),
$x (the x coords of the points on a contour at that level) and
$y (the y coords).
I can of course get these individually with, for the 5th one for
instance,