similar to: proposal for "strict" versions of subsetting operators

Displaying 20 results from an estimated 30000 matches similar to: "proposal for "strict" versions of subsetting operators"

2003 Oct 28
1
proposal for
Having written a number of R programs and having been stung with this myself, I think this is a very good idea. In fact, if the aim of R is to "to do it right" (as one person on the list claimed) rather than be compatible with S-Plus or prior versions of R then I would go even further and make all subscripting behave like this. (If that were to be the way R goes then, of course,
2005 Feb 17
1
Subsetting using dimnames on S4 array-based class
Hello, I did send this message to r-help and got no reply, no I am resubmitting here in case this was a bit too specific for the other list. Many thanks, Iago From: Iago Mosqueira <imosqueira@suk.azti.es> To: r-help@stat.math.ethz.ch Subject: Subsetting using dimnames on S4 array-based class
2005 Feb 11
0
Subsetting using dimnames on S4 array-based class
Hello, I am encountering some problems when overloading the "[" operator for a new S4 class based on array. This is an example class definition: setClass("foo", representation("array"), prototype(array(NA, dim=c(3,3)), dimnames=list(age=1:3, year=10:12)) ) And this the corresponding setMethod with print estatements to see what is being passed:
2017 Aug 28
0
Extracting subset from netCDF file using lat/lon and converting into .csv in R
Two questions: 1. Is the order of the dimensions shown what is shown if you look at str(ncin) - I mean shown at the end where it describes the variable and its dimensions? 2. Is you problem how to subset the netcdf file, how to write to the .csv file, or both? -Roy > On Aug 28, 2017, at 2:21 PM, Eeusha Nafi <eshad002 at gmail.com> wrote: > > I have a series of nertCDF files
2003 Jul 14
2
Subsetting a matrix
I'd welcome some comments or advice regarding the situation described below. The following illustrates what seems to me to be an inconsistency in the behaviour of matrix subsetting: > Z<-matrix(c(1.1,2.1,3.1,1.2,2.2,3.2,1.3,2.3,3.3),nrow=3) > Z [,1] [,2] [,3] [1,] 1.1 1.2 1.3 [2,] 2.1 2.2 2.3 [3,] 3.1 3.2 3.3 > dim(Z) [1] 3 3 >
2006 Oct 19
2
arraytake for extracting subarrays from multidimensional arrays
Hi, I recently encountered a problem with array subsetting and came up with a fix. Given an array of arbitrary dimensions, in which the number of dimensions is only known at runtime, I wanted to extract a subarray. The main issue with doing this is that in order to extract a subarray from an array of (say) 4 dimensions you usually specify something like this a.subarray <- a[,c(4,2),1:5,]
2010 Sep 01
1
Looks like a bug in subsetting of a complicated object
I don't understand what is happening! I have a (large) object sim1, an matrix list with dim c(101,101) where each element is an 3*3 matrix. I am subsetting that with a matrix coo, of dim c(100,2), of unique indices, but the resulting object has length 99, not 100 as expected. Code reproducing the problem follows: library(RandomFields) set.seed(123) sim0 <- GaussRF(x=seq(0, 100, by=1),
2005 Feb 27
1
subsetting data set dimenion problem
(See DAAG book, p. 173, ex. 3) I'm a new user of R, and I'm following the DAAG text. I want to create a subset of the races2000 data frame, but get errors because of a mismatch of values in some columns: > library(DAAG) > attach(races2000) > hills2000 <- races2000[races2000$type == 'hill'] Error in as.matrix.data.frame(x) : dim<- : dims [product 770] do not
2018 Jun 08
0
Subsetting the "ROW"s of an object
Also the TRUEs cause problems if some dimensions are 0: > matrix(raw(0), nrow=5, ncol=0)[1:3 , TRUE] Error in matrix(raw(0), nrow = 5, ncol = 0)[1:3, TRUE] : (subscript) logical subscript too long H. On 06/08/2018 10:29 AM, Hadley Wickham wrote: > I suspect this will have suboptimal performance since the TRUEs will > get recycled. (Maybe there is, or could be, ALTREP,
2012 Oct 12
3
Loss of dimensions in subsetting arrays
Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] dim(B) 5 2 # so now dim(B)[3] doesn't work C=B[2,] dim(C) NULL # so now nrow(C) doesn't work Typically, you can get rid of this by writing as.matrix, as.array(...) but that generates extra lines of code.
2018 Jun 08
3
Subsetting the "ROW"s of an object
> On Jun 8, 2018, at 10:37 AM, Herv? Pag?s <hpages at fredhutch.org> wrote: > > Also the TRUEs cause problems if some dimensions are 0: > > > matrix(raw(0), nrow=5, ncol=0)[1:3 , TRUE] > Error in matrix(raw(0), nrow = 5, ncol = 0)[1:3, TRUE] : > (subscript) logical subscript too long OK. But this is easy enough to handle. > > H. > > On
2017 Aug 28
3
Extracting subset from netCDF file using lat/lon and converting into .csv in R
I have a series of nertCDF files containing global data for a particular variable, e.g. tmin/tmax/precipiation/windspeed/relative humuidity/radiation etc. I get the following information when using *nc_open* function in R: datafile: https://www.dropbox.com/s/xpo7zklcmtm3g5r/gfdl_preci.nc?dl=0 File gfdl_preci.nc (NC_FORMAT_NETCDF4_CLASSIC): 1 variables (excluding dimension variables):
2006 Jun 09
1
Idempotent apply
Dear all, I have been working on an idempotent version of apply, such that applying a function f(x) = x (ie. force) returns the same array (or a permutation of it depending on the order of the margins): a <- array(1:27, c(2,3,4)) all.equal(a, iapply(a, 1, force)) all.equal(a, iapply(a, 1:2, force)) all.equal(a, iapply(a, 1:3, force)) all.equal(aperm(a, c(2,1,3)), iapply(a, 2, force))
2018 Jun 08
1
Subsetting the "ROW"s of an object
On 06/08/2018 10:15 AM, Michael Lawrence wrote: > There probably should be an abstraction for this. In S4Vectors, we > have extractROWS(). FWIW the code in S4Vectors that does what your subset_ROW() does is: https://github.com/Bioconductor/S4Vectors/blob/04cc9516af986b30445e99fd1337f13321b7b4f6/R/subsetting-utils.R#L466-L476 (This is the default "extractROWS" method.) Except
2011 Dec 05
1
Subsetting a data frame
Hi R users, I really need help with subsetting data frames: I have a large database of medical records and I want to be able to match patterns from a list of search terms . I've used this simplified data frame in a previous example: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2, 1.3, 3), test2 = c(56L, 27L, 58L,
2018 Jun 08
2
Subsetting the "ROW"s of an object
I suspect this will have suboptimal performance since the TRUEs will get recycled. (Maybe there is, or could be, ALTREP, support for recycling) Hadley On Fri, Jun 8, 2018 at 10:16 AM, Berry, Charles <ccberry at ucsd.edu> wrote: > > >> On Jun 8, 2018, at 8:45 AM, Hadley Wickham <h.wickham at gmail.com> wrote: >> >> Hi all, >> >> Is there a better to
2018 Jun 08
0
Subsetting the "ROW"s of an object
Hmmm, yes, there must be some special case in the C code to avoid recycling a length-1 logical vector: dims <- c(4, 4, 4, 1e5) arr <- array(rnorm(prod(dims)), dims) dim(arr) #> [1] 4 4 4 100000 i <- c(1, 3) bench::mark( arr[i, TRUE, TRUE, TRUE], arr[i, , , ] )[c("expression", "min", "mean", "max")] #> # A tibble: 2 x 4
2012 Mar 10
1
Subsetting a data.frame -> Read in with FWF format from .DAT file
Hi there, I am having trouble subsetting a data frame by a conditional via one column (of many). I read the file into R through "read.fwf," where I specified column widths. Original data is .DAT. I then utilized "names" function to read in column headings. For one column, PRVDR_NUM, I wish to further amend the entire data set, but only have PRVDR_NUM == 050108. This is
2010 Mar 24
1
flexible alternative to subsetting dataframe inside nested loops
I have a dataFrame variable: L1 L2 L3 ... v1 v2 ... 1 2 3 4 ... I want to process subsets of it as defined by combinations of L1-L2-L3. I do it successfully using nested loops: for (i in valuesOfL1 { for (j in valuesOfL2) { for (k in valuesOfL3) { tempData <- subset(dataFrame, (L1 == i & L2 == j & L3 == k, select=c(v1,v2) )) if
2018 Jun 08
0
Subsetting the "ROW"s of an object
On Fri, Jun 8, 2018 at 2:09 PM, Berry, Charles <ccberry at ucsd.edu> wrote: > > >> On Jun 8, 2018, at 1:49 PM, Hadley Wickham <h.wickham at gmail.com> wrote: >> >> Hmmm, yes, there must be some special case in the C code to avoid >> recycling a length-1 logical vector: > > > Here is a version that (I think) handles Herve's issue of arrays