Category "r"

How to make function aliases?

I am trying to create aliases for functions in R. For example, to get the length of a vector in R: length(the_vector) #returns the length of the vector I w

plotting geom_text() with free scale facet_wrap

I would like to plot geom_text() in a facet_wrap with scale = free. I tried to use geom_blank() or, set each height on each graph, but it was not successful. Wo

Matplotlib in Rmarkdown/RStudio fails when calling LaTeX on `\$` with Anaconda

Problem description I am having to use Anaconda on Windows, and am trying to write an RMarkdown document, knitted into a pdf, where within the RMarkdown I am us

Why is SparkR-dropna not giving me the desired output?

I have applied the following code on airquality dataset available in R, which has some missing values. I want to omit the rows which has NAs library(SparkR) Sys

Is there a function for not-a-knot cubic splines?

I need to use the "not-a-knot" cubic spline for interpolation in my R scripts. Although there are some R packages for splines, none of them seem to consider th

Density plot based on time of the day

I've the following dataset: https://app.box.com/s/au58xaw60r1hyeek5cua6q20byumgvmj I want to create a density plot based on the time of the day. Here is what

emacs ess-indent-or-complete sends newline to R process

Occasionally, for reasons I can not determine, ess-indent-or-complete sends an input to the R console. In other words, I will be typing something, hit tab to au

Uploading zip with multiple files into a shiny application

I am trying to upload a zip file through my shiny app that contains a bunch of xml files in it, and then process them. My code looks something like this: libra

R - Data.table - Using variable column names in RHS operations

How do I use variable column names on the RHS of := operations? For example, given this data.table "dt", I'd like to create two new columns, "first_y" and "firs

Predict values in place of NA by using the original data frame?

I have a dataset and the row which I need has an NA value. If I use na.omit, the rows will be omitted; however, I need the row. Hence I need to predict a value

Combination of all pairs of rows using R

Here is my dataset: data <- read.table(header = TRUE, text = " group index group_index x y z a 1 a1 12 13 14 a 2 a2

R how to group part of overlapped values among rows?

I have a data frame that some rows that need to be further grouped by some of the overlapped values among rows col1, col2 a1, 2;3 a2, 2 a3, 3;4 a4, 4 a

How to connect across multiple consecutive missing data values using geom_line?

I have a similar problem to Q: Connecting across missing values with geom_line, but found the answers provided only connect the lines when there is one missing

bipartite graph for the yelp dataset rstudio

I am trying to produce a bipartite graph for a yelp sample dataset. If the user reviews one restaurant, one edge will connect this user and the restaurant, that

How to convert list of list into a dataframe with differential list structure

I applied machine learning algorithm with caret package (caretlist) to predict death in a cohort of patients according to multiple variables (e.g. age, gender,

How to fix the var(X) is now defunct

I used the following function to find standard error of variables. but when I run the same function now, it is not working. st.err <- function(x) { sd(

Removing Table entries using remove UI in Shiny

I am populating a table by using Insert UI elements. I also want to delete both table entries and the inserted panels by using the remove UI elements. I could

R/exams: Duplicated images in PDF files

When using several R/exams exercises with TikZ plots, I have no problems generating exams in HTML format or for Canvas. However, exactly the same exercises when

Use max page width using rmdformats?

I'm trying to use the entire page width when rendering an R markdown document using rmdformats::readthedown. First, you can see that it isn't a problem using on

Stripping mapping such as colour and line type from an existing ggplot2 object to re-do it

Within a Shiny application, I would like to provide users the option to select a regression method and then show the fit on their data on an existing ggplot2 gr