search for: colwise

Displaying 20 results from an estimated 36 matches for "colwise".

2010 Apr 07
1
unexpected behaviour with ddply and colwise
Hi, I am confused by results from: > ddply(aa, names(aa), colwise(sum)) I thought ddply was just calling colwise(sum)() with each column. However ddply() returns a 13 x 5 result !! The general result I expected is similar to that of apply() , or using colwise(sum)() alone. Shouldn't ddply() produce the same ? Thanks in advance for your help,...
2012 Jan 31
0
Error in linearHypothesis.mlm: The error SSP matrix is apparently of deficient rank
...re("plyr")) suppressMessages(require(ez)) source.file <- file.path(path.expand("~"), "test-data.csv") data <- read.csv(source.file, stringsAsFactors = TRUE) data$Participant <- as.factor(data$Participant) summary(data) colwise(class)(data) colwise(mode)(data) colwise(mean)(data[3:4]) colwise(sd)(data[3:4]) ops <- options(contrasts = c('contr.sum', 'contr.poly')) ezANOVA(data, dv = .(Measure.2), wid = .(Participant), within = .(Factor), type = 3, detailed = T)...
2011 Oct 12
3
Applying function to only numeric variable (plyr package?)
...ound(100*x, 1) I want to apply the pct function to only the numeric variables so that the proportions are computed to percentages, and retain all the columns: c1 c2 x1 x2 1 A Y 52.3 92.5 2 B Y 69.2 76.2 3 C N 23.1 36.2 4 C N 11.6 44.6 I've been approaching it with the ddply and colwise functions from the plyr package, but in that case each I need each row to be its own group and retain all columns. Am I on the right track? If not, what's the best way to do this? Thanks in advance, M. L.
2009 Apr 15
0
plyr version 0.1.7
...ormation about where errors within your data - hopefully this will make problems easier to track down Speed-ups * massive speed ups for splitting large arrays * fixed typo that was causing a 50% speed penalty for d*ply * rewritten rbind.fill is considerably (> 4x) faster for many data frames * colwise about twice as fast Bug fixes: * daply: now works when the data frame is split by multiple variables * aaply: now works with vectors * ddply: first variable now varies slowest as you'd expect plyr 0.1.5 (2008-02-23) --------------------------------------------------- * colwise now accepts...
2009 Apr 15
0
plyr version 0.1.7
...ormation about where errors within your data - hopefully this will make problems easier to track down Speed-ups * massive speed ups for splitting large arrays * fixed typo that was causing a 50% speed penalty for d*ply * rewritten rbind.fill is considerably (> 4x) faster for many data frames * colwise about twice as fast Bug fixes: * daply: now works when the data frame is split by multiple variables * aaply: now works with vectors * ddply: first variable now varies slowest as you'd expect plyr 0.1.5 (2008-02-23) --------------------------------------------------- * colwise now accepts...
2010 Jun 09
2
Read in dataset without saving it
...ing more files saving it as a .txt/.csv and then reading that in. I want to read in 3 columns e.g. 1 2.5 3.4 1 2.3 3.1 1 2.6 3.9 2 2.9 2.8 2 2.6 2.9 2 2.7 2.9 3 2.3 3.3 3 2.4 3.0 3 2.7 3.2 I thought I could use scan() but don't know how to extend it to multiple columns? I thought about using colwise (plyr) but think I am making this more complicated than it probably should be! Is there an easy way to do this? Any ideas gratefully received, Paul -- View this message in context: http://r.789695.n4.nabble.com/Read-in-dataset-without-saving-it-tp2248495p2248495.html Sent from the R help mailin...
2008 Nov 03
4
How do you apply a function to each variable in a data frame?
I want to apply a more complicated function than what I use in my example, but the idea is the same: Suppose you have a data frame named x and you want to a function applied to each variable, we'll just use the quantile function for this example. I'm trying all sorts of apply functions, but not having luck. My best guess would be: sapply(x, FUN=quantile) -- View this message in
2012 Dec 17
4
Splitting up of a dataframe according to the type of variables
Dear R users, I have a dataframe which consists of variables of type numeric and factor. What is the easiest way to split up the dataframe to two dataframe which contain all variables of the type numeric resp. factors? Thank you very much for your efforts in advance! Best, Martin
2011 Nov 29
2
aggregate syntax for grouped column means
...=T) head(results1,1) # id var1 var2 # 1 0m11 30.79 32.27 library(data.table) mydt <- data.table(myData) setkey(mydt,id) results2 <- mydt[,lapply(.SD,mean,na.rm=TRUE),by=id] head(results2,1) # id var1 var2 # [1,] 0m11 30.84 32.27 library(plyr) results3 <- ddply(myData,.(id),colwise(mean),na.rm=TRUE) head(results3,1) # id var1 var2 # 1 0m11 30.84 32.27 > sessionInfo() R version 2.14.0 (2011-10-31) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC...
2011 May 11
3
ddply with mean and max...
I'm trying to use ddply to compute summary statistics for many variables splitting on the variable site. however, it seems to work fine for mean() but if i use max() or min() things fall apart. whats going on? test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100)) means<-ddply(test.set,.(site),mean) means site x y 1 1 -97459496 -0.14826303 2
2013 Apr 04
3
summing vectors
Hi All, Year Area Q Bin FD I have a large dataset I need to re-structure. It looks something like this: 2000 1 1 5 0 2000 1 1 10 1 2000 1 1 15 23 2000 1 1 20 12 2000 1 1 25 1 2000 2 1 5 1 2000 2 1 10 3 2000 2 1 15 15 2000 2 1 20 11 2000 2 1 25 3 2000 1 2 5 0 2000 1 2 10 1 2000 1 2 15 23 2000 1 2 20 12 2000 1 2 25 1 2000 2 2 5 1 2000 2 2 10 3 2000 2 2 15 15 2000 2 2 20 11
2013 Jun 18
1
transform 3 numeric vectors empty of 0/1
Dear all, Without a loop, I would like transform 3 numeric vectors empty of 0/1 of same length Vec1 : transform 1 to A and 0 to "" Vec2 : transform 1 to B and 0 to "" Vec3 : transform 1 to C and 0 to "" to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC, BC, AC, AB,...) Any idea ? Thank you for your help -- Michel ARNAUD
2011 Jul 30
0
plyr version 1.6
...n up at http://groups.google.com/group/manipulatr. Version 1.6 ------------------------------------------------------------------------------ * documentation improved using new features of `roxygen2` * fixed namespacing issue which lead to lost labels when subsetting the results of `*lply` * `colwise` automatically strips off split variables. * `rlply` now correctly deals with `rlply(4, NULL)` (thanks to bug report from Eric Goldlust) * `rbind.fill` tries harder to keep attributes, retaining the attributes from the first occurrence of each column it finds. It also now works with variabl...
2010 Jan 30
2
Applying a transformation to multiple data frame columns
How can one simplify the folowing? t$aum[is.na(t$aum)] = 0; t$aum.core[is.na(t$aum.core)] = 0 t$num[is.na(t$num)] = 0; t$num.core[is.na(t$num.core)] = 0 Thank you. -- View this message in context: http://n4.nabble.com/Applying-a-transformation-to-multiple-data-frame-columns-tp1457641p1457641.html Sent from the R help mailing list archive at Nabble.com.
2011 Jul 30
0
plyr version 1.6
...n up at http://groups.google.com/group/manipulatr. Version 1.6 ------------------------------------------------------------------------------ * documentation improved using new features of `roxygen2` * fixed namespacing issue which lead to lost labels when subsetting the results of `*lply` * `colwise` automatically strips off split variables. * `rlply` now correctly deals with `rlply(4, NULL)` (thanks to bug report from Eric Goldlust) * `rbind.fill` tries harder to keep attributes, retaining the attributes from the first occurrence of each column it finds. It also now works with variabl...
2013 Nov 19
0
How to extract sets of rows (not sorted) from text file in R, do some methods on these rows, save the result in another text file, then pick others set of rows and do the same
...call(rbind,lapply(split(dat1,dat1[,1]),function(x) c(V1=x[1,1],colSums(x[,-1],na.rm=TRUE)))) ?write.table(res1,file="new.txt",row.names=FALSE,quote=FALSE) #or res2 <- with(dat1,aggregate(cbind(V2,V3,V4,V5,V6),list(V1=V1),sum,na.rm=TRUE)) #or library(plyr) res3 <- ddply(dat1,.(V1),colwise(sum,na.rm=TRUE)) A.K. Hi, in a text file like 1 2 4 7 8 9 1 4 5 8 9 1 4 5 6 9 2 3 4 8 3 6 7 8 1 5 6 9 2 5 7 9 And so on where the first column represents group's number data <- read.table("in.txt") ## first: ? ? ? ?- select rows that strat with one (check first c...
2011 Mar 11
5
How to calculate means for multiple variables in samples with different sizes
Hello R-helpers: I have data like this: sample replicate height weight age A 1.00 12.0 0.64 6.00 A 2.00 12.2 0.38 6.00 A 3.00 12.4 0.49 6.00 B 1.00 12.7 0.65 4.00 B 2.00 12.8 0.78 5.00 C 1.00 11.9 0.45 6.00 C 2.00 11.84 0.44 2.00 C 3.00 11.43 0.32 3.00 C 4.00 10.24 0.84 4.00 D
2008 Dec 16
3
Check if data frame column is numeric
Hi R-users, I want to apply a function to each column of a data frame that is numeric. Thus I tried to check it for each column first: > apply(df, 2, function(x) is.numeric(x)) A60 A64 A66a A67 A71 A75a A80 A85 A91 A95 A96 A97 A98 A99 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
2009 May 13
5
Help with reshape/reShape and indexing
Dear R Helpers, I have trouble applying reShape and reshape although I read the documentation and several posts, so I would very much appreciate your help on the two points below. I have a dataframe df = data.frame(Name=c("a", "a", "a", "b", "b", "c"), X1=c("12", "13", "14", "20", "25",
2013 Apr 19
5
how to subtotal by rows
Dear R-users, I have a dataset as like below, and I want to subtotal the values of rice,wheat and maize by year for each fid. fid      year     rice     wheat      maize ------------------------------------------------ 1        1995      5        NA           NA 1        1995      NA        3           NA 1        1995      NA       NA           2 1        1996      4        NA           NA 1