Displaying 20 results from an estimated 10000 matches similar to: "Format of numbers in plotmath expressions."
2010 Feb 02
2
mysterious extra spaces appearing in expression paste
Hi,
i'm trying to put a legend on some figures and they're coming out a
bit wonky. here's an example:
a <- c(1:10)
par(mfrow=c(2,1))
plot(a,type="s",lwd=3)
leg <- c(expression(paste("data1 (",rho,"=1)")),
expression(paste("data2 (",rho,"=0.0)")))
legend("bottomright",legend=leg,col=c(1,2),lwd=3)
2011 Jun 02
2
plotmath: paste string and expression [from a vector of expressions]
Dear all,
I have a vector of expressions and would like to "paste" some string to it before using it in a plot:
vars <- vector("expression", 2)
vars[1] <- expression(alpha)
vars[2] <- expression(beta)
plot(0, 0, main=substitute(bold("Foo" ~~ VAR), list(VAR=vars[2]) ))
Although I tried hard, I just can't figure out how to solve this. The title should be
2006 Mar 23
3
Intercepts in linear models.
A colleague asked me if there is a way to specify with a
***variable*** (say ``cflag'') whether there is an intercept in a
linear model.
She had in mind something like
lm(y ~ x - cflag)
where cflag could be 0 or 1; if it's 0 an intercept should
be fitted, if it's 1 then no intercept.
This doesn't work ``of course''. The cflag just gets treated
as another predictor
2007 Oct 03
3
Factor levels.
I have factors with levels ``Unit", "Achieved", and "Scholarship"; I
wish to replace these with
"U", "A", and "S".
So I do
fff <- factor(fff,labels=c("U","A","S"))
This works as long as all of the levels are actually present in the
factor. But if ``Scholarship'' is absent
(as if often is) then
2006 Mar 06
3
how to make plotmath expression work together with paste
Recent questions about using plotmath have renewed my interest in this question
I want to have expressions take values of variables from the
environment. I am able to use expressions, and I am able to use paste
to put text and values of variables into
plots. But the two things just won't work together.
Here is some example code that shows what I mean.
plot(NA,xlim=c(0,100),ylim=c(0,100))
2012 May 19
1
Names of Greek letters stored as character strings; plotmath.
I had such good luck with my previous question to r-help, (a few minutes
ago) that I thought I would try again with the following query:
> Suppose I have
>
> xNm <- "gamma"
>
> I would like to be able to do
>
> plot(1:10,xlab = <something involving xNm">)
>
> and get the x axis label to be the Greek letter gamma
> (rather than the
2012 Mar 30
1
avoiding expression evaluation when calling a function
Another question on functions - I have something that looks like
plotter<-function(i){
temp.i<-rwb[rwb$vector1 <=(i*.10),]
with(temp.i, plot(vector2, vector3, main=(i*.10),))
mod<-lm(vector3~vector3-1,data=temp.i)
r2<-summary(mod)$adj.r.squared
rsqrd[i]<-r2
legend("bottomright", legend=signif(r2), col="black")
abline(mod)
rsqrd<<-rsqrd
}
I'd
2006 Mar 10
2
Plot.date and legends
Hi:
I'm trying to plot dates on the x-axis of a code, but the legend is not being
displayed. I receive the following error:
Error in match.arg(x, c("bottomright", "bottom", "bottomleft", "left", :
'arg' should be one of bottomright, bottom, bottomleft, left,
topleft, top, topright, right, center
In addition: Warning message:
longer
2024 Sep 28
1
Is there a sexy way ...?
Hi Rolf,
this topic is probably already saturated, but here is a tidyverse solution:
```
library(purrr)
x <- list(
? `1` = c(7, 13, 1, 4, 10),
? `2` = c(2, 5,? 14, 8, 11),
? `3` = c(6, 9, 15, 12, 3)
)
x |>
? pmap(~ c(..1, ..2, ..3)) |>
? reduce(c)
#> [1]? 7? 2? 6 13? 5? 9? 1 14 15? 4? 8 12 10 11? 3
```
Here, we map over the elements of the list in parallel (hence pmap),
2012 Apr 01
1
indexing in a function doesn't work?
Hello,
I've written a small function that's supposed to save me some time, and
it's ending up killing it- the intention is to iteratively subset a dataset
fram on framevec, fit a model (either lm or nls depending on type) and
return the r2 or AIC from the model, respectively. Although as far as I can
tell in my code the plots are dependent on the fit of the model to the data
and the
2011 Jul 25
1
Creating png of layered legend
I am trying to create a plot that has multiple plot characters for
each point (e.g. a point within a triangle, a triangle within a
square, etc). The workaround I have found to do this is by plotting
twice, as in this example:
x <- c(1.1, 2.3, 4.6)
y <- c(2.0, 1.6, 3.2)
plot(x, y)
points(x,y, pch=20, col="red", cex=0.5)
This works, but perhaps there is a better way to do it in one
2006 Feb 09
7
putting text in the corner
I want to write some text in a corner of my plot.
Is it possible to get the xlim and ylim of an open window?
Or is there anything similar like
legend(x="bottomright", inset=0.01,legend=...)
for
text(x=1,y=2, "test")
Thomas
2004 Oct 23
1
Legend/Substitute/Plotmath problem
Hello,
I seem unable to construct a legend which contains a substitution as
well as math symbols. I'm trying to do the following:
strain2 <- "YJG48"
legend.txt <- c(
substitute(
strain *
%==% *
"YJG45, rpn10" *
%Delta%,
list(strain=strain2)
),
"Verhulst/Logistic",
"Malthus"
)
legend(
100,2.5,
legend.txt,
cex=0.75,
2024 Sep 28
1
Is there a sexy way ...?
Sorry to append, but I just realised that of course
```
x |>
? pmap(c) |>
? reduce(c) |>
? unname()
```
also works and is a general solution in case your list has more than
three elements. Here, we map in parallel over all elements of the list,
always combining the current set of elements into a vector, and then
reduce the resulting list into a vector by combining the elements
2008 Feb 20
2
Data frame with 0 rows.
For reasons best known only to myself ( :-) ) I wish to create a data
frame with 0 rows and 9 columns.
The best I've been able to come up with is:
junk <- as.data.frame(matrix(0,nrow=0,ncol=9))
Is there a sexier way?
cheers,
Rolf
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
2012 Jun 08
2
changing font to italic for one entry in legend()
Hello,
I need to change the font for one of the items (C. elegans) in my
legend to italic. Can someone suggest how to accomplish this?
legend('bottomright', bty='n', c('C. elegans range', 'Study area'),
cex=0.8, fill=c('light gray', 'white'), border=c('black','black'))
I tried using lab.font=c(1,3) but R ignored and did not write
2016 Oct 26
2
borrar texto en una gráfica
Hola a todos,
Os envío una consulta que considero sencilla pero me está resultando imposible de resolver. Si ejecutáis el siguiente código, obtendréis la gráfica que os adjunto:
library(ltm)
modelo <- rasch(LSAT)
plot(modelo, main="Curva probabilidad pregunta 1",legend = TRUE, cx = "bottomright", items=1,xlab="Conocimiento",ylab="Probabilidad")
Resulta
2008 Jul 15
1
manipulating (extracting) data from distance matrices
Hi all,
Does anyone have any tips for extracting chunks of data from a distance matrix?
For instance, if one was interested in only a subset of distance
comparisons (i.e., that of rows 4 thru 6, and no others), is there a
simple way to pull that data out?
>From some playing around with an example (below), I've been able to
figure out that a distance matrix in R is stored as a single
2024 Sep 28
1
Is there a sexy way ...?
I see a book coming:
"666 ways to do the same thing in R ranked by sexiness."
Kidding aside, if you look under the covers of some of the functions we are using, we may find we are taking steps back as some of them use others and perhaps more functionality than we need.
But for a new reader , looking at many approaches may open up other ways and ideas and see the problem space as quite
2013 Jun 07
1
cannot update battery.date value of APC ups battery
Hi,
I'm running this command:
# upsrw -s "battery.date=2013Jun7" -u ups-mon-IT "IT-APC-BOTTOMRIGHT at 127.0.0.1"
Password:
OK
but I'm getting this listing:
# upsc IT-APC-BOTTOMRIGHT at 127.0.0.1
battery.alarm.threshold: 0
battery.charge: 100.0
battery.charge.restart: 15
battery.date: 01/10/06
battery.packs: 000
battery.runtime: 1440
battery.runtime.low: 120