mutate_if and mutate_at functionality in one line
Is it possible to (1) use select helpers and (2) check type of columns to apply a function?For example this will not work - I would like to convert to factor all integer columns the names of which do...
View ArticleHow can I use na.locf() for factor 'inputs'?
I want to fill NAs of my dataset in group variables according to the values of the group in previous years of that ID itself. the na.locf(newData, na.rm = TRUE) part of code does not work. I think it...
View ArticleSeeing metadata/docvars associated with STM topics
I am new to text analysis and am stuck on a question that doesn't seem to be answered in the documentation (or at least, I can't find it). I have created an STM in R from a Quanteda DfM which has...
View Articlehow to group data based on the same value of a column [duplicate]
This question already has an answer here:Collapse / concatenate / aggregate a column to a single comma separated string within each group 3 answersassume my data frame is: Col1 Col2 1 A 3 C 8 L 1 H I...
View ArticleRegex to remove everything, but emojis from the string in R?
I have a big .xlsx file containing tweets with emojis. I am working on a personal project where I want to make a network graph from the extracted emojis. For example, if I have this in one of the...
View ArticleValidate-need with more than one option
I am able to validate-need one column in R, but not more. See examples below:Works fine: validate(need(!(c("b") %in% c("a", "b")), "x"))Works fine: validate(need(!(c("z") %in% c("a", "b")), "x"))Not...
View ArticleHeatmap for US county-Level data in R
I am working with the radon dataset fromdata("radon", package = "rstanarm") I have seen some tutorials with tm_shape but it seems like it only has country level maps. How can I most efficiently create...
View ArticleHow to calculate marginal effect in r for conditional logit model,...
I am running a conditional logit model using mclogit function in R. The purpose of the study is to construct a choice model of how factors influence the likelihood of parents choosing a particular...
View ArticleHist of circular residual in R programme between -pi and pi [closed]
I have the data of error, firstly I need to transform the range of data between -pi and pi then using code hist(error)my question is how I can transform this data using code in R, if there exists code...
View ArticleCreate histogram from the new column using base R
I make several new columns from the existing column, the total variable A, the total variable B, the different price A, the different price B. Because I am the newest beginner, I make it step by step,...
View ArticleError in `[.default`(data, , pos) : subscript out of bounds using predict...
I am banging my head against the wall with this one. I have made predictions from a decision tree, my predictor variables are exactly the same dimensions in both the prediction object and my training...
View ArticleConverting dates in column of a data frame R
I am having problems converting a column of imported dates in a data frame, represented as characters in a different date format, into date objects in that same data frame. Here is a toy example:xx...
View ArticleExpand function with arbitrary number of arguments
Lets say I have the functions foo and bar as followsbar <- function(a, b) { # Some operations with a and b ... } foo <- function(...) { test <- baz(bar(...)) return (test) } Is there a...
View ArticleCan I use a subset of results from DESeq2 to calculate Bray-Curtis...
I am having trouble using my results from DESeq2 when comparing the differential expression of bacterial genes between disease and control to then calculate the Bray-Curtis dissimilarity and...
View ArticleUsing NbClust for Number of clusters in gene expression data does not work
I have a normalized gene expression data, with 2800 rows and 600 columns. I need to find the number of clusters, I am trying to use NbClust function to calculate the number of clusters using different...
View ArticleHow to find the frequency of second histogram based on quantile of first
I have two sets of data. In the first set I can calculate the 25th percentile and output the x value. I would then like to take that x value to a second data set and determine the frequency and...
View ArticleUsing the map function along with the image function for geospatial data in R
I am trying to plot geospatial sea surface temperature correlation data on the world map (only Northern hemisphere). I am using the image function (plot correlation data) along with the map function...
View ArticleEncode string for heatmap
I am struggling to visually present my data to better understand it. I would like to visually present the df in a Heatmap. To do that, I would thought to convert the strings into numeric codes, such as...
View ArticleR intersection plot
I have two csv files each looking like:Sample1 Sample2 C C G G C C I uploaded two csv files to R and made an input read list using:1 <- read.csv(file = "set1.csv", header = TRUE, sep=",") 2...
View ArticleHow to make subcategories in table in R?
so I am trying to load this data into R for a two-way ANOVA test. I was just wondering how to have subcategories within each dependent category. I am not asking to "fill out the table for me in R" I...
View Article