rstudio

数据可视化——一文入门ggplot2

拜拜、爱过 提交于 2020-04-18 17:55:11
目录 0引言 1、函数包的安装与载入 2、数据的构造 3、映射和代码风格 4、添加几何对象 4.1添加单个几何对象 4.2 分类设置颜色、形状、大小 4.3设置整体的颜色形状大小 4.4添加多个几何对象 5、分层 6、总结 0引言 之前在 R语言分组画条形图 一文中使用过ggplot2包中的qplot函数,今天就简单介绍下ggplot2的语法风格和使用示例。ggplot2这个函数包是R语言的一款可视化包。他的作者是Hadley Wickham,RStudio首席科学家,美国莱斯大学统计学助理教授,毕业于爱荷华州立大学统计系。这个包具有独树一帜的画图风格:映射、分面、集合对象、统计变换、坐标系、图层等等众多系统的画图的风格。不吹不黑直接上干货,本文将会带领大家入门ggplot2,让大家设计出符合自己的数据的可视化作品。 1、函数包的安装与载入 我一般习惯的安装包 tidyverse ,里面函数有包: tidyverse、ggplot2、tidyr、readr、forcats 。下面是安装载入命令: # 包的安装 install.packages("tidyverse") library(tidyverse) # 加载画图包 -- Attaching packages ------------------------------------ tidyverse 1.3.0 -- √

plot emoji/custom image in axis labels in R

吃可爱长大的小学妹 提交于 2020-04-18 02:46:07
问题 I'm trying to plot Emojis and custom images in R as labels of X axis. I've read similar threads and questions, but I don't want to use emojifont in R, and instead use my own images as label (.png) and there's around 270 of these custom emojis. I followed this article and managed to show emojis at top of bars, but I want the emojis as labels. similar to this image. The only solution that came to my mind was changing value of density in mapply (df.plot$dens) to 1, in this code: ... mapply

change mathjax renderer in R notebooks (with “self_contained: false”)

大城市里の小女人 提交于 2020-04-16 03:54:07
问题 I am creating R notebooks that contain equations. I am using RStudio 1.2.5033 on Windows 10, R 3.5.1, and rmarkdown 2.1. When my R notebooks are rendered as HTML, MathJax (v2.7.2) uses the "HTML-CSS" output processor to render the equations. But I think that the output from the "CommonHTML" output processor looks better. So I want to include a directive, in my R notebooks, that forces MathJax to use the CommonHTML output processor. How may I do this? If I were rendering an ordinary R Markdown

How to stop all (multiple) executed lines of code / commands in R in one go?

China☆狼群 提交于 2020-04-16 02:32:14
问题 Suppose we run multiple lines of R code, how can we stop all lines of code in on go? Example If the following 3 lines of code are copy/pasted into the R console in RStudio and we press enter, this will take 3 Esc or ctrl + c to stop (one press for each command). Alternatively, pressing the red Stop button in the RStudio gui also must be done three times (once per command) Sys.sleep(10) Sys.sleep(10) Sys.sleep(10) How can we stop all lines of R code from executing with one action? What I know

Error installing packages in RStudio: error reading from connection

蓝咒 提交于 2020-04-12 07:49:18
问题 I have recently updated both R (version 3.4.1) and RStudio (version 1.0.143) and I am now unable to install packages from Rstudio. If I install a package in R directly using install.packages() it works fine. If I try and install a package in Rstudio using either install.packages() or using the package install menu I get the error below. I have tried a few different packages, and have uninstalled and reinstalled both R and RStudio. To get the error: Run: install.packages("lme4") Output:

移动硬盘遇到无法访问,文件或目录损坏且无法读取的解决办法

纵然是瞬间 提交于 2020-04-07 06:43:46
文件或目录损坏且无法读取的解决办法大集合 方法很简单,用chsdsk命令即可 详解如下: 开始--运行--输入cmd--输入chkdsk 盘符: /f ,例如:“chkdsk d: /f”。 等命令运行完即可。 这里要注意的是,那个冒号后面要空一格,别跟着就写"/f" 故障现象 不管是移动硬盘还是U盘,包括本地电脑上的硬盘分区,双击打开时,提示:“无法打开H盘 ,文件或目录损坏且无法读取,....”。有的分区格式变为RAW。 数据丢失原因分析 出现这种错误提示,是由于各种原因导致的磁盘文件目录(FAT,MFT)出错造成。主要发生在优盘、MP3、移动硬盘等移动设备上,其中大容量(160G以上)NTFS分区格式的外置移动硬盘发生几率最高最多。产生的原因很多,一般有下面几种原因: 1、没有正常插拔移动设备,系统没有完成完整的读写操作,致使文件目录信息错乱和不完整。比如我们复制一个文件到移动设备,关机重启、拔取后,再次打开使用或到别的电脑上使用时出现症状。 2、选用了劣质产品,包括劣质电源、主板、数据线、特别是劣质外置硬盘盒。产品的电源、主控电路不稳定,致使磁盘寻址出错,写信息错乱。 3、使用了PQ、PM等磁盘分区调整工具。 4、病毒、硬盘硬件本身故障、工作期间突然停电。 恢复效果质量 如果是大移动硬盘并且是NTFS分区格式的,恢复质量十分理想,基本都能成功恢复文件和目录结构。

change remote repo for a project forked from github on local machine (Rstudio)

我是研究僧i 提交于 2020-03-28 04:47:46
问题 This question seems obvious, but I can't seem to find a direct answer in my searching of stackoverflow and other corners of the internet. I have a project I work on using R studio on a local machine. The project started by pulling from a repo on Github. I can't push to this repo, as its not mine and I don't have permission. No big deal, I'd like to create a new repository on github to save all my changes to the original repo and the current state of the project. I can't just enter: git remote

change remote repo for a project forked from github on local machine (Rstudio)

落爺英雄遲暮 提交于 2020-03-28 04:47:25
问题 This question seems obvious, but I can't seem to find a direct answer in my searching of stackoverflow and other corners of the internet. I have a project I work on using R studio on a local machine. The project started by pulling from a repo on Github. I can't push to this repo, as its not mine and I don't have permission. No big deal, I'd like to create a new repository on github to save all my changes to the original repo and the current state of the project. I can't just enter: git remote

How to build Rcpp packages within Rstudio using RcppArmadillo?

社会主义新天地 提交于 2020-03-26 05:46:29
问题 I'm trying to compile a Rcpp package that uses RcppArmadillo within RStudio. I am only trying to compile: #include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]] using namespace Rcpp; // Implementation of MASS' rmvrnorm() // [[Rcpp::export]] arma::mat rmvrnorm_arma2(int n, arma::vec mu, arma::mat sigma) { int ncols = sigma.n_cols; arma::mat Y = arma::randn(n, ncols); return arma::repmat(mu, 1, n).t() + Y * arma::chol(sigma); } which is found here: http://gallery.rcpp.org/articles

How to build Rcpp packages within Rstudio using RcppArmadillo?

泄露秘密 提交于 2020-03-26 05:46:10
问题 I'm trying to compile a Rcpp package that uses RcppArmadillo within RStudio. I am only trying to compile: #include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]] using namespace Rcpp; // Implementation of MASS' rmvrnorm() // [[Rcpp::export]] arma::mat rmvrnorm_arma2(int n, arma::vec mu, arma::mat sigma) { int ncols = sigma.n_cols; arma::mat Y = arma::randn(n, ncols); return arma::repmat(mu, 1, n).t() + Y * arma::chol(sigma); } which is found here: http://gallery.rcpp.org/articles