510,925 questions
0
votes
0
answers
17
views
Changing order of lines between points in ggplot2
I am creating a line graph, showing nutrient data against depth. I would like R to join the points on the graph according to depth (lowest to highest) but instead it is joining the points from the ...
0
votes
0
answers
13
views
ggsurvfit Kaplan Meier risk table customisation
Does anyone known how to customize the risk table below the plot using ggsurvfit such that for one cohort all the values are set to NC (not calculated) instead of the N at risk that is presented ...
1
vote
1
answer
21
views
Plotly choropleth - change width to rectangular
I'm making an R Shiny application that uses a choropleth to display some data. The plotly version works well, but I can't find how to adjust its sizing to make full use of the space.
It always looks ...
1
vote
1
answer
28
views
Change colour of text that labels a tile in ggplot2
This question follows on from this one (Warning message: Removed 2 rows containing missing values (`geom_tile()`)). Some of the days are weekend days and I would like to communicate this in the chart. ...
2
votes
3
answers
47
views
Drop rows with missing values in all columns
It looks like tidyr's drop_na will drop rows if any of the specified columns contain missing values.
Example:
> library(tidyverse)
> df <- data.frame(a=c(1,NA,2,NA), b=c(3,4,NA,NA))
> df
...
0
votes
1
answer
21
views
Setting xlim when the x-value is a factor causes the x-axis to extend beyond the plot window
When I plot my data without explicitly setting the x coordinate range (the fourth and lowest plot in the screenshot, "Sonntag"), par("usr") tells me what range R uses by default:
&...
0
votes
1
answer
26
views
Unexpected String Constant when completing Confirmatory Factor Analysis
I keep getting an error message stating unexpected string constant in R when trying to complete factor analysis. It always seems to be the last two lines of information which are causing the issue. ...
1
vote
3
answers
52
views
Adding labels to multiple data points based on a condition [R] [duplicate]
I'm trying to get a plot that shows some important data points highlighted.
Dataset:
df <- structure(list(its = 1:20, pd = c(-0.521, -1.866, -0.11, 0.296,
-0.14, -0.303, 0.141, 0.181, -0.116, 0....
0
votes
1
answer
49
views
Nested elements in body for REST API using R package httr
I would like to use the REST API of the Canvas Learning Management System to make changes to quizzes students make via the system. I use the R package httr for this. This generally works fine using ...
0
votes
0
answers
23
views
Exit swirl in the middle of a cmd_question
I know I can exit swirl by typing bye() but this doesn't work when I have a cmd question that is waiting for my input. In this case it works as "normal R" and if I type some of the keywords ...
0
votes
0
answers
58
views
Why does R evaluate `NA==T|F` as NA, but `NA==F|T` as True? (and related Qs) [duplicate]
If you run the following lines of code in R, you may be surprised by the results (printed above each line as a comment)
#1: NA
NA==T
#2: NA
NA==F
#3: NA
NA==T&T
#4: FALSE
NA==F&F
#5: NA
NA==F&...
0
votes
0
answers
38
views
Creating a utilization distribution of telemetry data using the circular normal model [closed]
I am trying to replicate a procedure performed in Ramsey et al. 2022 to assess the efficiency of radio tracked animals in locating conspecifics for removal. This procedure uses a utilization ...
2
votes
2
answers
59
views
Why does spec() return NULL after subsetting a tibble? (And how do I avoid that?)
After reading in my data using read_csv() from readr, the command spec() returns "full column specification" for the resulting tibble:
> spec(steps)
cols(
duration = col_double(),
...
1
vote
1
answer
29
views
glmmTMB issue with number of observations and groups
I have a dataset with 125 animals across 3 sites and 100500 observations. Both show up properly when looking at the structure of the data but when I run the model with an updated data frame (I added a ...
3
votes
1
answer
62
views
Plot the best fit linear regression with the slope set to a fixed value (m=1)
Currently using R 4.4.3 on Windows 11. I'm plotting the following data set with ggplot2 and performing a linear regression with geom_smooth:
df <- data.frame(A= c(1.313, 1.3118, 1.3132, 1.3122, 1....