someshk
someshk

Reputation: 21

How do I view array type data in Data Viewer in RStudio?

When I run View() to view the data after creating the array, I cannot view the data in tabular form. Instead I see the name, type and values of this data as seen in the screenshot. What do I need to do to view the data in the Data Viewer Panel?

enter image description here

a<-array(c('HI','all','!!'),dim = c(3,5,5))

View(a)

Upvotes: 0

Views: 835

Answers (1)

Sercan
Sercan

Reputation: 5081

The Data Viewer in the RStudio IDE

In R programming, the View() command prints the output to the Data Viewer 1 panel. Data Viewer panel is only compatible with data in data frame format; not compatible for printing arrays 2.

data(iris)
View(iris)

After converting an array to a matrix in the R programming language, you can display it in the Data Viewer using the View() command. For example:

a <- array(c('HI','all','!!'),dim = c(3,5,5))
View(apply(a, 3, c))

enter image description here


Print Values

You can use the print() command to print the contents of a value to the console.

a <- array(c('HI','all','!!'),dim = c(3,5,5))
print(a)

1. Using The Data Viewer in the RStudio IDE

2. R Language Vectors vs. Arrays vs. Lists vs. Matrices vs. Data Frames

Upvotes: 1

Related Questions