Category "r"

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

Export data from R to Excel

I am writing codes to export database from R into Excel, I have been trying others codes including: write.table(ALBERTA1, "D:/ALBERTA1.txt", sep="\t") write.cs

unable to set xlim and ylim using min() and max() in ggplot

I am missing something crucial here and can't see it. Why does min and max not work to set the axis limits? mtcars %>% select(mpg, cyl, disp, wt) %>

Only two distinct values of probabilities in Logistic regression output

I am running a logistic regression in R and extracting the predicted probabilities for a test data of about 15,000 rows using predict(modelglm, test_data, type

How to plot histogram with 2 variables

I have the following dataset date region Nr_individuals Povertydecile 01-01-2019 1 80 2 01-01-2019

R markdown to PDF - Printing console output

I am working in RStudio for a course, and I want to write up my reports with R markdown. I would like to display certain console output in the pdf that will be

R SUR regression with systemfit gets error "LU computationally singular: ratio of extreme..." can work around but still concerned about error margins

Before I get into the problem, I want to acknowledge that I have seen that there is a previous question that has been answered, and it gave me an idea for a wor