Hai Rui,
It seems doesnt work for me, the "" still there.
So I used this one (Bert suggestion),
test<-lapply(test,function(x){x$RR[x$RR==] <- NA; x})
Best,
Ani
On Sat, Oct 19, 2019 at 6:55 PM Rui Barradas wrote:
> Hello,
>
> Why not use read.xlsx argument 'na.strings', an argumen
Hi Subhamitra,
This is not the only way to do this, but if you only want the monthly
averages, it is simple:
# I had to change the "soft" tabs in your email to commas
# in order to read the data in
spdf<-read.table(text="PERMNO,DATE,Spread
111,19940103,0.025464308
111,19940104,0.064424296
111,1994
Hello everyone again,
I much appreciated the explanations.
On Wed, Sep 25, 2019 at 11:02:42AM +0200, Francesco Ariis wrote:
> Maybe the Introduction should link to it (or similar page) with text
> "In case you are interest in the difference between static and lexical
> scope, check this explan
On 21/10/19 11:07 AM, Rui Barradas wrote:
Hello,
Sorry, you're right, in the method it's x, X is the test dataframe.
Repost:
`[.myclass` <- function(x, i, j, drop = if (missing(i)) TRUE else
length(cols) == 1){
SaveAt <- lapply(x, attributes)
x <- NextMethod()
lX <- lapply(names(x
Well, the direct answer is "no", but then again I did not know the answer to
the other question until I Googled it either.
When I do the same for grid.draw, it appears to be a generic function for
drawing graphical objects... data frames are not grobs, so you must be doing
something to convert
Hello,
Sorry, you're right, in the method it's x, X is the test dataframe.
Repost:
`[.myclass` <- function(x, i, j, drop = if (missing(i)) TRUE else
length(cols) == 1){
SaveAt <- lapply(x, attributes)
x <- NextMethod()
lX <- lapply(names(x),function(nm, x, Sat){
attributes(x[[nm]]) <
On 21/10/19 1:15 AM, Rui Barradas wrote:
Hello,
Richard's idea is good but shouldn't it be `[.myclass` instead?
Yes, I kind of thought that, and cobbled together something on that
basis that seemed to work. However my code was rather a hodge-podge. I
kept having to work around errors th
You're right. I was worried that c() would create a character vector and
deparse the unevaluated call in the process, but apparently it is an implicit
as.character _inside_ legend that is doing us in. (I can't offhand see where it
is happening, but there might be scope for improvement if legend(
To continue down this rabbit hole ...
Actually, both solutions are the same; Peter's is just more general than
mine, as it works more conveniently for more lines in the legend.
However, note that:
> class(c("Sans renard", bquote(.(densren) (ind./km)^2)))
[1] "list" # by coercion
so it does not
Would be nice to put those two way examples in the documentation of the
function 'expression' and 'bquote' in the next R version (we are in the
base) for other users ;-) I am sure many would enjoy.
Le 20/10/2019 à 19:15, Patrick Giraudoux a écrit :
> Great ! You have helped to solve a prob
Now, we have two solutions working. This is great since I did not find
any example of the kind searching r-help archives and google...
Thanks !
Le 20/10/2019 à 19:31, Peter Dalgaard a écrit :
It's tricky, but I think what you want is
legend(list(x=0,y=100),
legend=as.expression(list(
It's tricky, but I think what you want is
legend(list(x=0,y=100),
legend=as.expression(list(
"Sans renard",
bquote(.(densren) * " ind."/"km"^2)
)),
lty=c(1,2),col=c("black","red"),bty="n")
Generally, if you want a vector of unevaluated expressions, you need an object
of mode "
Great ! You have helped to solve a problem on which I was sweating
(sporadically, however) since months...
Thanks,
Best,
Le 20/10/2019 à 18:29, Bert Gunter a écrit :
> The legend must be "an expression vector."
> c("Sans renard",bquote(.(densren) (ind./km)^2)) is not because the
> first el
Hello,
Here are two other ways using aggregate.
The difference is in the way to create a MONTH grouping column.
The second way is base R only.
df1$MONTH <- zoo::as.yearmon(as.Date(as.character(df1$DATE), '%Y%m%d'))
aggregate(Spread ~ PERMNO + MONTH, df1, mean)
df1$MONTH <- df1$DATE %/% 100
agg
The legend must be "an expression vector."
c("Sans renard",bquote(.(densren) (ind./km)^2)) is not because the first
element is a character string.
This works:
plot(1:100,1:100,type="n")
legend(list(x=0,y=100),legend=c(expression("Sans
renard"),bquote(.(densren)
(ind./km)^2)),lty=c(1,2),co
Does this do what you want:
> library(tidyverse)
> input <- read_delim("PERMNO DATE Spread
+ 111 19940103 0.025464308
+ 111 19940104 0.064424296
+ 111 19940105 0.018579337
+ 111 19940106 0.018872211
..." ... [TRUNCATED]
> # drop last two digits to get the month
> monthly <- input %>%
+ group_
Thanks Bert and Peter,
Yes Bert, I was aware of the legend() function syntax, and just quoting
the legend argument within the function.
However, Bert and Peter, I do not understand why it works with your
absolutely reproducible examples and not in the slightly (not so
slightly apparently) diff
Assuming you are using base graphics, your syntax for adding the legend
appears to be wrong.
legend() is a separate function, not a parameter of plot.default afaics.
The following works for me:
> densren <- 1.25
> plot(1:10)
> legend (x="center", legend =bquote(.(densren) (ind./km)^2))
See ?lege
Thanks Eric. I got it too already (and already tried some variations
based on it), but to my understanding it does not include a variable
whose contents is used in the expression as in the case submitted...
Le 20/10/2019 à 14:56, Eric Berger a écrit :
> I did a Google search on
>
> R plot super
I did a Google search on
R plot superscript in legend
and the first search result was
https://stackoverflow.com/questions/20453408/superscript-r-squared-for-legend
which looks like it might address your question.
On Sun, Oct 20, 2019 at 3:30 PM Patrick Giraudoux <
patrick.giraud...@univ-fcomte
Dear listers,
I am trying to pass an expression inlcuding a variable and a
superpscript to a legend. What I want to obtain is e.g. with densren = 1.25
1.25 ind./km^2
I have tried many variants of the following:
legend=bquote(.(densren) (ind./km)^2)
but if not errors, do obtain
1.25 (ind./km^
Hello,
Richard's idea is good but shouldn't it be `[.myclass` instead?
`[.myclass` <- function(x, i, j, drop = if (missing(i)) TRUE else
length(cols) == 1){
SaveAt <- lapply(X, attributes)
X <- NextMethod()
lX <- lapply(names(X),function(nm, x, Sat){
attributes(x[[nm]]) <- Sat[[nm]]
Dear Sir,
Thank you very much for your suggestions.
Due to certain inconveniences, I was unable to work on your suggestions.
Today I worked on both suggestions and got the result that I really wanted
that monthly averages for each country.
Here, I am asking one more query (just for learning pur
23 matches
Mail list logo