ibecav / cgpfunctions Goto Github PK
View Code? Open in Web Editor NEWPowell Miscellaneous Functions for Teaching and Learning Statistics
License: Other
Powell Miscellaneous Functions for Teaching and Learning Statistics
License: Other
Could parse the formula input and branch accordingly
Thank you for making CPGfunctions available.
I found it very useful.
I have 2 questions:
Hi, chaid_table.R has been really helpful, but when creating node_table, only filtering complete cases may result in 0 frequencies for the outcome levels (if each case has at least one missing value across the independent variables). Those 0 frequencies will later cause the chisq.test to raise an error because x must be positive.
I've removed both filter(complete.cases(.)) %>%
and it works just fine to me.
Also noticed that you did tidyr::pivot_wider
in row 76 but not in row 87.
If I print the interaction plot in back and white, I am unable to differentiate the groups because the lines are solid for the entire group. That also applies for the points. I want to be able to vary the linetype to match one of the factors. For example, If I have a factor with two levels, I want to use solid line for level 1 and broken lines for level 2.
mtcars and others work and explicitly show some issues but they are not necessarily for seeing the classic
Add them for completeness?
In newggslopegraph.R
:
If the dataframe is sent to newggslopegraph()
in a local function, then the evaluation Ndataframe <- deparse(substitute(dataframe))
doesn't return the name of the dataframe as intended, but the structure of the dataframe.
Then, when testing with exists(Ndataframe)
, it always fails and returns FALSE, giving you the error "The first object in your list does not exist. It should be a dataframe"
A (dirty) workaround : creating a dataframe with the same name from the global environment.
Hi all,
Thank you for developing such an interesting package.
My question is I would like to know if it is possible to delete those lines between data labels and Y text. I also had some problems setting up LineColor.
My script:
newggslopegraph(dataframe = df,
Times = Group,
Measurement = Value,
Grouping = GeneID,
Title = "Artesunate",
Caption = NULL,
SubTitle = NULL,
DataTextSize = 0,
Data.label = NULL,
YTextSize = 0,
DataLabelPadding = 0,
DataLabelLineSize = 0,
DataLabelFillColor = "white",
WiderLabels = F,
ThemeChoice = "wsj",
LineColor = col
)
My error:
Error: Continuous value supplied to discrete scale
Any advice will be highly appreciated! Thanks!
Kind regards,
Birong
Hello,
R tells me CGPFunctions is not available for my version of R. I am running it in Ubuntu 20.04. The development version installs, but only after I install the pwr package first manually.
If you use this for rank order than the first rank will be at the bottom. Given the functions requirements you can not use a categorical y axis factored variable to change the text label/order of the slopes.
Hello,
this is a heads up that your code is breaking with the upcoming ggplot2 3.3.1 release (tidyverse/ggplot2#3871 (comment)). This is due to changes in stat_function()
that now make it more sensitive to certain bad programming patterns, such as feeding in data via the aes()
function.
The code at issue is code such as the following:
Lines 262 to 271 in 62efdb6
You can generally fix the issue by feeding in the data via the data
argument rather than via aes()
:
library(ggplot2)
x <- rnorm(100)
# bad
ggplot() +
aes(x) +
geom_density(color = "blue") +
stat_function(fun = dnorm)
#> Error: Aesthetics must be either length 1 or the same as the data (1): x
# good
ggplot(data.frame(x)) +
aes(x) +
geom_density(color = "blue") +
stat_function(fun = dnorm)
Created on 2020-05-25 by the reprex package (v0.3.0)
If you encounter any problems fixing these issues, I'm happy to help.
The function works just need to document it
First, thanks for creating newggslope graph, it looks great.
How do I control the number format of the Measurement?
For example, what if I want the graph to display "X %", or if I want integers displayed with a thousands separator?
library(CGPfunctions)
Error: package or namespace load failed for ‘CGPfunctions’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘MatrixModels’
Need this package to access a few functions. What is the solution to this
Great package! There is a small typo in the vignette: https://cran.r-project.org/web/packages/CGPfunctions/vignettes/Using-newggslopegraph.html
Last chunk it should be "GDP" instead of "rGDP" I think.
Hello,
I am trying to plot the change of ranking overtime from 2000s to 2010s.
However, the genre observations overlap on both y-axis. Take for example, Fantasy genre which was ranked 5th on 2000s, is now ranked 3th in 2010s. However, Fantasy genre showed respectively on rank 3th and 5th in 2000s.
How do I resolve this? Thank you.
Thank you for this nice package.
The parameters package
and palette
are not working in Plot2WayANOVA
function. I checked the code and these are never called in the function. I think a small update could fix that.
Is there a way to save PlotXTabs output in png or pdf?
I can change the newggslopegraph data point color using DataTextColor
, but there doesn't seem to be a corresponding way to change the label color. Am I missing something?
Is there a way to color the lines (LineColor) based on the slope or change over time? For example, positive increase the line=green and for negative change the line=red? It would be the equivalent to your cancer dataset example where you used: LineColor = c("red", rep("gray",4), "red", rep("gray",3)). Thanks very much.
Is there a way to save the plot output from the function Plot2WayANOVA as a ggplot object (not a png or pdf) so that further modifications can be made using ggplot tools and the panels for multiple different plots could be compiled into a multipanel figure?
Is it worth the energy to back track on this? A front end to accept either type?
First I'd like to thank-you for such a fantastic implementation of slope graphs.
This is less a bug and more a refinement.
On the example attached we're getting numerical labels colliding on each axis. Given the distribution of our data this happens on most plots.
You've obviously been able to avoid the category labels colliding. Is there something that can be done on these numerical labels?
Hi,
I'm maintaining the sjstats package, of which you're using the anova_stats()
function in your package. I'm writing you because in the long run, this functions is going to be deprecated first, and then removed at some point in the future.
The reason is that we have started a new project, easystats, where we build new packages from scratch that are focused on particular tasks. In the course of this development, we also refactored some existing packages and re-implemented functions in the easystats ecosystem. The information retrieved by anova_stats()
is now available in packages like effectsize or parameters, and these functions are more robust, reliable and consistent.
Thus, could you please update your package and replace anova_stats()
? It looks like parameters::model_parameters()
gives you all the information you need, including effect sizes for anova tables. It's just that parameters::model_parameters()
returns different column names than anova_stats()
, so you would have to fix that.
library(CGPfunctions)
library(parameters)
library(sjstats)
mtcars$cyl <- factor(mtcars$cyl)
mtcars$am <- factor(mtcars$am)
mod <- aov(hp ~ cyl * am, data = mtcars)
a <- aovtype2(mod)
anova_stats(a)
#> term | sumsq | meansq | df | statistic | p.value | etasq | partial.etasq | omegasq | partial.omegasq | epsilonsq | cohens.f | power
#> -----------------------------------------------------------------------------------------------------------------------------------------------
#> cyl | 1.027e+05 | 51364.469 | 2 | 60.164 | < .001 | 0.711 | 0.822 | 0.695 | 0.787 | 0.699 | 2.151 | 1.000
#> am | 7317.893 | 7317.893 | 1 | 8.572 | 0.007 | 0.051 | 0.248 | 0.044 | 0.191 | 0.045 | 0.574 | 0.833
#> cyl:am | 12181.313 | 6090.656 | 2 | 7.134 | 0.003 | 0.084 | 0.354 | 0.072 | 0.277 | 0.073 | 0.741 | 0.930
#> Residuals | 22197.125 | 853.736 | 26 | | | | | | | | |
model_parameters(a, eta_squared = "partial", ci = .9)
#> Parameter | Sum_Squares | df | Mean_Square | F | p | Eta2 (partial) | Eta2 90% CI
#> -------------------------------------------------------------------------------------------
#> cyl | 1.03e+05 | 2 | 51364.47 | 60.16 | < .001 | 0.82 | [0.70, 0.88]
#> am | 7317.89 | 1 | 7317.89 | 8.57 | 0.007 | 0.25 | [0.05, 0.46]
#> cyl:am | 12181.31 | 2 | 6090.66 | 7.13 | 0.003 | 0.35 | [0.10, 0.54]
#> Residuals | 22197.13 | 26 | 853.74 | | | |
model_parameters(a, eta_squared = "raw", ci = .9)
#> Parameter | Sum_Squares | df | Mean_Square | F | p | Eta2 | Eta2 90% CI
#> ---------------------------------------------------------------------------------
#> cyl | 1.03e+05 | 2 | 51364.47 | 60.16 | < .001 | 0.71 | [0.53, 0.80]
#> am | 7317.89 | 1 | 7317.89 | 8.57 | 0.007 | 0.05 | [0.00, 0.24]
#> cyl:am | 12181.31 | 2 | 6090.66 | 7.13 | 0.003 | 0.08 | [0.00, 0.25]
#> Residuals | 22197.13 | 26 | 853.74 | | | |
Created on 2021-01-08 by the reprex package (v0.3.0)
There is no pressure at the moment, as the way to deprecating and removing anova_stats()
will take several weeks from now on, I just wanted to point out to this change timely.
Daniel
I'm sorry if this has been asked before, but I couldn't find a clear answer.
When I pipe my data frame to the Plot2WayANOVA
function, it returns the following error: That dataframe does not exist
I've been using the same pipe sequence to feed data to ggplot
and the lm
functions, so there don't seem to be any errors
Is this by design or am I missing something here?
Min reproducible example:
iris %>%
Plot2WayANOVA(formula = Sepal.Length ~ Sepal.Width * Species,
dataframe = .,
plottype = "line")
Also results in:
Error in Plot2WayANOVA(formula = Sepal.Length ~ Sepal.Width * Species, :
That dataframe does not exist
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.