RMarkdown自动添加不需要的空格

时间:2017-07-10 14:07:37

标签: r pdf r-markdown pandoc

尝试弄清楚为什么这段代码在渲染为pdf(windows10,tex live,所有内容都是最新的)时为我的文档添加整页空白区域

此版本会跳过pdf中标题后的整个第一页:

---
title: "quiz_1_takehome"
author: "PSYC243"
date: "July 9, 2017"
output: 
    pdf_document:
        number_sections: true
---

# Load the `mtcars` data and save it as `my_data`, e.g., `my_data <- mtcars`. 
```{r echo = FALSE}
my_data <- mtcars
```
## We don't need to worry about where this data is (e.g., we don't need to examine the working directory with `getwd()` or `setwd()`) because `R` automatically loads it when it starts.  


# Print the length of `my_data` with `length()`. 
## What happened? Is this information useful for examining dataframes? Why or why not (Respond in a comment)?

此版本不添加空格。我只删除了一些关于getwd()

的额外括号内的文字
---
title: "quiz_1_takehome"
author: "PSYC243"
date: "July 9, 2017"
output: 
    pdf_document:
        number_sections: true
---

# Load the `mtcars` data and save it as `my_data`, e.g., `my_data <- mtcars`. 
```{r echo = FALSE}
my_data <- mtcars
```
## We don't need to worry about where this data is (e.g.,  with `getwd()` or `setwd()`) because `R` automatically loads it when it starts.  


# Print the length of `my_data` with `length()`. 
## What happened? Is this information useful for examining dataframes? Why or why not (Respond in a comment)?
## Now print the result of using `dim()` with your dataframe. Why is this more useful?  

# The previous functions are great for finding the most basic info about the dataframe but there is so much more we'd want to know. Use the functions we have used in class to explore the data. 
## How many variables are there? What are their types? The functions you use should provide all this information so print it to the console (i.e., do not manually count and type this information).

所以空白问题似乎与该部分的长度有关,这对我来说没有任何意义,并且它似乎不会发生在我的文档中的任何其他地方。为什么RMarkdown在这个例子中似乎任意添加空格?

以下是我遇到此问题的另一个示例:

---
title: "hw5"
author: "PSYC243"
date: "July 18, 2017"
output: 
    pdf_document:
        number_sections: true
---


# Load the housing price data, `landdata-states.csv`, and name it `housing` (on bb).


## You'll probably want to change the variable names with `tolower()`. 
```{r, eval = FALSE}
colnames(housing) <- tolower(colnames(housing))
```  

## Examine the `home.value` data by `date`. Create a visualization that shows the states with the most volatile (i.e., changing) state housing markets. Make sure this graph prints---don't just create it and assign it.


## Print the acronyms of five states you identify as the most volatile (you do *not* need to do this programmatically, a simple `print( c('state1', 'state2', ... )` statement will work.)


### There are several ways you could do this. You could visually inspect the data with a well-designed graph (or graphs). You could use one of our descriptive statistics (i.e., what would give us a measure of variability in the data?). You could also manually look at the data (though that would be the most work-intensive approach)


# One problem with looking at housing value by state is that costs in each state are dramtically different---meaning value in one state might not be on the same scale as value in another. 


## Use a `for()` loop to standardize the `home.value` variable by state. This is identical to the process we used in class except that we are using different variables. Step by step instructions are directly below.


### Create a vector named `std_home_value` and a vector named `state`.
### Use a `for()` loop to iterate through the state and standardize the values *from each state only* using `scale`.
### On each iteration of the loop, save the values and state labels into your vectors `std_home_value`, and `state` with `c()`.
### Finally, assign your `std_home_value` vector to a column in the `housing` data frame.

## Now examine the new variable you created (i.e., the same plots/code should work, you only need to change variable names). Did this standardization change you opinion about volatility in the states? Explain what changed and revise your answer.

rmarkdown whitespace issue

0 个答案:

没有答案