All Questions
1,109
questions
1
vote
2
answers
63
views
getting the latest date for a a duplicated item in r [closed]
I have the following dataset (below).
I am trying to get the latest SEnd value for each individual tag (see Desired output) where I have the Tag, Owner and the latest SEnd date only. Essentially I am ...
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
1
answer
59
views
Conditional filtering of dataframe in R
I wonder how to dplyr::filter() my DATA to catch the rows for IDs whose Language value when 'Type!=5F' and when 'Type==5F' changes from other languages to "English"?
For example, ID==1 has ...
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
1
answer
77
views
Order columns based of suffix condition in R
The name of my variables looks like this:
df <- data.frame(var_NA = 1:10, var = 11:20, var_Level = 21:30, var_Total = 31:40)
Except I have lots of variables. The key feature is that for every &...
0
votes
1
answer
55
views
Color code values conditionally in xlsx produced by openxlsx package in R in a loop
My reproducible code below writes a super small .xlsx file that has two sheets.
I was wondering if there might be a way to color-code values of 3 in red, 4 in orange, and 5 in green anywhere in the ...
1
vote
3
answers
82
views
Remove elements with same prefix from a string in a column
and thank you for being part of an awesome community of learners and explorers! :) I have an issue with removing elements from a character column. This answer pointed me in a correct direction (split ...
1
vote
1
answer
98
views
minimum number of unique values by row
I have a tibble with 10k rows and 10 columns of different ID strings. I am attempting to write a function similar to dplyr::distinct() which has a min_distinct numeric variable that would be a ...
1
vote
1
answer
25
views
How to merge two columns when long-formatting data frame in R
Below, I'm can use tidyr::pivot_longer(DATA, -InstNm, names_sep = "_", names_to = c("Indicator", ".value")) to get very close to my Desired_output.
But I wonder how I can ...
0
votes
1
answer
26
views
Long-formatting several sets of similarly named of variables in an R data.frame
I have several sets of columns whose names are related. For example, in the toy DATA below, one set of variables start with OTE_ and another set of variables start with RAE_.
In my actual data, I have ...
0
votes
2
answers
62
views
Reformatting a dataframe into wide format in R
I was 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 ...
1
vote
1
answer
54
views
How to compute which values and how many values of a given variable satisfy a condition for another variable?
I have a dataframe of the form
# Minimum example
> data.frame(variable = c("A", "B", "C", "A", "B", "C"),
+ quantity1 = c(2,4,...
0
votes
1
answer
32
views
Replace wrong values in a dataframe using a dataframe of correct values [duplicate]
In my DATA below, some Names are misspelled. I've determined the Unique_Names and correspondingly created the Correct_Unique_Names for those unique names.
But I wonder how to insert my ...
1
vote
1
answer
75
views
Create list of unique dataset combinations of duplicate removal
I have a dataset with duplicates across groups.
For instance:
dat <- data.frame(
group = c("A", "A", "A", "B", "B", "C","C",&...
2
votes
2
answers
64
views
Calculate the mean of each column and exlude rows
I have data contain 1000 column and 80 rows each five rows correspond to a group (the first column is class column) i want to calculate the mean of each group for all the numerical columns then i want ...