Extract previous value by group from other group column
One option is to create a row number column on DF, then use data.table
rolling join:
library(data.table)
setDT(DF)[, rn := seq_len(.N)]
DF[DF,
on=.(ID_2 = ID_1, rn = rn),
.(ID_1 = i.ID_1, ID_2 = i.ID_2, Value = i.Value, New = x.Value),
roll=Inf
]
# ID_1 ID_2 Value New
# 1: A G 10 NA
# 2: B D 9 NA
# 3: C I 15 NA
# 4: D A 27 9
# 5: A J 3 27
# 6: A B 28 27
# 7: B K 4 28
# 8: E D 3 NA
# 9: D A 11 3
#10: F H 19 NA
#11: H A 12 19
Unable to append group to user gropus with usermod
Your '-' character is incorrect. Maybe you've copy and paste it from somewhere or you're using a non-standard keyboard.
Take a look at your command hex-dump:
echo 'usermod –a –G support user1' | hd
00000000 75 73 65 72 6d 6f 64 20 e2 80 93 61 20 e2 80 93 |usermod ...a ...|
00000010 47 20 73 75 70 70 6f 72 74 20 75 73 65 72 31 0a |G support user1.|
00000020
But the correct one is:
echo 'usermod -a -G support user1' | hd
00000000 75 73 65 72 6d 6f 64 20 2d 61 20 2d 47 20 73 75 |usermod -a -G su|
00000010 70 70 6f 72 74 20 75 73 65 72 31 0a |pport user1.|
0000001c
Notice the -
character in the second hex and compare it with your
Related Topics
Monitor/Audit File Delete on Linux
How to Print on Stderr with Swift
Linux + Verify If File Is Text or Binary
I Need a Tcp Option (Ioctl) to Send Data Immediately
Print The Lines Between Two Dates from The Log Using Shell Command in Linux
How to Execute a Command in a Bash Script and Then Focus The Appearing Window
Problem of Understanding Clock_Gettime
How Do Parent and Child Share Pages After Fork() with Copy-On-Write in Linux
Sending Snmp2 Trap Message from Linux Command Lne
Awk: Find and Replace in Certain Field Only
Kate Text Editor Cannot Handle Lines Longer Than 1024
Write Something to Linux Hid Device
How to Compile Redis So That I Can Upload and Run It on Shared Hosting
Linux Process Context and Svc Call in Arm
How Event Packet Header Is Getiing in Hci_Send_Req API Implementation