How to replace some characters after the last dot with their lower cases
A simple question but I cannot solve it. I got a string like this mail address:ma <- "something@somewhere.COM"My goal is to get:"something@somewhere.com"So to put the to lower cases the part after...
View ArticleGet the path of current script
I would like to set the working directory to the path of current script programmatically but first I need to get the path of current script.So I would like to be able to do: current_path = ...retrieve...
View Articlepdf_text function not releasing ram (on windows)
pdf_text() is not releasing RAM. Each time the function runs, it uses more RAM, and doesn't free it up until the R session is terminated. I am on windows.Minimal example# This takes ~60 seconds and...
View ArticleMann-Whitney-Wilcoxon Test on two samples of financial ratios with different...
I have two dataframes of financial ratios differing in sample size. I'd like to perform a non-parametric test to compare each ratio in the two samples. How do I efficiently combine the dataframes in...
View ArticleAdd summarize variable in multiple statements using dplyr?
In dplyr, group_by has a parameter add, and if it's true, it adds to the group_by. For example:data <- data.frame(a=c('a','b','c'), b=c(1,2,3), c=c(4,5,6)) data <- data %>% group_by(a,...
View ArticleRolling regression with expanding window in R
I would like to do a rolling linear regression, with expanding window, between two variables in a data frame, grouped by a third categorical column. For example, in the toy data frame below, I would...
View ArticleProblem with CoverageHeatmap (Bioconductor) function in R
I have 2 sets of pairwise alignments, where query genome 1 (q1) is aligned to the reference genome and query genome 2 (q2) is aligned to the same reference genome. Therefore, I have both alignments...
View ArticleScrap free text that has changing number of elements in different websites
I am scrapping a database of companies available in this format, where each company is under a different website, defined by the number at the end of the url (example above is 15310; see url). I am...
View ArticleDefine a new type of for loop in R?
I am trying to work out how to define a custom for loop in R, or if that's even possible.ExamplesA couple of things that would be nice to have are something equivalent to ruby's each_with_index, as...
View ArticleDimension of the multi barplot using ggplot2 facet_wrap() in R
Please I wonder to send a pdf file containing the multi barplot I generated using ggplot2 / geom_bar() and facet_wrap(). It is required that the dimension of each single barplot must measure 2 cm * 2...
View Articlein R, please help condensing x axis in ggplot2, binary x value
looking at some nfl data.. I am looking to condense my x axis.. my x value is binary.. so I only want to see 0 or 1 yet values in between 0 and 1 are appearing.. so I am seeing .25, .50, .75 and it is...
View ArticleUsing melt in R to change DF from long to wide [duplicate]
This question already has an answer here:Transpose / reshape dataframe without “timevar” from long to wide format 6 answersI have a very simple data frame called PlantGrowth that I am trying to change...
View ArticleVolcano plot for multiple clusters
I am trying to make a volcano plot for different clusters. I have 2 conditions, untreated vs. treated. I have a differential expression excel file that cellranger generated for me but within the file...
View ArticleCreate Second Dropdown as column values and draw Area chart
I am new to R .I am creating a dashboard with date ranges and I have one dropdown for column names of the data table and I need to create another dropdown of column commenttype(i.e., good or bad) that...
View ArticleOrder Columns in ggplot
I've tried what others have suggested (Order bars in ggplot and Order Bars in ggplot2 bar graph) for ordering columns and I still can't get it.I have a dataset with a column called "Zap", which has...
View ArticleLooping to restructure data for time series
I have a data frame that I need to restructure for a time series analysis. I have sales data for ITEMS where the date is a YEAR_MONTH value (e.g., 2014_06). I don't care about the date, however; what I...
View ArticleCombine two words in a corpus with R
So here is my code ny <- read.csv2("nyt.csv", sep = "\t", header = T) ny_texte <- as.vector(ny) iterator <- itoken(ny_texte, preprocessor=tolower, tokenizer=word_tokenizer, progressbar=FALSE)...
View ArticleHow to work with special row after group_by in R
I have a data frame something like bellow:amount <- sample(10000:2000, 20) year<- sample(2015:2017, 20, replace = TRUE) company<- sample(LETTERS[1:3],20, replace = TRUE)...
View ArticleHow to perform operations in Stata with different groups for each row
Say that I have these data:clear all input n str6 G1 str6 G2 v desired computed 1 "B""A" 1 5 . 2 "A""A" 2 5.5 . 3 "C""A" 3 4.5 . 4 "A""B" 4 2 . 5 "B""B" 5 2.5 . 6 "C""B" 6 1.5 . end n is observation...
View ArticleTooltip for calculated shares in a stacked and filled bar chart
I've plotted a bar chart in ggplot and converted it using ggplotly. I want the tooltip to display relative and absolute frequencies within each bar of the chart. I try to do this the following way:gg +...
View Article