首页 \ 问答 \ 父进程何时获取子进程的退出状态,如果子进程调用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上使用combntidyverse选项:

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 using combn 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))
  • 你非常接近,只是你必须使用一个矩阵来沿着多个维度下标,否则你会得到这些组合的产品。 正确的是: 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 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。