在R中的htmlTable中对齐脚注

时间:2017-02-20 11:24:39

标签: r htmlwidgets

我正在尝试使用htmlTable中的R包创建一个表格,我发现很难将脚注对齐到表格的左下角。

以下是相关代码:

library(htmlTable)

# Create a sample matrix
output <-  matrix(rep(paste("xx (xx.x)"),times = 36), 
                  ncol=3, byrow = TRUE)

# Generate htmlTable outputs
tblOutput <- htmlTable(output,
                       header       =  c("Group A", "Group B", "Goup C"),
                       rnames       = paste0("Row name", 1:12),
                       css.rgroup   = "text-align: left; font-weight: 10;",
                       css.cgroup   = "line-height: 2px;",
                       css.tspanner = "font-weight: 10; text-align: left;",
                       caption      = "Title name",
                       tfoot        = "- Details about row name 1")

# Return table in html format
htmlTableWidget(tblOutput,number_of_entries = 10)

谢谢!

1 个答案:

答案 0 :(得分:0)

我终于发现如果"<div align='left'> Information about row name 1 </div> 被以下内容取代:

'use strict';

import React, {Component} from 'react';
import {StyleSheet, View, Text, ListView, ScrollView} from 'react-native';

const ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});

class BusList extends Component {

    constructor() {
    super();
    // const ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
    this.state = {
      dataSource: ds.cloneWithRows([]),
      getData: []
    };
  }

    componentDidMount() {
        this.loadJSONData();
    }

    loadJSONData() {
        fetch('api')
          .then((response) => {
            this.setState({getData: response})
            this.setState({dataSource: ds.cloneWithRows(response.data.onwardflights)})
            return response.json()
          })
          .then((responseJSON) => {
                    console.log(responseJSON)
              return this.setState({dataSource: this.state.dataSource.cloneWithRows(responseJSON)});
          })
          .catch((error) => {
            console.warn(error);
          });
    }

    renderRow(rowData) {
        return (
            <View>
                <Text>{rowData.origin}</Text>
            </View>
        );
    }

    render() {
    return (
        <View>
            <ListView
                dataSource = {this.state.dataSource}
                enableEmptySections = {true}
                renderRow = {(rowData) => <Text>{rowData}</Text>}   
            />
        </View>
    );
  }
}

module.exports = BusList;

它实际上是完美的。

谢谢!