傳遞字串 R中的變數傳遞引數內容

2021-10-16 02:32:20 字數 592 閱讀 7010

當需要批量處理資料或者生成ggplot2時,往往需要通過自己構建函式處理,寫函式就不可避免的需要使用引數傳遞,r中的引數傳遞絕大部分自寫函式都是通過傳遞字串來構成,但是當使用dplyr或者ggplot2時,不能直接處理字串,並且就算使用字串處理資料,plotly之類的互動顯示的也是表示式(比如iris[[input$variable]])。

ggplot(mtcars, aes(x=wt, y=mpg))+geom_point()

## pass string parameter to the function

ggplot(mtcars, aes_string(x='wt', y='mpg'))+geom_point()

iris %>% filter(petal.length >= mean(petal.length))

## 使用rlang的函式sym

library(rlang)

iris %>% filter(!!sym('petal.length') >= mean(!!sym('petal.length')))

傳遞字串 Linux Shell 傳遞引數

物聯網開發入門直播課 嵌入式 物聯網 快速上手linux 創客學院直播室 www.makeru.com.cn 嵌入式應用層開發 1小時全面認識linux網路經典案例 創客學院直播室 www.makeru.com.cn 我們可以在執行 shell 指令碼時,向指令碼傳遞引數,指令碼內獲取引數的格式為 ...

shell 變數,字串,陣列,注釋,引數傳遞

linux的shell有很多種,常見的有bourne shellbourne again shellc shellk shellshell for root 等,其中bourne again shell,由於易用和免費,bash在日常工作中被廣泛使用,本系列文章就是基於b shell進行 的 之前所...

mysql儲存過程傳遞字串引數

儲存過程 create procedure pro getuserinfo in szempname varchar 1000 begin declare strsql varchar 1000 set strsql concat insert into tmptable userinfo empn...