1

I am newbie to R Markdown. I am using R Studio and am very comfortable with it. I have some R code in an R Markdown file that I am using in R Studio. The code reads a .csv file of streamflow data and calculates the mean flow. I want to export the resulting mean flow to HTML, which is done when I hit the Knit icon. But all I see in the last line of the HTML file is "mean_flow", and the actual numeric value is missing. I understand I need to do this using r in inline mode, which I tried to do using the following r code excerpt:

    mean_flow<-mean(daily_flow$Value,na.rm=T)
    max_flow<-max(daily_flow$Value,na.rm=T)
    min_flow<-min(daily_flow$Value,na.rm=T)
    sd_flow<-sd(daily_flow$Value,na.rm=T)
    CV_flow<-(sd_flow/mean_flow)*100
    mean_flow `r print(mean_flow)

Note: all except " mean_flow r print(mean_flow) " is in one code chunk.

1 Answer 1

1

Try this:

mean_flow `r mean_flow`

Also, we can use format to change the format:

mean_flow `r format(mean_flow, digits = 1, nsmall = 1)`
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.