Category "r"

How to fix the var(X) is now defunct

I used the following function to find standard error of variables. but when I run the same function now, it is not working. st.err <- function(x) { sd(

Removing Table entries using remove UI in Shiny

I am populating a table by using Insert UI elements. I also want to delete both table entries and the inserted panels by using the remove UI elements. I could

R/exams: Duplicated images in PDF files

When using several R/exams exercises with TikZ plots, I have no problems generating exams in HTML format or for Canvas. However, exactly the same exercises when

Use max page width using rmdformats?

I'm trying to use the entire page width when rendering an R markdown document using rmdformats::readthedown. First, you can see that it isn't a problem using on

Stripping mapping such as colour and line type from an existing ggplot2 object to re-do it

Within a Shiny application, I would like to provide users the option to select a regression method and then show the fit on their data on an existing ggplot2 gr

Return TRUE/FALSE if common elements/no common elements between vectors

I'm looking for an efficient way to create a boolean vector which returns TRUE if one or more of a number of specified variables e.g. c(1,2,3) are in another ve

Glue vector to string

I want to produce this string: All my variables: a, b, c from this variable vars <- c("a", "b", "c") using glue(). My best attempt so far is: library(glu

Placing Commas Between Names

I am trying to find out if certain patterns appear within a data frame. Suppose I have the following "dictionary of patterns" (notice "james" vs "jamesj"): patt

Is there any way to improve performance (e.g. vectorize) this look-up and recoding problem implemented by a for loop?

I need to make recodings to data sets of the following form. # List elements of varying length set.seed(12345) n = 1e3 m = sample(2:5, n, T) V = list() for(i

How do I group my date variable into month/year in R?

I have a "date" vector, that contains dates in mm/dd/yyyy format: head(Entered_Date,5) [1] 1/5/1998 1/5/1998 1/5/1998 1/5/1998 1/5/1998 I am trying to plot

Group-based trajectory modelling in R

I've been looking for a way to conduct group-based trajectory modeling in R with no avail. Something along the lines of what PROC TRAJ (http://www.andrew.cmu.e

Leaflet map 'Error in polygonData.default(data) : Don't know how to get path data from object of class data.frame'

I'm trying to create a leaflet map of census data. I have a csv file contains the number of deaths across Ireland. The data consists of the year($Year), the Sex

Encoding and raw in R

I not sure if this is a bug or not. If I encode one of the characters to UTF-8 before converting to raw and back again, then the characters are not the same. I

Splitting row into two rows

I'm recently working with data as year <- c('1990', '1990', '1994', '2000', '2012') n1 <- c(30, 70, 20, 31, 10) n2 <- c(40, 60, 20, 21, 8) r1 <- c(0

Using R code to scrape data from a webpage into an Excel file

I have written a code in R which is supposed to retrieve certain information from a website and import it into an Excel file. I have used it for one website and

data.table join with date

hello im trying to extract some id with a group and Date in range > d1 id group Date 1: 1 A 2017-07-02 2: 2 A 2017-07-04 3: 3 A

Can I bound an st_distance call by a polygon?

I have seen similar posts on this topic (see, for example, here and here) but not one that is specific to the sf-tidyverse ecosystem. I have a series of lakes,

How can I merge an empty data frame and a data frame in R

I'm trying to merge to data frames like this: data1 <- data.frame(hola = as.numeric(), toma = as.character()) data2 <- data.frame(hola = as.numeric(1), t

R - Plots without Shiny - Create with JavaScript and produce screenshot

I have a Shiny application that generates one image after clicking an action button, and saves the screenshot of that image after pressing on another action but

append values in for loop R as in python

I am trying to reproduce the following functions created in Python in R. # Python def square_area(side): return side * side results = [] for i in range(1