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

Image may be NSFW.
Clik here to view.

align variable width font strings in ggplot2 ggrepel geom_label_repel

I am trying to use multiple line labels in ggrepel::geom_label_repel. It seems like the geom_label_repel wants to center all text - whereas I want to flush it left. hjust = 0 does what I want with...

View Article


data.table assigning output to a variable column

So I have a loop that I want to implement which assigns the original value (in row a and col b) + 1 if the value (at row a and col b) is equal to a certain number, however, when i try to assign the...

View Article


Why won't the bars on my geom_bar reorder with reorder() command?

My dataset has data about college graduates. Each observation is a major, which fall into twelve categories. I am trying to find the category of majors that have the highest percentage of women. The...

View Article

How to add the legend to combo plot?

Here is the data set:d <- tribble( ~priceseg, ~price_n, ~zet_n, ~zet_n2, "(0,1]", 16, 2, 24, "(1,3]", 33, 3, 38, "(3,5]", 33, 2, 25, "(5,6]", 17, 1, 13, ) And here is the visualisation thanks to...

View Article

Is it possible to use a for loop and mutate()?

I am attempting to write a code that will automatically scramble the columns of multiple 96-well plates.Here is a small example of the data:plate <- data.frame(column = rep(c(rep("02", 4), rep("03",...

View Article


variance-covariance matrix in R

I have the data frame below and from there I've calculated the matrix b from the betas of coefficients of my linear regression model. How do I create the variance-covariance matrix in R, or s^2_b? y...

View Article

Image may be NSFW.
Clik here to view.

How do I get the value of the x-axis in qqnorm plot

I'm trying to make a norm qqplot using plotly.js with the value obtained in R. I can get the y-axis values. m <- lm(Sepal.Length ~ Sepal.Width + Petal.Width, data=iris) plot(m, which=2) #this plot...

View Article

Reference a Variable Within Quotations [duplicate]

This question already has an answer here:Save several ggplots to files 2 answersI have a plot I am trying to save to a PNG for a bunch of different objects in a list of lists. The code looks something...

View Article


dplyr::select function clashes with MASS::select

If I load the MASS package:library(MASS) then load try to run dplyr::select, I get a error:library(dplyr) mtcars %.% select(mpg) # Error in select(`__prev`, mpg) : unused argument (mpg) How can I use...

View Article


How to sort data into weeks in R?

Here is my current data, using R, I sorted the dates into Year/Month/Day; however, now I wish to sort them into weeks.library(tidyr) library(astsa) mydata <-...

View Article

Computing stock returns from stock prices of multiple companies using a...

I have a matrix with multiple columns (each column represents a company) and multiple rows (consisting of stock prices)I would like to calculate the Returns without the use of a package!I try to do it...

View Article

FactorMineR package in R saying N/A for R 3.6.1 (R3.6.1 "Action of Toes" /...

This question already has an answer here:How should I deal with “package 'xxx' is not available (for R version x.y.z)” warning? 15 answersI am using the same version of R and RStudio on Windows 10. The...

View Article

Build python - R - python pipeline

I am trying to build a pipeline which has 3 modules. The first module uses a python script to generate the outstanding product names, the second module uses the product name as an input in R script to...

View Article


Image may be NSFW.
Clik here to view.

Progress bar within drake functions

I'm trying to implement progress bars within function for use in a drake-r project. I am using the progress package for the progress_bar R6 class. The following example produces the expected progress...

View Article

Plotting Kaplan-Meier Survival Plots in R

I'm trying to plot a Kaplan-Meier survival plot in R, but I'm having some trouble.I'm quite new to R, so forgive my terrible code.library(survival) data_time =...

View Article


Changing standard error color for geom_smooth

I'm plotting some data using geom_smooth and looking for a way to change the color of the standard error shading for each line to match that line (ie., a red line would have it's standard error shaded...

View Article

Decision Tree model with value being < = > or combination for splitting...

I would like to build a decision tree (DT) model to answer my question based on tgis: "Decision is Yes if (EF =< 25 or SB=< 100) and (CR>1.8 or NT<136 or BU>40), otherwise No." But I am...

View Article


Conditional imputation with LOCF

I've this example of longitudinal data. I need to impute 0, 999 or -1 values according to what occurs before.ID = c(1,1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6) Oxy = c(0, 999, 1, 999, 999, 0,...

View Article

Need helping changing legend title in ggmap using scale_color_gradient2

I have created a ggmap with points sized and color coded by "count". Therefore, the legend displays "count" as the title when I would like it to be "Visitors". Here is the code:ggmap(sites_map) +...

View Article

Create grouping based on cumulative sum and another group

This question is nearly identical to: Create new group based on cumulative sum and groupHowever, when I apply the accepted solution to my data, it doesn't have the expected result.In a nutshell, I have...

View Article
Browsing all 206180 articles
Browse latest View live


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