plyr Questions
5
Solved
I have a data frame that looks like this:
#df
ID DRUG FED AUC0t Tmax Cmax
1 1 0 100 5 20
2 1 1 200 6 25
3 0 1 NA 2 30
4 0 0 150 6 65
Ans so on. I want to summarize some statistics on AUC, Tmax ...
Petula asked 14/11, 2014 at 6:0
6
Solved
I want to count the number of occurrences of a factor in a data frame. For example, to count the number of events of a given type in the code below:
library(plyr)
events <- data.frame(type = c(...
4
Solved
My guess is that this is easy using ddply but Im still a newbie at R and can't get my head around it.
I have a data.frame looking like this
txt <- "label var1 var2 var3 var4 var5 var6 var7
la...
3
Solved
I would like to take a set of intervals, possibly overlapping, within categories of an identifier and create new intervals that are either exactly overlapping (ie same start/end values) or complete...
Horrific asked 24/4, 2019 at 18:28
2
Solved
I am trying to install R’s plyr package. Here is the error message:
* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/opt/R-3...
7
I have a data frame with about 200 columns, out of them I want to group the table by first 10 or so which are factors and sum the rest of the columns.
I have list of all the column names which I w...
Mccaffrey asked 21/11, 2011 at 13:38
3
Solved
I'm trying to repeat the elements of vector a, b number of times. That is, a="abc" should be "aabbcc" if y = 2.
Why doesn't either of the following code examples work?
sapply(a, function (x) rep(...
2
Solved
I have 2 scripts that doing exactly the same.
But one script is producing 3 RData files that weights 82.7 KB, and the other script creating 3 RData files that weights 120 KB.
the first one is wi...
1
Solved
If I have the following data:
D = tibble::tribble(
~firm, ~ind, ~var1_1, ~var1_2, ~op2_1, ~op2_2,
"A", 1, 10, 11, 11, 12,
"A", 2, 12, 13, 13, 14,
"B", 1, 14, 15, 15, 16,
"B", 2, 16, 17, 17, 1...
4
Solved
I'm trying to learn R and there are a few things I've done for 10+ years in SAS that I cannot quite figure out the best way to do in R. Take this data:
id class t count desired
-- ----- --------...
3
Solved
I have the following data frame.
date id value
2012-01-01 1 0.3
2012-01-01 2 0.5
2012-01-01 3 0.2
2012-01-01 4 0.8
2012-01-01 5 0.2
2012-01-01 6 0.8
2012-01-01 7 0.1
2012-01-01 8 0.4
2012-01-01 9 ...
6
Solved
edit
The question was originally asked for data.table. A solution with any package would be interesting.
I am a little stuck with a particular variation of a more general problem. I have panel d...
Responsive asked 8/12, 2014 at 23:13
5
Solved
I am trying to convert the following format:
mydata <- data.frame(movie = c("Titanic", "Departed"),
actor1 = c("Leo", "Jack"),
actor2 = c("Kate", "Leo"))
movie actor1 actor2
1 Titanic Leo...
3
Solved
I am (probably) NOT referring to the "all other variables" meaning like var1~. here.
I was pointed to plyr once again and looked into mlplyand wondered why parameters are defined with leading dot ...
Damp asked 23/9, 2011 at 8:51
6
Solved
I have a data.frame that looks like this.
x a 1
x b 2
x c 3
y a 3
y b 3
y c 2
I want this in matrix form so I can feed it to heatmap to make a plot. The result should look something ...
4
Solved
Apply function table() to each column of a data.frame using dplyr
I often apply the table-function on each column of a data frame using plyr, like this:
library(plyr)
ldply( mtcars, function(x) d...
6
Solved
I would like to subset a data frame for n rows, which are grouped by a variable and are sorted descending by another variable. This would be clear with an example:
d1 <- data.frame(Gender = c(...
Pellegrini asked 20/5, 2011 at 17:38
2
Solved
I'm doing some analysis something like this:
library(plyr)
input.files <- c("file1.txt", "file2.txt", "file3.txt")
input.data <- llply(input.files, load.file, .parallel=TRUE)
step.one.result...
Wham asked 27/3, 2012 at 18:54
4
Solved
I have a data.frame where I'd like to remove entire groups if any of their members meets a condition.
In this first example, if the values are numbers and the condition is NA the code below works.
...
3
Solved
R Version 2.11.1 32-bit on Windows 7
I got two data sets: data_A and data_B:
data_A
USER_A USER_B ACTION
1 11 0.3
1 13 0.25
1 16 0.63
1 17 0.26
2 11 0.14
2 14 0.28
data_B
USER_A USER_B ACTION...
4
Solved
When using summarise with plyr's ddply function, empty categories are dropped by default. You can change this behavior by adding .drop = FALSE. However, this doesn't work when using summarise with ...
4
Solved
I am trying to obtain counts of each combination of levels of two variables, "week" and "id". I'd like the result to have "id" as rows, and "week" as columns, and the counts as the values.
Example...
6
Solved
I would like to select a row with maximum value in each group with dplyr.
Firstly I generate some random data to show my question
set.seed(1)
df <- expand.grid(list(A = 1:5, B = 1:5, C =...
Golfer asked 16/6, 2014 at 6:0
3
Solved
As a guideline I prefer apply functions on elements of a list using lapply or *ply (from plyr) rather than explicitly iterating through them. However, this works well when I have to process one lis...
3
Solved
This is probably a silly question, but I have read through Crawley's chapter on dataframes and scoured the internet and haven't yet been able to make anything work.
Here is a sample dataset simila...
Escharotic asked 3/5, 2012 at 3:16
© 2022 - 2024 — McMap. All rights reserved.