Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with qplot_on_normal with docu example on R 4.0.x #27

Open
p0g opened this issue Oct 6, 2020 · 1 comment
Open

Error with qplot_on_normal with docu example on R 4.0.x #27

p0g opened this issue Oct 6, 2020 · 1 comment

Comments

@p0g
Copy link

p0g commented Oct 6, 2020

Getting an Fehler: Aesthetics must be either length 1 or the same as the data (1): x on running the example code from: https://rdrr.io/github/rubenarslan/formr/man/qplot_on_normal.html

My Code:

devtools::install_github("rubenarslan/formr", force=TRUE)
library(formr)

normed_value = scale(x = 20, center = 14, scale = 5) # standardise value
qplot_on_normal(normed_value, xlab = "Extraversion")

SessionInfo:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.9.0
LAPACK: /usr/lib/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8        LC_COLLATE=C               LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.3.2 formr_0.8.5   tibble_3.0.3 
@p0g p0g changed the title Error with qplot_on_normal with docu example Error with qplot_on_normal with docu example on R 4.0.x Oct 6, 2020
@jnagler-git
Copy link

jnagler-git commented Nov 11, 2020

Das liegt an den Änderungen mit der aes Funktion. Der folgende Code funktioniert bei mir:

qplot_on_normal = function(normed_value,  ylab = "Percentage of other people with this value", 
						 xlab = '' , colour = "blue", x_ticks = c('--','-','0','+','++')) 
{
	ggplot(data.frame(x = c(-3, 3)), aes(x))+
  stat_function(fun = stats::dnorm,size = I(1)) + 
  geom_vline(xintercept= normed_value, colour= colour,size = I(1)) +
	scale_x_continuous(xlab, breaks = c(-2:2),labels = x_ticks) +
	scale_y_continuous(ylab, labels = scales::percent_format())+
	theme_minimal() + 
	theme(text = element_text(size = 18))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants