similar to: Reshape with multiple aggregation functions

Displaying 20 results from an estimated 9000 matches similar to: "Reshape with multiple aggregation functions"

2012 Jan 18
1
Reshape with multiple aggregate functions
I have a data frame and I would like to reshape it to wide format while at the same time applying different aggregate functions to each column AND at times multiple aggregate functions: test1 = data.frame( id = c(rep('101',8),rep('102',8)), phase = rep(c('D','D','L','L'),4), day =
2013 Jan 11
2
Merging list of dataframes with reshape merge_all
Hi, I'd like to merge mutliple dataframes from a list of dataframes by some common columns. The approach for simply merging 2 dataframes is working with: merge(df1,df2,by=c("col1","col2","col3"),all=TRUE) For mutliple dataframes in a list I try to use the merge_all command from the package reshape. The documentation states that the command takes a list of
2008 Nov 06
3
Reshape a matrix
Dear R users, I have a matrix like A X 1 B Y 2 C Z 3 I want to reshape this matrix into this format X Y Z A 1 B 2 C 3 Thanks in advance for your help. Dinesh -- Dinesh Kumar Barupal Junior Specialist Metabolomics Fiehn Lab UCD Genome Center 451 East Health Science Drive GBSF Builidng University of California DAVIS 95616
2013 Jan 11
3
split & rbind (cast) dataframe
Hi, I would like to split dataframe based on one colum and want to connect the two dataframes by rows (like rbind). Here a small example: # The orgininal dataframe df1 <- data.frame(col1 = c("A","A","B","B"),col2 = c(1:4), col3 = c(1:4)) # The datafame how it could look like df2 <- data.frame(A.col2 = c(1,2), A.col3 = c(1,2), B.col2 = c(3,4), B.col3
2011 Mar 16
3
making dataframes
Dear all, I have a dataframe which looks like this (dummy): date<-c("jan", "feb", "mar", "apr", "may", "june", "july", "aug","sep","oct","nov","dec") col1<-c(8.2,5.4,4.3,4.1,3.1,2.5,1.1,4.5,3.2,1.9,7.8,6.5) col2<-c(3.1,2.3,4.7,6.9,7.5,1.1,3.6,8.5,7.5,2.5,4.1,2.3)
2013 Sep 09
1
windowing
Is there a package or a command that does window aggregation like select sum(col1) over (partition by col2, col3 order by col4 rows between unbounded preceding and current row) as sum1 from table1 ; the above is Netezza syntax, but Postgre has same capability. Stephen B [[alternative HTML version deleted]]
2010 Apr 19
1
Formatting data, adding column names, use reshape, a newbie question
Hi all, I'm an R novice. I have data that's already formatted as "molten" that reshape should be able to work with. For example, the following was read in with read.csv(filename,sep=" ", header=FALSE) V1 V2 V3 V4 V5 1 original book book.source1.txt 328900494 3039.525 2 original book book.source1.txt
2007 Jul 16
5
how do I draw such a barplot?
Hi, I cannot figure out how to draw a certain plot: could someone help me out? I have this data.frame from a survey my.data that looks like something like this: col1 col2 col3 col4 1 5 5 4 5 2 3 5 3 1 3 2 3 4 5 4 3 1 1 2 5 5 5 4 5 6 4 2 5 5 .... Each row represents a single questionnaire
2010 Jan 25
5
Data transformation
Dear all, I have a dataset that looks like this: x <- read.table(textConnection("col1 col2 3 1 2 2 4 7 8 6 5 10"), header=TRUE) I want to rewrite it as below: var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 1 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 0 0
2009 Oct 21
2
How to average subgroups in a dataframe? (not sure how to apply aggregate(..))
Dear all, Lets say I have the following data frame: > set.seed(1) > col1 <- c(rep('happy',9), rep('sad', 9)) > col2 <- rep(c(rep('alpha', 3), rep('beta', 3), rep('gamma', 3)),2) > dates <- as.Date(rep(c('2009-10-13', '2009-10-14', '2009-10-15'),6)) > score=rnorm(18, 10, 3) > df1<-data.frame(col1=col1,
2010 Jul 24
2
union data in column
Is there any function/way to merge/unite the following data GENEID col1 col2 col3 col4 G234064 1 0 0 0 G234064 1 0 0 0 G234064 1 0 0 0 G234064 0 1
2010 Jul 16
2
aggregate(...) with multiple functions
hi all - i'm just wondering what sort of code people write to essentially performa an aggregate call, but with different functions being applied to the various columns. for example, if i have a data frame x and would like to marginalize by a factor f for the rows, but apply mean() to col1 and median() to col2. if i wanted to apply mean() to both columns, i would call: aggregate(x, list(f),
2012 Aug 13
4
if else elseif for data frames
Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='L' else #chuch a warning? Note that col2 was not an existing column and was newly assigned for this
2006 Mar 16
3
Did I use "step" function correctly? (Is R's step() function reliable?)
Hi all, I put up an exhaustive model to use R's "step" function: ------------------------ mygam=gam(col1 ~ 1 + col2 + col3 + col4 + col2 ^ 2 + col3 ^ 2 + col4 ^ 2 + col2 ^ 3 + col3 ^ 3 + col4 ^ 3 + s(col2, 1) + s(col3, 1) + s(col4, 1) + s(col2, 2) + s(col3, 2) + s(col4, 2) + s(col2, 3) + s(col3, 3) + s(col4, 3) + s(col2, 4) + s(col3, 4) + s(col4, 4) + s(col2, 5) + s(col3,
2017 Aug 23
2
Comparing 2 dale columns
Dear R fellows, I created a new column Date_flag to compare the dates of COL1 and COL2 using the code below. But it showed that 5/1/15 is greater than 6/1/2014 and 5/1/2015 greater than 7/1/2014 despite the year is greater. How do I fix that? I did try to format as %y/%m/%d but it does not fix that. data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) COL1 COL2 6/1/14
2018 Feb 25
3
include
Thank you Jim, I read the data as you suggested but I could not find K1 in col1. rbind(preval,mydat) Col1 Col2 col3 1 <NA> <NA> <NA> 2 X1 <NA> <NA> 3 Y1 <NA> <NA> 4 K2 <NA> <NA> 5 W1 <NA> <NA> 6 Z1 K1 K2 7 Z2 <NA> <NA> 8 Z3 X1 <NA> 9 Z4 Y1 W1 On Sat, Feb 24, 2018 at 6:18 PM, Jim
2018 Feb 25
0
include
Hi Val, My fault - I assumed that the NA would be first in the result produced by "unique": mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) val23<-unique(unlist(mydat[,c("Col2","col3")])) napos<-which(is.na(val23)) preval<-data.frame(Col1=val23[-napos],
2018 Feb 25
2
include
HI Jim and all, I want to put one more condition. Include col2 and col3 if they are not in col1. Here is the data mydat <- read.table(textConnection("Col1 Col2 col3 K2 X1 NA Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) The desired out put would be Col1 Col2 col3 1 X1 0 0 2 K1 0 0 3 Y1 0 0 4 W1 0 0 6 K2 X1
2005 Oct 07
2
finding missing lines...
Take this as an example: > a=data.frame(col1=c(1,2,3,4,5), col2=c ("my","beloved","daughter","son","wife")) > b=data.frame(col1=c(1,2,4), col2=c("my","beloved","son")) > a col1 col2 1 1 my 2 2 beloved 3 3 daughter 4 4 son 5 5 wife > b col1 col2 1 1 my 2
2017 Aug 23
0
Comparing 2 dale columns
Patrick, ## Run the following script an notice the different values of the dataframe "data" in each instance. # I understand you have done something like the following: data <- data.frame(COL1 = c("6/1/14", "7/1/14"), COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE) data$Date_Flag <- ifelse(data$COL2 >