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

How would I be able to remove opposite values (e.g. refunds) in panel data?

Given the following data:id|datee | price | quant | discrete_x 1 2018-12-19 4 -3000 A 1 2018-12-04 4 3000 A 1 2018-12-21 4 3000 B 1 2018-12-20 3 2000 A ... Desired output:id|datee | price | quant |...

View Article


How to find common elements from multiple vectors?

Can anyone tell me how to find the common elements from multiple vectors?a <- c(1,3,5,7,9) b <- c(3,6,8,9,10) c <- c(2,3,4,5,7,9) I want to get the common elements from the above vectors (ex:...

View Article


Anonymous function for a regex filter

I have a filter() function which filters for specific Regex in a tibble. Because I need to do this more than one time I want to write a as_mapper() function to end up with shorter code. How can I do...

View Article

how to download and display an image from an URL in R? And Rename ((Whole)

The file I attach there are a link and Name column. I wanted to download a file and give the name the same time. How could I do that on R. All of the links and names are sequentialReference Image

View Article

Convert for loop into (?)apply in R

I need your help with these two for loops in R, because it takes literally hours to get the job done and I already tried a few to get the job myself done... :for (i in 1:nrow(neg.sent.dictionary)){...

View Article


Image may be NSFW.
Clik here to view.

Distorted line (with non-solid linetype) ggplot on mac

First time poster here. I hope I am doing it correctly. I have had the following issue for a while now and I really want to understand what is going wrong.I am trying to plot a dashed line with...

View Article

Image may be NSFW.
Clik here to view.

Error in annotate when trying to indicate the statistically significant...

my code looks like this:p <- ggplot(data = df, aes(x = Name, y = prop, fill = Name)) + geom_bar(stat = "identity") + labs(x = "", y = "EQTL / gene") + scale_fill_brewer(palette="Greens",name =...

View Article

How to split a Single Column with multiple entries into multiple columns

I have a csv file with entries of multiple columns in a single column with multiple quotes. When I load it in R using data.table(fread) it appears as a table with quotes. I have tried using...

View Article


Change Vector Type keep Names

Sorry, if this is a duplicate. I could not find an answer.I have a named vector (logical in this case):a <- c("a" = TRUE, "b" = TRUE, "c" = FALSE, "e" = FALSE) a a b c e TRUE TRUE FALSE FALSE If I...

View Article


ODBC Microsoft Access Error: missing operator

Running a query using dplyr on a microsoft access database from R 3.6.2 using DBI and odbc results in a syntax error "missing operator". The query: db %>% filter(year(Date) == 2017) The field Date...

View Article

R built in Web server

Since R 2.13, R comes with a built-in web server. Is there a simple way to create a local web server using R with a custom port number?In python it will be (to use "http://localhost:8080") :python -m...

View Article

How to create column names form character vector when using data.table

I have a data.table like so:dt = data.table(id_1 = c(rep(1:3, 5)), id_2 = sort(rep(c('A', 'B', 'C'), 5)), value_1 = rnorm(15, 1, 1), value_2 = rpois(15, 1)) I would like to create a function which...

View Article

replace Yes, No to 1, 0 in multiple columns in r

I need to replace the Yes and No values to 1 and 0 in 200 columns.I was using with the commanddata %>% mutate(x=ifelse(x=="Yes", 1,0)) but i have to go through each column at a time, and i was...

View Article


From .csv to .nc file using ncdf4 package (Error in ncvar_put)

I'm trying to write a .nc file from a .csv file.This is PART of my .csv table (df) long lat elev 1 -47.99206 -7.501234 242.0362 2 -47.99206 -7.751234 200.7271 3 -47.99206 -8.001234 165.6918 4 -47.99206...

View Article

Reading list of json files using for loop

I am trying to read list of json files in my local folder. But the below code does not work. Can anyone help me in solving thisjson_files <- list.files(pattern = "*.json") for(i in...

View Article


travis builds failing due to rstan compilation issues

My package builds on Linux are failing with the following compilation error for rstan package:lto-wrapper: fatal error: make returned 2 exit status compilation terminated. /usr/bin/ld: lto-wrapper...

View Article

How to remove duplicated values in columns of a data.table?

I want to remove duplicated values in each coulmn of an uneven data.table. For instance, if the original data is (the real data.table has many rows and columns):dt <- data.table(A = c("5p", "3p",...

View Article


How to create xml from R objects, e.g., is there a 'listToXml' function?

R's XML package has an xmlToList function, but does not have the reverse, is there a function for R that will convert a list to an XML object?I would like something likelistToXML(list('a')) that...

View Article

How to reduced length of code ifelse statement

I would like to calculate total page number, based on total number of days. Example: 0 to 25 days page 1, 26 to 50 days page 2 etc…! I am using below method.df$totalpage <- ifelse(df$days >=0...

View Article

R write elements of nested list to csv

I have a list of lists which, in turn, have multiple lists in them due to the structure of some JSON files. Every list has the same number (i.e., 48 lists of 1 list, of 1 list, of 1 list, of 2 lists...

View Article
Browsing all 201839 articles
Browse latest View live


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