在R中我怎么能尝试使用这个unix命令
printf "%s\t" NAMES n{1..1600} >file_o
尝试
system(paste("printf \"%s\t\" NAMES n{1..1600} >file_o"))
不会导致任何消息,但它不会创建相同的输出。该文件只是
NAMES n{1..1600}
什么时候应该
NAMES n1 n2 (/t in betwen up to the max number )
评论表明这可能与操作系统有一些关系 - 在ubuntu上它既不能在Debian上运行
printen的输出
[1] "LESSOPEN=| /usr/bin/lesspipe %s"
[2] "R_UNZIPCMD=/usr/bin/unzip"
[3] "USER=katoui"
[4] "LANGUAGE=en_GB:en"
[5] "UPSTART_INSTANCE="
[6] "XDG_SEAT=seat0"
[7] "TEXTDOMAIN=im-config"
[8] "SSH_AGENT_PID=1272"
[9] "COMPIZ_CONFIG_PROFILE=ubuntu"
[10] "LD_LIBRARY_PATH=/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server"
[11] "SHLVL=1"
[12] "HOME=/home/katou"
[13] "QT4_IM_MODULE=ibus"
[14] "DESKTOP_SESSION=ubuntu"
[15] "R_LIBS_SITE=/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library"
[16] "GTK_MODULES=overlay-scrollbar:unity-gtk-module"
[17] "XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0"
[18] "R_BROWSER=xdg-open"
[19] "PAGER=/usr/bin/pager"
[20] "INSTANCE=Unity"
[21] "DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-hR5PKeEWoO"
[22] "R_SYSTEM_ABI=linux,gcc,gxx,gfortran,?"
[23] "COLORTERM=gnome-terminal"
[24] "GNOME_KEYRING_CONTROL=/run/user/1000/keyring-FBpib0"
[25] "UBUNTU_MENUPROXY=1"
[26] "QT_QPA_PLATFORMTHEME=appmenu-qt5"
[27] "MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path"
[28] "IM_CONFIG_PHASE=1"
[29] "SESSIONTYPE=gnome-session"
[30] "UPSTART_JOB=unity-settings-daemon"
[31] "LOGNAME=katou"
[32] "GTK_IM_MODULE=ibus"
[33] "TAR=/bin/tar"
[34] "WINDOWID=67112765"
[35] "DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path"
[36] "R_LIBS_USER=~/R/x86_64-pc-linux-gnu-library/3.1"
[37] "XDG_SESSION_ID=c1"
[38] "TERM=xterm"
[39] "COLUMNS=80"
[40] "GNOME_DESKTOP_SESSION_ID=this-is-deprecated"
[41] "R_ARCH="
[42] "R_PAPERSIZE_USER=a4"
[43] "PATH=/opt/texbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
[44] "SELINUX_INIT=YES"
[45] "GDM_LANG=en_GB"
[46] "R_BZIPCMD=/bin/bzip2"
[47] "R_INCLUDE_DIR=/usr/share/R/include"
[48] "XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0"
[49] "XDG_RUNTIME_DIR=/run/user/1000"
[50] "R_SESSION_TMPDIR=/tmp/Rtmpg8bGY1"
51] "DISPLAY=:0"
[52] "LANG=en_GB.UTF-8"
[53] "XDG_CURRENT_DESKTOP=Unity"
[54] "XMODIFIERS=@im=ibus"
[55] "XAUTHORITY=/home/maurice/.Xauthority"
[56] "XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/maurice"
[57] "SSH_AGENT_LAUNCHER=upstart"
[58] "SSH_AUTH_SOCK=/run/user/1000/keyring-FBpib0/ssh"
[59] "R_GZIPCMD=/bin/gzip"
[60] "SED=/bin/sed"
[61] "SHELL=/bin/bash"
[62] "LN_S=ln -s"
[63] "QT_ACCESSIBILITY=1"
[64] "GDMSESSION=ubuntu"
[65] "R_PDFVIEWER=/usr/bin/xdg-open"
[66] "LESSCLOSE=/usr/bin/lesspipe %s %s"
[67] "UPSTART_EVENTS=started starting"
[68] "R_TEXI2DVICMD=/usr/bin/texi2dvi"
[69] "GPG_AGENT_INFO=/run/user/1000/keyring-FBpib0/gpg:0:1"
[70] "UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1191"
[71] "R_HOME=/usr/lib/R"
[72] "TEXTDOMAINDIR=/usr/share/locale/"
[73] "R_PRINTCMD=/usr/bin/lpr"
[74] "XDG_VTNR=7"
[75] "QT_IM_MODULE=ibus"
[76] "R_DOC_DIR=/usr/share/R/doc"
[77] "PWD=/home/ryo"
[78] "R_SHARE_DIR=/usr/share/R/share"
[79] "R_ZIPCMD=/usr/bin/zip"
[80] "CLUTTER_IM_MODULE=xim"
[81] "XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg"
[82] "XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/"
[83] "PYTHONPATH=:/usr/lib/python2.7/site-packages"
[84] "R_PLATFORM=x86_64-pc-linux-gnu"
[85] "R_PAPERSIZE=letter"
[86] "LINES=24"
[87] "MAKE=make"
[88] "VTE_VERSION=3409"
[89] "R_RD4PDF=times,inconsolata,hyper"
[90] "JOB=gnome-session"
[91] "EDITOR=vi"
答案 0 :(得分:0)
获得输出的两种替代方法是:
system('echo -n "NAMES\\\\t" > file_o')
和
system(' for i in $(seq 0 1600) ; do printf "n${i}\\\\t" >> file_o ; done')