quick-R

http://www.statmethods.net/interface/workspace.html

The Workspace

The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, dataframes, lists, functions). At the end of an R session, the user can save an image of the current workspace that is automatically reloaded the next time R is started. Commands are entered interactively at the R user prompt. Up and down arrow keys scroll through your command history.

You will probably want to keep different projects in different physical directories. Here are some standard commands for managing your workspace.

IMPORTANT NOTE FOR WINDOWS USERS:
   R gets confused if you use a path in your code like
       c:\mydocuments\myfile.txt
   This is because R sees "\" as an escape character. Instead, use
       c:\\my documents\\myfile.txt
       c:/mydocuments/myfile.txt
   Either will work. I use the second convention throughout this website.

getwd() # print the current working directory - cwd
ls()    # list the objects in the current workspace

setwd(mydirectory)      # change to mydirectory
setwd("c:/docs/mydir")  # note / instead of \ in windows
setwd("/usr/rob/mydir") # on linux

# view and set options for the session
help(options) # learn about available options
options() # view current option settings
options(digits=3) # number of digits to print on output

# work with your previous commands
history() # display last 25 commands
history(max.show=Inf) # display all previous commands

# save your command history
savehistory(file="myfile") # default is ".Rhistory"

# recall your command history
loadhistory(file="myfile") # default is ".Rhistory"

# save the workspace to the file .RData in the cwd
save.image()

# save specific objects to a file
# if you don't specify the path, the cwd is assumed
save(object list,file="myfile.RData")

# load a workspace into the current session
# if you don't specify the path, the cwd is assumed
load("myfile.RData")

q() # quit R. You will be prompted to save the workspace.

posted on 2011-12-05 13:53  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2011/12/05/2276760.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值