Category "r"

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

Is this a panel data set (multiple individuals and two variables from different points of time)?

I have a dataset with multiple individuals and two variables from different points of time, for example: Company Employees at t=1 (before a specific event) Rev

Import multiple Excel files with names in R as a list

Consider I have two Excel files in my subdirectionary: .../Myfolder/File1.xlsx .../Myfolder/File2.xlsx I know that I can read them into R as a list using the f

Statistical difference between linear regressions

I have a statistical question on which I am stuck: Imagine you have 5 corn fields. You know the number of corn plant there is in each fields. You know want to c

Kable table: how to keep duplicate rownames, add arrows to indicate effect direction and add values to the pack_rows header row

I am trying to format an ANOVA style output for my paper using kableExtra. I want to make it automatic to avoid mistakes. I need to glue together several ANOVA

Is it possible to create a stratified table (tbl_strata) using tbl_svysummary()?

I am pretty new to survey data and gtsumarry package. I'm trying to create a stratified table from the survey data using the following code, and I get the error

NLP textEmbed function

I am trying to run the textEmbed function in R. Set up needed: require(quanteda) require(quanteda.textstats) require(udpipe) require(reticulate) #udpi

Multiply without eliminate information

I have a dataframe and I would like to maintain information. My data frame is like: a <- c("a","b", "c", "d") b <- c("e","f", "g", "h") c <- c(1, 2, 1,

R shiny : display text as code on several lines

I would like to display some R code on my shiny app. Therefore, I used verbatimTextOutput but I can't find a way to break lines and to display paragraphs of cod

Summing NAs in each row in a new column

for (i in 1:nrow(survey_clean)) { for(j in 1:ncol(survey_clean)) { survey_clean$invalid_answers[i] <- sum(survey_clean$old_col == survey_clean$ol

why a specific model is not appropriate, given a data with 6 variables (they are chr variables)

i want to show why a specific model is not appropriate, given a data with 6 variables (they are chr variables) the model is y= abc*(x1+x2) a and b from the data

Copy a Shiny DT cell to users clipboard

Based on this question: I want to select a row in a shiny datatable and want to copy the content of a specific cell to the clipboard. What I've got so far: libr

Using jupyter R kernel with visual studio code

For python jupyter notebooks I am currently using VSCode python extension. However I cannot find any way to use alternative kernels. I am interested in jupyter

A better way to write dplyr pipes? (without using dollar sign) [closed]

Quite often when using the tidyverse to manipulate data, I come up with a situation like the one below. Can someone explain why option 3 works

Muliple table captions in DT in R

I'm following the example from here: https://rstudio.github.io/DT/ I can get a caption above the table with: library(DT) datatable( head(iris), caption =

ifelse is giving me NAs when I want 0s

I am trying to create a variable using ifelse, and would like the column to be 0 when the condition is not true, but they are showing up as NA. Any tips? df$z &