dt=read.table("C:/Users/Administrator/python_test/combos1.txt")
dim(dt)
dt
?read.table
1+1
2
getwd()
'C:/Users/Administrator'
?write.table
write.table(dt, file = "C:/Users/Administrator/python_test/combos1_R.txt", sep=',', col.names = NA,
qmethod = "double")
dt1=read.table("C:/Users/Administrator/python_test/combos1_R.txt",header = TRUE,sep=',')
dt1
<table>
<thead><tr><th scope=col>X</th><th scope=col>age</th><th scope=col>amount</th><th scope=col>grade</th><th scope=col>gender_1</th><th scope=col>intercept</th><th scope=col>predict</th></tr></thead>
<tbody>
<tr><td>0 </td><td>18 </td><td>208182 </td><td>6 </td><td>0 </td><td>1 </td><td>0.485540</td></tr>
<tr><td>1 </td><td>18 </td><td> 26141 </td><td>8 </td><td>1 </td><td>1 </td><td>0.519408</td></tr>
<tr><td>2 </td><td>18 </td><td>325354 </td><td>9 </td><td>0 </td><td>1 </td><td>0.499659</td></tr>
<tr><td>3 </td><td>18 </td><td>183147 </td><td>5 </td><td>1 </td><td>1 </td><td>0.479521</td></tr>
<tr><td>4 </td><td>18 </td><td> 13923 </td><td>5 </td><td>1 </td><td>1 </td><td>0.495424</td></tr>
</tbody>
</table>
str(dt1)
'data.frame': 5 obs. of 7 variables:
$ X : int 0 1 2 3 4
$ age : int 18 18 18 18 18
$ amount : int 208182 26141 325354 183147 13923
$ grade : int 6 8 9 5 5
$ gender_1 : int 0 1 0 1 1
$ intercept: int 1 1 1 1 1
$ predict : num 0.486 0.519 0.5 0.48 0.495
library(readr)
yitian=readLines("D:/R_test/倚天屠龙记.txt")
para_head=grep("\\s",yitian)
para_head=grep("\\s+",yitian)
cut_para=cbind(para_head[1:length(para_head)-1],para_head[-1]-1)
yitian_para=sapply(1:nrow(cut_para),function(i) paste(yitian[cut_para[i,1]:cut_para[i,2]],collapse=""))
#yitian_para[1:4]
writeLines(yitian_para, "D:/R_test/YTTL/yitian_para.txt")
x<-read_lines("D:/R_test/YTTL/yitian_para.txt")
#x[1:4]
################################编码转换
y<-iconv(x,to='UTF-8')
y[1:4]
writeLines(y,"D:/R_test/YTTL/y.txt")
<ol class=list-inline>
<li><span style=white-space:pre-wrap>' 一 天涯思君不可忘'</span></li>
<li><span style=white-space:pre-wrap>' “春游浩荡,是年年寒食,梨花时节。白锦无纹香烂漫,玉树琼苞堆雪。静夜沉沉,浮光霭霭,冷浸溶溶月。人间天上,烂银霞照通彻。浑似姑射真人,天姿灵秀,意气殊高洁。万蕊参差谁信道,不与群芳同列。浩气清英,仙才卓荦,下土难分别。瑶台归去,洞天方看清绝。”'</span></li>
<li><span style=white-space:pre-wrap>' 作这一首《无俗念》词的,乃南宋末年一位武学名家,有道之士。此人姓丘,名处机,道号长春子,名列全真七子之一,是全真教中出类拔萃的人物。《词品》评论此词道:“长春,世之所谓仙人也,而词之清拔如此”。这首词诵的似是梨花,其实词中真意却是赞誉一位身穿白衣的美貌少女,说她“浑似姑射真人,天姿灵秀,意气殊高洁”,又说她“浩气清英,仙才卓荦”,“不与群芳同列”。词中所颂这美女,乃古墓派传人小龙女。她一生爱穿白衣,当真如风拂玉树,雪裹琼苞,兼之生性清冷,实当得起“冷浸溶溶月”的形容,以“无俗念”三字赠之,可说十分贴切。长春子丘处机和她在终南山上比邻而居,当年一见,便写下这首词来。'</span></li>
<li><span style=white-space:pre-wrap>' 这时丘处机逝世已久,小龙女也已嫁与神雕大侠杨过为妻。在河南少室山山道之上,却另有一个少女,正在低低念诵此词。这少女十八九岁年纪,身穿淡黄衣衫,骑着一头青驴,正沿山道缓缓而上,心中默想:“也只有龙姊姊这样的人物,才配得上他。”这一个“他”字,指的自然是神雕大侠杨过了。她也不拉缰绳,任由那青驴信步而行,一路上山。过了良久,她又低声吟道:“欢乐趣,离别苦,就中更有痴儿女。君应有语,渺万里层云,千山暮雪,只影向谁去?”'</span></li>
</ol>
x=c(1,2,3)
x
x[x>2]
y=c("dcfg",'dcbds','dsjjkdsj')
which(nchar(y)>4)
<ol class=list-inline>
<li>1</li>
<li>2</li>
<li>3</li>
</ol>
3
<ol class=list-inline>
<li>2</li>
<li>3</li>
</ol>