basic question: how can I export a table that I print into the R console and paste into a text editor (e.g this dialog box) keeping a decent format. Consider that I want to print the head of my table:
> head(cytoplasmic)
I will get the following output in the console:
V1 V2 V3 V4 V5 V6
3 LdBPK_020440.1 cytoplasmic: 0.54 nuclear: 0.45 mitochondrial: 0.0 Golgi apparatus: 0.0 peroxisomal: 0.0
5 LdBPK_201720.1 cytoplasmic: 0.89 nuclear: 0.06 mitochondrial: 0.02 peroxisomal: 0.01 Golgi apparatus: 0.01
6 LdBPK_070130.1 cytoplasmic: 0.61 nuclear: 0.32 peroxisomal: 0.05 mitochondrial: 0.02 Golgi apparatus: 0.0
7 LdBPK_040060.1 cytoplasmic: 0.52 nuclear: 0.43 mitochondrial: 0.02 extracellular: 0.01 peroxisomal: 0.01
13 LdBPK_191560.1 cytoplasmic: 0.49 nuclear: 0.46 mitochondrial: 0.03 peroxisomal: 0.01 Golgi apparatus: 0.0
15 LdBPK_364730.1 cytoplasmic: 0.93 nuclear: 0.06 mitochondrial: 0.0 peroxisomal: 0.0 Golgi apparatus: 0.0
V7 V8 V9 V10
3 plasma membrane: 0.0 extracellular: 0.0 ER: 0.0 lysosomal: 0.0
5 extracellular: 0.0 plasma membrane: 0.0 ER: 0.0 lysosomal: 0.0
6 plasma membrane: 0.0 extracellular: 0.0 ER: 0.0 lysosomal: 0.0
7 Golgi apparatus: 0.01 plasma membrane: 0.0 ER: 0.0 lysosomal: 0.0
13 plasma membrane: 0.0 extracellular: 0.0 ER: 0.0 lysosomal: 0.0
15 extracellular: 0.0 plasma membrane: 0.0 ER: 0.0 lysosomal: 0.0
Which does not have a decent format in this text dialog at all.
I also tried using the kable function from the knitr package with the following code:
> kable(head(cytoplasmic, format = "markdown"))
then I get the following output:
|V1 |V2 |V3 |V4 |V5 |V6 |V7 |V8 |V9 |V10 |
|:--|:--------------|:-----------------|:-------------|:-------------------|:--------------------|:---------------------|:---------------------|:--------------------|:-------|:--------------|
|3 |LdBPK_020440.1 |cytoplasmic: 0.54 |nuclear: 0.45 |mitochondrial: 0.0 |Golgi apparatus: 0.0 |peroxisomal: 0.0 |plasma membrane: 0.0 |extracellular: 0.0 |ER: 0.0 |lysosomal: 0.0 |
|5 |LdBPK_201720.1 |cytoplasmic: 0.89 |nuclear: 0.06 |mitochondrial: 0.02 |peroxisomal: 0.01 |Golgi apparatus: 0.01 |extracellular: 0.0 |plasma membrane: 0.0 |ER: 0.0 |lysosomal: 0.0 |
|6 |LdBPK_070130.1 |cytoplasmic: 0.61 |nuclear: 0.32 |peroxisomal: 0.05 |mitochondrial: 0.02 |Golgi apparatus: 0.0 |plasma membrane: 0.0 |extracellular: 0.0 |ER: 0.0 |lysosomal: 0.0 |
|7 |LdBPK_040060.1 |cytoplasmic: 0.52 |nuclear: 0.43 |mitochondrial: 0.02 |extracellular: 0.01 |peroxisomal: 0.01 |Golgi apparatus: 0.01 |plasma membrane: 0.0 |ER: 0.0 |lysosomal: 0.0 |
|13 |LdBPK_191560.1 |cytoplasmic: 0.49 |nuclear: 0.46 |mitochondrial: 0.03 |peroxisomal: 0.01 |Golgi apparatus: 0.0 |plasma membrane: 0.0 |extracellular: 0.0 |ER: 0.0 |lysosomal: 0.0 |
|15 |LdBPK_364730.1 |cytoplasmic: 0.93 |nuclear: 0.06 |mitochondrial: 0.0 |peroxisomal: 0.0 |Golgi apparatus: 0.0 |extracellular: 0.0 |plasma membrane: 0.0 |ER: 0.0 |lysosomal: 0.0 |
which, on the R console looks somewhat better, it is although not really readable here.
Thanks