ne:
Error in library(quantmod) : there is no package called ‘quantmod’
How do I install and load these packages successfully?
Thank you!
Phil Smith
Sent with [Proton Mail](https://proton.me/) secure email.
[[alternative HTML version deleted]]
__
R
Hi R-Help People!
I'm using the current version of R for Ubuntu: R version 4.2.1 (2022-06-23) --
"Funny-Looking Kid."
I'm using the quantmod package and am having difficulty with the getDividends()
function from the quantmod package.
Here is my code:
> library(quantmod)
>
> getDividends(
Thanks for this. I was unable to install the gggrid package apparently
because it is unavailable for my version of R (4.1.1 (2021-08-10)). But
I found it here https://github.com/pmur002/gggrid/releases/tag/v0.1-0,
copied the code into your code, and it worked very well.
On 2021-10-26 19:18,
Thanks for the suggestions. As it happens, I just a moment ago found a
solution. By adding the lines: ct$date <- 1 and ct$vari <- 1 everything
works as I want it to.
Philip
On 2021-10-25 22:37, Ben Tupper wrote:
Hi,
I don't quite follow what you want to achieve - colored backgrounds
for
I am using ggplot2 and I want to use different colours for some facets.
Here is a reprex:
library(tidyverse)
date <- as.numeric(c(2017,2017,2017,2017,2017,2017,2018,2018,
2018,2018,2018,2018,2019,2019,2019,2019,2019,2019))
vari <- as.numeric(c(4.8,3.3,4.2,5.2,4.8,5.7,5.4,3.1,5.7,4.1,
Thank you Jeff. This solves my problem.
On 2021-08-28 21:54, Jeff Newmiller wrote:
Maybe you will find that coord_cartesian( ylim=c(-30,30) ) works
better since it doesn't filter out data before rendering.
On August 28, 2021 6:45:11 PM PDT, p...@philipsmith.ca wrote:
I am preparing a time
I am preparing a time series plot using the ggplot function. It includes
an area plot outlined at its edges with a line plot. For some reason the
line plot, drawn with geom_line(), has some broken portions where the
line does not appear, although the filled geom_area() part of the plot
is
frames, I get stuck trying to blank-out the first column
name and make the other column names bold. How can I refer to the
columns properly in the cols_label() function in a general way? Any help
much appreciated. Phil
\library(gt)
library(tidyverse)
# Create example data frame
blank <
Thank you, Messrs Barradas and Gross, for your very helpful advice.
Philip
Message: 21
Date: Wed, 24 Mar 2021 22:41:25 -0400
From: "Avi Gross"
To:
Subject: Re: [R] Including a ggplot call with a conditional geom in a
function
Message-ID: <07e801d72120$59e5c720$0db15560$@verizon.net>
How can I write an R function that contains a call to ggplot within it,
with one of the ggplot geom statements being conditional? In my reprex,
I want the plot to contain a horizontal zero line if the y values are
both positive and negative, and to exclude the horizontal line if all of
the y
Your help is much appreciated. I now understand what my problem was and
can move forward.
Philip
On 2021-03-17 01:19, Hervé Pagès wrote:
Hi,
stringr::str_replace() treats the 2nd argument ('pattern') as a
regular expression and some characters have a special meaning when
they are used in a
I have a problem with the str_replace() function in the stringr package.
Please refer to my reprex below.
I start with a vector of strings, called x. Some of the strings contain
apostrophes and brackets. I make a simple replacement as with x1, and
there is no problem. I make another simple
Thank you for your suggestions. I found, after much experimentation,
that scale_fill_gradientn did indeed provide a good solution, as below.
library(ggplot2)
a <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
b <- c(0.1, 0.5,-0.3, 1.2,-0.4,-1.2,
0.7, 0.8,-1.2,-0.5,10.0, 0.3,
I am having trouble with a gradient fill application in ggplot2, caused
by outlier values. In my reprex, most of the values are between 2 and
-2, but there are two outliers, 10 and -15. The outliers stand out well,
which is good, but all the other numbers show almost no colour
variation. I
Thanks so much for your speedy replies. Yes, removing those brackets did
the trick. I was relying on an example in Stackoverflow at
https://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r
Philip
On 2021-02-07 14:36, Jeff Newmiller wrote:
Too many curly braces. warning and
I need help using the tryCatch function. I have a function and I want to
surround it with tryCatch to catch errors and thereby avoid stopping
execution of my program if the function fails. In my reproducible
example below I have used a very simply function that just adds two
numbers together.
Yes, geom_violin does the trick. Thanks for your fast and useful reply,
Bert.
Philip
On 2021-01-11 11:05, Bert Gunter wrote:
Search for "violin plots" at rseek.org [1].
There is a whole package devoted to them, many packages provide them,
and there is a geom_violin in ggplot2.
Don't know if
I have a point plot where the estimated points have normally distributed
errors and I want to plot not just the estimated points, but also an
indication of the range of uncertainty in each case. The usual way of
doing this, I believe, is with geom_pointrange, as shown in my reprex.
However,
Thank you so much for this elegant solution, Jeff.
Philip
On 2020-11-12 02:20, Jeff Newmiller wrote:
I am not a data.table afficiando, but here is how I would do it with
dplyr/tidyr:
library(dplyr)
library(tidyr)
do_per_REL <- function( DF ) {
rng <- range( DF$REF1 ) # watch out for
I am stuck on a data transformation problem. I have a data frame, df1 in
my example, with some original "levels" data. The data pertain to some
variable, such as GDP, in various reference periods, REF, as estimated
and released in various release periods, REL. The release periods follow
after
Thanks Bert. That did it.
Philip
On 2020-06-02 22:02, Bert Gunter wrote:
In a function you must explicitly print/plot the ggplot() object, I
assume. i.e. plot(ggplot(...)) etc.
I do not use ggplot, so if I'm wrong, sorry. But try it. Hopefully
someone else will get it right if it doesn't do
I have made what must be a simple mistake, but I have not been able to
find it.
I create a function to plot a chart for a single variable. I want to
display separate charts for several variables, one after another, with
"Press [enter] to continue" in between. The function works fine for a
Thank you very much, Jim and Jeff. Both of your solutions work
splendidly.
Philip
On 2020-03-29 02:25, Jim Lemon wrote:
Hi Phil,
Sorry it's not in the environment you are using, but perhaps this will
help:
taby<-table(df$y)
ynames<-names(taby)
for(yval in 1:length(taby)) {
if(tab
I have a problem involving inefficient coding. My code works, but in my
actual application it takes a very long time to execute. I have included
a reprex here that uses the same code, but with a much smaller-scale
application.
The data frame I am working with (df in my reprex) is in long form
Thanks so much Jim. Yes, this is giving me what I want.
Philip
On 2019-12-08 05:00, Jim Lemon wrote:
Hi Philip,
This may be a starter:
attach(airquality)
heights <- tapply(Temp,Month,mean)
temp_sd<-tapply(Temp,Month,sd)
lower <- tapply(Temp,Month,function(v) t.test(v)$conf.int[1])
upper <-
Thanks for these helpful suggestions.
These options don't work in my case because I don't know the individual
observations (the dots). A statistical agency collects the observations
and keeps them confidential. It provides the mean value and the standard
deviation, plus the fact that the
I want to show little bell curves on my bar chart to illustrate the
confidence ranges. The following example from Paul Teetor's "R Cookbook"
does what I want, but shows I-beams instead of bell curves. The I-beams
suggest uniform, rather than normal distributions. So I am looking for a
way to
I finally got it to work, drawing on your advice William. I extracted
the time vector (REF_DATE) from the data frame (vseries) so the latter
was numeric only, and I converted the resulting data frame to a matrix.
I also converted the dts data frame to a matrix. Now it works properly.
Your help
Thanks for your suggestions. I have tried them all, with no success.
William's looked quite promising. I put in the
stopifnot(is.numeric(x), NCOL(x)==1, length(x)>dt2)
statement and it detected the problem:
length(x) > dt2 is not TRUE
Then I changed all the references to vseries to the [[j]]
Thanks for the suggestion Rui, but no, this will not remove the error.
In fact, if I drop the second term entirely as in:
if ( (!is.na(dts[1,j-1])) ) {
then I still get the error. I have been unable to find a work-around.
Philip
On 2019-10-30 05:17, Rui Barradas wrote:
Hello,
Is this as
I am having a problem that generates the error message: " Error in
firstnonmiss:lastnonmiss : argument of length 0 ". There is an article
on this in stackoverflow, but I have been unable to understand it well
enough to solve my problem. Essentially, I have a data frame with 41
indicator series
.1, 0, 0.6, 0.6, 0.8,
0.7, 0.7, 0.7, 0.2, 0.2, 0.3, 0.4, 0.3, 0.2, 0.4, 1.2, 0.6,
0.9, 0.7, 0.1, 0.4, -0.1, 0.2, 0.4, -0.1, 0.9, 0.2, 1.1,
1.2, 1.1, 1, 0.4, 0.7, 1, 1.2, 0.3, 0.5, 0.6, 0.4, 0.4, 0.4,
0.2, 0, -0.1, -0.1, 0.1, 0, 0.2, 0.9, 0.4, 0.7, 0.3, -0.1,
0.4, -0.5,
, 0.4, 0.3, 0.2, 0.4, 1.2, 0.6,
0.9, 0.7, 0.1, 0.4, -0.1, 0.2, 0.4, -0.1, 0.9, 0.2, 1.1,
1.2, 1.1, 1, 0.4, 0.7, 1, 1.2, 0.3, 0.5, 0.6, 0.4, 0.4, 0.4,
0.2, 0, -0.1, -0.1, 0.1, 0, 0.2, 0.9, 0.4, 0.7, 0.3, -0.1,
0.4, -0.5, 0.4, 0.7, 0.4, 0.8, 0.9, 0.5, 1.5, -0.1, 1, 0.6,
0.5, 0.9, -0
I am having difficulty with a chart using ggplot. It is a facetted
column chart showing GDP growth rates by country. The columns are
coloured navyblue, except that I want to colour the most recent columns,
for 2019-Q1 and 2019-Q2, red. For some countries data are available up
to 2019-Q2 while
the functions useful when conducting goodness-of-fit
tests using the K-S test.
Sincerely,
Phil Novack-Gottshall and Steve Wang
--
~
Phil Novack-Gottshall
Associate Professor
Department of Biological Sciences
Benedictine University
5700 College
Thank you so much Eric. I had tried searching stackoverflow too, but I
could not find the right way to word the query.
Philip
On 2019-06-20 04:03, Eric Berger wrote:
Hi Phil,
Try this
library(tidyverse)
# Test data
dta <- data.frame(dta_names=c("Series 1","Series 2&quo
# RStudio version 1.1.463
# sessionInfo()
# R version 3.5.1 (2018-07-02)
# Platform: x86_64-apple-darwin15.6.0 (64-bit)
# Running under: macOS 10.14.5
# I am constructing a bar chart using ggplot, as in the example below.
# I want to highlight "Series 2" by colouring the bar red,
# with the
summarise_all() does the trick. Thanks very much for the help.
Philip
On 2019-03-03 22:14, p...@philipsmith.ca wrote:
I have a data frame in which the first column is a sequence of monthly
dates and the other columns are variables. There are a great many
variables. I want to create another
I have a data frame in which the first column is a sequence of monthly
dates and the other columns are variables. There are a great many
variables. I want to create another data frame similar to the first one,
but with annual values instead of monthly, created by summing the months
within each
Gentlemen,
Thank you so much for your help. You have solved my problem.
> Using Achim's d this also works to generate z where FUN is a function used
> to transform the index column and format is also passed to FUN.
>
> z <- read.zoo(d, index = "time", FUN = as.yearqtr, format = "Q%q %Y")
>
> On
I have a data set with quarterly time series for several variables. The
time index is recorded in column 1 of the dataframe as a character vector
"Q1 1961", "Q2 1961","Q3 1961", "Q4 1961", "Q1 1962", etc. I want to
produce line plots with ggplot2, but it seems I need to convert the time
index from
‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(fit.Y)
Df Sum Sq Mean Sq F valuePr(F)
sample.Y 3 2202.70 734.23 190706 2.2e-16 ***
Residuals80.030.00
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
- Phil Spector
As well, the mirt package contains a function for DIF using likelihood
ratio tests via multiple-group estimation methods (the multiple group
estimation generally goes beyond simply testing for DIF), as well Wald
tests if the information matrix was computed. Hope that helps.
Phil
On Wednesday
6.4618792 7.1932613
7.7595619
x4 x6
7.8394477 9.9437848
As you see the glm calculates residuals for x82 (which is in fact 1.314)
but the outlierTest does not assign a p/q value to it. Does anyone know why?
Thanks in advance,
Phil
On 10/17/2014 08:54 PM, John Fox wrote:
Dear
] colorspace_1.2-4 compiler_3.1.1 digest_0.6.4 grid_3.1.1
[5] gtable_0.1.2 labeling_0.3 MASS_7.3-33 munsell_0.4.2
[9] nnet_7.3-8 plyr_1.8.1 proto_0.3-10 Rcpp_0.11.2
[13] reshape2_1.4 scales_0.2.4 stringr_0.6.2tools_3.1.1
Any help is highly appreciated.
Thanks
Phil
Thanks a lot for your input.
--
View this message in context:
http://r.789695.n4.nabble.com/Plot-regression-results-with-various-predictors-tp4691307p4691416.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org
Sorry for not explaining it further. plm() is the regression command for
panel data, i.e., similar to lm() for simple linear regressions. I run the
plm() and get an output which I call here POLS. Next I simply use plot(POLS)
which looks like
plot=(POLS) adding further the
regression line to illustrate the results graphically.
Any help is highly appreciated. Thanks in advance.
Phil
--
View this message in context:
http://r.789695.n4.nabble.com/Plot-regression-results-with-various-predictors-tp4691307.html
Sent from the R help
for regression on panel data?
Help is really appreciated. Looking forward to your answers.
Thank you very much in advance.
Regards,
Phil
--
View this message in context:
http://r.789695.n4.nabble.com/panel-data-variable-selection-AND-multicollinearity-tp4689935.html
Sent from the R help mailing
Hi Arne,
thanks a lot for your reply, it was really helpful!
Now, after having managed to apply the censReg to my data, I get the
following error message when I enter the command summary():
Error in printCoefmat(coef(x, logSigma = logSigma), digits = digits) :
'x' must be coefficient
and
independent variable(s) is not adequate. Haven't thought about that...
I think you will see it the same way.
Thanks in advance.
Regards,
Phil
--
View this message in context:
http://r.789695.n4.nabble.com/Tobit-model-with-panel-data-tp4689760p4689847.html
Sent from the R help mailing list archive
Hi all,
I just started to work with R a couple of weeks ago. Right now I would like
to regress an independent variable on a couple of explanatory variables. The
dependent variable is left censored in the sense that all negative values
and zero are set equal to one. This is done because I want to
://www.stat.berkeley.edu/classes/s243/calling.pdf
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
to the missing time-dependent covariate at day
6. Is there a way I can keep this event without filling in a covariate
value at day 6?
-Phil
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman
Barry =
Suppose your data frame is called mydat. Then something like
mydat[,sapply(mydat,class) %in% c('numeric','integer')]
might do what you want.
- Phil
On Sat, 16 Feb 2013, Barry DeCicco wrote:
Hello,
I've got a data frame
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
Tim -
Another approach to your problem is to use xtabs:
xtabs(count~site+bug,data=myf)
bug
site grasshopper ladybug spider stinkbug
A 4 0 20
B 0 6 08
- Phil Spector
Possibly overkill, I use a Windows batch file that calls a perl script.
Both the bat and pl files need to be in the executable path. Open a
command prompt, type `pwd ' and then drag the file or folder from the
Windows Explorer to the cmd. The script will return the file with
backslashes
.)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
I wanted to round rather than truncate timestamps
# create a data set to work with
s - 30 * rnorm(10, 1, 0.1)
gps.timestamp - Sys.time() + s*1:10
gps.timestamp - c(round(gps.timestamp[1], min), gps.timestamp,
as.POSIXct(2012-06-08 17:32:59), as.POSIXct(2012-06-08 17:32:30))
f -
.)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Wed, 30
Iain -
Do you see the same behaviour if you use
z - unz(pathToZip, 'x.txt')
instead of
z - unz(pathToZip, 'x.txt','r')
- Phil Spector
Statistical Computing Facility
I've found the keep,log=TRUE option of sas.get to be useful in cases like this.
There's also a log.file= option if you don't want the default location for the
log file.
- Phil Spector
Statistical Computing Facility
It sounds like the problem boils down to counting the number
of _s in the WELLID variable, and seeing if there are two:
nchar(gsub('[^_]','',edm$WELLID)) == 2
[1] FALSE FALSE TRUE TRUE TRUE TRUE FALSE
- Phil Spector
answer.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
Try
sub - subset(Claims, Year==Y1)
In R, the equality test is performed by two
equal signs, not one.
- Phil Spector
Statistical Computing Facility
Department
],])
should give you what you want. In this simple case, you could
also use
do.call(rbind,by(df,df$z,function(dat)dat[order(dat$x,decreasing=TRUE)[1:10],]))
from base R to get the same result.
Hope this helps.
- Phil Spector
Dan -
Try using having Premie not null instead of
having !is.na(Premie) .
- Phil Spector
Statistical Computing Facility
Department of Statistics
) search.
Thanks in advance,
Phil.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide
requirement, particularly among earth
scientists - perhaps they are all still using Matlab. Does anyone have
have a solution? Or maybe I am just not proficient enough at finding
solutions on the R-network...
Thanks in advance for your time,
Phil.
[[alternative HTML version deleted
Hello All,
I am currently using the vennDiagram function in the limma pkg to
construct venn diagrams. I would like to change the size of the circles
based upon the n of each set (if that makes sense). Does anyone have any
ideas of how to do this?
Thanks,
Phil
[[alternative HTML
anyone help?
Thanks,
Phil
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
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
Hi All,
Is there anyway to combine vennDiagrams with venneuler commands so I can
have both of the diagrams as one? venneuler gives me proportionate circles
but without numbers and veenDiagrams gives me numbers without proportionate
circles.
Thanks,
Phil
[[alternative HTML version
There's no need to use sapply or loops with grep -- it's
already vectorized. So you can find the rows you're
interested in with
wh = grep('^[.,]+$',df[,9])
store them with
sf = df[wh,]
and delete them with
df = df[-wh,]
- Phil Spector
you what you want.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
[,7] [,8][,9]
[1,] -1.7481451 0.4467964 -0.41358420
[2,] -0.2882922 1.0243662 -0.48263684
[3,] 0.9402479 0.5467952 -0.01922035
[4,] 0.6795783 1.4560765 -0.23013826
[5,] 0.9800312 -1.3462175 -0.77064872
- Phil Spector
selected
x[['PHQ']]
NULL
So if you don't want this feature, you can use brackets instead
of the dollar sign for extraction.
- Phil Spector
Statistical Computing Facility
Philipp -
I believe you're looking for the merge function.
If you need more guidance, please provide a meaningful
reproducible example.
- Phil Spector
Statistical Computing Facility
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Sun, 29
a reproducible example.
- Phil
On Fri, 27 May 2011, Jeanna wrote:
I may have prematurely excited...
I ended up using the split method since my family indicators are
alphanumeric so my issue is as follows.
I'm applying this to different subsets of my main
0
[2,]10
[[2]]
[,1] [,2]
[1,]32
[2,]32
[[3]]
[,1] [,2] [,3]
[1,]101
[2,]010
[[4]]
[,1] [,2] [,3]
[1,]222
[2,]223
- Phil Spector
|ddd
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
John -
Try
infert[,toolong] = sapply(infert[,toolong],cut2,g=10,levels.mean=TRUE)
- Phil Spector
Statistical Computing Facility
Department of Statistics
as factors.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
On May 24, 2011, at 10:19 AM, Kang Min
this helps. Take a look at the help page for the ave function
to understand how it works.
- Phil Spector
Statistical Computing Facility
Department of Statistics
rain forests']]$Genus
Bromheadia Homalomena
1 1
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
2 2
3 S1 T2 2 2
7 S2 T2 NA 4
- Phil Spector
Statistical Computing Facility
Department of Statistics
of the final
query. You might also familiarize yourself with
dbGetQuery, which may be more suited to your needs.
- Phil Spector
Statistical Computing Facility
Department
with the data frames you're creating.
- Phil
On Fri, 13 May 2011, Woida71 wrote:
I would like to create a certain number of dataframes out of one dataframe
where each of the dataframes
is related to a factor. This should be possible with a loop
John -
In your example, the misclassified observations (as defined by
your predict.function) will be
kyphosis[kyphosis$Kyphosis == 'absent' prediction[,1] != 1,]
so you could start from there.
- Phil Spector
(-2)^2.1
[1] NaN
complex(real=-2)^2.1
[1] 4.077269+1.324785i
- Phil Spector
Statistical Computing Facility
Department of Statistics
One way to get the ratings would be to use the ave() function:
rating = ave(x$freq,x$track,
FUN=function(x)cut(x,quantile(x,(0:5)/5),include.lowest=TRUE))
- Phil Spector
Statistical Computing Facility
?arima.sim
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Mon, 2 May 2011
Ryan -
summary expects an lm object, and fit is a list. So
you need to use something like
lapply(fit,summary)
to pass each list element to the summary function.
- Phil Spector
Statistical Computing Facility
Here's one possibility:
funmaker = function(x,y,z)function(z)x + y + (x^2 - z)
uniroot(funmaker(1,3,z),c(0,10))$root
[1] 5
uniroot(funmaker(5,2,z),c(30,40))$root
[1] 32
(The third argument to the function doesn't really do anything.)
- Phil Spector
),paste,collapse='')
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
,] -2.5787357 1.381395 -1.6545857 0.8239982 -1.169961
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC
no control over
the default ticks. yaxt = 'n' has no effect, nor does xaxt = 'n'. However I can
add ticks with with yaxp or xaxp; I just can't remove the existing ticks. Is
this known/correct behavior? Am I overlooking some way to remove those default
ticks?
Thanks,
Phil
1 - 100 of 476 matches
Mail list logo