Combine Legends with Lines and Points

I can't seem to figure out how to combine these legends. Can anyone help? Here's a MWE data("iris") iris % mutate(smell = if_else(Species %in% "setosa","smells good", "does not smell good")) ggplot(iris, aes(x = Sepal.Length, y = Sepal.

Continue reading →

R is not rendering to pdf tlmgr

i have a Rmarkdown document that contains a data frame and a plot in the same chunck. --- title: "Untitled" output: pdf_document date: "2024-04-23" --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(dplyr, warn

Continue reading →

How to find the best fit of a GMM trying multiple components in Matlab

In R, there is Mclust, which would by default run the EM algorithm considering G=9 components. In Matlab, it seems that it only performs the EM algorithm for a single given number of components. Is there either: A function that is like

Continue reading →

How does wilcox_test understand which column specifies the individual sample in paired test?

How do I know that wilcox_test (package statix) recognizes the correct column for each individual sample, when doing a paired test? Here is an example: install.packages("statix") install.packages("datarium") library(statix) library(datar

Continue reading →

Plot probability of detection against number of surveys using 'unmarked' package

I am trying to plot the probability of detection vs number of surveys following an eradication attempt, to produce plots like the below: From the following publication: https://dspace.lib.hawaii.edu/server/api/core/bitstreams/d5c5c776-a

Continue reading →

Gaussian Process Regression stock price prediction

I need some help making a gpr model. I have data for 15 different stocks (Olje_Energi). This data contains price and the price change 1 and 3 months after the stock price reaches above the 50SMA, the close price and the 50SMA . I want to

Continue reading →

In officer package, how to add a simple border to body_add_table?

I'm using the officer package to create a Word document with some tables in it. I want the tables to have simple lines separating cells, but I don't know how to do it. I add each table with body_add_table(), and I know there is a functio

Continue reading →

replace cases contain a certain word with another word and replace all other cases with a third word in R

My data is in a text file (data from different farms). I have many columns (about 100 columns) in this file. But for now I'm focusing on one of columns, this column represent locations (name of locations). I need to change this column, a

Continue reading →

Issues converting chr to POSIXct and watr.heat.map in lakeanalyzer

I am trying to create a water heat map (wtr.heat.map) using lake analyzer and I keep running into this error Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to binary operator" I believe it's because I'm h

Continue reading →

why does name injection while programming with dplyr behave differently in different iterations with the same data?

I'm not sure what is happening here but can anyone explain why this variable does not get correctly converted to a factor on the first iteration only? # a tibble datF

Continue reading →

Keep getting a mutate error at the end with R

it will not read the titles d_df %>% + mutate ( Year = substr(Date, 7, 10)) %>% + mutate(Structures = ifelse(ID %in% tnnls, "tunnelS", "bridges")) %>% + filter( Year %in% yrs_wnt) %>% + group_by(Year, Structures) %>% + sum

Continue reading →

Mutate based on partial string with spaces

In the below string, I only want to extract the value that matches "Left" and "Right", and excludes the rest using mutate(). Let's pretend I have a dataset data with a column called string. library(tidyverse) data$string

Continue reading →

Concatenate 2 dataframe in alternate way ( first column of first dataframe, first column of second dataframe and so on but with column names unchanged

Hello i am new to R programming and i am stuck with one problem. I would like to combine 2 dataframe into a new one in this way. First column of first dataframe, first column of second dataframe and then the third column of the new dataf

Continue reading →

Boxplots in R, plotting multiple points

I am trying to add a list of points to my boxplots, however, the points only show up for one boxplot and not for the another. I was wondering if anyone could help me identify the problem. Here is the code I am using. #graphics.off() rm

Continue reading →

unnest() when nulls are stored as empty lists

I would like to unnest() a data frame where NULL values are stored as list(). How can I do it? library(dplyr) library(tidyr) df # A tibble: 2 x 2 #> date id #> #> 1 1 #> 2 140 unnest(df, date) #> Error in

Continue reading →

Conditional formatting in datatable R

I have a dataframe similar to this: data % formatStyle( columns = c("Rider1", "Rider2", "Rider3", "Rider4"), valueColumns = "Rider", backgroundColor = styleEqual(data$Rider, c("Rider1" = "yellow", "Rider2" = "lightblue", "R

Continue reading →

KML/XML parsing at R not working: whole XML data gets stored in single object and is not being parsed

I'm guilty of newbieness. Help. I'vs downloaded data from Google Maps (personalized maps) in KML format and was expecting to transform it into some clean looking table. Boy was I wrong! KML reading functions only were only able to read 5

Continue reading →

R add plots to a same axis

I created two Lists: List1 and List2. The elements of the lists are dataframes and using each 'n' element of the lists i create a plot: fff= List1[[x]] %>% gather(key, value, tmp117_corr, bme280_temp_corr) %>% ggplot(., aes(Time))

Continue reading →

How to force authentication using shiny and bigrquery

I'm building a shiny app to connect to big query and return info on projects, datasets and tables in a big query account. I'm also using the bigrquery package and would like to know how to force it to ask for authentication. Right now, o

Continue reading →

How do you make an empty named list?

In R, the term "empty list" is usually understood to mean list(). But this isn't what you get when you delete all the elements from a named list: x = list(a = 1) x$a = NULL print(x) # named list() print(identical(x, l

Continue reading →