[R] R: How to multiplying y-axis ticks value by 100?

2017-07-22 Thread iPad via R-help
R: how multiplying y-axis ticks value by 100 (without put the % symbol next to 
the number) here: 
plot (CI.overall, curvlab=c("Discharge", "Death"), xlab="Days", las=1) 
P.S. So instead 0.00, 0.20 etc. the 0, 20 etc.
Thank you in advance, Nic

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] cannot use package RcmdrPlugin.plotByGroup

2017-07-22 Thread Lu Wei
On 2017-7-23 6:21, Fox, John wrote:
> Dear Lu Wei,
> 
> I'm the author of the Rcmdr package but not of
> RcmdrPlugin.plotByGroup, so if there really is a problem -- which
> isn't apparent from your message -- then you may wish to contact the
> package author.
> 
> First, as a general matter, menu items in the Rcmdr are grayed out if
> they're inappropriate in the current context. Rcmdr plug-in authors
> can use the same mechanism. So, for example, most menu items are
> grayed out before you read a data set, and menu items that require a
> categorical variable will be grayed out if there are no factors (or
> character variables or logical variables) in the active data set.
> ...

Thanks for the reply. I change to another data set and the menu is
available. I did not know the type of variable -- I am a newbie who is
searching a quick solution, that's why I try R-commander. But after some
test I find that plugin's output is not exactly what I want.

I am seeking a way to visualize data by plotting grouped box and
distribution chart. The latter may be called Q-Q chart, which I just
learned from R, though it seems not exactly the same as I have seen
below. I hope the groups are in the same chart for comparison, like this:
http://cubeupload.com/im/WFc4CC.png

or even plot a set of variables:
http://cubeupload.com/im/wK69NN.jpg

These charts are produced by Minitab. The norm-axis is not the same as
Q-Q chart in R, but I think they are equivalent. Is it right?

I hope you or the author of RcmdrPlugin.plotByGroup could implement the
feature in the picture I posted. This "distribution chart" or Q-Q chart
is the most I want from a statistic tool, since it gives full
information of experiment data, and putting groups together in a chart
for comparison is the ultimate judgement.

Thank you for making R an easy tool to learn and use. Great job.

-- 
Regards,
Lu Wei
PGP key ID: 0x A12F EF75 92CC E1EA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] about installing smwrGraphs package

2017-07-22 Thread lily li
Hi R users,

I'm trying to install the package, but got the error and don't know how to
fix it. Can anyone help me? Thanks very much.

