Category "r"

How add a row of 0 to a dataframe

I have this dataframe in R mat <-structure(list(a = c(2, 5, 90, 77, 56), b = c(45, 78, 98, 55, 63), c = c(77, 85, 3, 22, 4), d = c(52, 68, 4, 25, 79), e = c

How do I make a more concise extraction from a character vector in R?

We use google calendar for reservations of several machines, and I am making graphs of the usage. I have a line to extract the titles of the calendars for plot

R: How to remove a part of string, which with a specific start and end, in a R dataframe?

I have a data frame like this: df = data.frame(order = c(1,2,3), info = c("an apple","a banana[12],","456[Ab]")) I want to clean up to remove the [] and conten

Predicting multinom model in R - NAs are not allowed in subscripted assignments

I'm having an issue with a recurring error in a multinomial model I'm trying to create. Specifically, the error occurs when trying to predict test data with the

How do I remove letters from numeric cells so that I can make the column entirely numeric? (R)

I've got a dataframe with a column full of pixel coordinates. I want to remove the 'px' from these values so that I can make the entire column numeric without i

Plotly not displaying the labs caption from ggplot

I have this code for making a ggplot, which works fine (MRE with a built-in dataset): mydata <- airquality avg <- mean(mydata$Wind) stde <- sd(mydata$W

Problem with regex (check string for certain repetitions)

I would like to check whether in a text there are a) three consonants in a row or b) four identical letters in a row. Can someone please help me with the regula

Adding a column of totals using dplyr in a dataframe

how would you add a column to this dataset showing the number of individuals of each species?. install.packages("ggplot") library(ggplot) library(ggplot2) star

For Loop in R to find duplicates in single vector WITHOUT built-in functions

I found this as an interview question and can't seem to work a solution. You can't use any built in R functions. x <- c(77, 12, 4, 8, 77, 2, 4, 12) answer &

minimum value in dataframe greater than 0 in R

I have a dataset with ~2500 columns in R, and I am trying to find the minimum value greater than zero from the entire data frame. Once I have found this number,

Adjust place of downloading buttons of a DT table in Shiny

please see this picture I have a DT table in the shiny. I added buttons for downloading the content of the table (Copy, CSV, Excel, PDF). But I would like to ch

Select set of columns so that each row has at least one non-NA entry

I have a large number of variables (columns), but each has missing values for some of the observations (rows). How can I get a set (or all sets) of columns so t

R : Loop to keep only one specific value

I have a dataset and I would like to keep the value in a column of this dataframe (test_masses) for the mass having the highest intensity for masses close to th

aggregate methods treat missing values (NA) differently

Here's a simple data frame with a missing value: M = data.frame( Name = c('name', 'name'), Col1 = c(NA, 1) , Col2 = c(1, 1)) # Name Col1 Col2 # 1 name NA

Error in asMethod(object): Cholmod error 'problem too large'

I have the following object Formal class 'dgCMatrix' [package "Matrix"] with 6 slots ..@ i : int [1:120671481] 0 2 3 6 10 13 21 22 25 36 ... ..@ p

Remove pattern that occurs outside of words

I am trying to remove pattern 'SO' from the end of a character vector. The issue I run into with the below code is that it will remove any sequence of 'SO' case

Docker image has error when running from R Studio

My Dockerfile contains the exact code as shown in the statworx website to build an image for a Shiny app. Whenever I run the following code however: # Base imag

SVM doesn't plot in R

I'm doing predictive analytics on R, and I executed a plot command with neither an error message nor an output. I'll reproduce my code from a stroke dataset. st

How do I create my own Oauth app for R script?

Hey im using the 'rgoogleads' library in R. https://github.com/selesnow/rgoogleads The problem im facing is that the app is able to access the googleads api fro

How can I pass function to formulas?

guys: I want to use systemfit to estimate a set of formulas which is composed by two parts,as the picture showing: there are four equations needed to be estima