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

Retain value from nested for loop

So basically I am trying the following loop:rawData = read.csv(file = "SampleData.csv") companySplit = split(rawData, rawData$Company) NameOfCompany <- numeric() DateOfOrder <- character()...

View Article


R Standardized Precipitation Index .nc file

I'm trying to calculate the SPI from CHIRPS monthly mean precipitation data, because it's too large I cut it down to my area of interest and here it is:...

View Article


Repeat each row of data.frame the number of times specified in a column

df <- data.frame(var1 = c('a', 'b', 'c'), var2 = c('d', 'e', 'f'), freq = 1:3) What is the simplest way to expand each row the first two columns of the data.frame above, so that each row is repeated...

View Article

R: compute the bootstrap estimate using rms:bootcov on caret model and glm model

How do I compute the bootstrap estimate for my regression coefficients using the function bootcov from the package rms? I tried the below with sample dataset but got an error:library(mlbench)...

View Article

Image may be NSFW.
Clik here to view.

How to add points to lines with ggplot2 in R when using ggplot(df)

I am always plotting data.frames.The style that is fairly easy to use is ggplot(df)+... since one can simply add more geom_lines for additional lines without reshaping/pivoting/melting the source data...

View Article


Plot a density differential semantic dataset

I'm coming here because after hours of research and failed trials, i dont know what to do next. I've a database (opened via dyplr with the open_excel command) that looks like the one below (but more...

View Article

Issue with Shiny Input

I'm trying to make an app that changes based on the political question and demographics selected. I'm running into an issue with how I call my inputs, I think. Here is a dput version of my data frame...

View Article

ggsurvplot:Error in parse(text = paste0("list(", paste(varnames, collapse =...

I am trying to plot a KM curve using ggsurvplot. R throws an "unexpected symbol" , exception when I use a string something like this as a variable "RP11-181G12.2" (please see the code). There seems no...

View Article


How to correctly include a hash value in the model?

I come across a set of hashed values ​​for one categorical variable in my data frame.Like that > hashed_data[1,2] [1] 045344e350db36e5aa27d44707026c693b6fbc513348497de3befaafb25df8c1 4112 Levels:...

View Article


Image may be NSFW.
Clik here to view.

Segmented linear regression with discontinuous data

I have a dataset that looks to be piecewise linear. I would like to perform a segmented linear regression in R. The issue is that there is a discontinuity at the breakpoint. By using some pieces of...

View Article

How to use the dplyr `distinct()` function on a SQL database?

I'm getting the following error when I apply a specific dplyr function distinct() to a table in a SQL database.tbl(P0_MAU_3N_V, "D_QNO_MTYPE") %>% distinct() #> Error: <SQL> 'SELECT...

View Article

R: convert elements of list into expression from function input

I am writing a function, where the inputs are arguments and name of another function. I would like to convert these arguments and function name into an unevaluated expression or call. For example, if...

View Article

Image may be NSFW.
Clik here to view.

Convert List and Dataframe to a DATAFRAME

I have a DF called "billing". <?xml version="1.0" encoding="ISO-8859-1" ?> <test:TASS xmlns="http://www.vvv.com/schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...

View Article


The most efficient and fastest way to categorise data in dataframes and save...

I have 1000 dataframes importing from 1000 different txt files as below. Surname Name Type Age Dept Gold Craige 1 24 100 Goodwin Madison 1 41 49 Young Emma 2 31 34 Young Rose 2 26 3 Young Brad 2 42 76...

View Article

Image may be NSFW.
Clik here to view.

Code needed to convert call variable to two separate variables

I have a file exported from a PCR plate software. I need a code to convert the call variable ("Allele 1, Allele 2, Heterozygote and No Call") to the two separate variable ("G1-2 1" and "G1-2...

View Article


Image may be NSFW.
Clik here to view.

How to replace a variable without interfere with the variable just being...

I have a survey data as shown in this screenshot, some of the items are revised graded, therefore I need to replace the revised graded item's value: 1 to 5, 2 to 4 However, after changing 1 to 5, I...

View Article

Paste a string of variable names into function in R

I've got two strings of variable names that looks like this> names_a = paste(paste0('a', seq(0,6,1)), collapse = ", ") > names_a [1] "a0, a1, a2, a3, a4, a5, a6"> names_b = paste(paste0('b',...

View Article


Image may be NSFW.
Clik here to view.

Propensity Score Matching and subset the data by using a weighting factor in R

I am doing Propensity Score Matching and want to subset the data for treatment and control but by using weights. I have 5 variables: ID, treatment(yes/No), Outcome(Yes/No), Age and "Weights". I was...

View Article

Return name of the row with its maximum value from certain column

I am writing a function that has arguments of utensil but actually returns the name of the brand that sells in maximum cost using data frame below: utensil cost brand 1 pen 1 a 2 pencil 2 b 3 pen 5 c 4...

View Article

R function to download XLS files using URL

After receiving an answer from Montgomery Clift in another post (see here), I tried writing a function in order to loop through multiple days within a month span to collect data from Baseball...

View Article
Browsing all 201839 articles
Browse latest View live


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