Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8238489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:50:03+00:00 2026-06-07T19:50:03+00:00

I have the following dataframe: > dput(py6s_pwc_16) structure(list(source = c(AERONET, BIGF, MODIS), ndvi_real =

  • 0

I have the following dataframe:

> dput(py6s_pwc_16)
structure(list(source = c("AERONET", "BIGF", "MODIS"), ndvi_real = c(0.618, 
0.618, 0.618), ndvi_95 = c("0.616", "0.616", "0.615"), ndvi_05 = c("0.62", 
"0.62", "0.621"), perc_95 = c("-0.288", "-0.315", "-0.431"), 
    perc_05 = c("0.374", "0.289", "0.471")), .Names = c("source", 
"ndvi_real", "ndvi_95", "ndvi_05", "perc_95", "perc_05"), row.names = c(NA, 
-3L), class = "data.frame")

When I just print it out at the R command prompt it looks like this:

> py6s_pwc_16
   source ndvi_real ndvi_95 ndvi_05 perc_95 perc_05
1 AERONET     0.618   0.616    0.62  -0.288   0.374
2    BIGF     0.618   0.616    0.62  -0.315   0.289
3   MODIS     0.618   0.615   0.621  -0.431   0.471

I want to produce a LaTeX representation of this table using xtable. I’m trying to do this with the following code:

x <- xtable(py6s_pwc_16)
digits(x) <- 3
print(x, include.rownames=FALSE, table.placement=NULL, latex.environments=NULL, size="\\centering", booktabs=TRUE, sanitize.colnames.function=add_bold)

However, that produces LaTeX code which looks like the following (just a snippet from inside the table):

AERONET & 0.618 & 0.616 & 0.62 & -0.288 & 0.374

As you can see, the 4th column doesn’t have three digits – it’s just 0.62, and I’d like it to be 0.620. Is there a way to make xtable do this?

I’ve tried adding the line:

display(x) <- rep("fg", ncol(x)+1)

to try and get R to use significant figures rather than digits, but that doesn’t change the output.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:50:05+00:00Added an answer on June 7, 2026 at 7:50 pm

    This happens because your data contains character where it should be numeric:

    str(py6s_pwc_16)
    'data.frame':   3 obs. of  6 variables:
     $ source   : chr  "AERONET" "BIGF" "MODIS"
     $ ndvi_real: num  0.618 0.618 0.618
     $ ndvi_95  : chr  "0.616" "0.616" "0.615"
     $ ndvi_05  : chr  "0.62" "0.62" "0.621"
     $ perc_95  : chr  "-0.288" "-0.315" "-0.431"
     $ perc_05  : chr  "0.374" "0.289" "0.471"
    

    To fix it, convert the chr columns to numeric:

    py6s_pwc_16[, 2:6] <- lapply(py6s_pwc_16[2:6], as.numeric)
    

    Then run xtable:

    library(xtable)
    xtable(py6s_pwc_16, digits=3)
    
    % latex table generated in R 2.15.0 by xtable 1.7-0 package
    % Wed Jul 18 12:00:33 2012
    \begin{table}[ht]
    \begin{center}
    \begin{tabular}{rlrrrrr}
      \hline
     & source & ndvi\_real & ndvi\_95 & ndvi\_05 & perc\_95 & perc\_05 \\ 
      \hline
    1 & AERONET & 0.618 & 0.616 & 0.620 & -0.288 & 0.374 \\ 
      2 & BIGF & 0.618 & 0.616 & 0.620 & -0.315 & 0.289 \\ 
      3 & MODIS & 0.618 & 0.615 & 0.621 & -0.431 & 0.471 \\ 
       \hline
    \end{tabular}
    \end{center}
    \end{table}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Multindex DataFrame with the following structure: 0 1 2 ref A
Say I have the following R data.frame ZZZ : ( ZZZ <- structure(list(n =
I have the following data frame: id,property1,property2,property3 1,1,0,0 2,1,1,0 3,0,0,1 4,1,1,1 d.f <- structure(list(id
Lets have the following dataframe inside R: df <- data.frame(sample=rnorm(1,0,1),params=I(list(list(mean=0,sd=1,dist=Normal)))) df <- rbind(df,data.frame(sample=rgamma(1,5,5),params=I(list(list(shape=5,rate=5,dist=Gamma))))) df
I have the following dataframe: sp <- combn(c(sp1,sp2,sp3,sp4),2) d <- data.frame(t(sp),freq=sample(0:100,6)) and two factors
I have the following dataframe: DF <- data.frame(x = c(1, 2, 3,NA), y =
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I have a large data frame with the following fields (example data). #dput(data) gives...
If I have the following dataframe called result > result Name CV LCB UCB
Suppose I have the following dataframe: df <- data.frame(BR.a=rnorm(10), BR.b=rnorm(10), BR.c=rnorm(10), USA.a=rnorm(10), USA.b =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.