install.packages("smwrGraphs", repos=c("http://owi.usgs.gov/R",;
http://cran.us.r-project.org;), dependencies = TRUE)

Error in install.packages : Line starting ' ...' is malformed!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 3-day moving average for block maxima

2017-07-22 Thread Jeff Newmiller
Thank you for the dput, but you roll the dice each time you fail to learn 
how to post using plain text that we may not find your email readable or 
even intact. Please learn to post plain text email on this mailing list.


# The following assumes you have no missing days in your time sequence.
# There are better solutions in packages if that is not true for your data
# (e.g. zoo or data.table)
# The filter function looks backward, while your example appears 
# to look foward from the "current" value. The filter function presumes 
# that near the beginning the "previous" values are missing, which causes

# it to generate NA values, which I remove and tack on the NAs at the end.
# (It would be misleading to put in alternate calculations at the end 
# because those would be different than all the rest.)

dt$`Moving Average` <- c( filter( dt$Amount
, rep(1/3,3)
, sides = 1
)[ -(1:2) ]
, NA
, NA
)
dta <- aggregate( list( Max3dMA = dt$`Moving Average` )
, dt[ , "Year", drop=FALSE ]
, FUN = max
, na.rm = TRUE
)

On Sat, 22 Jul 2017, roslinazairimah zakaria wrote:


Dear r-users,

I would like to construct 3-day moving average for block maxima series.

I tried this:

bmthree <- lapply(split(dt, dt$Year), function(x) max(sapply(1:(nrow(x)-2),
   function(i) with(x, mean(Amount[i:(i+2)],na.rm=TRUE)
bmthree

and got the following output.

$`1971`
[1] 70.81667

$`1972`
[1] 68.94553

$`1973`
[1] 102.7236

$`1974`
[1] 73.6625

$`1975`
[1] 92.98889

$`1976`
[1] 95.8125

$`1977`
[1] 31.33974

$`1978`
[1] 141

$`1979`
[1] 71.4

$`1980`
[1] 115.9667

$`1981`
[1] 66.73718

$`1982`
[1] 189.5

$`1983`
[1] 183.1

$`1984`
[1] 131.5667

$`1985`
[1] 96.8

$`1986`
[1] 267.9667

$`1987`
[1] 113.6667

$`1988`
[1] 246.6667

$`1989`
[1] 83.3

$`1990`
[1] 79.5

$`1991`
[1] 138.

$`1992`
[1] 117

$`1993`
[1] 99.7

$`1994`
[1] 205.

$`1995`
[1] 142.6667

$`1996`
[1] 106.6667

$`1997`
[1] 112.5

$`1998`
[1] 62.7

$`1999`
[1] 100.6333

$`2000`
[1] 146.1333

$`2001`
[1] 171.7333

$`2002`
[1] 78.3

$`2003`
[1] 100.5667

$`2004`
[1] 115.0667

$`2005`
[1] 163.8667

$`2006`
[1] 79.9

$`2007`
[1] 130.6667

$`2008`
[1] 156.5

$`2009`
[1] 162.1667

$`2010`
[1] 99.3
$`2011`
[1] 162.8333

$`2012`
[1] 247.6667

How do I tweak the code so that I can see the moving average for the block
maxima before the maximum for that particular year is chosen.

Year  Month  Day Amount
Moving average 3-day BM
1971 1 1 55.81429 47.63658
1971 1 2 49.01818 34.95606
1971 1 3 38.07727
1971 1 4 17.77273

This is my data:


dput(try.dt)

structure(list(Year = c(1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L,
1971L, 1971L, 1971L, 

Re: [R] cannot use package RcmdrPlugin.plotByGroup

2017-07-22 Thread Fox, John
Dear Lu Wei,

I'm the author of the Rcmdr package but not of RcmdrPlugin.plotByGroup, so if 
there really is a problem -- which isn't apparent from your message -- then you 
may wish to contact the package author.

First, as a general matter, menu items in the Rcmdr are grayed out if they're 
inappropriate in the current context. Rcmdr plug-in authors can use the same 
mechanism. So, for example, most menu items are grayed out before you read a 
data set, and menu items that require a categorical variable will be grayed out 
if there are no factors (or character variables or logical variables) in the 
active data set.

Second, Rcmdr plug-in packages aren't loaded by the library("Rcmdr") command. 
You can load a plug-in from the Rcmdr Tools menu; and many (but not all) Rcmdr 
plug-in packages can be loaded directly via the library() command, in which 
case the Rcmdr package is also loaded. I don't know whether 
library("RcmdrPlugin.plotByGroup") will work, but you can try it.

I hope this helps,
 John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
Web: socserv.mcmaster.ca/jfox




> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Lu Wei
> Sent: Saturday, July 22, 2017 12:49 PM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] cannot use package RcmdrPlugin.plotByGroup
> 
> Greetings,
> 
> I am a new use of R, starting from R-commander.
> 
> I find that the default quantile-comparison (Q-Q plot) of R-commander
> has no group option, and I happened to notice RcmdrPlugin.plotByGroup in
> the packages list. As the name is so explicit, I installed it, loaded
> it, R-commander restarted, but the 3 menu item under Graphs->plot by
> group are all greyed out. What could be wrong?
> 
> --
> Regards,
> Lu Wei
> PGP key ID: 0x A12F EF75 92CC E1EA
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] cannot use package RcmdrPlugin.plotByGroup

2017-07-22 Thread Lu Wei
Greetings,

I am a new use of R, starting from R-commander.

I find that the default quantile-comparison (Q-Q plot) of R-commander
has no group option, and I happened to notice RcmdrPlugin.plotByGroup in
the packages list. As the name is so explicit, I installed it, loaded
it, R-commander restarted, but the 3 menu item under Graphs->plot by
group are all greyed out. What could be wrong?

-- 
Regards,
Lu Wei
PGP key ID: 0x A12F EF75 92CC E1EA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] spaghetti plot - urgent

2017-07-22 Thread Rosa Oliveira
Thanks for the tip! Ulrik, I've solved the problem with a different
code

Best ;)

Ulrik Stervbo  escreveu em qua, 19/07/2017 às
20:28 :

> Hi Rosa,
>
> You pass a vector to ggplot, which expects a data.frame. I am sure you
> meant to do this:
>
> point7$y_point7 <- point7$beta0_7 + point7$beta1_7*point7$time + point7
> $epsilon_7
>
> ggplot(point7, aes(time, y_point7)) + geom_line()
>
> HTH
> Ulrik
>
>
> On Wed, 19 Jul 2017 at 20:37 Rosa Oliveira  wrote:
>
>> Hi everyone,
>>
>> I’m trying to do a spaghetti plot and I know I’m doing all wrong, It must
>> be.
>>
>> What I need:
>>
>> 15 subjects, each with measurements over 5 different times (t1, ..., t5),
>> and the variable that I need to represent in the spaguetti plot is given by:
>>
>> PCR = b0 + b1 * ti + epsilon
>>
>> B0, - baseline of each subject
>> B1 - trajectory of each subject over time (so multiply by t)
>> Epsilon - error associated with each subject
>>
>> Regression model with mixed effects.
>>
>> Thus, I generated b0, b1, epsilon and time created sequence.
>>
>> But I need to do spaguetti plot of the outcome and I can not understand
>> how much I search the publications.
>>
>> Sorry for the stupidity, but I do not even know how to do it and I need
>> it with the utmost urgency to finish a publication proposal :(
>>
>> Follows what I tried to do :( :( :(
>>
>>
>> library(ggplot2)
>> library(reshape)
>> library(lattice)
>> library(gtable)
>> library(grid)
>>
>>
>> set.seed(9027)
>>
>> n.longitudinal.observations  = 5  # number of PCR
>> measures (per subject) in the hospital period
>> subjects = 15  # Number
>> of simulations (1 per subject in the study)
>>
>> beta0_7_gerar  = rnorm(subjects, mean = 1, sd = .5)
>> beta0_7=
>> as.data.frame(matrix(beta0_7_gerar,nrow=subjects,ncol=1))  # beta 0 -
>> input variable used to calculate PCR (the outcome)
>> beta1_7_gerar = rnorm(subjects, mean = -1, sd = .5)
>> beta1_7   =
>> as.data.frame(matrix(beta1_7_gerar,nrow=subjects,ncol=1) )  # beta 1 -
>> input variable used to calculate PCR (the outcome)
>>
>> tj_gerar= seq.int(1,
>> n.longitudinal.observations, 1)
>> epsilon_7_gerar  = rnorm(5*subjects, mean = 0, sd = .1)
>> epsilon_7 =
>> as.data.frame(matrix(epsilon_7_gerar,nrow=subjects,ncol=1) )   # epsilon_7
>> - input variable used to calculate PCR (the outcome) - associated with each
>> subject
>>
>> tj  =
>> as.data.frame(matrix(tj_gerar,nrow=subjects,ncol=1) )   #
>> time
>>
>> point7 <- cbind(beta0_7, beta1_7, tj, epsilon_7)
>> point7
>> point7 <- as.data.frame(point7)
>>
>> colnames(point7) = c("beta0_7","beta1_7","time", "epsilon_7")
>>
>>
>> y_point7 <- point7$beta0_7 + point7$beta1_7*point7$time + point7
>> $epsilon_7 (the outcome of the study - PCR)
>> y_point7
>>
>> require(ggplot2)
>>
>> png('test.png')
>> p = ggplot(y_point7, aes(time, y_point7)) + geom_line()
>> print(p)
>> dev.off()
>> savehistory()
>>
>>
>>
>>
>>
>>
>> OR:
>>
>> In the last part I also tried:
>>
>>
>> ID = rep(1:3, each = 5)
>>
>>
>> point7 <- cbind(ID,beta0_7, beta1_7, tj, epsilon_7)
>> point7
>> point7 <- as.data.frame(point7)
>>
>> colnames(point7) = c("ID","beta0_7","beta1_7","time", "epsilon_7")
>>
>>
>>
>>
>>
>> y_point7 <- point7$beta0_7 + point7$beta1_7*point7$time + point7
>> $epsilon_7
>> y_point7
>>
>> crp7 <- y_point7
>>
>> head(point7, n = 15)
>>
>>
>> ggplot(aes(x = tj_gerar, y = crp7), data = point7) +
>>   geom_line(aes(group = ID), color = "gray") +
>>   geom_smooth(aes(group = 1), method = "lm", size = 3, color = "red", se
>> = FALSE) +
>>   theme_bw()
>>
>> But none of these worked :(
>>
>> I was looking to have something like:
>>
>>
>> Being the outcome PCR and the year the times (1, 2, 3, 4, 5).
>>
>> Can someone help me please?
>>
>>
>> Thanks,
>>
>> Best Rosa
>>
>>
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --
Enviado do Gmail Mobile

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.