相关疑难解决方法(0)

将文件名拆分为名称,扩展名

我有这样一个文件的名称:name1.csv我想提取这个字符串的两个子串.一个存储name1一个变量,另一个存储扩展csv,而不存在另一个变量中的点.

我一直在寻找是否有类似indexOfJava 的功能允许进行那种操作,但我还没有找到任何东西.

有帮助吗?

filenames split substring r

37
推荐指数
2
解决办法
3万
查看次数

Chop off the first letter of every variable name

I have some data that looks like this:

    country agdp apop
1        US  100  100
2 Australia   50   50
Run Code Online (Sandbox Code Playgroud)

The variable names are agdp and apop, but I would like them to be gdp and pop. My real data has many, many variables that all need that transformation.

And this is what my desired outcome:

 country gdp pop
1        US  100  100
2 Australia   50   50
Run Code Online (Sandbox Code Playgroud)

Reproducible code below:

df <- data.frame(stringsAsFactors=FALSE,
     country = c("US", "Australia"),
        agdp = …
Run Code Online (Sandbox Code Playgroud)

r dplyr tidyverse

5
推荐指数
1
解决办法
105
查看次数

标签 统计

r ×2

dplyr ×1

filenames ×1

split ×1

substring ×1

tidyverse ×1