如何导出 R 生成的数据框?
How do I export a dataframe produced by R?
我无法在 rscu 计算中导出由 uco(seqinr) 函数生成的数据帧。我应该使用什么方法?数据框也没有显示在 r 环境中,它只保留在控制台中。试了那么多复制到excel,word,记事本都是徒劳。有人可以帮忙吗?
> library("seqinr")
> rcds <- read.fasta("virus.fasta")[[1]]
> uco( rcds, index = "freq")
aaa aac aag aat aca acc
0.068669528 0.025751073 0.004291845 0.030042918 0.030042918 0.012875536
acg act aga agc agg agt
0.008583691 0.012875536 0.034334764 0.000000000 0.008583691 0.025751073
ata atc atg att caa cac
0.025751073 0.012875536 0.017167382 0.034334764 0.017167382 0.008583691
cag cat cca ccc ccg cct
0.008583691 0.004291845 0.017167382 0.004291845 0.004291845 0.008583691
cga cgc cgg cgt cta ctc
0.008583691 0.000000000 0.000000000 0.004291845 0.004291845 0.012875536
ctg ctt gaa gac gag gat
0.012875536 0.008583691 0.008583691 0.004291845 0.021459227 0.012875536
gca gcc gcg gct gga ggc
0.021459227 0.004291845 0.000000000 0.008583691 0.017167382 0.000000000
ggg ggt gta gtc gtg gtt
0.004291845 0.012875536 0.008583691 0.000000000 0.008583691 0.012875536
taa tac tag tat tca tcc
0.047210300 0.017167382 0.034334764 0.047210300 0.008583691 0.017167382
tcg tct tga tgc tgg tgt
0.004291845 0.004291845 0.034334764 0.017167382 0.025751073 0.012875536
tta ttc ttg ttt
0.017167382 0.017167382 0.034334764 0.038626609
> uco( rcds, index = "eff")
aaa aac aag aat aca acc acg act aga agc agg agt ata atc atg att caa cac
16 6 1 7 7 3 2 3 8 0 2 6 6 3 4 8 4 2
cag cat cca ccc ccg cct cga cgc cgg cgt cta ctc ctg ctt gaa gac gag gat
2 1 4 1 1 2 2 0 0 1 1 3 3 2 2 1 5 3
gca gcc gcg gct gga ggc ggg ggt gta gtc gtg gtt taa tac tag tat tca tcc
5 1 0 2 4 0 1 3 2 0 2 3 11 4 8 11 2 4
tcg tct tga tgc tgg tgt tta ttc ttg ttt
1 1 8 4 6 3 4 4 8 9
> uco( rcds, index = "rscu")
aaa aac aag aat aca acc acg
1.8823529 0.9230769 0.1176471 1.0769231 1.8666667 0.8000000 0.5333333
act aga agc agg agt ata atc
0.8000000 3.6923077 0.0000000 0.9230769 2.5714286 1.0588235 0.5294118
atg att caa cac cag cat cca
1.0000000 1.4117647 1.3333333 1.3333333 0.6666667 0.6666667 2.0000000
ccc ccg cct cga cgc cgg cgt
0.5000000 0.5000000 1.0000000 0.9230769 0.0000000 0.0000000 0.4615385
cta ctc ctg ctt gaa gac gag
0.2857143 0.8571429 0.8571429 0.5714286 0.5714286 0.5000000 1.4285714
gat gca gcc gcg gct gga ggc
1.5000000 2.5000000 0.5000000 0.0000000 1.0000000 2.0000000 0.0000000
ggg ggt gta gtc gtg gtt taa
0.5000000 1.5000000 1.1428571 0.0000000 1.1428571 1.7142857 1.2222222
tac tag tat tca tcc tcg tct
0.5333333 0.8888889 1.4666667 0.8571429 1.7142857 0.4285714 0.4285714
tga tgc tgg tgt tta ttc ttg
0.8888889 1.1428571 1.0000000 0.8571429 1.1428571 0.6153846 2.2857143
ttt
1.3846154
> uco( rcds, as.data.frame = FALSE, NA.rscu = NA)
aaa aac aag aat aca acc acg act aga agc agg agt ata atc atg att caa cac
16 6 1 7 7 3 2 3 8 0 2 6 6 3 4 8 4 2
cag cat cca ccc ccg cct cga cgc cgg cgt cta ctc ctg ctt gaa gac gag gat
2 1 4 1 1 2 2 0 0 1 1 3 3 2 2 1 5 3
gca gcc gcg gct gga ggc ggg ggt gta gtc gtg gtt taa tac tag tat tca tcc
5 1 0 2 4 0 1 3 2 0 2 3 11 4 8 11 2 4
tcg tct tga tgc tgg tgt tta ttc ttg ttt
1 1 8 4 6 3 4 4 8 9
> uco( rcds, as.data.frame = TRUE, NA.rscu = NA)
AA codon eff freq RSCU
aaa Lys aaa 16 0.068669528 1.8823529
aac Asn aac 6 0.025751073 0.9230769
aag Lys aag 1 0.004291845 0.1176471
aat Asn aat 7 0.030042918 1.0769231
aca Thr aca 7 0.030042918 1.8666667
acc Thr acc 3 0.012875536 0.8000000
acg Thr acg 2 0.008583691 0.5333333
act Thr act 3 0.012875536 0.8000000
aga Arg aga 8 0.034334764 3.6923077
agc Ser agc 0 0.000000000 0.0000000
agg Arg agg 2 0.008583691 0.9230769
agt Ser agt 6 0.025751073 2.5714286
ata Ile ata 6 0.025751073 1.0588235
atc Ile atc 3 0.012875536 0.5294118
atg Met atg 4 0.017167382 1.0000000
att Ile att 8 0.034334764 1.4117647
caa Gln caa 4 0.017167382 1.3333333
cac His cac 2 0.008583691 1.3333333
cag Gln cag 2 0.008583691 0.6666667
cat His cat 1 0.004291845 0.6666667
cca Pro cca 4 0.017167382 2.0000000
ccc Pro ccc 1 0.004291845 0.5000000
ccg Pro ccg 1 0.004291845 0.5000000
cct Pro cct 2 0.008583691 1.0000000
cga Arg cga 2 0.008583691 0.9230769
cgc Arg cgc 0 0.000000000 0.0000000
cgg Arg cgg 0 0.000000000 0.0000000
cgt Arg cgt 1 0.004291845 0.4615385
cta Leu cta 1 0.004291845 0.2857143
ctc Leu ctc 3 0.012875536 0.8571429
ctg Leu ctg 3 0.012875536 0.8571429
ctt Leu ctt 2 0.008583691 0.5714286
gaa Glu gaa 2 0.008583691 0.5714286
gac Asp gac 1 0.004291845 0.5000000
gag Glu gag 5 0.021459227 1.4285714
gat Asp gat 3 0.012875536 1.5000000
gca Ala gca 5 0.021459227 2.5000000
gcc Ala gcc 1 0.004291845 0.5000000
gcg Ala gcg 0 0.000000000 0.0000000
gct Ala gct 2 0.008583691 1.0000000
gga Gly gga 4 0.017167382 2.0000000
ggc Gly ggc 0 0.000000000 0.0000000
ggg Gly ggg 1 0.004291845 0.5000000
ggt Gly ggt 3 0.012875536 1.5000000
gta Val gta 2 0.008583691 1.1428571
gtc Val gtc 0 0.000000000 0.0000000
gtg Val gtg 2 0.008583691 1.1428571
gtt Val gtt 3 0.012875536 1.7142857
taa Stp taa 11 0.047210300 1.2222222
tac Tyr tac 4 0.017167382 0.5333333
tag Stp tag 8 0.034334764 0.8888889
tat Tyr tat 11 0.047210300 1.4666667
tca Ser tca 2 0.008583691 0.8571429
tcc Ser tcc 4 0.017167382 1.7142857
tcg Ser tcg 1 0.004291845 0.4285714
tct Ser tct 1 0.004291845 0.4285714
tga Stp tga 8 0.034334764 0.8888889
tgc Cys tgc 4 0.017167382 1.1428571
tgg Trp tgg 6 0.025751073 1.0000000
tgt Cys tgt 3 0.012875536 0.8571429
tta Leu tta 4 0.017167382 1.1428571
ttc Phe ttc 4 0.017167382 0.6153846
ttg Leu ttg 8 0.034334764 2.2857143
ttt Phe ttt 9 0.038626609 1.3846154
>
这是计算的输出
首先,将函数的输出存储在变量中,例如:
results_final_v2 <- uco( rcds, index = "freq")
对于变量的名称,您可以使用任何字母A-Z、a-z、0-9、下划线。最好避免使用特殊字符。
现在你将在R环境中看到结果,其他功能将可以使用它。它不会自动显示在控制台中,但您仍然可以通过键入变量名称来查看它,例如results_final_v2
.
现在导出您的数据。将其导出 给其他 R 用户:
save(results_final_v2, file='export1.RData')
如果要将多个变量导出到一个文件中,可以指定多个变量名。
要导出 到 CSV(对于 Excel):
write.csv(results_final_v2, file='export1.csv'
在 Excel 中,您通过 'Import' 或 'Data > From Text' 导入生成的 .csv 文件。对于欧洲用户,write.csv2()
通常效果更好。
还有方法write to an xlsx file directly or copy the data to the clipboard。
我无法在 rscu 计算中导出由 uco(seqinr) 函数生成的数据帧。我应该使用什么方法?数据框也没有显示在 r 环境中,它只保留在控制台中。试了那么多复制到excel,word,记事本都是徒劳。有人可以帮忙吗?
> library("seqinr")
> rcds <- read.fasta("virus.fasta")[[1]]
> uco( rcds, index = "freq")
aaa aac aag aat aca acc
0.068669528 0.025751073 0.004291845 0.030042918 0.030042918 0.012875536
acg act aga agc agg agt
0.008583691 0.012875536 0.034334764 0.000000000 0.008583691 0.025751073
ata atc atg att caa cac
0.025751073 0.012875536 0.017167382 0.034334764 0.017167382 0.008583691
cag cat cca ccc ccg cct
0.008583691 0.004291845 0.017167382 0.004291845 0.004291845 0.008583691
cga cgc cgg cgt cta ctc
0.008583691 0.000000000 0.000000000 0.004291845 0.004291845 0.012875536
ctg ctt gaa gac gag gat
0.012875536 0.008583691 0.008583691 0.004291845 0.021459227 0.012875536
gca gcc gcg gct gga ggc
0.021459227 0.004291845 0.000000000 0.008583691 0.017167382 0.000000000
ggg ggt gta gtc gtg gtt
0.004291845 0.012875536 0.008583691 0.000000000 0.008583691 0.012875536
taa tac tag tat tca tcc
0.047210300 0.017167382 0.034334764 0.047210300 0.008583691 0.017167382
tcg tct tga tgc tgg tgt
0.004291845 0.004291845 0.034334764 0.017167382 0.025751073 0.012875536
tta ttc ttg ttt
0.017167382 0.017167382 0.034334764 0.038626609
> uco( rcds, index = "eff")
aaa aac aag aat aca acc acg act aga agc agg agt ata atc atg att caa cac
16 6 1 7 7 3 2 3 8 0 2 6 6 3 4 8 4 2
cag cat cca ccc ccg cct cga cgc cgg cgt cta ctc ctg ctt gaa gac gag gat
2 1 4 1 1 2 2 0 0 1 1 3 3 2 2 1 5 3
gca gcc gcg gct gga ggc ggg ggt gta gtc gtg gtt taa tac tag tat tca tcc
5 1 0 2 4 0 1 3 2 0 2 3 11 4 8 11 2 4
tcg tct tga tgc tgg tgt tta ttc ttg ttt
1 1 8 4 6 3 4 4 8 9
> uco( rcds, index = "rscu")
aaa aac aag aat aca acc acg
1.8823529 0.9230769 0.1176471 1.0769231 1.8666667 0.8000000 0.5333333
act aga agc agg agt ata atc
0.8000000 3.6923077 0.0000000 0.9230769 2.5714286 1.0588235 0.5294118
atg att caa cac cag cat cca
1.0000000 1.4117647 1.3333333 1.3333333 0.6666667 0.6666667 2.0000000
ccc ccg cct cga cgc cgg cgt
0.5000000 0.5000000 1.0000000 0.9230769 0.0000000 0.0000000 0.4615385
cta ctc ctg ctt gaa gac gag
0.2857143 0.8571429 0.8571429 0.5714286 0.5714286 0.5000000 1.4285714
gat gca gcc gcg gct gga ggc
1.5000000 2.5000000 0.5000000 0.0000000 1.0000000 2.0000000 0.0000000
ggg ggt gta gtc gtg gtt taa
0.5000000 1.5000000 1.1428571 0.0000000 1.1428571 1.7142857 1.2222222
tac tag tat tca tcc tcg tct
0.5333333 0.8888889 1.4666667 0.8571429 1.7142857 0.4285714 0.4285714
tga tgc tgg tgt tta ttc ttg
0.8888889 1.1428571 1.0000000 0.8571429 1.1428571 0.6153846 2.2857143
ttt
1.3846154
> uco( rcds, as.data.frame = FALSE, NA.rscu = NA)
aaa aac aag aat aca acc acg act aga agc agg agt ata atc atg att caa cac
16 6 1 7 7 3 2 3 8 0 2 6 6 3 4 8 4 2
cag cat cca ccc ccg cct cga cgc cgg cgt cta ctc ctg ctt gaa gac gag gat
2 1 4 1 1 2 2 0 0 1 1 3 3 2 2 1 5 3
gca gcc gcg gct gga ggc ggg ggt gta gtc gtg gtt taa tac tag tat tca tcc
5 1 0 2 4 0 1 3 2 0 2 3 11 4 8 11 2 4
tcg tct tga tgc tgg tgt tta ttc ttg ttt
1 1 8 4 6 3 4 4 8 9
> uco( rcds, as.data.frame = TRUE, NA.rscu = NA)
AA codon eff freq RSCU
aaa Lys aaa 16 0.068669528 1.8823529
aac Asn aac 6 0.025751073 0.9230769
aag Lys aag 1 0.004291845 0.1176471
aat Asn aat 7 0.030042918 1.0769231
aca Thr aca 7 0.030042918 1.8666667
acc Thr acc 3 0.012875536 0.8000000
acg Thr acg 2 0.008583691 0.5333333
act Thr act 3 0.012875536 0.8000000
aga Arg aga 8 0.034334764 3.6923077
agc Ser agc 0 0.000000000 0.0000000
agg Arg agg 2 0.008583691 0.9230769
agt Ser agt 6 0.025751073 2.5714286
ata Ile ata 6 0.025751073 1.0588235
atc Ile atc 3 0.012875536 0.5294118
atg Met atg 4 0.017167382 1.0000000
att Ile att 8 0.034334764 1.4117647
caa Gln caa 4 0.017167382 1.3333333
cac His cac 2 0.008583691 1.3333333
cag Gln cag 2 0.008583691 0.6666667
cat His cat 1 0.004291845 0.6666667
cca Pro cca 4 0.017167382 2.0000000
ccc Pro ccc 1 0.004291845 0.5000000
ccg Pro ccg 1 0.004291845 0.5000000
cct Pro cct 2 0.008583691 1.0000000
cga Arg cga 2 0.008583691 0.9230769
cgc Arg cgc 0 0.000000000 0.0000000
cgg Arg cgg 0 0.000000000 0.0000000
cgt Arg cgt 1 0.004291845 0.4615385
cta Leu cta 1 0.004291845 0.2857143
ctc Leu ctc 3 0.012875536 0.8571429
ctg Leu ctg 3 0.012875536 0.8571429
ctt Leu ctt 2 0.008583691 0.5714286
gaa Glu gaa 2 0.008583691 0.5714286
gac Asp gac 1 0.004291845 0.5000000
gag Glu gag 5 0.021459227 1.4285714
gat Asp gat 3 0.012875536 1.5000000
gca Ala gca 5 0.021459227 2.5000000
gcc Ala gcc 1 0.004291845 0.5000000
gcg Ala gcg 0 0.000000000 0.0000000
gct Ala gct 2 0.008583691 1.0000000
gga Gly gga 4 0.017167382 2.0000000
ggc Gly ggc 0 0.000000000 0.0000000
ggg Gly ggg 1 0.004291845 0.5000000
ggt Gly ggt 3 0.012875536 1.5000000
gta Val gta 2 0.008583691 1.1428571
gtc Val gtc 0 0.000000000 0.0000000
gtg Val gtg 2 0.008583691 1.1428571
gtt Val gtt 3 0.012875536 1.7142857
taa Stp taa 11 0.047210300 1.2222222
tac Tyr tac 4 0.017167382 0.5333333
tag Stp tag 8 0.034334764 0.8888889
tat Tyr tat 11 0.047210300 1.4666667
tca Ser tca 2 0.008583691 0.8571429
tcc Ser tcc 4 0.017167382 1.7142857
tcg Ser tcg 1 0.004291845 0.4285714
tct Ser tct 1 0.004291845 0.4285714
tga Stp tga 8 0.034334764 0.8888889
tgc Cys tgc 4 0.017167382 1.1428571
tgg Trp tgg 6 0.025751073 1.0000000
tgt Cys tgt 3 0.012875536 0.8571429
tta Leu tta 4 0.017167382 1.1428571
ttc Phe ttc 4 0.017167382 0.6153846
ttg Leu ttg 8 0.034334764 2.2857143
ttt Phe ttt 9 0.038626609 1.3846154
>
这是计算的输出
首先,将函数的输出存储在变量中,例如:
results_final_v2 <- uco( rcds, index = "freq")
对于变量的名称,您可以使用任何字母A-Z、a-z、0-9、下划线。最好避免使用特殊字符。
现在你将在R环境中看到结果,其他功能将可以使用它。它不会自动显示在控制台中,但您仍然可以通过键入变量名称来查看它,例如results_final_v2
.
现在导出您的数据。将其导出 给其他 R 用户:
save(results_final_v2, file='export1.RData')
如果要将多个变量导出到一个文件中,可以指定多个变量名。
要导出 到 CSV(对于 Excel):
write.csv(results_final_v2, file='export1.csv'
在 Excel 中,您通过 'Import' 或 'Data > From Text' 导入生成的 .csv 文件。对于欧洲用户,write.csv2()
通常效果更好。
还有方法write to an xlsx file directly or copy the data to the clipboard。