cut

Getting same output as cut() using speedier hist() or findInterval()?

纵饮孤独 提交于 2019-12-13 02:07:42
问题 I read this article http://www.r-bloggers.com/comparing-hist-and-cut-r-functions/ and tested hist() to be faster than cut() by ~4 times on my PC. My script loops through cut() many times so the time-saving would be significant. I thus tried to switch to the speedier function but am having difficulties getting the exact output as per cut() . From the sample code below: data <- rnorm(10, mean=0, sd=1) #generate data my_breaks <- seq(-6, 6, by=1) #create a vector that specifies my break points

Extracting specific pattern from nmap

◇◆丶佛笑我妖孽 提交于 2019-12-13 00:43:43
问题 Imagine I have nmap results like so: # Nmap 6.40 scan initiated Sat Jun 14 10:14:35 2014 as: nmap ... Nmap scan report for x.x.x.x. Host is up (0.21s latency). PORT STATE SERVICE 23/tcp open telnet | telnet-brute: |_ No accounts found Nmap scan report for y.y.y.y Host is up (0.24s latency). PORT STATE SERVICE 23/tcp open telnet Nmap scan report for z.z.z.z Host is up (0.22s latency). PORT STATE SERVICE 23/tcp open telnet |_telnet-brute: var1 - <blank> Nmap scan report for w.w.w.w Host is up

paste two files according to concordance between columns

久未见 提交于 2019-12-12 17:06:42
问题 I would need some help about this: I have file1: ID 100 102 103 104 108 109 112 . . . And file2: ID [] p1 p2 100 2.5 3.0 2.0 101 2.0 4.0 3.0 102 2.6 4.0 2.5 103 2.3 2.0 NA 104 2.3 2.0 2.0 105 3.5 2.8 2.0 106 1.7 NA 3.2 107 5.0 4.0 4.0 108 3.2 2.0 4.0 109 2.9 1.0 1.5 110 5.0 NA NA 111 2.9 4.0 4.0 112 3.1 2.5 2.0 . . . I would like to paste both files in file3 looking like: ID [] p1 p2 100 2.5 3.0 2.0 102 2.6 4.0 2.5 103 2.3 2.0 NA 104 2.3 2.0 2.0 108 3.2 2.0 4.0 109 2.9 1.0 1.5 112 3.1 2.5 2.0

Joining Columns on Command Line with Paste or PR Not Working

[亡魂溺海] 提交于 2019-12-12 15:49:50
问题 So I have two files that I want to take columns out of and join them in a single file. f1: 02/10/2013,16:00:00.091,123.82,OTCX,GLO,,123.82 02/10/2013,16:00:03.072,123.766,FXN,NAM,,123.766 02/10/2013,16:00:03.491,123.769,FXN,,,123.769 02/10/2013,16:00:03.565,123.79,COMM,ASI,HKG,123.79 02/10/2013,16:00:03.721,123.769,FXN,NAM,NYC,123.769 02/10/2013,16:00:04.194,123.81,AKM,EUR,MOW,123.81 02/10/2013,16:00:06.130,123.764,FXN,NAM,NYC,123.764 02/10/2013,16:00:06.330,123.764,FXN,,,123.764 02/10/2013

Breaking a continuous variable into categories using dplyr and/or cut

三世轮回 提交于 2019-12-12 04:54:23
问题 I have a dataset that is a record of price changes, among other variables. I would like to mutate the price column into a categorical variable. I understand that the two functions of importance here in R seem to be dplyr and/or cut . > head(btc_data) time btc_price 1 2017-08-27 22:50:00 4,389.6113 2 2017-08-27 22:51:00 4,389.0850 3 2017-08-27 22:52:00 4,388.8625 4 2017-08-27 22:53:00 4,389.7888 5 2017-08-27 22:56:00 4,389.9138 6 2017-08-27 22:57:00 4,390.1663 >dput(btc_data) ("4,972.0700", "4

Using awk to extract a column containing spaces

不羁岁月 提交于 2019-12-12 03:28:18
问题 I'm looking for a way to extract the filename column from the below output. 2016-02-03 08:22:33 610540 vendor_20160202_67536242.WAV 2016-02-03 08:19:25 530916 vendor_20160202_67536349.WAV 2016-02-03 08:17:10 2767824 vendor_20160201_67369072 - cb.mp3 2016-02-03 08:17:06 368928 vendor_20160201_67369072.mp3 One of the files has spaces in the name which is causing issues with my current commmand awk '{print $4}' How would I treat a column with spaces as a single column? 回答1: awk to the rescue! $

R: Cut function with POSIXct dates: Creating specific categories based on time of day

独自空忆成欢 提交于 2019-12-12 02:16:15
问题 I have a small training set of data that I am beginning to analyze. The dataset is comprised of hospital procedural codes, values for said procedure, and a date/time stamp. I am attempting to break down the time stamps into 'time of day' categories, as some of the procedural values will vary depending on morning/evening. I have tried using cut() , but I can't seem to figure out how to input specific time intervals for the categories (ex. 00:00 to 06:00 = "Fasting", 06:01- 10:00 = "Morning

extract header if pattern in a column matches

陌路散爱 提交于 2019-12-12 01:59:30
问题 I am trying to extract and print header of a file if the pattern in that particular column matches. Here is a example : [user ~]$ cal |sed 's/July 2014//' Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Expected output : if input date =31 then print the day on 31st. Just to be clear, I cannot use date -d flag as its not supported by my OS.Probably would need awk here to crack the question. [user ~]$ date -d 20140731 +%A Thursday I hope

How to move first N bytes from text file to another text file

五迷三道 提交于 2019-12-11 14:55:26
问题 I've got an extreme problem, and all of the solutions I can imagine are complicated. According to my UNIX/Linux experience there must be an easy way. I want to delete the first n bytes of file in log.txt.file is long enough. Well, I'm sure somebody will deliver me a suprisingly easy solution I just can't imagine. 回答1: I am not sure what you want: Your headline says move first N byte to another file, your text says you want to delete the first N bytes tail -c +N log.txt Will output everything

what is the meaning of delimiter in cut and why in this command it is sorting twice?

妖精的绣舞 提交于 2019-12-11 14:49:11
问题 I am trying to find the reason of this command and as I know very basic I found that last | cut -d" " -f 1 | sort | uniq -c | sort last = Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. cut is to show the desired column. The option -d specifies what is the field delimiter that is used in the input file. -f specifies which field you want to extract 1 is the out put I