similar to: removing values from a vector, where both the value and its name are the same?

Displaying 20 results from an estimated 50000 matches similar to: "removing values from a vector, where both the value and its name are the same?"

2005 Aug 29
5
Testing if all elements are equal in a vector/matrix
Is there a canonical way to check if all elements of a vector or matrix are the same? Solutions below work, but look hackish to me. > x <- rep(1, 10) > all(x == x[1]) # == operator does not provide for small differences [1] TRUE > isTRUE(all.equal(x, rep(x[1], length(x)))) # ugly [1] TRUE Best, Vincent -- Vincent Goulet, Associate Professor ??cole d'actuariat
2006 Feb 03
2
all.equal() and which()
Please excuse the lack of a complete dataset here, if its needed I'll be happy to provide it. Can anyone show me how to rewrite this? Browse[1]> time(data)[24210:24220] [1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217 [10] 24.218 24.219 Browse[1]> which(time(data)==24.211) numeric(0) I'm assuming its an eps fault but which(all.equal(time(data),24.211)) dosnt
2005 Oct 18
2
The meaning of functional language
It's often heard that the S language is a functional language.But What's the exact meaning of this termology in the context of S language? 2005-10-18 ------ Deparment of Sociology Fudan University Blog:http://sociology.yculblog.com
2007 May 13
2
extracting text contained in brackets ("[ ... ]") from a character string?
I have a text string that contains text within two brackets. e.g. "testdata[3]" "testdata[-4]", "testdata[-4g]", I wish to "extract" the string enclosed in brackets? What is a good way to do this? e.g. fun(testdata[3]) = '3' fun(testdata[-4g]) = '-4g' --------------------------------- Moody friends. Drama queens. Your life?
2009 Apr 01
4
Variable Wildcard Value
Is there a wildcard value for vector values in r? For instance: > M <- *wildcard > (M==1) TRUE >(M=="peanut butter") TRUE >is.na(M) FALSE thanks, Francis -- Francis Smart (406) 223-8108 cell
2009 Mar 12
2
Removing
Hi All, > act_2 Date Dtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54
2008 Dec 24
3
filling values in a vector using smaller vector
Dear list members: I am looking for an elegant (or efficient) way to accomplish the following: take a large boolean vector and fill the TRUE values with the values from a smaller boolean vector that has a length that is the number of TRUE values of the large vector. Example: large<- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) small<- c(TRUE,
2004 Apr 17
3
Box-Ljung p-value -> Test for Independence
Hi all I'm using the Box-Ljung test (from within R) to test if a time-series in independently distributed. 2 questions: 1) p-value returned by Box-Ljung: IF I want to test if the time-series is independant at say 0.05 sig-level (it means that prob of erroneously accepting that the time-series is independent is 0.05 right?) --> then do I consider time-series as "independant"
2007 May 12
1
function similar to "get" that works for both an object, and elements of an object?
#Is there a single function similar to "get" that works for both an object, and elements of an object ? #(I want the function to be able to return objects, and/or the deeper elements of an object.) #(i.e. elements of a dataframe and/or list)? #e.g. tempdf = data.frame(a=c(4,5,6) , b=c(10,11,12) ) templist= list(x=tempdf, y=c(1,2)) get('tempdf') #works as desired
2008 Nov 24
14
how to test for the empty set
Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. This is borne out by y <- letters[1:3] z <- letters[4:6] intersect(y,z) which, of course, is non-NULL: is.null(character(0)) #
2009 Jan 25
2
commercially supported version of R for 64 -bit Windows?
Can anyone please refer me to all firms that offer and/or are developing a commercially supported version of R for 64 -bit Windows? - Thanks [[alternative HTML version deleted]]
2008 Jul 11
1
Subsetting an array by a vector of dimensions
Hi Is it possible to subset an n-dimensional array by a vector of n dimensions? E.g. assume I have > x <- array(1:24, dim=2:4) > x[1,1,2] [1] 7 > dims <- c(1,1,2) I would like a function that I can supply x and dims as parameters to, and have it return 7. Also, I would like to do something like: > x[1,1,] [1] 1 7 13 19 > dims2<- c(1,1,NA) And have a function of x and
2004 Mar 26
3
regression problem
i need to know how to estimate a linear regression whose coefficients sum to zero
2009 Jan 09
5
The R Inferno
"The R Inferno" is now on the Burns Statistics website at http://www.burns-stat.com/pages/Tutor/R_inferno.pdf Abstract: If you are using R and you think you're in hell, this is a map for you. Also, I've expanded the outline concerning R on the Burns Statistics 'Links' page. Suggestions (off-list) for additional items are encouraged. Patrick Burns patrick at
2009 Mar 27
3
nls, convergence and starting values
"in non linear modelling finding appropriate starting values is something like an art"... (maybe from somewhere in Crawley , 2007) Here a colleague and I just want to compare different response models to a null model. This has worked OK for almost all the other data sets except that one (dumped below). Whatever our trials and algorithms, even subsetting data (to check if some singular
2005 Jan 03
3
spreadsheet addiction
There's a new page on the Burns Statistics website http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html that looks at spreadsheets from a quality assurance perspective. It presents R as a suitable alternative to spreadsheets. Also there are several specific problems with Excel that are highlighted, including the status of statistical functionality in Excel. Patrick Burns Burns
2004 Nov 20
1
sum and partial argument name matching
"sum" (and perhaps other functions?) allows partial argument name matching after its three-dots argument: > sum(1:4, NA, n=78, na.rm=FALSE) [1] 10 > sum(1:4, NA, n=78, na.rm=TRUE) [1] 11 I can see there could be a discussion about whether or not this is a bug, but I think all will agree that it's a might peculiar. This is done in 2.0.1 but the same behavior is in 1.8.1.
2008 Jun 25
1
weighted inverse chi-square method for combining p-values
Hi, This is more of a general question than a pure R one, but I hope that is OK. I want to combine one-tailed independent p-values using the weighted version of fisher's inverse chi-square method. The unweighted version is pretty straightforward to implement. If x is a vector with p-values, then I guess that this will do for the unweighted version: statistic <- -2*sum(log(x)) comb.p <-
2008 Jul 13
2
multiple names to assign
'assign' does not give a warning if 'x' has length greater than 1 -- it just uses the first element: assign(c('a1', 'a2'), 1:2) One way of thinking about this is that people using 'assign' get what they deserve. The other is that it is used seldom enough that adding a warning isn't going to slow things down appreciably. Patrick Burns patrick at
2007 May 16
2
substitute "x" for "pattern" in a list, while preservign list "structure". lapply, gsub, list...?
I am experimenting with some of the common r functions. I had a question re:using "gsub" (or some similar functions) on the contents of a list. I want to design a function that looks at "everything" contained din a list, and anytime it finds the text string "pattern" replace it with "x". I also wish to preserve the "structure" of the original