All Questions
9,210
questions
1
vote
1
answer
27
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
39
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
40
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
41
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 ...
0
votes
1
answer
44
views
How do I document complex function parameters in my own R package?
I am currently transforming my big R-Project into a package and I am trying to document it properly with enough examples and tests.
Some of my functions use parameters that are of a complex type like ...
1
vote
1
answer
29
views
bootstrap for model estimation with a created function
I am trying to make comparisons between treatments of my heritability estimates, values that I calculated with the following function:
data <-
data.frame(treatment=c("control", "...
2
votes
2
answers
30
views
Wide format data by pasting two sets of variables into one in R
I've tried to wide-format my DATA into my Desired_output using:
pivot_wider(DATA, names_from = Year, values_from = c(Type, Language))
without success. Is there a way to achieve my Desired_output?
...
0
votes
0
answers
12
views
Custom function to create sequential index variable in longitudinal data [duplicate]
This is probably very basic but I'm having a hard time finding an answer to my question in existing posts. I'm working with longitudinal data and need to create a sequential index variable that ...
1
vote
1
answer
36
views
Problem using select and filter when used in purrr::compose with purrr::partial in R
I'm trying to compose a set of partially applied functions using the purrr package. I'm noticing that I can do this with some functions but not others and I would like to know why (or what am I ...