How to get the package name of a function in R?

I'm debugging some code and I think I might have twice the same function in 2 packages. I want to output the package name of the function as it would be executed by the R console. Examples : function_package_name(print) # --> base function_packag...
more »

2017-06-22 12:06 (3) Answers

Convert YYYYMMDD to mm/dd/yyyy format in R

I have a dataframe in R, which has two variables that are dates and I need to calculate the difference in days between them. However, they are formatted as YYYYMMDD. How do I change it to a date format readable in R? ...
more »

2017-06-21 22:06 (2) Answers

R - Faster sorting of matrix product

There are 2 matrices A and B. A is of size 2M*50, B is 20k*50. I want to compute the top 10 values of A %*% t(B) for each row. I was wondering if there is a faster implementation than this one library(parallel) library(pbapply) set.seed(1) A <-...
more »

2017-06-21 00:06 (1) Answers

Group dataframe by dates in R

I have data read into dataframes in R. I want to be able to group all the data with dates corresponding to month into a new category called "January", or whatever month it is. For instance if I have a row that looks like this area file `#...
more »

2017-06-20 20:06 (1) Answers

Using dplyr group_by in a function

I am trying to use dplyr's group_by in a local function, example: testFunction <- function(df, x) { df %>% group_by(x) %>% summarize(mean.Petal.Width = mean(Petal.Width)) } testFunction(iris, Species) and I get an error "... unknown va...
more »

2017-06-20 19:06 (2) Answers

Align multiple time series in R

I imported into Excel some time series, I got 20 columns and every second column contain dates. I would like to have only one date column with all data aligned and NA where not available. 2007-06-11 1509 2007-06-11 1138 2008-01-17 990 2007-06-12 149...
more »

2017-06-20 07:06 (1) Answers

R + Adding n number of weeks to YYYYWW format

I am trying to add 52 weeks to a date variable which is in YYYYWW format. my initial date is 201616 (year 2016 and week 16) and i am trying to add 52 weeks to this date and the expected output is 201715. I tried couple of things but no luck, here is...
more »

2017-06-20 01:06 (2) Answers

single digit month format

I have a date variable that includes month and year where the month is a single digit (e.g. this month/year is '62017', but October is '102017'). I need the final format to be '6/1/2017'. I have tried using as.Date to convert but it will not work as...
more »

2017-06-19 17:06 (1) Answers

How to parse year from a date in r

I have 53000 Date data-set and I want to extract only "year" from the date variable. Do you guys know how can I do this? My data are as follows: OPN_DT_TM 18/07/2003 10:55 12/06/2004 6:00 9/06/2007 12:20 29/06/2001 16:00 6/06/2000 7:55 27/11/2006 10...
more »

2017-06-19 04:06 (1) Answers

Read a large (1.5 GB) file in h2o R

I am using h2o package for modelling in R. For this I want to read a dataset which has a size of about 1.5 GB using h2o.importfile(). I start the h2o server using the lines library(h2oEnsemble) h2o.init(max_mem_size = '1499m',nthreads=-1) This pro...
more »

2017-06-18 22:06 (2) Answers

How to build libRmath.dylib on Mac

I am a Mac user. I am trying to install libRmath.dylib, the standalone Rmath library from R. I found that R does not compile libRmath by default. So I tried to compile the Rmath library from source. But I can only find .tar file for Windows/Unix on C...
more »

2017-06-17 20:06 (0) Answers

R POSIXct returns NA with "03/12/2017 02:17:13"

I have a data set containing the following date, along with several others 03/12/2017 02:17:13 I want to put the whole data set into a data table, so I used read_csv and as.data.table to create DT which contained the date/time information in date....
more »

2017-06-17 18:06 (2) Answers

Write a for loop in a function to get a matrix

I need to put delta.vec and sigma.vec values through my required.replicates function and store them in my practice1 matrix. But I get NULL. sigma.vec <- c(2,4,6,8,10,12) delta.vec <- c(1,2,5,8,10) practice1 <- matrix(0, nrow=length(delta...
more »

2017-06-17 14:06 (1) Answers

Sort list of strings by order of numeric parts

I have a list of paths of files, which I want to sort in ascending order based on the first path of each list. The list of paths is show $`HG-U133_Plus_2` [1] "C:\\Users\\agaz\\AppData\\Local\\Temp\\Rtmp0wZI21/008947515435900b4d1a0b8d/22" [2] "C:\\U...
more »

2017-06-17 13:06 (2) Answers