similar to: ave gives unexpected NA's

Displaying 20 results from an estimated 7000 matches similar to: "ave gives unexpected NA's"

2010 Jun 29
1
Performance enhancement for ave
library(plyr) n<-100000 grp1<-sample(1:750, n, replace=T) grp2<-sample(1:750, n, replace=T) d<-data.frame(x=rnorm(n), y=rnorm(n), grp1=grp1, grp2=grp2) system.time({ d$avx1 <- ave(d$x, list(d$grp1, d$grp2)) d$avy1 <- ave(d$y, list(d$grp1, d$grp2)) }) # user system elapsed # 39.300 0.279 40.809 system.time({ d$avx2 <- ave(d$x, interaction(d$grp1, d$grp2, drop =
2011 Jan 31
2
identify subsets based on two grouping factors
Hi, I have a data.frame that has a categorical variable, for which I would like to look at the distribution of levels of this variable, based on a grouping of two other variables. As an example: x <- data.frame(obs=sample(c('low', 'high'),100, replace=TRUE), grp1=sample(1:10, 100, replace=TRUE), grp2=runif(100)) cut.grp1 <- cut(x$grp1, 3) cut.grp2 <- cut(x$grp2, 3)
2006 Dec 08
1
lattice: defining an own function using args for "formula" and "groups"
x.fun <- function( formula, data ) dotplot( formula, data ) x.grp <- function( formula, groups, data ) dotplot( formula, groups, data ) data( barley ) > x.fun( variety ~ yield | site, data=barley ) # no problem > dotplot( variety ~ yield | site, groups=year, data=barley ) # no problem > x.grp( variety ~ yield | site, groups=year, data=barley ) object "year" not found
2011 Jan 31
1
arranging pie charts in a matrix layout with row/col labels
Hi, I have a vector of data, that I group based on two factors via tapply. For each such grouping I would like to plot a pie chart. I can layout these pie charts in a matrix layout, correpsonding to the levels of the two factors. But I am getting stuck on how to label the rows and colums. My current approach looks like this: x <- data.frame(obs=sample(c('low', 'high'),100,
2009 Dec 10
1
Help with beanplot fromatting
Dear Helpful R Users, I am graphing some data using the beanplot, but I am having trouble getting the output I desire. I have five tanks (A-E) and 2 groups for each tank grp1 or grp2, except tank C where there is only grp1. (I only changed the grouprep to "C grp1" for the example) When I plot them, I would like A B C(only grp1 - half of the bean plot) then D and E (as full beans).
2011 Feb 08
2
Convert the output of by() to a data frame
I'd like to summarize several variables in a data frame, for multiple groups, and store the results in a data.frame. To do so, I'm using by(). For example: df<-data.frame(a=1:10,b=11:20,c=21:30,grp1=c("x","y"),grp2=c("x","y"),grp3=c("x","y")) dfsum<-by(df[c("a","b","c")],
2018 Dec 05
6
Restricting sending mail to domain or group
Hi folks, has anybody a simple solution for the following request? I have a group alias (all at company.com). (1) Only company.com accounts should be able to send an email to everybody in that company via all at company.com. (2) - rather optional: refine the restrictions, e.g. two groups, grp1 at company.com and grp2 at company.com. Grp1 members should be able to send mails to grp2 but not vice
2011 Apr 07
1
plyr workaround to converting by() to a data frame
Dear all Is there a clean plyr version of the following by() and do.call(rbind, ...) construct: > df<-data.frame(a=1:10,b=11:20,c=21:30,grp1=c("x","y"),grp2=c("x","y"),grp3=c("x","y")) > dfsum<-by(df[c("a","b","c")], df[c("grp1","grp2","grp3")], range) >
2008 Aug 18
3
Samba 3.0.x access rights issue with secondary groups or Unix rights
Hi experts I have a trouble in access rights I am running Samba 3.0.31 on Solaris 10 x86 64 bits as member server of an Active Directory 2003 R2 domain (MYDOMAIN) using Identity Management for Unix I set rights to access a sub folder of a Samba share. On Solaris the user "toto" jdoe can write a new file. From Windows, the same user can't. Itlooks like OK when the primary group
2010 Aug 11
2
help to polish plot in ggplot2
Hi, I wanted to generate a plot which is almost like the plot generated by the following codes. category <- paste("Geographical Category", 1:10) grp1 <- rnorm(10, mean=10, sd=10) grp2 <- rnorm(10, mean=20, sd=10) grp3 <- rnorm(10, mean=15, sd=10) grp4 <- rnorm(10, mean=12, sd=10) mydat <- data.frame(category,grp1,grp2,grp3,grp4) dat.m <- melt(mydat) p <-
2013 Sep 26
1
Less than equal to symbol in ggplot2 legend text
Hello, I am trying to add a less than equal to symbol in a ggplot2 legend text. See sample code below. I have tried using the expression function and \u2264. I also tried adding labels to legend.text under theme. Neither of these 3 options work. Please help, Mahesh ++++++++++++++ Extra.column=ifelse(data[,covariate]>cutpoint,1,0) Grp1 <- "\u2264 1.5" Grp2 <-
2018 Dec 05
1
Restricting sending mail to domain or group
On Wed, 5 Dec 2018, Alexander Dalloz wrote: >> I have a group alias (all at company.com). >> (1) Only company.com accounts should be able to send an email to everybody >> in that company via all at company.com. >> (2) - rather optional: refine the restrictions, e.g. two groups, >> grp1 at company.com and grp2 at company.com. Grp1 members should be able to send
2002 May 03
2
sub() of matrix returns a vector and not a matrix
Is there a simple possibility to become directly a matrix from a call of sub() on a matrix? --------- START OF LOGFILE ---------------- # R 1.4.1 > a <- matrix( letters[1:6], 2, 3 ) # a is a matrix > print( a ) [,1] [,2] [,3] [1,] "a" "c" "e" [2,] "b" "d" "f" > b <- sub( '(.)', '-\\1-', a )
2004 Oct 04
11
inverse function of order()
I have: d <- sample(10:100, 9) o <- order(d) r <- d[o] How I can get d (in the original order), knowing only r and o? Thanks - Wolfram
2005 Apr 11
6
How to change letters after space into capital letters
What is the easiest way to change within vector of strings each letter after a space into a capital letter? E.g.: c( "this is an element of the vector of strings", "second element" ) becomes: c( "This Is An Element Of The Vector Of Strings", "Second Element" ) My reason to try to do this is to get more readable abbreviations. (A suggestion would be to
2006 Nov 29
4
Why the factor levels returned by cut() are not ordered?
What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? > is.ordered( cut( breaks=3, sample(10 ) ) ) FALSE > help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... Wolfram
2003 Jan 24
4
new function: showcolors {base}
I propose to add a function that allows to display colors selected by a text pattern or by color vectors in a plot. Wolfram Fischer #--- showcolors.R showcolors <- function( col = "red" , index = NULL , pie = TRUE , lwd = 6 , cex = 1.0 , main = NULL , sub = NULL , ... ){ n.colors <- length( col ) if( n.colors > 1 ){ main <- deparse( substitute( col ) )
2003 Jan 07
1
Hiding shares
Hi everybody, I assume this is no real problem but only some setup thing but I don't get through it. How can I mount only shares that a specified group is supposed to see? Meaning if I have somebody member of grp1 I want him to see dir A. If some one is member of grp2 I want him to see dir B. So a section of our company can have his own shared directory for their own.. At the moment I
2003 Aug 29
2
length() and nchar()
I would propose to add " See also: `nchar' for counting the number of character in character vectors. " to the helpfile of length(), because it is rather difficult to find nchar() if one has only search terms as "length", "len", "strlen" in mind. Sincerly Wolfram Fischer
2004 Dec 07
1
how to test the existence of a name in a dataframe
I wanted to test if there exists already a name (which is incidentally a substring of another name) in a dataframe. I did e.g.: > data(swiss) > names(swiss) [1] "Fertility" "Agriculture" "Examination" "Education" [5] "Catholic" "Infant.Mortality" > ! is.null(swiss$EduX) [1] FALSE > !