All Questions
61
questions
2
votes
3
answers
84
views
How to reshape long format data and count the values
I think this is a basic question, but it seems to be frustrating me...
I am using R and have data in long format; a data.frame with each value a string. I want to produce a summary table of the counts ...
0
votes
1
answer
49
views
transforming complex wide data to long in R, multiple year columns, corresponding values, UTF-8 issues (Duplicate?)
What I have is a wide format, that need to get reshaped and sorted differently. I have 10 columns in total for year, one same year for all rows, different year per column. These I would like to merge ...
2
votes
1
answer
84
views
Looping to get outliers data using dplyr in R
I have task to find outliers data, here it is my data:
# combination 1
datex <- c(rep("07/01/2021", 24), rep("07/02/2021", 24), rep("07/03/2021", 24), rep("07/04/...
1
vote
3
answers
46
views
Looping to delete conditional combination in dataframe using dplyr in R
Here it is my data
datex <- c(rep("2021-01-18", 61), rep("2021-01-19", 139))
hourx <- c(0,1,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,16,10,0,1,1,2,2,3,3,...
1
vote
1
answer
215
views
Convert Long Form data to three dimensional array in R
I have some data that looks like this:
> ExampleData
# A tibble: 14,833 x 4
CountryCode Flow FuelType Value
<fct> <fct> <fct> <dbl>
1 ALB ...
0
votes
1
answer
48
views
aggregating rows by id into multiple columns where number of rows per id varies (R)
My question got shut down due to being a duplicate since i did not explain myself well. Here in is the problem which has since thwarted my use of gather-unite-spread of dplyr. Usually this is a simple ...
0
votes
1
answer
192
views
Using cast() or ddply() to summarise the mean for two continuous variables in one dataframe
The data (below) has two columns named "Date" and "Independent Variable (IV)" containing factors, plus two extra columns called "Independent_value" and "Sapflow" containing continuous values.
...
0
votes
1
answer
32
views
Transforming key values from one data frame into columns of another data frame
I have searched around but could not find a particular answer to my question.
Suppose I have two data frames:
df1 <- data.frame(name = c('a', 'b', 'c'),
t1 = c(3, 25, 400),
...
0
votes
1
answer
386
views
R: How to substract values depending on factor levels on multiple columns?
I have a dataframe looking like this (using reshape2::cast and merge):
time days treatment extrafactor1 extrafactor2 extrafactor3 animal1 animal2 animal3
10 83 control B water 2 2 67 40
...
0
votes
1
answer
638
views
Counting frequency of factor levels from attributes in a second data.frame
I'm trying to count the frequency o factor levels but using the information available in two different matrices.
The first one (I called, below, as df1) is the abundance of certain species (coded as "...
0
votes
1
answer
33
views
Getting counts within Time range
My data is a basically a purchase list with Products , dates and customer ID . A sample data can be created as below -
custId=c('A','A','B','C','A','D','E','F','B','C','F')
ProductPurchase=c('Milk','...
1
vote
1
answer
163
views
Aggregating factor level counts - by factor
I have been trying to make a table displaying the counts of factor levels by another factor. For this, I looked on dozens of pages, questions... trying to use functions in some packages (dplyr, ...
1
vote
2
answers
2k
views
R - get all pairs of values with same ID
I'm having trouble manipulating data in the way I need to. Take the following sample data frame:
df <- data.frame(id=factor(c(1,1,1,2,2,3)), person=c('P1','P2','P3','P4','P1','P3'))
id person
1 ...
1
vote
1
answer
1k
views
How to combine columns in a data frame so that they overlap in R?
Basically, I have data from a between subjects study design that looks like this:
> head(have, 3)
A B C
1 b
2 a
3 c
...
7
votes
3
answers
167
views
Reshaping a Table in R - Better Approach?
I have a data frame of factors called questions
q1 q2 q3
A A B
C A A
A B C
That I want to reshape into
question answer freq
1 A 2
1 B 0
1 C 1
2 A ...