All Questions
9,214
questions
-1
votes
0
answers
37
views
Exact same line of code not working between 2 PCs [closed]
On my home PC with R4.4.0
avg_demand_per_yearday <- aggregate(demand ~ yearday, df, 'mean')
it works as expexted. On my work machine with R4.4.1 an error occurs
Error in UseMethod("aggregate&...
0
votes
0
answers
18
views
Multilevelannotation function error in xMSannotator package. Error in hclust() NA/NaN/Inf
I have been trying to use the multilevelannotation function within the xMSannotator package to process mass spectrometry data. This package can be accessed through using:
install.packages(c('...
1
vote
1
answer
75
views
Finding largest root of a function in R
I have a function that is data generated and not a polynomial. For most data, it only has one root, but it can also have two roots, as in in the following plot:
uniroot() tends to fail because the ...
3
votes
2
answers
78
views
How to find the file that contains the code of an R function?
I have R 4.3.2 installed on my Windows PC. I downloaded it from https://cran.r-project.org/bin/windows/base/. I have not downloaded the .tar.gz file with the R source code.
I know how to view the code ...
0
votes
1
answer
28
views
Dynamically perform calculation down column in R
I have data that looks like this:
library(tidyverse)
df<-tibble(date = as.Date("2024-07-01"), starting_n = 100, growth_rate = 0.05)%>%
bind_rows(
tibble(date = seq.Date(as.Date("...
1
vote
1
answer
35
views
Pass element form character vector in loop to function and use in assign
I have a function that chooses, reads and formats Excel reports from Workday, and produces data.frames. I've simplified for purposes of begging for your help. :-)
In the function, I pass a parameter ...
0
votes
0
answers
40
views
i'm having a problem using Survey package in R, i coded a prop an cv function but its returning different results for the same svytotal results
library(survey)
wrap.table3 = function(SVYres, Niv1, Niv2, Niv3) {
Tabela = array(SVYres, dim = c(length(Niv1), length(Niv2), length(Niv3)))
TabCV = array(cv(SVYres), dim = c(...
0
votes
0
answers
29
views
Can you use an argument in a function to specify ggplot2 "fill" parameter? [duplicate]
I want to be able to define the fill= as one of the arguments in a function. First, here is what my tibble looks like:
> x
# A tibble: 16 × 6
popA popB genome chr1 chr2 chr3
<chr&...
0
votes
1
answer
30
views
How to vectorize a custom function to use with mutate() and case_when() in R?
I'm trying to run a custom function, QA2Char, to iterate down all the rows of a specific column in my dataframe and then append the output as a new column.
QA2Char takes a decimal/integer and outputs ...
0
votes
0
answers
23
views
How to apply a conditional filter to certain variables in tableby function?
I have the following dataframe with tableby.control function and its parameters as follows :
---
title: "Title"
subtitle: "Descriptive analysis"
author:
- name: AA
date: last-...
0
votes
1
answer
41
views
How to modify the function in Table1 package to get a p value for ANOVA
I am using R markdown and trying to simulate the vignette for table1 package on the following link and using the melanoma2 data set.
The link: Using the table1 Package to Create HTML Tables of ...
0
votes
0
answers
42
views
How to call an R function conditional on a printed string?
I'm using the tesseract package to mine text from a very large (>500K) set of scanned documents. Some of the documents are rotated the wrong way, so when I call tesseract::ocr on those, the ...
0
votes
1
answer
52
views
Is there a way to loop through a custom function to generate multiple ggplot2 graphs in R?
I created a custom function in R to standardize multiple graphs. The function is essentially as follows:
CustomFunction <- function(SpecificEvent) {
ggplot()+
geom_point(data = df[df$...
1
vote
1
answer
24
views
Long to wide format based on variable suffixes in tidyverse in R
I wonder if there is a way for my DATA to be reformatted to my Desired_output below?
Specifically, for each unique study, we stick together a pair of pre and postNUMBER together, separately for T and ...
1
vote
2
answers
42
views
How to get column-wise summary statistics with missing codes?
I have written a custom function ord_table() to extract summary statistics from a series of databases. To get those summary statistics, I have to filter out missing data codes (all codes are large ...