rstudio

答读者问~R语言ggplot2添加拟合曲线并给指定点添加注释

白昼怎懂夜的黑 提交于 2021-02-20 11:05:03
image.png 昨天收到了公众号一位读者的邮件,今天的推文回答一下开头提到的问题。还是使用昨天推文的示例数据:3个品种小麦种子的7个不同的指标,这7个指标分别是 A 面积 B 周长 C紧凑度 LK 长度 WK 宽度 A_coef 偏度系数 LKG 腹沟长度 使用周长和面积构建拟合方程 首先是读入数据 seed <- read.csv( "kaggle/Seed_Data.csv" ,header=T) names(seed) <- c( "Area" , "Perimeter" , "Compactness" , "Length" , "Width" , "Asymetry.coef" , "Grove.length" , "Type" ) head(seed) seed $Type <- as.factor(seed $Type ) 拟合方程 fitted.model<-lm(Area~Perimeter,data = seed) summary(fitted.model) image.png 接下来是使用ggplot2画图 library(ggplot2) ggplot()+ geom_point(data=seed,aes(x=Perimeter,y=Area), size=5,color= "red" ,alpha=0.3)+ geom_abline(intercept

Displaying cyrillic in RStudio console

断了今生、忘了曾经 提交于 2021-02-19 02:32:21
问题 I am having trouble displaying Russian characters in the Rstudio console. I load an Excel file with Russian using the readxl package. The cyrillic displays properly in the dataframe. However, if I run a function that has an output that includes the variable names, the RStudio consoles displays symbols instead of the proper Cyrillic characters. test.xlsx contains two columns - зависимая переменная (dependent variable - numeric) and независимая переменная (independent variable, factor).

RStudio v1.1.456 Rpubs upload error, no login prompt

房东的猫 提交于 2021-02-19 02:27:07
问题 Hi I couldn't find any useful information in regards to this one. When I try to publish to Rpubs on Rstudio v1.1.456, instead of login prompt I get this error message below. [Edited] Rstudio v1.1.456, R v3.5.1 Upload Error Occurred Error in if (result$status == 201) succeeded <- TRUE : missing value where TRUE/FALSE needed Calls: In addition: Warning message: In http(protocol, "api.rpubs.com", port, method, path, headers, : NAs introduced by coercion Execution halted I've already addded this

Sweave in Rstudio — no plots showing in pdf

大兔子大兔子 提交于 2021-02-17 06:47:08
问题 Sweave/Latex newbie here. I have no problems generating regular functions outputs, but the plots don't show up. Here's a basic example: \documentclass{article} \begin{document} \SweaveOpts{concordance=TRUE} <<chunk1>>= print("Hello World") boxplot(rnorm(100)) @ \end{document} And the corresponding .tex output: \documentclass{article} \usepackage{Sweave} \begin{document} \input{test2-concordance} \begin{Schunk} \begin{Sinput} > print("Hello World") \end{Sinput} \begin{Soutput} [1] "Hello World

Tabs not rendering when knitting rmarkdown to html

自闭症网瘾萝莉.ら 提交于 2021-02-13 16:04:40
问题 I've been using rmarkdown and knitr to create html output. Quite suddenly, the {.tabset} function seems to have stopped working when knitting, and documents render as they would without this option. Here is a simple example that does not work as it should on my system. --- title: "Plot Tabs" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ## Title {.tabset .tabset-fade .tabset-pills} ### tab 1 ```{r} plot(cars) ``` ### tab 2 ```{r} plot(pressure)

Tabs not rendering when knitting rmarkdown to html

ⅰ亾dé卋堺 提交于 2021-02-13 16:04:25
问题 I've been using rmarkdown and knitr to create html output. Quite suddenly, the {.tabset} function seems to have stopped working when knitting, and documents render as they would without this option. Here is a simple example that does not work as it should on my system. --- title: "Plot Tabs" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ## Title {.tabset .tabset-fade .tabset-pills} ### tab 1 ```{r} plot(cars) ``` ### tab 2 ```{r} plot(pressure)

How do I exit a function that is waiting for more input?

北慕城南 提交于 2021-02-11 12:58:13
问题 I screwed up a ggplot function and ran this wonky line all by itself: label = as.character(share)+'%"), -- and then I didn't realize the cursor was showing a + instead of > so I ran the whole ggplot function again and only then noticed that the console was looking for more input. I did figure out what was wrong (I needed to close the ' and " I had opened) but I couldn't figure out how to just exit the function entirely. I tried ctrl c and every "exit" command I could think of: + break + } + }

How do I convert RMarkdown ioslides presentations to 2-up PDFs programmatically?

大兔子大兔子 提交于 2021-02-10 12:29:27
问题 I use rmarkdown to generate ioslides HTML presentations, using custom css. This bit is great and I love it. My question is about generating 'notes' versions of presentations. The only way I've seen to get 2up PDF A4 notes from these slides is to print out of Safari, by clicking Print..., then landscape, then layout 2pages, then border = hairline, then save as. then find the right folder etc. However, it gets the formatting and fonts right, and Webkit renders things that Chrome or other

Make execution stop on error in RStudio / Interactive R session

不打扰是莪最后的温柔 提交于 2021-02-08 12:19:49
问题 When executing a block of code in RStudio, execution doesn't actually stop when an error occurs. For example, if I have the following code in the open editor: x <- 'test' stopifnot(is.numeric(x)) print('hello world') And run it (either with command-return or by clicking the "Run" button), it prints the error but then marches on and executes the print statement. Is there a way to configure RStudio to not proceed past the error? i.e. make it stop at line 2 above and not proceed to the print

Make execution stop on error in RStudio / Interactive R session

人盡茶涼 提交于 2021-02-08 12:18:53
问题 When executing a block of code in RStudio, execution doesn't actually stop when an error occurs. For example, if I have the following code in the open editor: x <- 'test' stopifnot(is.numeric(x)) print('hello world') And run it (either with command-return or by clicking the "Run" button), it prints the error but then marches on and executes the print statement. Is there a way to configure RStudio to not proceed past the error? i.e. make it stop at line 2 above and not proceed to the print