尝试创建Forest Plot时出现R代码错误

时间:2018-01-06 23:05:49

标签: r

我在R中使用以下代码来构建Forest Plot:

import { compose, createStore } from 'redux';
import RNFirebase from 'react-native-firebase';
import { getFirebase, reactReduxFirebase } from 'react-redux-firebase';
import thunk from 'redux-thunk';
import makeRootReducer from './reducers';

const reactNativeFirebaseConfig = {
  debug: true
};

const reduxFirebaseConfig = {
  userProfile: 'users', // save users profiles to 'users' collection
};

export default (initialState = { firebase: {} }) => {
  // initialize firebase
  const firebase = RNFirebase.initializeApp(reactNativeFirebaseConfig);

  const store = createStore(
    makeRootReducer(),
    initialState,
    compose(
      reactReduxFirebase(firebase, reduxFirebaseConfig), // pass initialized react-native-firebase app instance
     // applyMiddleware can be placed here
    )
  );

  return store;
};

当我这样做时,我收到以下错误:

library(forestplot)

    cochrane_from_rmeta <-
  structure(list(
    mean  = c(NA, NA, 1.62, 1.48, 1.43, 1.55, 1.60, 1.63, 1.48, 1.43, 1.43, 1.41, NA),
    lower = c(NA, NA, 1.23, 0.95, 1.04, 1.15, 1.01, 1.83, 1.15, 1.04, 1.07, 0.79, NA),
    upper = c(NA, NA, 2.14, 2.31, 1.95, 2.09, 2.53, 5.68, 1.91, 1.95, 1.92, 2.54, NA)),
    .Names = c("mean", "lower", "upper"),
    row.names = c(NA, -13L),
    class = "data.frame")

    tabletext<-cbind(
  c("", "Subgroup", "RRMS", "<40 years-old",
    "≥ 40 years-old", "Female", "Male", "First-Line",
    "Non First-Line", "Baseline GdE Lesions","No Baseline GdE Lesions",
    "Direct Switch from NTZ", NA),
  c("Discontinuation", "(DMF)", "244", "93",
    "233", "238", "88", "27",
    "299", "63", "240","41", NA),
  c("Discontinuation", "(FTY)", "148", "62",
    "124", "137", "49", "7",
    "179", "32","138","57", NA),
  c("", "OR", "1.62", "1.48",
    "1.43", "1.55", "1.60", "1.63",
    "1.48", "1.43", "1.43", "1.41", NA))

    forestplot(tabletext,
           cochrane_from_rmeta,new_page = TRUE,
           is.summary=c(TRUE,TRUE,rep(FALSE,10),TRUE),
           clip=c(0.1,2.5),
           xlog=TRUE,
           col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))

有关如何调整代码以便修复错误的任何想法?

提前致谢, 卡丽

1 个答案:

答案 0 :(得分:0)

您需要指定mean,lower和upper参数

    forestplot(tabletext,
                   cochrane_from_rmeta$mean,
                   cochrane_from_rmeta$lower,
                   cochrane_from_rmeta$upper,
                   new_page = TRUE,
                   is.summary=c(TRUE,TRUE,rep(FALSE,10),TRUE),
                   clip=c(0.1,2.5),
                   xlog=TRUE,
                   col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))

enter image description here