This is a rStudio question.
In the console, I put my first values in as:
x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
and then I add my second values as:
y <- c(x, 0, x)
So why, when I enter in view(y), that is only show me 5 columns, but when I enter in length(y) is shows 11?
I don't understand. Please help?
1 Like
Welcome to the forum.
Your results make sense.
x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
length(x)
y <- c(x, 0, x)
length(y)
Therefore, 5 +1 + 5 = 11
Were you intending something like this?
z <- cbind(x, 0 , x)
length(z)
nrow(z)
startz
January 19, 2026, 2:36pm
3
If you type y
in the console you get
[1] 10.4 5.6 3.1 6.4 21.7 0.0 10.4 5.6 3.1 6.4 21.7
If you type View(y) (and note that V is a capital) you get however many numbers there is room for in the viewing window. If you change the width of the window you will see more or fewer.
1 Like
No, I not trying to do anything like that. I guess I was asking how the viewing window works. It doesn't make sense that the view(y) only shows 5.
1 Like
How can I change the width of the windows?
1 Like
startz
January 20, 2026, 11:51pm
6
On my machine you can drag some little vertical lines in the View window to change how much is devoted to showing values or to change how large the window is.
1 Like
I don't use View() but my guess is that you cannot without hacking the code.
View() is not intended to show all the vector, data.frame or whatever. It is intended to show the structure of your data.
This output is telling you that "Y" is a double-precision floating-point number vector with 11 entries, and is showing you a sample of the data.
You can get the basic equivalent using the base R command str()
str(y)
num [1:11] 10.4 5.6 3.1 6.4 21.7 0 10.4 5.6 3.1 6.4 ...
1 Like
jrkrideau:
x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
length(x)
y <- c(x, 0, x)
length(y)
Further experimentation suggests I have no idea what View() is doing.
It acts like str() on a vector but is showing a rectangular "spreadsheet-like" output with no information about the variables.
Where I was expecting something like this
dd1 <- data.frame(AA = LETTERS[1:10], BB = 10:1, CC = as.factor(LETTERS[11:20]))
str(dd1)
'data.frame': 10 obs. of 3 variables:
$ AA: chr "A" "B" "C" "D" ...
$ BB: int 10 9 8 7 6 5 4 3 2 1
$ CC: Factor w/ 10 levels "K","L","M","N",..: 1 2 3 4 5 6 7 8 9 10
Interestingly enough
View()
# &
view()
are giving me identical results but this may be a function of the packages I have loaded. Ttere may be a view() in there somewhere.
pacman numform here tinytable janitor unpivotr
"0.5.1" "0.7.1" "1.0.2" "0.15.1" "2.2.1" "0.6.4"
smungs tidyxl readxl lubridate forcats stringr
"0.0.0.9000" "1.0.10" "1.4.5" "1.9.4" "1.0.1" "1.6.0"
dplyr purrr readr tidyr tibble ggplot2
"1.1.4" "1.2.0" "2.1.6" "1.3.1" "3.3.0" "4.0.1"
tidyverse data.table
"2.0.0" "1.17.8"
startz
January 21, 2026, 2:07pm
9
View() with a capital V is built-in as part of the utils package. view() with a lower-case v is not part of base R so must come from some other package. The tibble package does have the lower-case version, but it seems to just call the upper-case version.
1 Like
Ah, thanks. It was late when I wrote the above post and I decided bed sounded better than trying to track down View & view. It did strike me as strange though.
1 Like
system
Closed
May 20, 2026, 8:27pm
12
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.