Hi,
When I display a table in Rmarkdown it is displaying with the wrong number of columns, compared with the number listed in the bottom-left of the table.
It says "1-8 of 11 columns" but it's only showing 7. When I scroll right, it says "9-11 of 11 columns", but it's actually showing columns 8 to 11.
The file is the patients.csv file from the Hospital Management example on Kaggle (Hospital Management Dataset | Kaggle) or the doctors.csv file works similarly too.
This doesn't produce exactly the same set of columns I was looking at in that screenshot, but for me it still produces the same effect of one fewer column being shown than is reported.
Thanks.
I downloaded the data with no problem but I can not duplicate what you are getting. Of course I normally use Quarto rather RMarkdown so I may be missing something.
The first problem is that your output looks to be a tibble not a data.frame. The <chr> and dbl> indicate this.
There must be something happening in your code that I am not seeing because that table does not look like typical output from a tibble.
Here is what I get after I convert the data.frame to a tibble.
Hi,
I restarted R and just ran the lines of code that I showed you, and got the same thing. The display is the inline table I get by running the R markdown code chunk interactively. I didn't knit the file.
I also didn't ask for a tibble, I simply asked R to show me the first few rows of the data frame.
Thanks
Louise
I believe that RStudio is using rmarkdown::paged_table() to display the table. Apparently there is a "feature" (quirk? bug?) in that function in which it counts the row numbers as column 1, the first data column as column 2, etc. ... but reports the total number of columns in the original dataframe (not counting the row number). So if you scroll to the far right, you'll get "3 rows | n-12 of 11 columns" for some value of n.
Possibly the function was written by the same folks who do the federal budget?