in Education by
So I'm trying to make box and whisker plots for my weekly/monthly profit and loss for my sports betting picks for each day. Here is a google sheet with my data. Below is an image of what my code has gotten me so far And following that here is my code exceldata <- read_excel("C:\\Users\\User-Ryzen\\Downloads\\Profit_Loss.xlsx") df <- data.frame(exceldata) month <- c(df$month) week <- c(df$week) p_l <- c(df$profit_loss) library(tidyverse) qplot(x=month, y=p_l, geom="boxplot", fill=month, xlab="Month", ylab="Profit/Loss") Here are the following things I'd like to be able to do in the plot: 1.) Instead of ordering the x axis alphabetically, have it ordered chronologically (i.e. January goes first, April goes last) 2.) Make the y axis go from -500 to 750 in intervals of 100 The last thing I would like to do is find out the mean and median for each week and month. I thought I could do this by using mean(month) and so forth, but that gave me this error: "In mean.default(month) : argument is not numeric or logical: returning NA" Thanks for all the help and please let me know if this needs clarification! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
library(tidyverse) # example data set.seed(1337) data <- list( Jan = rnorm(100, mean = -300, sd = 100), Feb = rnorm(100, mean = 0, sd = 100), Mar = rnorm(100, mean = 500, sd = 100) ) %>% enframe(name = "month", value = "profit_loss") %>% unnest() #> Warning: `cols` is now required when using unnest(). #> Please use `cols = c(profit_loss)` data <- mutate(data, month = month %>% factor(levels = c("Jan", "Feb", "Mar"))) data %>% group_by(month) %>% summarise( median = median(profit_loss), mean = mean(profit_loss) ) #> # A tibble: 3 × 3 #> month median mean #> #> 1 Jan -281. -276. #> 2 Feb -13.2 4.11 #> 3 Mar 496. 484. qplot(month, profit_loss, data = data, geom = "boxplot") + scale_y_continuous(breaks = seq(-500, 750, by = 100), limits = c(-500, 750)) #> Warning: Removed 2 rows containing non-finite values (stat_boxplot). Created on 2022-04-01 by the reprex package (v2.0.0)

Related questions

0 votes
    When I plot densities with ggplot, it seems to be very wrong around the limits. I see that geom_density ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I made the following plot in my Rmarkdown file, and render it using Xaringan. --- title: "myTitle ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I'm graphing data with ggplot and animating it using gganimate. I have colors as my labels and when I add a ... changing the labels from color names to the number codes. df...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I'm graphing data with ggplot and animating it using gganimate. I have colors as my labels and when I add a ... changing the labels from color names to the number codes. df...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    4. is a key that is used to identify the colours, patterns, or symbols assigned to data series. * OData Series O ... Y - Axis O Legend Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    I'm trying to make it so when a user scrolls down a page, click a link, do whatever it is they ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    The probability that the graph of y=16x2+8(a+5)x-7a-5=0, is strictly above the x-axis, If a∈[-20,0] A. 1720 B. 1320 C. 720 D. 320 Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    The conversion of molecules X to Y follows second order kinetics. If the concenration of X is increased to three ... formation of Y ? Select the correct answer from above options...
asked Jan 4, 2022 in Education by JackTerrance
0 votes
    Calculate the Green's value for the functions F = y^2 and G = x^2 for the region x ... theory proposed by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 11, 2021 in Education by JackTerrance
0 votes
    How do you find the number with the highest value of x and y? (a) ceil(x,y) (b) top(x ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 21, 2021 in Education by JackTerrance
0 votes
    Two natural numbers x and y are chosen at random from the set {1,2,3,4,...3n}. find the probability that x2-y2 is ... D. 3n-1 2(5n-3) Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    Since I can't intercept action_down event for gridview, I would like to get (x,y) coordinate of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    (i) x=5, y=6,2=20 Q8) Consider the following statements and describe the output/statement required: ... multiple assignment statements. Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
...