Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 206180 articles
Browse latest View live

Pivot by group for unequal data size

I have the following DF:DF = structure(list(ID = c(21785L, 21785L, 21785L), V1 = c(0.828273303, 6.404590021, 0.775568448), V2 = c(2L, 3L, 2L), V3 = c(NA, 1.122899914, 0.850113234), V4 = c(NA, 4L, 3L),...

View Article


difference between working on R directly working under...

I was just reading the article https://spark.rstudio.com/ But I am not sure what is the difference between working on R directly working under install.packages("sparklyr") packagesCould you let me...

View Article


Text to be written must be a length-one character vector

After installing the new version of shiny (1.4.0) package, I face a strange error message > Warning: Error in writeImpl: Text to be written must be a length-one > character vector [No stack trace...

View Article

Optimise R code (SQL read and write) for quicker performace

The below double nested loop runs across 850 branches, 2 service points and 25 specific needs. As it stands the total estimated run time is 70 hours. Please help me optimise so this runs quicker?Code...

View Article

return ID's of unique combinations

My data table has the following formatID Var1 Var2 Var3 ... 1_1 0 0 1 ... 1_2 1 1 0 ... 1_3 0 0 1 ... ... ... ... ... ... I want to extract the ID's from unique combinations (Varcolumns). Getting the...

View Article


Counting the number of specific integers per column in an R matrix

I have a matrix (10 x 100) where I need to count the number of each integer per column so I have a final matrix that is (3 x 100). Counts for 0, 1, and 2 per column. I think the apply function will be...

View Article

Image may be NSFW.
Clik here to view.

How to calculate a particular index in R

Hello everyone, I need your help for the calculation of this expression. I have a dataframe with income streams (made of 5 "t" periods) from different years. What I need is a command to make R...

View Article

cor and cov2cor different results with use = pairwise.complete.obs

Running: cor(x, use = "pairwise.complete.obs")` vs runningc <- cov(x, use = "pairwise.complete.obs") cov2cor(c) give different results. Anyone know why and which one gives correct results? Both...

View Article


Error in if() missing value where TRUE/FALSE needed, but there's actually a...

I have this error in R. I'm working with a database, where my NA values are called "# VALOR N/A", so I did a simple function to see how many of this values I have. estavencido <- function(a){ count...

View Article


set missing values for multiple labelled variables

How to I set missing values for multiple labelled vectors in a data frame. I am working with a survey dataset from spss. I am dealing with about 20 different variables, with the same missing values. So...

View Article

Dynamic naming of download filename from DataTable buttons extension in R shiny

I have: library(shiny) library(DT) ui <- fluidPage( h2("Explorer"), tabPanel(h3("Inspector"), p("Overview of data for a particular sample."), selectInput(inputId = "sample", label = h3("Select...

View Article

Image may be NSFW.
Clik here to view.

geom_dumbbell chart with scales for line and dots

I'm trying to make a dumbbell chart with additional information about change (green/red) and significance of the change (vol) and add an additional legend for the dots at the end of the dumbbells. My...

View Article

parse dates from multiple columns with NAs and dates hidden in text

I have a data.frame with dates distributed across columns and in a messy format: the year column contains years and NAs, the column date_old contains the format Month DD or DD (or a date duration) or...

View Article


Convert frequency vector to logical matrix

I would like to convert a frequency vector (i.e. the colSums() of a matrix) to one of the possible versions of the original logical matrix in R. Something like: s <- c(1,2,3) # Some function of s #...

View Article

Creating a vector of numbers based on letters

So, this is the question:"Create a function that given one word, return the position of word’s letters on letters vector. For example, if the word is ‘abba’, the function will return 1 2 2 1."What I...

View Article


Suppress ggpairs messages when generating plot

ggpairs prints out a progress bar and estimated remaining time while generating plots, which is nice when used interactively since some of the computations can take a few seconds. But when making...

View Article

beamer rmarkdown presentation unable to knit pdf file instead knit html...

I have a beamer rmarkdown file for preparing PDF presentation as teaching material. However, when I click knit with pdf, the output is displayed in html document, instead of beamer_presentation (pdf)....

View Article


Error in R Code if called in a function (multcompleters, strsplit:...

I would like to generate labels from a Tukey test inside a function. There it throws an error whereas if I call the code not inside a function it works absolutely fine.Other threads say the solution is...

View Article

Populating NAs and correcting data based on sequence within a sequence

I have a data frame with two issues that I am trying to correct. Here is a toy example. require(data.table) tempdt <-...

View Article

how to properly plot igraph's graphs to make them comparable?

So, as in the title, I need to be able to plot some igraph's graphs and be able to compare them. To do so I believed that passing coordinates and then plotting them was enough. Then I found out that...

View Article
Browsing all 206180 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>