Category "r"

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

Algorithm name in nlminb's PORT routines? [duplicate]

I'm using gnls function of nlme package to fit a curve. When I try to know what optimizer it was using, I was directed to nlminb function docu

Using dplyr to conditionally replace values in a column

I have an example data set with a column that reads somewhat like this: Candy Sanitizer Candy Water Cake Candy Ice Cream Gum Candy Coffee What I'd like to do

Using dplyr to conditionally replace values in a column

I have an example data set with a column that reads somewhat like this: Candy Sanitizer Candy Water Cake Candy Ice Cream Gum Candy Coffee What I'd like to do

Excel Cell Coloring using xlsx

Initial code: Lets assume we're using this command to create the dummy data: Data <- data.frame( X = paste(c(sample(1:10),sample(1:10)), collapse=";")

Creating a symmetric matrix in R

I have a matrix in R that is supposed to be symmetric, however, due to machine precision the matrix is never symmetric (the values differ by around 10^-16). Si

Barplot of summed values per category in R - currently plotting highest value only

I have a data set (named data) as follows site year month supplier FG total 540853 2015 1 790122 T25 3 540853 2015 3 7901

Calculate percentage within a subgroup in R

I am new to R and I am struggling with calculating the percentage of certain observations in a data frame. My data frame is coming from an excel table with many

Add text to R mosaicplot

I am trying to add text to individual tiles within a mosaicplot built using the base R function. However, I cant determine the coordinates of each center tile.

Determining when there is a decrease in the rate of change

I have created plots of heart rate recovery against time, using ggplot2. I have noticed them seem to have an inflection point where the heart rate levels off. I

Rtools with R portable

Hello Fellow enthusiasts, I use portable version of R for a project in a computer where I have no administrator privilege. I use zip function to encrypt & z

How do I limit the range of the viridis colour scale?

I have two sets of data, which I want to present using a heat map with the viridis color scale. For the first data set, my values range from 0 to 1.2 and I can

Does markercluster work together with leafletProxy() and option iconCreateFunction?

Am I doing something wrong, or why does the below example not work? I am trying to make leaflet markercluster plugin work with leafletProxy() in an R Shiny app,

Making an adjusted Kaplan Meier Surve Curve

I am doing a study looking at the long-term survival of patients admitted to an Intensive Care Unit. I have done a multivariate Cox regression to describe the a

apply box plots to multiple variables

I have this dataframe: set.seed(50) data <- data.frame(age=c(rep("juv", 10), rep("ad", 10)), sex=c(rep("m", 10), rep("f", 10)),