plyr Questions

3

Solved

I like to write a function using ddply that outputs the summary statistics based on the name of two columns of data.frame mat. mat is a big data.frame with the name of columns "metric", "length"...
Nerine asked 19/4, 2011 at 10:0

2

Solved

I am trying to write some code which identifies the greatest two values for each row and provides their column number and value. df = data.frame( car = c (2,1,1,1,0), bus = c (0,2,0,1,0), walk = ...
Conceptualism asked 24/4, 2012 at 11:21

6

I am using the mtcars dataset. I want to find the number of records for a particular combination of data. Something very similar to the count(*) group by clause in SQL. ddply() from plyr is working...
Oxidate asked 31/3, 2014 at 17:11

6

Solved

I have a simulation that has a huge aggregate and combine step right in the middle. I prototyped this process using plyr's ddply() function which works great for a huge percentage of my needs. But ...
Decrepitude asked 10/9, 2010 at 14:39

4

Solved

I'm looking for something similar to bedtools subtract but with dataframes. For example, say I have the range as a dataframe here: Start End Value 0 100 P And I have another dataframe, which is so...
Heeler asked 23/2, 2023 at 21:29

5

Solved

I wonder whether there is a more straighforward way to calculate a certain type of variables than the approach i normally take.... The example below probably explains it best. I have a dataframe ...
Lankester asked 17/3, 2013 at 22:49

4

Solved

I have a data frame (datadf) with 3 columns, 'x', 'y, and z. Several 'x' values are missing (NA). 'y' and 'z' are non measured variables. x y z 153 a 1 163 b 1 NA d 1 123 a 2 145 e 2 NA c 2 NA b...
Sabella asked 17/9, 2015 at 19:51

4

Solved

I do know about the basics of combining a list of data frames into one as has been answered before. However, I am interested in smart ways to maintain row names. Suppose I have a list of data frame...
Abbe asked 30/6, 2015 at 13:47

9

Solved

Please consider the following: I recently 'discovered' the awesome plyr and dplyr packages and use those for analysing patient data that is available to me in a data frame. Such a data frame could...
Appendicectomy asked 19/1, 2018 at 14:10

5

Solved

This question is about a generic mechanism for converting any collection of non-cyclical homogeneous or heterogeneous data structures into a dataframe. This can be particularly useful when dealing ...
Clydeclydebank asked 19/7, 2012 at 3:39

3

Solved

for tidyverse users, dplyr is the new way to work with data. For users trying to avoid older package plyr, what is the equivalent function to rbind.fill in dplyr?
Prelude asked 9/6, 2017 at 18:20

7

Solved

This is more of a conceptual question, I do not have a specific problem. I am learning python for data analysis, but I am very familiar with R - one of the great things about R is plyr (and of cou...
Thor asked 12/11, 2014 at 2:55

5

Solved

I have a large data frame in which I am multiplying two columns together to get another column. At first I was running a for-loop, like so: for(i in 1:nrow(df)){ df$new_column[i] <- df$column1...
Autum asked 10/9, 2012 at 18:40

8

Solved

I'm going through Machine Learning for Hackers, and I am stuck at this line: from.weight <- ddply(priority.train, .(From.EMail), summarise, Freq = length(Subject)) Which generates the followi...
Sladen asked 4/1, 2013 at 7:40

3

Solved

I need to use group by in levels with ddply or aggregate if that's easier. I am not really sure how to do this as I need to use cumsum as my aggregate function. This is what my data looks like: le...
Selia asked 21/2, 2013 at 10:11

8

Solved

When working with plyr I often found it useful to use adply for scalar functions that I have to apply to each and every row. e.g. data(iris) library(plyr) head( adply(iris, 1, transform , Max.Le...
Zamora asked 16/2, 2014 at 23:21

6

Solved

I am having trouble figuring out the most elegant and flexible way to switch data from long format to wide format when I have more than one measure variable I want to bring along. For example, her...
Shape asked 14/5, 2012 at 18:33

3

Solved

I have a data frame that looks like this: Store Temperature Unemployment Sum_Sales 1 1 42.31 8.106 1643691 2 1 38.51 8.106 1641957 3 1 39.93 8.106 1611968 4 1 46.63 8.106 1409728 5 1 46.50 8.106 1...
Sapro asked 15/11, 2014 at 19:55

5

Solved

I'm a fan of the revalue function is plyr for substituting strings. It's simple and easy to remember. However, I've migrated new code to dplyr which doesn't appear to have a revalue function. What...
Wigfall asked 14/4, 2016 at 6:53

3

Solved

I have several R script files, such as f1.R, f2.R, f3.R. I have another function called AddSignal(signal), which adds a signal vector to a list. Functions in f1.R, f2.R, etc. may call this AddSign...
Saxena asked 14/2, 2012 at 6:32

3

Solved

I have a data frame, say payroll, like: payroll <- read.table(text=" AgencyName Rate PayBasis Status NumRate HousingAuthority $26,843.00 Annual Full-Time 26843.00 HousingAuthority $14,970.00 Pr...
Andres asked 11/6, 2013 at 21:2

4

Solved

I have a dataframe consisting of an ID, that is the same for each element in a group, two datetimes and the time interval between these two. One of the datetime objects is my relevant time marker. ...
Revisal asked 18/10, 2013 at 13:33

2

Solved

Given a list of dataframes l as follows: l <- list(a = data.frame(a_1 = c(11, 12), a_2 = c(13, 14)), b = data.frame(b_1 = c(21, 22), b_2 = c(23, 24)), c = data.frame(c_1 = c(31, 32), ...
Gentle asked 29/7, 2021 at 8:25

3

Solved

plyr::mapvalues can be used like this: mapvalues(mtcars$cyl, c(4, 6, 8), c("a", "b", "c")) But this doesn't work: mtcars %>% dplyr::select(cyl) %>% mapvalues(c(4, 6, 8), c("a", "b", "c"))...
Edbert asked 18/1, 2015 at 19:9

3

I am trying to figure out why I am getting an error message when using ddply. Example data: data<-data.frame(area=rep(c("VA","OC","ES"),each=4), sex=rep(c("Male","Female"),each=2,times=3), ...
Grecoroman asked 19/11, 2015 at 15:12

© 2022 - 2024 — McMap. All rights reserved.