Keep layer name after rasterize
I have a data frame with x, y, values and unique IDs of 50 locations. I converted this data frame to a raster, but I lost the unique IDs of these locations. How can I preserve the name of each location...
View ArticleHow to make a vector using a for loop
I'm very new to R (and programming in general) and I've been stuck on this (probably very easy) question for a few days...How would one make the vector 3 6 12 24 48 96 192 384 768 with a for loop?All...
View ArticleHow to filter out negative data in R
$Data4-4 0 1 41 3 4 1I would like to filter out -4 and 4 from the table function. Any idea ? the "table function" showed the frequency the number occurred and the number itself. Bottom = occurrence,...
View ArticleSpecifying names of arguments with a function in R
What I want to do is the following: I want to write a function, let's call it 'function_creator' with one argument: name, and some additional arguments, such that its output is a function for which the...
View ArticlePlot regression lines in R
I need to add regression lines for each different combination of Sex and Race(white/nonwhite). These are the models and the plot I made, but I have no clue on where to put these lines and how to do it....
View ArticleHow to memoise a function at package startup in R
I work on an R package which wraps API calls. In order to reduce the number of actual calls and to speed things up, I memoise the function making the API call. To do so, I created the following...
View Articleelse and conditional categorical statement in R
if (p$2=′0′|p$2=′a0′ and p$3=′0′|p$3='a0') {p$LTD=0 } else {p$LTD=1 } trying to implement if else statement in R return 0 or 1 depending of 2 and 3 else it is one
View ArticleBold text in text of the axis in R using TeX()
How to render bold text in plot in R using TeX?TeX("$\\alpha$") TeX("The ratio of 1 and 2 is $\\frac{1}{2}$") a <- 1:100 plot(a, a^2, xlab=TeX("$\\alpha$ bold text"), ylab=TeX("$\\alpha^2$ bold...
View ArticleCreating a zipcode map in R?
I want to create a zipcode map for Dallas. I have this shapefile which should include all postal codes within it (Street files)I've been using this as a resourcebelow is an example of what I would like...
View ArticleSummarizing time series data
I have a data file that is two columns, Date, and Time which I have converted to a date and time in R and a glucose column (example below). The data are provided every 5 minutes and I am trying to get...
View ArticleSelect "All" radio button option in R Shiny
I am trying to create a shiny app which has radio buttons and allows a user to select an "All" button which shows all of the data prior to this filter.I have posted my full code below and here is a...
View ArticleDates Mysteriously Converted to Numeric Data Once Put Into Data Frame
I am using an API to get some data. To get the data, I use:library(httr) data=GET(url, add_headers(Authorization=token)) mydata=content(data)$data In a gross oversimplification, I then format all the...
View ArticlePrint separated by comma, remove quotes and add special quotes in R
I have a table which contains the names of data frames in TSV format, like so:df1 <- t(c('18-1829.tsv', '19-0193.tsv', '14-381.tsv', '19-940.tsv')) df1 V1 V2 V3 V4 1 18-1829.tsv 19-0193.tsv...
View Articleprofit drawdown of each column in data.frame
I want to calculate the profit/drawdown of each column A:C in the data.frame below. Header A thru C can be considered like a stock ticker symbol. Each row can be considered the hourly closing price....
View ArticleTidyverse Select function does not keep the unnamed columns of an unclass item
How can I filter EFA factors to include items that have only the items having loadings greater than a certain threshold? I used fa function. Here is a reproducible code:bfi_cor <- cor(bfi_data)...
View Articlehow can I use the stargazer package in R to report the lm.cluster()
alldata5 is my data and OROA,IROA,UROA,X2Y,PGR,LTA,gcode are different variables in this...
View ArticleGet Column names using pipes r
I am trying to get column names of NA columns using named pipes in R:-df <- structure(data.frame(id = c(1, 2, NA, NA, NA, NA), cat = c("SS","SS", "SS", "SV", "SV", "SV"), val = c(220L, 222L, 223L,...
View ArticleExtracting HTML tags from a webpage - Web Scraping with R
so I am trying to extract the tag (class = "c16H9d") from a website and for some reason the simple html Here is the html snippet of the site:> `<div class="c16H9d"><a age="0"...
View ArticleR loading Files from Folder Mac Catalina OS
In version R version 3.6.1 (2019-07-05) -- "Action of the Toes",on Mac Catalina OS. I'm trying to load files from folder, code bellow, however it does not do it at the first time, and I need to run it...
View Articlepivot_wider with duplicates
I have the following dfdf <- structure(list(ID = c(1, 1, 1, 1, 1, 2, 2, 2, 2), value = c("p", "p", "p1", "p2", "p3", "a", "b", "c", "d"), i1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1)), row.names = c(NA, -9L),...
View Article