在我最近对已推送的存储库的提交中,我注意到我在文件中拼错了一个单词,现在想更改它。但是,我不想创建一个全新的提交。有没有办法修改我最新的提交并将其推送到我的存储库中,而无需重置、删除和推送?
过去我是这样做的:
git reset HEAD~1 --soft
git push -f
# correct the spelling
git add .
git commit -m "bug10 fix"
Run Code Online (Sandbox Code Playgroud)
有没有办法纠正文件的拼写,修改我最新的提交并推送,而不必重置,强制删除,然后重新提交?
我试过:
# fixed the file
git add .
git commit --amend --no-edit
git push
Run Code Online (Sandbox Code Playgroud)
! [rejected] Nov21 -> Nov21 (non-fast-forward)
Run Code Online (Sandbox Code Playgroud) 我有以下数据框
tbl <- structure(list(col1 = c("a", NA, "b", NA, "c", "c"), col2 = c("n",
"n", "b", "a", NA, "c"), col3 = c("z", "a", "z", "b", "1", "c"
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)# A tibble: 6 x 3 col1 col2 col3 <chr> <chr> <chr> 1 a n z 2 NA n a 3 b b z 4 NA a b 5 c NA 1 6 c c c
是否可以将 dplyr::count 函数应用于每一列或返回每列的唯一条目以及可能每个唯一值出现的数量的其他函数?
我在 all_lists 中存储了一组列表。
all_list=c("LIST1","LIST2")
Run Code Online (Sandbox Code Playgroud)
从这些,我想创建一个数据框,这样
LISTn$findings${Coli}$character被输入到第 n 列,rowname from LISTn$rowname。
数据
LIST1=list()
LIST1[["findings"]]=list(s1a=list(character="a1",number=1,string="a1type",exp="great"),
=list(number=2,string="b1type"),
in2a=list(character="c1",number=3,string="c1type"),
del3b=list(character="d1",number=4,string="d1type"))
LIST1[["rowname"]]="Row1"
LIST2=list()
LIST2[["findings"]]=list(s1a=list(character="a2",number=5,string="a2type",exp="great"),
s1b=list(character="b2",number=6,string="b2type"),
in2a=list(character="c2",number=7,string="c2type"),
del3b=list(character="d2",number=8,string="d2type"))
LIST2[["rowname"]]="Row2"
Run Code Online (Sandbox Code Playgroud)
请注意,缺少某些字符,NA 就足够了。
所需的输出是这个数据帧:
Run Code Online (Sandbox Code Playgroud)s1a s1b in2a del3b Row1 a1 NA c1 d1 Row2 a2 b2 c2 d2
这些列表大约有 1000 个,速度是一个因素。在我加载它们之后,每个列表大约有 50mBrjson::fromJSON(file=x)
行名和列名不遵循特定模式。它们是名称和属性
我有一个重复的列表l1 <- list(c("a","b"), c("1","2"),c("x","y"))。还有一个数据框:
df <- structure(list(names = structure(c(2L, 1L, 3L, 4L), .Label = c("1",
"a", "x", "y"), class = "factor"), values = c(0, 0, 0, 0)), class = "data.frame", row.names = c(NA,
-4L))
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)names values 1 a 0 2 1 0 3 x 0 4 y 0
我想用 l1 列表中的对替换这些名称的任何出现。df 所需的输出将是:
Run Code Online (Sandbox Code Playgroud)names values 1 b 0 2 2 0 3 y 0 4 x 0
我有一个数据框如下:
df <- data.frame(s1=c("a","a/b","b","a","a/b"),s2=c("ab/bb","bb","ab","ab","bb"),s3=c("Doa","Doa","Dob/Doa","Dob/Doa","Dob"))
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)s1 s2 s3 1 a ab/bb Doa 2 a/b bb Doa 3 b ab Dob/Doa 4 a ab Dob/Doa 5 a/b bb Dob
每列可以采用两个值之一或两者都用“/”分隔。我想根据它们的值将它们分解为二进制的列集。
所需的数据框是:
Run Code Online (Sandbox Code Playgroud)a b ab bb Doa Dob 1 1 0 1 1 1 0 2 1 1 0 1 1 0 3 0 1 1 0 1 1 4 1 0 1 0 1 1 5 1 1 0 1 0 1
我尝试使用 tidyr::separate 和 tapply 来做这件事,但它变得相当复杂,因为我必须为每一对指定列名。有很多列。
我有以下文本文件
cat file.txt
name value
ID1 a;b;c
ID2 d
ID3 e;f
Run Code Online (Sandbox Code Playgroud)
我想旋转这些。
期望的输出
name value
ID1 a
ID1 b
ID1 c
ID2 d
ID3 e
ID3 f
Run Code Online (Sandbox Code Playgroud)
我想
文件.awk
BEGIN { FS=OFS="\t" }
NR>1 {
a=$1 split($2,a,";"); next
}
NR>1 {
a=$1 for (i in a)
print a, a[i]
printf "\n"
}
Run Code Online (Sandbox Code Playgroud)
但这无法启动阵列。有替代方案吗?
数据
df <- data.frame(a=c(1,1,1,1), b1=c(0,0,0,0), b2=c(0,0,0,0),c1=c(0,0,1,0),
c2=c(0,1,0,0), e=c(0,0,0,0), d=c(0,0,0,0))
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)a b1 b2 c1 c2 d e 1 1 0 0 0 0 0 0 2 1 0 0 0 1 0 0 3 1 0 0 1 0 0 0 4 1 0 0 0 0 0 0
我怎样才能将这些转换成 3 列变成 ab=a * sum(contains("b")) ac=a * (sum(contains("c")))
我正在寻找类似的东西 transmute(df, ab=a*(sum(b1+b2)), ac=a*(sum(c1+c2)), aothers=a*(sum (!contains ("a" | "b" | "c")))
AB: a * sum(any col that contains "b")
交流: a * sum(any …
我还在C的学习阶段,写了下面的函数。我没想到它会起作用,因为 void 指针只给出了 2 个字节,这对于我的 23 字节字符数组来说是不够的。尽管它存储在 char 数组中,并且可以将其类型转换为另一个指针变量。
void main(){
void *p = malloc(2 * sizeof(char));
p = "Unites State of America";
printf("%p length -> %ld, sizeof -> %ld\n", p, strlen(p), sizeof(p)/sizeof(p[0]));
char *pstr = (char*) p;
printf("%s length -> %ld\n", pstr, strlen(pstr));
}
Run Code Online (Sandbox Code Playgroud)
结果:
0x55600dccd008 length -> 23, sizeof -> 8
Unites State of America length -> 23
Run Code Online (Sandbox Code Playgroud)
我的 void 指针是如何超过我最初请求的大小的?