【发布时间】:2021-11-03 14:45:38
【问题描述】:
我有一个自然文章的源数据集。我想知道如何将第 4 行和第 12 行的值提取为具有相关分配组的长数据格式(即低效/高效)。
这是我用来将数据导入 R 的代码。
# load the required libraries
library(ggsignif)
library(readxl)
library(svglite)
library(tidyverse)
library(tidyr)
library(dplyr)
# The paper from which the figure is taken is Tasdogen et al. (2020)
# Metabolic heterogeneity confers differences in melanoma metastatic potential
# The figure is 2b and can be accessed at
# https://www.nature.com/articles/s41586-019-1847-2#MOESM3
# The link to the raw data used in the article is given below and directly improted for plotting
url <-'https://static-content.springer.com/esm/art%3A10.1038%2Fs41586-019-1847-2/MediaObjects/41586_2019_1847_MOESM3_ESM.xlsx'
#create a dataframe from the Excel data
temp <- tempfile()
download.file(url, temp, mode='wb')
myData <- read_excel(path = temp)
我不知道如何插入数据集的图像,但它应该与前面的代码一起显示。我需要 2-31 列来表示高效,2 到 37 列表示低效。
我希望这些信息足以让人们理解我在说什么。
【问题讨论】:
-
您好 Jago,有两个问题 1. 您的色谱柱规格是否正确?这些值是重叠的。 2.“长数据格式”是指具有两列的数据框:高效和低效?
-
@AdriaanNeringBögel 抱歉,我意识到当我指的是行时我放了列。我希望数据为 2 列。第一列的标题应该是组,第二列的标题应该是值。在这之后应该有 66 行(即 2-67),前 30 行应该被称为高效,而后 36 行应该被称为低效。第二列应具有从原始数据帧(即我的数据)中的第 4 行和第 12 行获取的相应值。我希望这有助于大声笑。
-
组列中标签的顺序实际上并不重要,只要相应的值正确即可。干杯。
标签: r data-wrangling