在R脚本中将代码拆分为多行 [英] Split code over multiple lines in an R script

查看:369
本文介绍了在R脚本中将代码拆分为多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将R脚本中的一行分割成多行(因为它太长了).我该怎么办?

I want to split a line in an R script over multiple lines (because it is too long). How do I do that?

具体来说,我有一行

setwd('~/a/very/long/path/here/that/goes/beyond/80/characters/and/then/some/more')

是否可以将长路径分成多行?我尝试过

Is it possible to split the long path over multiple lines? I tried

setwd('~/a/very/long/path/here/that/goes/beyond/80/characters/and/
then/some/more')

在第一行的末尾使用return键进行

;但这不起作用.

with return key at the end of the first line; but that does not work.

谢谢.

推荐答案

您不是在多行上破坏 code ,而是单个标识符.有区别.

You are not breaking code over multiple lines, but rather a single identifier. There is a difference.

对于您的问题,请尝试

R> setwd(paste("~/a/very/long/path/here",
               "/and/then/some/more",
               "/and/then/some/more",
               "/and/then/some/more", sep=""))

这也说明跨多行破坏代码是完全可以的.

which also illustrates that it is perfectly fine to break code across multiple lines.

这篇关于在R脚本中将代码拆分为多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