subset

R Dynamic split/subset of dataframe by selected rownumbers- Parsing textgrid praat

落爺英雄遲暮 提交于 2019-12-30 11:21:30
问题 I am trying to process a "segmentation file" called .TextGrid (generated by Praat program). ) The original format looks like this: File type = "ooTextFile" Object class = "TextGrid" xmin = 0 xmax = 243.761375 tiers? <exists> size = 17 item []: item [1]: class = "IntervalTier" name = "phones" xmin = 0 xmax = 243.761 intervals: size = 2505 intervals [1]: xmin = 0 xmax = 0.4274939687384032 text = "_" intervals [2]: xmin = 0.4274939687384032 xmax = 0.472 text = "v" intervals [3]: [...] (This is

R Dynamic split/subset of dataframe by selected rownumbers- Parsing textgrid praat

心已入冬 提交于 2019-12-30 11:21:12
问题 I am trying to process a "segmentation file" called .TextGrid (generated by Praat program). ) The original format looks like this: File type = "ooTextFile" Object class = "TextGrid" xmin = 0 xmax = 243.761375 tiers? <exists> size = 17 item []: item [1]: class = "IntervalTier" name = "phones" xmin = 0 xmax = 243.761 intervals: size = 2505 intervals [1]: xmin = 0 xmax = 0.4274939687384032 text = "_" intervals [2]: xmin = 0.4274939687384032 xmax = 0.472 text = "v" intervals [3]: [...] (This is

Get all subsets of a collection

最后都变了- 提交于 2019-12-30 10:52:33
问题 I am trying to create a method that will return all subsets of a set. For example if I have the collection 10,20,30 I will like to get the following output return new List<List<int>>() { new List<int>(){10}, new List<int>(){20}, new List<int>(){30}, new List<int>(){10,20}, new List<int>(){10,30}, new List<int>(){20,30}, //new List<int>(){20,10}, that substet already exists // new List<int>(){30,20}, that subset already exists new List<int>(){10,20,30} }; because the collection can also be a

rolling computations in xts by month

我与影子孤独终老i 提交于 2019-12-30 10:50:54
问题 I am familiar with the zoo function rollapply which allows you to do rolling computations on zoo or xts objects and you can specify the rolling increment via the by parameter. I am specifically interested in applying a function every month but using all of the past daily data in the computation. For example say my data set looks like this: dte, val 1/01/2001, 10 1/02/2001, 11 ... 1/31/2001, 2 2/01/2001, 54 2/02/2001, 34 ... 2/30/2001, 29 I would like to select the end of each month and apply

R: how to subset a data.frame in a list and return data.frame?

亡梦爱人 提交于 2019-12-30 09:43:35
问题 When subsetting a data.frame inside of a list, I get vectors instead of a data.frames (see the example below). How to avoid this and get a data.frames? l <- list(data.frame(a=c(1,2,3)), data.frame(b=c(4,5,6,5)), data.frame(c=c(3,4,5,6))) names(l) <- c("A", "B", "C") l lapply(l, function(x) x[2:nrow(x), ]) output > l <- list(data.frame(a=c(1,2,3)), data.frame(b=c(4,5,6,5)), data.frame(c=c(3,4,5,6))) > names(l) <- c("A", "B", "C") > l $A a 1 1 2 2 3 3 $B b 1 4 2 5 3 6 4 5 $C c 1 3 2 4 3 5 4 6 >

Subset check with slices in Go

戏子无情 提交于 2019-12-30 09:42:58
问题 I am looking for a efficient way to check if a slice is a subset of another. I could simply iterate over them to check, but I feel there has to be a better way. E.g. {1, 2, 3} is a subset of {1, 2, 3, 4} {1, 2, 2} is NOT a subset of {1, 2, 3, 4} What is the best way to do this efficiently? Thanks! 回答1: I think the most common way to solve a subset problem is via a map. package main import "fmt" // subset returns true if the first array is completely // contained in the second array. There

How does createDataPartition function from caret package split data?

拟墨画扇 提交于 2019-12-30 09:00:38
问题 From the documentation: For bootstrap samples, simple random sampling is used. For other data splitting, the random sampling is done within the levels of y when y is a factor in an attempt to balance the class distributions within the splits. For numeric y, the sample is split into groups sections based on percentiles and sampling is done within these subgroups. For createDataPartition, the number of percentiles is set via the groups argument. I don't understand why this "balance" thing is

r subset array using vector

血红的双手。 提交于 2019-12-30 07:09:08
问题 I feel like this question should have already been answered, but I found none. I have an array and I want to subset it using a vector. I know how to do it the hard way, but I'm sure there's got to be an easy way. Any ideas? Here's my example: dat <- data.frame(a = rep(letters[1:3], 2), b = rep(letters[1:2], 3), c = c(rep("a", 5), "b"), x = rnorm(6), stringsAsFactors = FALSE) l <- by(dat[ , "x"], dat[ , 1:3], mean) l["a", "a", "a"] # works l[c("a", "a", "a")] # does not work So I guess I need

Check if string is subset of a bunch of characters? (RegEx)?

孤街醉人 提交于 2019-12-30 05:28:25
问题 I have a little problem, I have 8 characters, for example "a b c d a e f g", and a list of words, for example: mom, dad, bad, fag, abac How can I check if I can or cannot compose these words with the letters I have? In my example, I can compose bad, abac and fag, but I cannot compose dad (I have not two D) and mom (I have not M or O). I'm pretty sure it can be done using a RegEx but would be helpful even using some functions in Perl.. Thanks in advance guys! :) 回答1: This is done most simply

How can I get the intersection, union, and subset of arrays in Ruby?

二次信任 提交于 2019-12-29 10:07:17
问题 I want to create different methods for a class called Multiset. I have all the required methods, but I'm unsure of how to write intersection, union, and subset methods. For intersection and union, my code starts like this: def intersect(var) x = Multiset.new end Here is an example: X = [1, 1, 2, 4] Y = [1, 2, 2, 2] then the intersection of X and Y is [1, 2] . 回答1: Utilizing the fact that you can do set operations on arrays by doing & (intersection), - (difference), and | (union). Obviously I