R - tapply column mean, returning logical array

R
I have a data frame. I am trying to use the tapply function to find the average of one column when the values of a second column are equal to a given...
1 year ago

Using purrr::map to iterate linear model over columns in data frame

R
I am trying to do an exercise to become more familiar with how to use the map function in purrr. I am creating some random data (10 columns of 10 data...
1 year ago

Datatype for linear model in R

R
I get two vectors as output from R analysis, respectively> [1] "216" "217" "218" "219" "220" "221" "222" "223" "224" "225" "226" [1] 10014733 10014...
1 year ago

R regex: retrieve currency abbreviations

R
I have a string of variable names and I want to extract the currencies as given by a vector from that. But I am having difficulties extracting the val...
1 year ago

lubridate: how to parse month-year?

R
I have a column of dates as follows, > mymonth = c('10/2015','11/2016','12/2016') > data <- data_frame(mymonth) > data # A tibble: 3 × 1 ...
1 year ago

Embed csv in html rmarkdown

R
Example Problem statement Solution search and Question ... see rmarkdown example code. Appreciate answers demonstrating the solution by modify...
1 year ago

Setting individual axis limits with facet_wrap and scales = "free" in ggplot2

R
I'm creating a facetted plot to view predicted vs. actual values side by side with a plot of predicted value vs. residuals. I'll be using shiny to he...
1 year ago

Finding which element of a vector is between two values in R

R
I have two vectors x and y. I would like to find which elements of x are between the two elements of vector y. How can I do it in R? x = c( .2, .4, 2...
1 year ago

r number of a factor per unique values

R
I have the following dataset: Names Category Jack 1 Jack 1 Jack 1 Tom 0 Tom 0 Sara 0 Sara 0 what I am looking for is the f...
1 year ago

Use a factor column in "by" and do not drop empty factors

R
Suppose I have a data.table: x <- data.table(x=runif(3), group=factor(c('a','b','a'), levels=c('a','b','c'))) I want to know how many rows in x ...
1 year ago

R gvisTable pre-selection using event trigger option and Javascript code

R
In R I am looking to set the selection of the output for a gvisTable so that a specific row or column is highlighted. For example I have the followin...
1 year ago

GBM multinomial distribution, how to use predict() to get predicted class?

R
I am using the multinomial distribution from the gbm package in R. When I use the predict function, I get a series of values: 5.086328 -4.738346 -8...
1 year ago

R: How to split a character string containing commas according to comma

R
Example string <- "field1,field2,\"there is a , in field3\", field4, \"2,456\", field6" A negative attempt: test <- unlist(strsplit(noquote(...
1 year ago

Unable to plot column in y axis in R

R
I have columns in R dataframe as StreetName BeginTime wls-wilkeson17-45 2016-11-26 20:04:33 wls-wilke...
1 year ago

Discrepancies in the density() kernel estimator compared to calculations by scratch

R
I am trying to calculate the Gaussian kernel density, and to test of my knowledge of the density() function, I decided to calculate it from scratch an...
1 year ago

select different rows from grouped data

R
I have a dataset of repeated measurements over days for variables t, l and c. I am trying to calculate the difference in days between the peaks for t,...
1 year ago

How to sum two matrices by seq_along in r?

R
I have two matrices that i want to sum mat1<-matrix(1:4,2,2) mat2<-matrix(5:8,2,2) mat1 [,1] [,2] [1,] 1 3 [2,] 2 4 mat2 ...
1 year ago

dynamic aggregations with data.table in R using derived column names

R
I have this data.table with different column types. I do not know the column names before hand and I would like to generate aggregations only for co...
1 year ago

Installing additional R Package on Azure ML

R
I am doing the following steps to install R Hash_2.2.6.zip package on to Azure ML Upload the .zip file as a dataset Create a new experiment and Add ...
1 year ago

R - handling NA in ifelse statements

R
This question is slightly similar to this question with a more theoretical component. Given df below: varA <- c(1,0,0,NA,NA) varB <- c(NA,NA,N...
1 year ago