tidyverse

Multi x-axis using ggplot to present z-scores, iq scores and raw data

天涯浪子 提交于 2021-01-24 19:32:05
问题 Just contextualizing, I work with psychometrics/psychological testing. I have a dataset formed of "points","percentile","z_real","z_normal","iq". I would like to have a single ggplot in which I could present the Z_score (from my raw data), the z_score (with an underlying normal distribution), and then have two supplementary x-axes with "raw score" and "iq scores". That's pretty common in statistics, as you can check it below This is the current plot This is the best solution I've got That's

Multi x-axis using ggplot to present z-scores, iq scores and raw data

别来无恙 提交于 2021-01-24 19:21:15
问题 Just contextualizing, I work with psychometrics/psychological testing. I have a dataset formed of "points","percentile","z_real","z_normal","iq". I would like to have a single ggplot in which I could present the Z_score (from my raw data), the z_score (with an underlying normal distribution), and then have two supplementary x-axes with "raw score" and "iq scores". That's pretty common in statistics, as you can check it below This is the current plot This is the best solution I've got That's

Multi x-axis using ggplot to present z-scores, iq scores and raw data

吃可爱长大的小学妹 提交于 2021-01-24 19:17:53
问题 Just contextualizing, I work with psychometrics/psychological testing. I have a dataset formed of "points","percentile","z_real","z_normal","iq". I would like to have a single ggplot in which I could present the Z_score (from my raw data), the z_score (with an underlying normal distribution), and then have two supplementary x-axes with "raw score" and "iq scores". That's pretty common in statistics, as you can check it below This is the current plot This is the best solution I've got That's

Modifying specified list elements r

雨燕双飞 提交于 2021-01-24 07:48:29
问题 I have an output that looks like this: test_list <- list(list(x = c(10, 101, 3), y = c(9, 12, 11)), list(x = c(10, 133, 4), y = c(9, 15, 13)), list(x = c(10, 101, 90), y = c(9, 18, 11)), list(x = c(10, 101, 1), y = c(9, 10, 15))) I would like to select and modify specific elements of sublists x and y. For example I would like to replace the last element of x with a number from a vector or generated from a function - i.e; map the vector z <- c(10, 50, 6, 12) over the last element of sublists x

Modifying specified list elements r

寵の児 提交于 2021-01-24 07:48:12
问题 I have an output that looks like this: test_list <- list(list(x = c(10, 101, 3), y = c(9, 12, 11)), list(x = c(10, 133, 4), y = c(9, 15, 13)), list(x = c(10, 101, 90), y = c(9, 18, 11)), list(x = c(10, 101, 1), y = c(9, 10, 15))) I would like to select and modify specific elements of sublists x and y. For example I would like to replace the last element of x with a number from a vector or generated from a function - i.e; map the vector z <- c(10, 50, 6, 12) over the last element of sublists x

What is the “embracing operator” `{{ }}`?

前提是你 提交于 2021-01-21 11:59:12
问题 I just came across the "embracing operator" {{ }} in section 2.2.3 of the tidyverse style guide. What does the embracing operator {{ }} do in R? 回答1: It's called curly-curly operator (see ?"{{}}" ). It's useful when passing an argument that has to be substituted in place before being evaluated in another context. See this simple example (although a bit awkward as we could simple quote the "cyl" when calling the function here): library(dplyr) # does not work get_var <- function(data, column) {

What is the “embracing operator” `{{ }}`?

我的梦境 提交于 2021-01-21 11:58:29
问题 I just came across the "embracing operator" {{ }} in section 2.2.3 of the tidyverse style guide. What does the embracing operator {{ }} do in R? 回答1: It's called curly-curly operator (see ?"{{}}" ). It's useful when passing an argument that has to be substituted in place before being evaluated in another context. See this simple example (although a bit awkward as we could simple quote the "cyl" when calling the function here): library(dplyr) # does not work get_var <- function(data, column) {

Collapse and merge overlapping time intervals

大城市里の小女人 提交于 2021-01-21 09:43:59
问题 I am developing a tidyverse -based data workflow, and came across a situation where I have a data frame with lots of time intervals. Let's call the data frame my_time_intervals , and it can be reproduced like this: library(tidyverse) library(lubridate) my_time_intervals <- tribble( ~id, ~group, ~start_time, ~end_time, 1L, 1L, ymd_hms("2018-04-12 11:15:03"), ymd_hms("2018-05-14 02:32:10"), 2L, 1L, ymd_hms("2018-07-04 02:53:20"), ymd_hms("2018-07-14 18:09:01"), 3L, 1L, ymd_hms("2018-05-07 13:02

Adding an additional legend manually for different data.frames used in the same ggplot

白昼怎懂夜的黑 提交于 2021-01-21 04:40:22
问题 In my plot below, I have two separate sources of data ( dat and dat2 ) used in two different geom_smooth() calls producing the black and the red regression lines ( see pic below ). Is it possible to manually add another legend that shows the black line is called "Between" and red line is called "Within" ? library(tidyverse) dat <- read.csv('https://raw.githubusercontent.com/rnorouzian/e/master/cw2.csv') dat$groups <- factor(dat$groups) dat2 <- dat %>% group_by(groups) %>% summarize(mean_x =

How to fit distribution on multiple columns using broom and dplyr

谁都会走 提交于 2021-01-05 08:03:05
问题 I have the following data: library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union set.seed(1) df <- data_frame( genes = paste("Gene_",letters[0:10],sep=""), X = rnorm(10, 0, 1), Y = rnorm(10, 0, 2), Z = rnorm(10, 0, 4)) df #> # A tibble: 10 × 4 #> genes X Y Z #> <chr> <dbl> <dbl> <dbl> #> 1 Gene_a -0.6264538 3.02356234 3