首页
\
问答
\
父进程何时获取子进程的退出状态,如果子进程调用exec()(when will the parent process get exit status of the child, if child calls exec())
父进程何时获取子进程的退出状态,如果子进程调用exec()(when will the parent process get exit status of the child, if child calls exec())
如果孩子调用exec(),任何人都可以让我知道父进程何时会获得子进程的退出状态?
它是在子调用exec时还是在子进程用exec程序完成执行时?
Can any one please let me know when will the parent process get exit status of the child, if child calls exec()?
Is it at the time when child calls exec or when the child process finishes its execution with exec program?
原文:
更新时间:2022-07-30 08:07
最满意答案
在分组data.frame上使用
combn
的tidyverse
选项:library(tidyverse) df %>% group_by(index) %>% summarise(gene = list(as_data_frame(t(combn(gene, 2))))) %>% unnest(.sep = '_') ## # A tibble: 4 × 3 ## index gene_V1 gene_V2 ## <int> <chr> <chr> ## 1 1 a b ## 2 1 a c ## 3 1 b c ## 4 2 d e
可以在基R中复制相同的逻辑:
df2 <- aggregate(gene ~ index, df, function(x){t(combn(x, 2))}) do.call(rbind, apply(df2, 1, data.frame)) ## index gene.1 gene.2 ## 1 1 a b ## 2 1 a c ## 3 1 b c ## 4 2 d e
数据
df <- structure(list(gene = c("a", "b", "c", "d", "e"), index = c(1L, 1L, 1L, 2L, 2L)), .Names = c("gene", "index"), row.names = c(NA, -5L), class = "data.frame")
A
tidyverse
option usingcombn
on a grouped data.frame:library(tidyverse) df %>% group_by(index) %>% summarise(gene = list(as_data_frame(t(combn(gene, 2))))) %>% unnest(.sep = '_') ## # A tibble: 4 × 3 ## index gene_V1 gene_V2 ## <int> <chr> <chr> ## 1 1 a b ## 2 1 a c ## 3 1 b c ## 4 2 d e
The same logic can be replicated in base R:
df2 <- aggregate(gene ~ index, df, function(x){t(combn(x, 2))}) do.call(rbind, apply(df2, 1, data.frame)) ## index gene.1 gene.2 ## 1 1 a b ## 2 1 a c ## 3 1 b c ## 4 2 d e
Data
df <- structure(list(gene = c("a", "b", "c", "d", "e"), index = c(1L, 1L, 1L, 2L, 2L)), .Names = c("gene", "index"), row.names = c(NA, -5L), class = "data.frame")
相关问答
更多-
这似乎有效: # clean up OP's example trace[, mark := NULL ] # lookup label trace[, mark := trace[.(dep = dep, id = id), on=.(label = dep, id < id), mult="last", x.id] ] # if not found, use current id trace[is.na(mark), mark := id ] id dep label mark 1 ...
-
我们可以使用lapply循环遍历列并检查它们中是否包含"," 。 lapply(dat, function(x) any(grepl(",", x))) # $d1 #[1] FALSE # #$d2 #[1] TRUE We could use lapply to loop over the columns and check if any of them contain ",". lapply(dat, function(x) any(grepl(",", x))) # $d1 #[1] ...
-
尝试使用base R:首先由David回答: index <- match(colname, names(df)) Try with base R: and first answered by David above: index <- match(colname, names(df))
-
R中的索引匹配(Index Match in R)[2022-03-16]
你非常接近,只是你必须使用一个矩阵来沿着多个维度下标,否则你会得到这些组合的产品。 正确的是: LoanData$Rate <- RateData[cbind( match(LoanData$OriginationDate, RateData$Date), match(LoanData$PriceIndex, colnames(RateData)) )] You were pretty close, it's just that you have to use a matrix to subscr ... -
您可能不需要在这里apply final_weights <- (wjs-omega)^2 要获取具有最小值的列的索引,可以使用arr.ind=TRUE来获取“行/列”索引(修改@Bhas注释) which(final_weights == min(final_weights), arr.ind=TRUE)[,2] 数据 set.seed(24) wjs <- as.data.frame(matrix(sample(0:20, 5*10, replace=TRUE), ncol=5)) set.see ...
-
正如@baptiste所指出的,你应该使用aes_string()而不是aes()来定义x和y值。 您还应该将value和variable放在引号内。 PropBarPlot<-function(df, mytitle=""){ melteddf<-melt(df, id=names(df)[1], na.rm=T) ggplot(melteddf, aes_string(x=names(df)[1],y= "value", fill="variable")) + geom_bar(pos ...
-
R配对列索引(R paired column index)[2022-07-29]
A2 <- merge(A,B, by = "mth")[ , -1] names(A2)[(which(names(A2)=="year"))] <- "mth" > A2 day hr v mth 1 10 3 3 2008 2 11 3 3 2008 3 11 4 4 2009 4 10 4 4 2009 5 11 5 5 2010 6 10 5 5 2010 7 11 6 4 2011 8 10 6 4 2011 9 10 7 3 201 ... -
在分组data.frame上使用combn的tidyverse选项: library(tidyverse) df %>% group_by(index) %>% summarise(gene = list(as_data_frame(t(combn(gene, 2))))) %>% unnest(.sep = '_') ## # A tibble: 4 × 3 ## index gene_V1 gene_V2 ##
... -
感谢您的建议。 我将确保下次发布具有可重复性示例的问题。 就这个问题而言,我尝试了@akrun建议的方法,首先将矩阵转换为数据帧,并成功地提取了所需的标识符。 Thank you for the advices. I will make sure to post a question with reproducible example next time. As far as this question goes, I tried the methods suggested by @akrun by fir ...
-
我们可以使用merge ,告诉R我们要合并的是: merge (index, locations, by.x="Column", by.y="Row") 这为您的测试数据提供: Column Row longitude latitude 1 3 2 98.9675 18.79663 根据您在没有匹配时要发生的情况,您还可以在调用中使用all = TRUE来包含缺失值。 退房?merge了解更多信息。 We can use merge, and tell R which ones w ...