科学网

 找回密码
  注册

tag 标签: paste

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

R中批量读入文件--assign+paste函数
feilei1986 2017-6-29 13:10
假设我有一批文件需要读取,单个读入如下: 纯文本查看 复制代码 ? 01 02 03 04 05 06 07 08 09 10 d48=read.csv(48.FPKM_TPM.sorted,sep=\t,row.names =transcript_id) d49=read.csv(49.FPKM_TPM.sorted,sep=\t,row.names =transcript_id) #... d59=read.csv(59.FPKM_TPM.sorted,sep=\t,row.names =transcript_id) all(rownames(d48)==rownames(d51)) all=cbind(d48,d49,d50,d51,d52,d53,d54,d55,d56,d57,d58,d59) # 当使用write.table命令时,col.names=NA,那么第一行就会空出一个位置,就不会造成第一列左移 write.table(all,file=all_FPKM_TPM.txt,quote=F,sep =\t,col.names=NA) 单个读入需要重复输入一批代码,而批量读入文件只需要for循环+assign函数+paste函数 纯文本查看 复制代码 ? 1 2 3 4 5 6 7 8 for(i in48:59) { assign(paste(d,i,sep=),read.csv(paste(i,.FPKM_TPM.sorted,sep=),sep =\t,row.names =transcript_id)) } # 查看读入的文件 head(d48) head(d59) so easy~~~~~~~~~~ ^_^
个人分类: R笔记|6458 次阅读|0 个评论
[转载]R语言中的paste函数
热度 1 PatientHeart 2017-1-12 13:06
R语言中的paste函数 1.功能 Concatenate vectors after converting to character. 2.语法结构 paste (..., sep = , collapse = NULL) paste0(..., collapse = NULL) 3.用法实例 (1)生成字符串 paste(1:12) 1 2 3 4 5 6 7 8 9 10 11 12 (2)字符串连接 nth - paste(1:12, c(st, nd, rd, rep(th, 9))) nth 1 st 2 nd 3 rd 4 th 5 th 6 th 7 th 8 th 9 th 10 th 11 th 12 th (3)字符串连接2 ## paste works the same, but separates each input with a space. ## Notice that the recycling rules make every input as long as the longest input. paste(month.abb, is the, nth, month of the year.) Jan is the 1 st month of the year. Feb is the 2 nd month of the year. Mar is the 3 rd month of the year. Apr is the 4 th month of the year. May is the 5 th month of the year. Jun is the 6 th month of the year. Jul is the 7 th month of the year. Aug is the 8 th month of the year. Sep is the 9 th month of the year. Oct is the 10 th month of the year. Nov is the 11 th month of the year. Dec is the 12 th month of the year. paste(month.abb, letters) Jan a Feb b Mar c Apr d May e Jun f Jul g Aug h Sep i Oct j Nov k Dec l Jan m Feb n Mar o Apr p May q Jun r Jul s Aug t Sep u Oct v Nov w Dec x Jan y Feb z (4)sep的用法 ## You can change the separator by passing a sep argument ## which can be multiple characters. paste(month.abb, is the, nth, month of the year., sep = _*_) Jan_*_is the_*_1 st_*_month of the year. Feb_*_is the_*_2 nd_*_month of the year. Mar_*_is the_*_3 rd_*_month of the year. Apr_*_is the_*_4 th_*_month of the year. May_*_is the_*_5 th_*_month of the year. Jun_*_is the_*_6 th_*_month of the year. Jul_*_is the_*_7 th_*_month of the year. Aug_*_is the_*_8 th_*_month of the year. Sep_*_is the_*_9 th_*_month of the year. Oct_*_is the_*_10 th_*_month of the year. Nov_*_is the_*_11 th_*_month of the year. Dec_*_is the_*_12 th_*_month of the year. (5)collapse ## To collapse the output into a single string, pass a collapse argument. paste0(nth, collapse = , ) 1 st, 2 nd, 3 rd, 4 th, 5 th, 6 th, 7 th, 8 th, 9 th, 10 th, 11 th, 12 th (6)collapse和sep ## For inputs of length 1, use the sep argument rather than collapse paste(1st, 2nd, 3rd, collapse = , ) # probably not what you wanted 1st 2nd 3rd paste(1st, 2nd, 3rd, sep = , ) 1st, 2nd, 3rd (7) ## You can combine the sep and collapse arguments together. paste(month.abb, nth, sep = : , collapse = ; ) Jan: 1 st; Feb: 2 nd; Mar: 3 rd; Apr: 4 th; May: 5 th; Jun: 6 th; Jul: 7 th; Aug: 8 th; Sep: 9 th; Oct: 10 th; Nov: 11 th; Dec: 12 th 不积跬步无以至千里,不积小流无以成江海
个人分类: R语言|8775 次阅读|1 个评论
和任胜利老师: 科技写作时态 (Past tense? Present tense?)
热度 10 zuojun 2013-1-28 06:31
任胜利 老师的科技写作 (103) :时态的使用要妥当 http://blog.sciencenet.cn/home.php?mod=spaceuid=38899do=blogid=656933cid=2437830 I left a comment at Ren lao shi’s Blog, and received this homework assignment. I don’t know if I can do a better job than his book, but let me try to add my two cents. (Why me? I was a researcher who wrote papers in English, and I am a freelance English editor who edits about 150 research papers each year.) First, I am a numerical modeler. So when I am ready to write a paper, I have done most of the numerical experiments already. 1. Introduction In the introduction, we often need to cite many publications. Our rules are: 1) use the past tense when a sentence starts with a publication; For example: Ren et al. (2012) noted a dramatic increase in publication by Chinese authors in SCI journals during the 2000s, thanks in part to the cash reward and promotion criteria set by the (Chinese) system. (Sorry, I made up this sentence, and this Ren is not any Ren lao shi at SciNet.) Note that even though the publication is recent, I still use the past tense, “noted.” Note also that I have no authority to make you follow this rule, but from now on you should pay attention to what your colleagues do when you read their papers. 2) use the present tense for a result/fact that remains true today, even though the result/fact was obtained 100 years ago. For example: The Gulf Stream is the most powerful western boundary current on Earth, which was discovered and confirmed by sailors and scientists hundred years ago. 3) use both mixed (say past and present) tenses in one sentence. If you don’t like the sentence I made up in 2), here is one from Wikipedia: European discovery of the Gulf Stream dates to the 1513 expedition of Juan Ponce de León , after which it became widely used by Spanish ships sailing from the Caribbean to Spain. 2. Methodology To describe the methods and data sets used in the paper, we use the present tense. For example: We use the WOA (World Ocean Atlas) data as initial conditions for our experiments. We use satellite data to validate model’s phytoplankton field in the surface layer. 3. Results We use the present tense to describe all our (finished) experiments. If you prefer to use the past tense, it is fine as long as you do so consistently. Do not switch from the past tense to the present tense randomly. 4) Discussion and Conclusion We tend to use the present perfect tense, such as “We have shown,” but again one can use the past tense or the present tense. Just be consistent. I hope this helps. ps. You may al so want to che ck this out: Scientific Writing for Beginners (1)-(8) by Zuojun Yu using this link: http://blog.sciencenet.cn/home.php?mod=spaceuid=306792do=blogid=432195
个人分类: Most shared|16603 次阅读|16 个评论
vi 列编辑 paste a.dat b.dat >> c.dat
shengxianlei06 2012-11-20 16:51
1. 把两个文件按列先后合并 $cat a.dat 0.76 -17717.653056372 0.78 -17717.654661810 0.80 -17717.655644779 $cat b.dat 0.76 -17717.625661875 0.78 -17717.627996671 0.80 -17717.629663721 执行命令 $paste a.dat b.dat c.dat 就发现ab两文件合并成了c文件如下: $ cat c.dat 0.76 -17717.653056372 0.76 -17717.625661875 0.78 -17717.654661810 0.78 -17717.627996671 0.80 -17717.655644779 0.80 -17717.629663721
个人分类: vi命令集|2911 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-19 16:38

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部