How to match identical characters in regex in R [duplicate]
I can't seem to figure out how to match identical characters in regex in R. Suppose I have this data:dt <- c("12345", "asdf", "#*§", "AAAA", ";;;;", "9999", "%:=+") I'm able to extract all strings...
View ArticleHow to create grouped bar plot instead of facet_wrap in R?
I have a dataset that has three categorical variables. I know how to use ggplot geom_bar to create a bar plot and facet_wrap. But I want the bars to be grouped by the third categorical variable rather...
View ArticleHow can I make a data frame of the unique values in an existing column?
I need to make a new data frame (col.3) using only the occurrences in a previous column (col.1) that correspond to unique values in another column (col.2) in an existing data frame. I need this:df1...
View ArticleInstruct R to follow a certain sequence when making random forest decision trees
I have some data where one of the columns is only relevant after evaluating a different column. For example, when analyzing car data to determine car values, it may be meaningful to evaluate whether a...
View ArticleR read.table: how to avoid error from column mismatch
I'm sharing here a text file a need to read into Rhttps://www.filehosting.org/file/details/846022/PLT_PERIOD_ALL_175_P98.PLTthis is what I've done so farfname<-'PLT_PERIOD_ALL_175_P98.PLT'...
View ArticleCalculate distance between vector of coordinates in 1 df and single...
Suppose I have the following two dataframes (with uneven rows)set.seed(1999) dfA <- data.frame(x = rpois(10,2), y = rpois(10,2), z = rpois(10,2), q = rpois(10,2), t = rpois(10,2)) set.seed(24) dfB...
View ArticleReplace lmer coefficients in R
From the post below, Replace lm coefficients in [r]I am also interested in changing the coefficients of a mixed model fitted with lmer. For e.g. in a a model of the form below: mod <- lmer(y ~ x1 +...
View ArticlePlot different variables on different graphs on top of each other
I have 3 different variables (A, B, C) to be plotted on 3 graphs on top of each other(as they have different axis). My output has a lot of space between graphs and I would like to reduce that space and...
View ArticleUsing fill in ggplot to colour polygons and boxplots with different types of...
I'm trying to great a plot with a grouped boxplot over the top of a set of polygons, and would like to use the fill aesthetic to colour the polygons based on a continuous variable, and the boxplot...
View ArticleAdding durations in HMS, ideally with lubridate R
My apologies if it is a repeat question. I'm not experienced working with timestamp data in R. I have a dataset that contains a duration data in HMS format. I want to find the total sum of these...
View ArticleHow can I convert a list of lists into a data frame for export?
I've generated a list of lists containing data for manual review. The sublists are a combination of text and numeric data, however they are all being treated as character data by R. Each sublist holds...
View ArticleScraping NBA team data into R [closed]
I'm relatively new to R and was wondering if there is an easy way to scrape the NBA data found in the URL provided below into R? Ultimately want to be able to pull in and manipulate team points scored...
View Articledisplaying `shape` values in `ggplot2` plot annotations
I want to display the shape value (shape argument for geom_point function) in the plot annotation.Below, for example, I am just writing 'point shape' where I actually want the shape itself to be...
View Article`README` badges not getting rendered properly in `pkgdown` website
I have thus far created 6 different pkgdown websites for my R packages (e.g., ggstatsplot, kittyR, etc.) and none of them ever had the following issue. For the first time, running the following command...
View ArticleHow can I select the nth digit from a number in R?
Given some number with at least 2 digits how do I pick a specific digit? x <- 4856 nth_digit(123, 4) 6
View ArticlePassing characters/strings from R to Fortran
I have a Fortran subroutine that selects a function based on the value of a string and then executes that function.!! file:select.f90 module funcs contains subroutine add(x, y, xy) real :: x, y, xy xy...
View Articlerun java script in R
I'm trying to use R to run javascript from a webpage. and create internal variables in R. I could do this with web drivers like selenium but I want to this with javascript engine v8 from inside R...
View ArticleSequence analysis clustering CHI2 EUCLID error
I am quite new to sequence analysis and trying to identify clusters in an aggregated sequence matrix, focusing on the state duration. However, when using method='CHI2'/'EUCLID' combined with step=1...
View ArticleError in UseMethod("xgboost") : no applicable method for 'xgboost' applied to...
I use a dataset that shows companies's default with a binary variable. using xgboost I have this problem. param <- list(objective = "binary:logistic", + eval_metric = "Aucklands", + max_depth = 7, +...
View ArticleUsing the pdf_data function from the pdftools package efficiently
The end goal is to use the pdftools package to efficiently move through a thousand pages of pdf documents to consistently, and safely, produce a useable dataframe/tibble. I have attempted to use the...
View Article