Displaying 20 results from an estimated 1000 matches similar to: "ggplot2 -- scale_colour_manual()"
2009 Dec 01
1
ggplot legend for multiple time series
Hello All,
I am trying to create a legend for a black-white graph. The package I
use is ggplot2. It can add colors to the legend key but not line types.
Can you please help?
# example from Wickman (2009, ggplot2 - elegant graphics for data
analysis, page 109)
library(ggplot2)
huron <- data.frame(year=1875:1972, level=LakeHuron)
ggplot(huron, aes(year)) +
2009 Apr 23
0
How to construct confidence bands from a gls fit?
Dear R-list,
I would like to show the implications of estimating a linear trend to
time series,
which contain significant serial correlation.
I want to demonstrate this, comparing lm() and an gls() fits, using
the LakeHuron
data set, available in R.
Now in my particular case I would like to draw confidence bands on the plot and
show that there are differences. Unfortunately, I do not know how to
2005 Feb 02
4
(no subject)
can you recommend a good manual for R that starts with a data set and gives
demonstrations on what can be done using R? I downloadedR Langauage
definition and An introduction to R but haven't found them overly useful.
I'd really like to be able to follow some tutorials using a dataset or many
datasets. The datasets I have available on R are
Data sets in package 'datasets':
2010 Aug 21
1
How to find residual in predict ARIMA
Dear All,
I have a model to predict time series data for example:
data(LakeHuron)
Lake.fit <- arima(LakeHuron,order=c(1,0,1))
then the function predict() can be used for predicting future data
with the model:
LakeH.pred <- predict(Lake.fit,n.ahead=5)
I can see the result LakeH.pred$pred and LakeH.pred$se but I did not
see residual in predict function.
If I have a model:
[\
Z_t =
2011 Apr 07
1
comparing ARIMA model to data
hi,
i am trying to teach myself about ARIMA models. i have followed examples
from a number of sources and have more or less got the hang of how it
works. i would like to compare the output from the fitted model to the
original data. is this possible? or even a meaningful thing to do?
to be clear, for example, having generated a fit to some data using
> fit <- arima(LakeHuron, order = c(1,
2017 Oct 12
2
dual y-axis for ggplot
Hi,
To my knowledge, an excellent of ggplot with a second y-axis is
https://rpubs.com/MarkusLoew/226759
In this example, the author uses two colors for the two lines, but the
line shapes are the same -- both are solid. Could each line have its own
color as well as its own shape? For example, can I make the red line with
the linetype "twodash", while the blue line with the
2017 Oct 12
1
dual y-axis for ggplot
Hi John,
You can try the following:
override.linetype=c("twodash","solid")
p <- ggplot(obs, aes(x = Timestamp))
p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
linetype="Humidity"))
p <- p +
2017 Oct 12
0
dual y-axis for ggplot
Sorry let me clarify.
If I modify the line
p <- p + geom_line(aes(y = air_temp, colour = "Temperature"))
by
p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
and
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity"))
by
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
2003 Apr 21
2
Anyone Familiar with Using arima function with exogenous variables?
I've posted this before but have not been able to locate what I'm doing
wrong. I cannot determine how the forecast is made using the estimated
coefficients from a simple AR(2) model when there is an exogenous
variable. Does anyone know what the problem is? The help file for arima
doesn't show the model with any exogenous variables. I haven't been able
to locate any documents
2017 Nov 29
3
Removing a data subset
Say I have a dataset that looks like
Location Year GW_Elv
MW01 1999 546.63
MW02 1999 474.21
MW03 1999 471.94
MW04 1999 466.80
MW01 2000 545.90
MW02 2000 546.10
The whole dataset is at http://doylesdartden.com/ExampleData.csv
and I use the code below to do the graph but I want to do it without MW01.
How can I
2011 Jul 08
1
Referencing a vector of data labels in ggplot function
Hi,
I really feel I've looked everywhere, although I know this can't be a hard
problem. I'd like to be able to call the graph below as a function, but I
can't get the function to recognize variables beyond 'dframe'. I've read
through many papers on writing functions in R, but I can't get this to work.
data <- data.frame('date' = as.Date(rep(c(15101,
2012 Nov 07
1
change colour of geom_step by scale_colour_manual
Hi,
Color of my step plot is now by default. Now I'd like to change the color as
the grey scale I specified. I don't know why I got three black plot. Here I
attach two version of codes. The first one produces a step plot with color
by default. The second one, modified from the first one, is not producing
the grey scale I want. Any help would be highly appreciated.
[version 1- working]
2007 Nov 18
0
question regarding time series packages
Good afternoon!
I'm trying to learn time series but i have a bit of of a problem using R packages for this.
1.
> LakeHuron
> sample(500:600, 98)
> sample(500:600, 98)->t
> fit<-arima(LakeHuron, order=c(2,1,1), xreg=t)
> fit
> predict(fit, n.ahead=1, newxreg=t)
Now, my problem is this: is it ok to use the same t in predict function or should my newxreg contain 99
2011 Jan 05
3
Adding lines in ggplot2
Hello,
this is probably a recurrent question, but I couldn't find any answers that
didn't involve the expression "data frame"... so perhaps I'm looking for
something new here.
I wanted to find a code equivalent to
> x=sqrt(1:10)
> y=log(1:10)
> plot(1:10, x, type="lines", col="darkgreen")
> lines(1:10, y, col="red")
to use with
2024 Mar 05
1
How to invert axis within defined range with ggplot2 scale_y_reverse?
Hello,
I am drawing some data with ggplot2 and would like to reverse the
order of the y axis and set a custom range for it.
I can do the former but when I add the key `limits` to
`scale_y_reverse` I get an error as shows below and, worse, no data
shown in the plot.
How can I properly set a reverse y scale with a defined range in ggplot2?
Thank you
```
A <- rep(c(0, 3, 6, 12, 24), 3)
B <-
2011 Nov 09
2
plot separate groups with plotmeans()
Hi,
I often use plotmeans() from the gplots package to quickly visualize a
pattern of change. I would like to be able to plot separate lines for
different groups, but the function gives an error when a grouping
variable is included in the formula argument.
For instance,
> require(gplots)
> x <- data.frame(Score=rnorm(100), Time=rep(1:10, 10),
2024 Mar 05
1
How to invert axis within defined range with ggplot2 scale_y_reverse?
On 05/03/2024 7:16 a.m., Luigi Marongiu wrote:
> A <- rep(c(0, 3, 6, 12, 24), 3)
> B <- c(rep(0,5), rep(1,5), rep(2,5))
> V <- c(27.5, 27.01, 27.75, 27.98, 27.4, 25.69,
> 26.17, 27.78, 26.08,
> 24.97, 23.18, 21.78, 22.49, 21.85, 22.2)
> df <- data.frame(Conc = A, Time = B, Value = V)
> df$Conc = as.factor(df$Conc)
>
2008 Nov 15
1
GAMs and GAMMS with correlated acoustic data
Greetings
This is a long email.
I'm struggling with a data set comprising 2,278 hydroacoustic estimates of
fish biomass density made along line transects in two lakes (lakes
Michigan and Huron, three years in each lake). The data represent
lakewide surveys in each year and each data point represents the estimate
for a horizontal interval 1 km in length.
I'm interested in comparing
2017 Nov 29
0
Removing a data subset
Reading in the data from the file
x <- read.csv( "ExampleData.csv", header = TRUE, stringsAsFactors = FALSE )
Subsetting as you want
x <- x[ x$Location != "MW01", ]
This selects all rows where the value in column 'Location' is not equal to "MW01". The comma after that ensures that all columns are copied into the amended data.frame.
Rgds,
2017 Sep 26
2
Adding non-data line to legend ggplot2 Maximum Contaminant Level
Hello everyone,
I have a plot showing chloride concentrations for various point over time.
I also have a dotted line that show the Secondary Maximum Contaminant Level
(my screening limit) on the graphs at 250 mg/L. But I can not figure out
how to include the dotted line / Secondary Maximum Contaminant Level in
the legend. Any thoughts? My code is as following and is linked to my
data on the