Category "r"

How to use a variable to specify column name in ggplot

I have a ggplot command ggplot( rates.by.groups, aes(x=name, y=rate, colour=majr, group=majr) ) inside a function. But I would like to be able to use a param

Getting the unused argument error while running climpact Rscript?

I was trying to run the sample file of climpact for the historical and I got the error error in create.indices.from.files(infiles, outdir, file.template, author

Rank Biserial Correlation with r

I have a non-normal distribution and two variables: one ordinal and the other a binary categorical, both from same sample population. I've found out that rank b

Refer to the last column in R

I am trying to do some manipulation on the last column in a generic way. I found here on the forums this nice piece of code that returns the name of the last c

Get the rate of change by finding the change in price

UPDATE: I'm getting a strange result in the outcome. Occasionally, the earliest date of the result show after 2 or 3 etc times for example Item Kg Date_1 Price

export data frames to Excel via xlsx with conditional formatting

I want to export data frames to Excel and highlight cells according to certain rules. I don't think this answer to a similar question is correct. I think it is

How to combine formatter and color_tile functions in a table using formattable

I need to make a report with a table where a column will have a background and font colors depending on each row value. I have success using formatter or color_

Display long table with hiding records

I want to show table which can display n number of top records and n number of bottom records if the table is very long. df <- nycflights13::flights funct &

r Remove parts of column name after certain characters

I have a large data set with thousands of columns. The column names include various unwanted characters as follows: col1_3x_xxx col2_3y_xyz col3_3z_zyx I wou

Decrease the size of a graph in ggplot - R

I have two questions for this graph I did: The first, is how do I decrease the graph size?, I have tried with coord_fixed: ggplot(x, aes(fill=is_pass, y=pe

Add at risk table and 95% confidence intervals to adjusted survival curves using survminer package in r

I want to add at-risk table and 95% confidence intervals to adjusted survival curves. Something like survival curves below (Link). I saw some relevant code here

recursively split a dataframe with partykit::lmtree as a stump tree

I am trying to recursively split my data using a stump tree based on the lmtree function from the partykitlibrary. The idea is the following: [1] for each varia

R: Lack of cronbach's alpha information

I am trying to calculate Cronbach alpha for an index of 5 different survey question. They are scaled identically, 0-10. I have created a matrix with the variabl

Is it possible to have one function to download various ggplot plots?

My shiny app generates a number of useful graphs. I would like to allow the user to download the graphs in various formats. I have done this before for a single

MCMCglmm gives very different results from lme4 - how to diagnose issue?

I am taking the plunge into Bayesian analysis for some new projects. I have some yes/no data, and three fixed effects and for the time being, I'm simply taking

replace default solve() by ginv

I want to replace solve() by ginv() in the mahanalobis function. Is there any way to force any functions in R to use ginv() instead of solve()?

Error: $ operator not defined for this S4 class

I'm trying to make a formula and I got the error: $ operator not defined for this S4 class with R. First of all, what is a S4 class? What am I doing wrong

Difference between double- precision data type and numeric data type

What is the difference between double-precision data type and numeric data type in R programming?

Error in modelinc[15] = dim(variance.model$external.regressors)[2] : replacement has length zero

I am trying to fit a GARCH model with external regressors. My external regressors are composed of production data and a dummy that covers a certain period (07-2

ggplot holes in stacked area chart

Here is a link to my data. I use the following code: #read in data data = read.csv("ggplot_data.csv") #order by group then year data = arrange(data, group, y