seq

Calculate Run Length Sequence and Maximum by Subject ID

喜你入骨 提交于 2021-02-20 04:36:12
问题 We have time series data in which repeated observations were measured for several subjects. I would like to calculate the number of occasions in which the variable positive == 1 occurs for each subject (variable id ). A second aim is to identify the maximum length of these runs of consecutive observations in which positive == 1 . For each subject there are likely to be multiple runs within the study period. Rather than calculating the maximum number of consecutive positive observations per

Sample using start and end values within a loop in R

让人想犯罪 __ 提交于 2021-02-05 07:53:36
问题 I am trying to sample between a range of values as part of a larger loop in R. As the loop progresses to each row j , I want to sample a number between the value given in the start column and the value given in the end column, placing that value in the sampled column for that row. The results should look something like this: ID start end sampled a 25 67 44 b 36 97 67 c 23 85 77 d 15 67 52 e 21 52 41 f 43 72 66 g 39 55 49 h 27 62 35 i 11 99 17 j 21 89 66 k 28 65 48 l 44 58 48 m 16 77 22 n 25

Sample using start and end values within a loop in R

拜拜、爱过 提交于 2021-02-05 07:53:12
问题 I am trying to sample between a range of values as part of a larger loop in R. As the loop progresses to each row j , I want to sample a number between the value given in the start column and the value given in the end column, placing that value in the sampled column for that row. The results should look something like this: ID start end sampled a 25 67 44 b 36 97 67 c 23 85 77 d 15 67 52 e 21 52 41 f 43 72 66 g 39 55 49 h 27 62 35 i 11 99 17 j 21 89 66 k 28 65 48 l 44 58 48 m 16 77 22 n 25

R - comparing two rows by columns and writing the result in a table

只谈情不闲聊 提交于 2021-01-27 12:50:19
问题 I'm an R newbie and probably the solution for my problem is very simple but it's out of my reach for now... I would like to compare rows in a data frame by columns. The data in each column is a letter (nucleotide base): seq1 A C T G T seq2 A C G G G seq3 A G G C A ... I'd like to compare all rows in the data set with each other by column. The result I would like to obtain is simple 1 or 0 for TRUE and FALSE in the comparison, written in a form of table as well. So it would look like this:

Serilog serializing fields

北城以北 提交于 2020-11-28 07:46:41
问题 If I have the following class public class Customer { public string Name; } and then have the following log command in Serilog Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); var item = new Customer(); item.Name = "John"; Serilog.Log.Information("Customer {@item}", item); The log just displays in Seq as Customer {} If I change the Name field to a property it works but I would prefer not to do that at this stage. Is there any way

Serilog serializing fields

江枫思渺然 提交于 2020-11-28 07:46:11
问题 If I have the following class public class Customer { public string Name; } and then have the following log command in Serilog Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); var item = new Customer(); item.Name = "John"; Serilog.Log.Information("Customer {@item}", item); The log just displays in Seq as Customer {} If I change the Name field to a property it works but I would prefer not to do that at this stage. Is there any way

R - Range of number sequences, or how can I get the reverse of 1:10

本秂侑毒 提交于 2020-04-30 07:14:05
问题 I can't seem to find an elegant solution to finding ranges. For me, it would come down to this: > seq(1:10) [1] 1 2 3 4 5 6 7 8 9 10 I would like to get the reverse: function(c(1,2,3,4,5,6,7,8,9,10)) result 1:10 Real world problem is that I have 1200 indices, some are 0, some are 1: c(0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1) And I would like the ranges/coordinates within the vector for each set of 0s and 1s. 回答1: Will this simple solution work? > rev(seq(1:10)) [1]

Bash Script Loop Out of Memory?

我与影子孤独终老i 提交于 2020-01-25 08:08:30
问题 In bash I need to run a script that loops from i=1 to i=99999999 but it always run out of memory. Is there any workaround? or is there a max value for i? first=1 last=99999999 randomString="CXCXQOOPSOIS" for val in $( seq $first $last ) do padVal=$( printf "%010d\n" $val ) hash=$( echo -n $randomString$padVal | md5sum ) if [[ "$hash" =~ ^000000) ]]; then echo "Number: $val" >> log_000000 echo "$val added to log - please check." fi done 回答1: bash provides C-like syntax for loop: first=1 last

max element in Z3 Seq Int

拥有回忆 提交于 2020-01-16 09:43:06
问题 I'm trying to write a max function that operates on Seq Int . It should return the index with maximal value . Here is what I have: (declare-fun max ((Seq Int)) Int) (assert (forall ((A (Seq Int))) (=> (> (seq.len A) 0) (and (<= 0 (max A)) (< (max A) (seq.len A)) (forall ((i Int)) (=> (and (<= 0 i) (< i (seq.len A))) (<= (seq.nth A i) (seq.nth A (max A)))))))) ) (assert (= (max (seq.++ (seq.unit 8) (seq.unit 3))) 0)) ;(assert (= (max (seq.++ (seq.unit 8) (seq.unit 3))) 1)) (check-sat) When I

Vectorizing rep and seq in R

孤者浪人 提交于 2020-01-14 12:59:30
问题 I am trying to accomplish two things. First if I have a vector 1:5 I want to get a matrix (or two vectors) indicating the unique combinations of these elements including twice the same number but excluding repetitions. Right now I can do this using a matrix: foo <- matrix(1:5,5,5) cbind(foo[upper.tri(foo,diag=TRUE)],foo[lower.tri(foo,diag=TRUE)]) [,1] [,2] [1,] 1 1 [2,] 1 2 [3,] 2 3 [4,] 1 4 [5,] 2 5 [6,] 3 2 [7,] 1 3 [8,] 2 4 [9,] 3 5 [10,] 4 3 [11,] 1 4 [12,] 2 5 [13,] 3 4 [14,] 4 5 [15,] 5