subset

How to take a subset from a netCDF file using latitude/longitude boundaries in R

ぃ、小莉子 提交于 2019-12-03 06:14:55
I have a netCDF file that I wish to extract a subset from defined by latitude/longitude boundaries (i.e. a lat/long defined box), using the ‘ncdf’ package in R. A summary of my netCDF file is below. It has two dimensions (latitude and longitude) and 1 variable (10U_GDS4_SFC). It is essentially a lat/long grid containing wind values: [1] "file example.nc has 2 dimensions:" [1] "lat_0 Size: 1280" [1] "lon_1 Size: 2560" [1] "------------------------" [1] "file example.nc has 1 variables:" [1] "float 10U_GDS4_SFC[lon_1,lat_0] Longname:10 metre U wind component Missval:1e+30" The latitude variable

how do I grep in R?

大城市里の小女人 提交于 2019-12-03 05:40:53
问题 I would like to choose rows based on the subsets of their names, for example If I have the following data: data <- structure(c(91, 92, 108, 104, 87, 91, 91, 97, 81, 98), .Names = c("fee-", "fi", "fo-", "fum-", "foo-", "foo1234-", "123foo-", "fum-", "fum-", "fum-")) how do I select the rows matching 'foo'? using grep() doesn't work: grep('foo', data) returns: integer(0) what am I doing wrong? or, is there a better way? Thanks! 回答1: You need to grep the names property of data, not the values

R: loop through data frame extracting subset of data depending on date

一曲冷凌霜 提交于 2019-12-03 04:37:39
I have a large data frame that consists of data that looks something like this: date w x y z region 1 2012 01 21 43 12 3 NORTH 2 2012 02 32 54 21 16 NORTH 3 2012 03 14 32 65 32 NORTH 4 2012 04 65 33 75 21 NORTH : : : : : : : : : : : : : : 12 2012 12 32 58 53 17 NORTH 13 2012 01 12 47 43 23 SOUTH 14 2012 02 87 43 21 76 SOUTH : : : : : : : 25 2012 01 12 46 84 29 EAST 26 2012 02 85 29 90 12 EAST : : : : : : : : : : : : : : I want to extract section of the data that have the same date value, for example to do this just for 2012 01 I would just create a subset of data data_1 <- subset(data, date ==

subset() of a vector in R

偶尔善良 提交于 2019-12-03 03:34:55
I've written the following function based on subset() , which I find handy: ss <- function (x, subset, ...) { r <- eval(substitute(subset), data.frame(.=x), parent.frame()) if (!is.logical(r)) stop("'subset' must be logical") x[r & !is.na(r)] } So, I can write: ss(myDataFrame$MyVariableName, 500 < . & . < 1500) instead of myDataFrame$MyVariableName[ 500 < myDataFrame$MyVariableName & myDataFrame$MyVariableName < 1500] This seems like something other people might have developed solutions for, though - including something in core R I might have missed. Anything already out there? I realize that

mongodb query subset of an array

北城以北 提交于 2019-12-03 03:34:37
I have a field _keywords which is an array of strings. I want to get documents of which _keywords are super-set of the query array. For example: db.article.insert({'_keywords': ['foo', 'foo1', 'foo2']}) I want to retrive this record when I query subset of ['foo', 'foo1', 'foo2'], eg: ['foo'], ['foo1', 'foo2'] EDIT: something like: db.article.find({'_keywords': {$contains: array}}) Use the $all operator: db.article.find( { _keywords: { $all: [ 'foo1', 'foo2' ] } } ); Source: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24all In MongoDb, for array field: "$in:[...]"

R Not in subset [duplicate]

放肆的年华 提交于 2019-12-03 02:34:25
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Standard way to remove multiple elements from a dataframe I know in R that if you are searching for a subset of another group or matching based on id you'd use something like subset(df1, df1$id %in% idNums1) My question is how to do the opposite or choose items NOT matching a vector of ids. I tried using ! but get the error message subset(df1, df1$id !%in% idNums1) I think my backup is to do sometime like this:

How to verify that one XSD schema is a subset of another XSD schema?

柔情痞子 提交于 2019-12-03 01:25:24
How can I verify that one XSD schema is a subset of another XSD schema? We are creating a system-of-systems application using a collection of "blueprint" XSD schemas (which defines all possible inputs or outputs available to a subcomponent). Many subcomponents are being implemented, and these subcomponents pass data among themselves using XML files. Each subcomponent creates a subset of the relevant blueprint XSD schema (to indicate which of the possible inputs or output it has chosen to implement). Any XML datafile that validates against a subset XSD schema must also validate against the

Subsetting in R using OR condition with strings

笑着哭i 提交于 2019-12-03 01:07:52
I have a data frame with about 40 columns, the second column, data[2] contains the name of the company that the rest of the row data describes. However, the names of the companies are different depending on the year (trailing 09 for 2009 data, nothing for 2010). I would like to be able to subset the data such that I can pull in both years at once. Here is an example of what I'm trying to do... subset(data, data[2] == "Company Name 09" | "Company Name", drop = T) Essentially, I'm having difficulty using the OR operator within the subset function. However, I have tried other alternatives: subset

Remove rows when cells are equal [duplicate]

做~自己de王妃 提交于 2019-12-03 00:47:38
问题 This question already has an answer here : Find rows in a data frame where two columns are equal (1 answer) Closed 2 years ago . I have a table: df <- read.table(text=" a b 5 a a 2 c a 3 d d 2 a a 1 b d 2 ") colnames(df) <- c("Gen1","Gen2", "N") I would like to remove the rows when Gen1 = Gen2. For example I would get for this example: result <- read.table(text=" a b 5 c a 3 b d 2 ") colnames(df) <- c("Gen1","Gen2", "N") I tried with duplicated but duplicate is working per rows, not columns.

Subset columns based on row value

情到浓时终转凉″ 提交于 2019-12-03 00:25:32
问题 This may be a simple question, but I haven't been able to find any answer. Consider you have a dataframe with n columns with molecular features. In the last row of each column, a coefficient of variance is expressed. Example data set: a <- data.frame(matrix(runif(30),ncol=3)) b <- c(50.23,45.23,21) a<-rbind(a,b) X1 X2 X3 1 0.1097075 0.78584027 0.20925033 2 0.6081752 0.39669748 0.65559913 3 0.9912855 0.68462073 0.54741795 4 0.8543848 0.53776889 0.43789447 5 0.2579654 0.92188090 0.61292895 6 0