Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 206180 articles
Browse latest View live
↧

Keep specific date range before and after a timestamp

Having a dataframe result like this:library(dplyr) dframefull <- data.frame(id = c(1,1,1,1,1,1,1,1), name = c("Google", "Google", "Google", "Google", "Google", "Google", "Google", "Google"), date =...

View Article


drive_auth() function not creating gargle-oauth token on password submission

R v3.6.2RStudio Desktop v1.2.5033R package 'googledrive' v1.0.0I have written an R script that uploads csv files to a googlesheets account. In order to avoid having to automate this, I have used the...

View Article


Get column name of each row which is closest to 0

Thanks, I tried the first option and work fine now I want to built a dataframe like df2 from df1, looking always for the closets value to 0: Where clossets_1 - closer value to 0 of the columns x,y and...

View Article

how to download pdf file with R from web (encode issue)

I am trying to download a pdf file from a website using R. When I tried to to use the function browserURL, it only worked with the argument encodeIfNeeded = T. As a result, if I pass the same url to...

View Article

Using plyr::mapvalues with dplyr

plyr::mapvalues can be used like this:mapvalues(mtcars$cyl, c(4, 6, 8), c("a", "b", "c")) But this doesn't work:mtcars %>% dplyr::select(cyl) %>% mapvalues(c(4, 6, 8), c("a", "b", "c")) %>%...

View Article


Create a count consecutive variable which resets to 1 based on POSIXct date

Follow up to this: Create a count-consecutive variable which resets to 1and the solution worked great. Now I have below, where date is POSixct: df<-data.frame(group=c(1, 1, 1, 1, 2, 2, 2),...

View Article

How to extract data from pdf files using R [closed]

I am trying to extract data (tables) from pdf files and store them as data frames.Here is my code ` #using package pdftoolslibrary(pdftools)f <- file.path("........")text <- pdf_text(f)#using...

View Article

Where to include text notes in R package directory structure?

I authored an R package which has currently the following directory structure: .git .Rproj.user docs inst man Meta R tests vignettes I keep the package code on the GitHub repository. I want to add a...

View Article


Extract dates in various formats from string in R

I need to quickly extract dates from character vectors. I have 2 main issues: Various date formats (European and American, alphanumeric and numeric...)Multiple dates in each vector.My vectors are...

View Article


Reshape by id and keep other variables fixed

What I'm trying to do is reorder the data where the data is in columns, but the rest of the variables are maintained c1<- c("ID","Location", "Year","Gender", "MoneySpent", "MoneyWithCreditCard")...

View Article

Distributing numeric variable into 3 categorical variables

I am new here so please let me know if I can improve myself to be clearer. I would like to predict absenteeism of employees, so I have to make a factor of this numerical variable. The data is skewed...

View Article

Most efficient way to calculate function with large number of parameter...

Minimalist example of what I'm trying to do:dX_i <- rnorm(100, 0, 0.0002540362) p_vec <- seq(0, 1, 0.25) gamma_vec <- seq(1, 2, 0.25) a_vec <- seq(2, 6, 1) sigma_hat_vec <- c(0.03201636,...

View Article

RcppParallel to estimate distances between rows of two matrix in R

I am trying to use RcppParrallel to estimate distances between rows of two 3D-matrix and return a new matrix. I saw examples of Parallel Distance Matrix Calculation using parallelFor, but these...

View Article


How do I calculate semi-colon separated values within a cell?

I have a table that looks like this:> head(dt) variant_id transcript_id HH HNL NLNL 1: chr10_60842447_A_G_b38 chr10_60871326_60871443 32968;685 1440;20 337;1 2: chr10_60846892_G_A_b38...

View Article

Back solving a function or goal seek in R

I'm trying to learn my way around R and I need a little help. Below is a little sample of the kind of problem I am working on.myFunction <- function(price1) { prices <- c(1:50) prices[1] <-...

View Article


Image may be NSFW.
Clik here to view.

Pyramidal (not rightangular) stacked barplot in R

Using the following code, I can create a simple stacked barplot that has a rightangular shape:barplot(as.matrix(prop.table(c(150,90,60))),col=c('Cornflowerblue','Yellow','Red'),las=1) The output looks...

View Article

R leaflet/shiny: display and offset polylines based on comma-separated column...

I'm trying to stretch what I can do in R and have hit a wall and hope you can point me in the right direction on how best I could accomplish what I want to do. I am plotting a bunch of polylines from a...

View Article


Image may be NSFW.
Clik here to view.

Place a border around points

I'd like to place a black border around points on a scatterplot that are filled based on data, using ggplot2. Also, I would like to avoid having a legend entry for the black border since it will be on...

View Article

R markdown: figure-html folder not showing up?

Hi I'm experiencing a weird issue whereby figures generated "figure-html" during the knitr is missing. It use to be that when I render an rmd file this folder is automatically generated with all my...

View Article

How to refer to variable of dataset in reactivity

I'm making a Shiny app. I use reactivity programming for better fuctionality. But I don't know how to refer to dataset that is reactive object. Here is the example:buffer_bank <- reactive({mydata...

View Article
Browsing all 206180 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>