如何转换Eigen :: Affine3f至Eigen :: Matrix4f(How to convert from Eigen::Affine3f to Eigen::Matrix4f)
我有两个问题。
Eigen :: Affine3f和Eigen :: Matrix4f中表示的刚性变换是否相同?
我们如何从Eigen :: Affine3f转换为Eigen :: Matrix4f,反之亦然?
谢谢你的帮助!
I have two questions.
Does the rigid transformation represented in Eigen::Affine3f and Eigen::Matrix4f will be the same ?
How can we convert from Eigen::Affine3f to Eigen::Matrix4f and vice versa ?
Thanks for your help!
原文:https://stackoverflow.com/questions/23262476
最满意答案
我希望能够实现它,以便它可以用于已知且始终命名为相同ID1,ID2,Grp和任何数量的具有未知名称的其他数字列的数据框。
您可以先覆盖ID列,然后按它们分组:
DF %>% group_by(Grp) %>% mutate_each(funs(. %>% unique %>% sort %>% toString), ID1, ID2) %>% group_by(ID1, ID2, add=TRUE) %>% summarise_each(funs(sum)) # Source: local data frame [2 x 6] # Groups: Grp, ID1 [?] # # Grp ID1 ID2 Col1 Col2 Col3 # (chr) (chr) (chr) (int) (int) (int) # 1 G1 A, C B, D 4 8 13 # 2 G2 E, G F, h 9 11 15
我想你会想要在折叠成字符串之前进行统一和排序,所以我添加了这些步骤。
I would like to be able to implement it so that it would work for a data frame with known and always named the same ID1, ID2, Grp, and any number of additional numeric column with unknown names.
You can overwrite the ID columns first and then group by them as well:
DF %>% group_by(Grp) %>% mutate_each(funs(. %>% unique %>% sort %>% toString), ID1, ID2) %>% group_by(ID1, ID2, add=TRUE) %>% summarise_each(funs(sum)) # Source: local data frame [2 x 6] # Groups: Grp, ID1 [?] # # Grp ID1 ID2 Col1 Col2 Col3 # (chr) (chr) (chr) (int) (int) (int) # 1 G1 A, C B, D 4 8 13 # 2 G2 E, G F, h 9 11 15
I think you'll want to uniqify and sort before collapsing to a string, so I've added those steps.
相关问答
更多-
如果你在一个字符串(也就是字符向量)中有一个列名,并且你想将它与tidyeval一起使用,那么你可以用rlang::sym() 。 只是改变 dplyr::filter( mpg > !!rlang::sym(probColName) ) 它应该工作。 这取自此github问题的建议: https : //github.com/tidyverse/rlang/issues/116 它仍然可以使用 dplyr::summarize( !!probColName := quantile(mpg, pctCut ...
-
我希望能够实现它,以便它可以用于已知且始终命名为相同ID1,ID2,Grp和任何数量的具有未知名称的其他数字列的数据框。 您可以先覆盖ID列,然后按它们分组: DF %>% group_by(Grp) %>% mutate_each(funs(. %>% unique %>% sort %>% toString), ID1, ID2) %>% group_by(ID1, ID2, add=TRUE) %>% summarise_each(funs(sum)) # Source: local d ...
-
dplyr 0.2包含summarise_each为此目的: df %>% group_by(grp) %>% summarise_each(funs(mean)) #> Source: local data frame [3 x 5] #> #> grp a b c d #> (int) (dbl) (dbl) (dbl) (dbl) #> 1 1 3.000000 2.666667 2.666667 3 ...
-
我们可以在base R尝试 cbind(data, setNames(data[sel_columns], paste0("prefix_", sel_columns))) # var1 var2 var3 prefix_var1 prefix_var3 #1 12 123 23 12 23 #2 3 5435 456 3 456 #3 4 121 123 4 123 ...
-
一个选项是使用tidyr::gather然后使用dplyr汇总: library(dplyr) library(tidyr) df %>% gather(feelings, value, -id) %>% #Change to long format filter(value) %>% #Filter for value which are TRUE group_by(id) %>% summarise(feelings= paste0(feelings,collapse=",")) ...
-
R Markdown中的内联dplyr(inline dplyr in R Markdown)[2022-06-11]
我会尝试 ```{r, echo=FALSE} library(magrittr) # for %$% extraction x <- temp %>% filter(name=="Dog") %>% slice(1) %$% n) ``` 快速的棕色狐狸跳过`rx`懒狗 但您也可以使用dplyr内联。 我成功测试了这个: --- title: "test" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$s ... -
如果在其他行中重复,则使用R中的dplyr添加列(add a column using dplyr in R based on if duplicated in other rows)[2022-04-03]
这是使用ave()的解决方案: df$newColumn <- ave(df$label,df$value,FUN=function(x) c(0L,rep(x[1L],length(x)-1L))) df; ## group label value newColumn ## 1 1 1 3 0 ## 2 1 2 4 0 ## 3 1 3 3 1 ## 4 1 ... -
列使用dplyr重命名(column renaming with dplyr)[2023-07-16]
这是另一种方式 cars %>% filter(speed > 20) %>% rename(new_speed = speed) It's the other way cars %>% filter(speed > 20) %>% rename(new_speed = speed) -
我们可以尝试 a %>% group_by(ID) %>% mutate(V2 = cumsum(V1 >= 1000)+1L) # ID V1 V2 #
#1 1 -1 1 #2 1 0 1 #3 1 1 1 #4 1 1000 2 #5 1 0 2 #6 1 1 2 #7 2 ... -
如果要将数据拆分为列表并使用lapply ,则可以这样做: lapply(split(DF, DF$Date), function(dd) { dd %>% group_by(expirationyear) %>% summarise(Sum = sum(amount)) %>% mutate(Percent = Sum/sum(Sum)*100) }) 另一个(和更简单)选项是简单地按日期和到期日分组: DF %>% group_by(Date, expi ...