plyr Questions
3
Solved
I have a data.frame as below and I want to add a variable describing the longest consecutive count of 1 in the VALUE variable observed in the group (i.e. longest consecutive rows with 1 in VALUE pe...
Flourish asked 7/12, 2018 at 14:54
4
Solved
I am trying to transition some plyr code to dplyr, and getting stuck with the new functionality of rename() in dplyr. I'd like to be able to reuse a single rename() expression for a set of datasets...
2
Solved
I am using the package dplyr with R (same problem applies to plyr, too). When I call source("dply_problem.R") to the following code
library("dplyr")
df <- data.frame("A" = 1:6,
"B" = 7:12)
mu...
4
Solved
how can I do this calculation:
library(ddply)
quantile(baseball$ab)
0% 25% 50% 75% 100%
0 25 131 435 705
by groups, say by "team"? I want a data.frame with rownames "team" and column names "...
6
Solved
I am attempting to reproduce one of the examples in the dplyr package but am getting this error message. I am expecting to see a new column n produced with the frequency of each combination. What a...
Dorseydorsiferous asked 2/4, 2014 at 3:44
1
I would like some help coloring a ggplot2 histogram generated from summarized data in a data.frame.
The dataset I'm using is the [R] build in (USArrests) dataset.
I'm trying to adapt the solutio...
3
Solved
I have a dataframe with one factor column with two levels, and many numeric columns. I want to split the dataframe by the factor column and do t-test on the colunm pairs.
Using the example datase...
5
Solved
I have a data.table:
require(data.table)
set.seed(1)
data <- data.table(time = c(1:3, 1:4),
groups = c(rep(c("b", "a"), c(3, 4))),
value = rnorm(7))
data
# groups time va...
Insurable asked 10/10, 2014 at 4:33
2
Solved
I have a data frame and I am trying to convert class of each variable of dt based on col_type.
Find example below for more detail.
> dt
id <- c(1,2,3,4)
a <- c(1,4,5,6)
b <- as.chara...
Covenanter asked 27/3, 2018 at 16:58
5
Solved
I'm trying to efficiently implement a block bootstrap technique to get the distribution of regression coefficients. The main outline is as follows.
I have a panel data set, and say firm and year a...
Discretionary asked 12/8, 2012 at 4:50
2
Does anyone know how to keep rownames in the rbind.fill function.
library(plyr)
#creating data
a <- mtcars[ 1:5 , c("mpg","hp","gear") ]
b <- mtcars[ 6:10 , c("mpg","disp","gear") ]
#does ...
2
I am trying to rename a column with dplyr::rename() and R is returning this error that I am unable to find anywhere online.
Error: `new_name` = old_name must be a symbol or a string, not formula
...
1
Solved
Consider a standard grouped operation on a data.frame:
library(plyr)
library(doMC)
library(MASS) # for example
nc <- 12
registerDoMC(nc)
d <- data.frame(x = c("data", "more data"), g = c("...
Coati asked 1/12, 2017 at 16:42
1
Solved
I am trying to transfer from plyr to dplyr. However, I still can't seem to figure out how to call on own functions in a chained dplyr function.
I have a data frame with a factorised ID variable an...
1
Solved
5
Solved
I've got a data.table in R:
library(data.table)
set.seed(1)
DT = data.table(
group=sample(letters[1:2],100,replace=TRUE),
year=sample(2010:2012,100,replace=TRUE),
v=runif(100))
Aggregating t...
Cupellation asked 16/2, 2012 at 16:41
6
Solved
Example data:
set.seed(1)
df <- data.frame(years=sort(rep(2005:2010, 12)),
months=1:12,
value=c(rnorm(60),NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA))
head(df)
years months value
1 2005 1 -0.626...
Contort asked 15/8, 2012 at 15:5
3
Solved
A common display of spectroscopic data (intensity vs wavelength) is used below to compare the position of peaks in the data across multiple spectra. Assuming they all share a baseline at 0, it is c...
5
Solved
I am looking for a method to bind lm residuals to an input dataset. The method must add NA for missing residuals and the residuals should correspond to the proper row.
Sample data:
N <-...
Petuntse asked 2/12, 2012 at 19:6
4
I have a column in my datasets where time periods (Time) are integers ranging from a-b. Sometimes there might be missing time periods for any given group. I'd like to fill in those rows with NA. Be...
Pothead asked 3/5, 2012 at 20:37
4
Solved
I am relatively new to R, and trying to use ddply & summarise from the plyr package. This post almost, but not quite, answers my question. I could use some additional explanation/clarification....
3
Solved
I have a data.frame with several factors such as:
df<-data.frame(Var1=as.factor(sample(c("AB", "BC", "CD", "DE", "EF"), 1000, replace=TRUE)))
with
summary(df$Var1)
AB BC CD DE EF
209 195 1...
2
Test Case:
library(dplyr)
library(plyr)
library(dplyr)
mtcars%>%rename(x=gear)
This gives error.
Any help would be greatly appreciated.
1
Solved
I found an answer (now deleted) to this question, and I'm curious why it doesn't work.
Question is: return the row corresponding to the minimum value, by group.
So for example, given the dataset...
2
Solved
I have a script which requires both reshape and reshape2 libraries. I know this is poor practise, but I think plyr (or another library I am using) Vennerable is loading reshape and I have personall...
© 2022 - 2024 — McMap. All rights reserved.