Неправильный вывод объекта S4 в цикле for - PullRequest
0 голосов
/ 09 июля 2019

Использование цикла for для получения выходных данных класса для объекта S4.Объект S4 называется данными и представляет собой большой объект.

для циклов, состоящих из 5 классов, а именно: «жир», «воспаление», «мышца», «железы», «просвет»

tissues = c("fat","inflammation","muscle","glands","lumen")
tissues
for (i in tissues) {
    print(i)
    print(data$i)
}

Вывод:

'fat' 'inflammation' 'muscle' 'glands' 'lumen' 

[1] "fat"
$`m424_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 169 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m424_inflammation_tic-normalization
    raster dimensions: 507 x 164 x 1
    coord(3): x = 1..507, y = 1..164, z = 1..1
    mass range:  599.9313 to 3200.0906 
    centroided: FALSE 

$`m80_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 149 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m80_inflammation_tic-normalization
    raster dimensions: 400 x 212 x 1
    coord(3): x = 1..400, y = 1..212, z = 1..1
    mass range:  599.6025 to 3200.7207 
    centroided: FALSE 

[1] "inflammation"
$`m424_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 169 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m424_inflammation_tic-normalization
    raster dimensions: 507 x 164 x 1
    coord(3): x = 1..507, y = 1..164, z = 1..1
    mass range:  599.9313 to 3200.0906 
    centroided: FALSE 

$`m80_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 149 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m80_inflammation_tic-normalization
    raster dimensions: 400 x 212 x 1
    coord(3): x = 1..400, y = 1..212, z = 1..1
    mass range:  599.6025 to 3200.7207 
    centroided: FALSE 

[1] "muscle"
$`m424_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 169 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m424_inflammation_tic-normalization
    raster dimensions: 507 x 164 x 1
    coord(3): x = 1..507, y = 1..164, z = 1..1
    mass range:  599.9313 to 3200.0906 
    centroided: FALSE 

$`m80_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 149 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m80_inflammation_tic-normalization
    raster dimensions: 400 x 212 x 1
    coord(3): x = 1..400, y = 1..212, z = 1..1
    mass range:  599.6025 to 3200.7207 
    centroided: FALSE 

[1] "glands"
$`m424_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 169 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m424_inflammation_tic-normalization
    raster dimensions: 507 x 164 x 1
    coord(3): x = 1..507, y = 1..164, z = 1..1
    mass range:  599.9313 to 3200.0906 
    centroided: FALSE 

$`m80_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 149 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m80_inflammation_tic-normalization
    raster dimensions: 400 x 212 x 1
    coord(3): x = 1..400, y = 1..212, z = 1..1
    mass range:  599.6025 to 3200.7207 
    centroided: FALSE 

[1] "lumen"
$`m424_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 169 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m424_inflammation_tic-normalization
    raster dimensions: 507 x 164 x 1
    coord(3): x = 1..507, y = 1..164, z = 1..1
    mass range:  599.9313 to 3200.0906 
    centroided: FALSE 

$`m80_inflammation_tic-normalization`
An object of class 'MSContinuousImagingExperiment'
  <53400 feature, 149 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ...
        files name
    run(1): m80_inflammation_tic-normalization
    raster dimensions: 400 x 212 x 1
    coord(3): x = 1..400, y = 1..212, z = 1..1
    mass range:  599.6025 to 3200.7207 
    centroided: FALSE 


Код должен выводить данные $ fat, за которыми следуют данные $ воспаления, данные $ мышц, данные $ желез, данные $ люмен.

Однако выводятся только данные $ воспаления

1 Ответ

0 голосов
/ 09 июля 2019

данные $ я проблема. Вместо этого используйте данные [[i]]. data $ i ищет элемент списка, который называется «i», поскольку такого элемента нет, он автоматически дополняет данные $ i до data $lammation.

...