Category "r"

How to create a quiz score variable in R

I have a dataset in R similar to the following, where each row belongs to a person who has taken a quiz: example <- tibble(ID = c(1,2,3), a

Remove underscore and number at the end of string

I am working with a dataset that has column with some underscores. There is a patter to it but they are different patterns, as shown below ID Col1 1029

Tokenization of Compound Words not Working in Quanteda

I'm trying to create a dataframe containing specific keywords-in-context using the kwic() function, but unfortunately, I'm running into some error when attempti

R column with a strange value [duplicate]

In one column of my dataset the assignment of a record to a phase is listed. Phase I (I), Phase II (I), Phase III (I). Each dataset has an ass

Error - replacement has [x] rows, data has [y]

I have a numeric column ("value") in a dataframe ("df"), and I would like to generate a new column ("valueBin") based on "value." I have the following condition

pandas equivalent to mutate accros

I would like to perform following operation in Pandas: library(tidyverse) df <- tibble(mtcars) df %>% select(ends_with('t')) %>% head(3) # A

I got NaN for my p value table and I don't know why

I am trying to perform a three way mixed anova on a dataset caled "data". The thing is that I am running into some warning messages and when trying to calculate

SMOTE within a recipe versus SMOTE in trainControl

I am trying to understand where exactly SMOTE-ing should occur when training a model with cross-validation. I understand that all pre-processing steps should oc

SHAP Summary Plot and Mean Values displaying together

Used the following Python code for a SHAP summary_plot: explainer = shap.TreeExplainer(model2) shap_values = explainer.shap_values(X_sampled) shap.summary_plot

R: Building phylogenetic tree from arbitrary features?

StackExchange. I'm trying to build a phylogenetic tree for >100 individuals, using R. However, while tutorials for packages like APE and ggtree readily show

How to clip SHP (road map) based on 4 lines (roads)?

How to clip SHP (road map) based on 4 lines (roads)? I have OSM street grid from http://download.geofabrik.de/ and I want to clip it only to selected city centr

Mahalanobis difference by group with dplyr

I want to get a Mahalanobis difference for each set of two scores, after being grouped by another variable. In this case, it would be a Mahalanobis difference f

How to solve : EnrichR website not responding?

I have faced with working EnrichR, is there any solution to solve it? install.packages("enrichR") library(enrichR) dbs <- listEnrichrDbs() `EnrichR websit

How can I create a condition to delete the files?

I am trying to get the pixel-variance of each image from my data folder and delete them when it's lower than 800. I have worked with deleting rows or columns in

Updating a table from data in another table and multiple matches

First time posting here, normally I am able to find an answer to my questions by searching but not this time... I have a table T1 with 2 sets of coordinates (st

Shiny R - Drop down list constantly resets to first in list when using observeEvent and updateVarSelection

When using observe event and update var selection it resets every time to top in drop down list I have a very large data set, when one unit is selected it fi

Join each term with list of keywords

Probably a simple problem and you can help me quickly. I have a vector with all the terms contained in a list of keywords. Now I want to join each term with all

I can not see the 3d figure when using r function persp3d

I can not see the 3d figure when using r function persp3d, like using this demo code, it does not appear andy 3d graph, is it because the version of R? # (1) Th

Create multiplot with map and scatter

I am trying to create multiplot that contains a map (using geom_sf) and a graph next to each other. I tried to use GGpubr::ggarrange and cowplot::plot_grid for

Simulating random numbers in R using a certain condition

I would like to simulate 100 random numbers from N(0,1) in such a manner that the i-th number generated is always greater than the (i-1)-th number. I've tried u