Posts

Showing posts with the label rstudio

Error when-> output: rticles::plos_article used in RMarkdown,

Image
Clash Royale CLAN TAG #URR8PPP Error when-> output: rticles::plos_article used in RMarkdown, When I used, Output: rticles::plos_article in RMarkdown, I get the following error after I knit the .Rcode ! Package pdftex.def Error: File `PLOS-submission-eps-converted-to.pdf' not found: using draft setting. The output using xfun::session_info(c('tinytex', 'rmarkdown')) is R version 3.3.1 (2016-06-21) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.5 (El Capitan), RStudio 0.99.903 Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8 Package version: backports_1.1.0 base64enc_0.1.3 digest_0.6.13 evaluate_0.10.1 graphics_3.3.1 grDevices_3.3.1 highr_0.6 htmltools_0.3.6 jsonlite_1.5 knitr_1.20 magrittr_1.5 markdown_0.8 methods_3.3.1 mime_0.5 Rcpp_0.12.14 rmarkdown_1.10 rprojroot_1.2 stats_3.3.1 stringi_1.1.5 stringr_1.2.0 tinytex_0.6.4 tools_3.3.1 utils_3.3.1 ...

Remove all characters in a string after a “.” in R

Image
Clash Royale CLAN TAG #URR8PPP Remove all characters in a string after a “.” in R I have a group of strings in a column like this Group1 Group1.1 Group1.2 Group1.3 Group1 Group1.1 Group1.2 Group1.3 I want to remove all characters after the decimal point so it looks like this Group1 Group1 Group1 Group1 Group1 Group1 How do I do this in R code? Thank you 2 Answers 2 We can use sub to match the dot ( \. - escape it as it is a metacharacter specifying any character) followed by other characters ( .* ) until the end ( $ ) of the string and replace it with blank ( "" ) sub \. .* $ "" df1$Col <- sub("\..*$", "", df1$Col) df1$Col #[1] "Group1" "Group1" "Group1" "Group1" df1 <- structure(list(Col = c("Group1", "Group1.1", "Group1.2", "Group1.3" )), .Names = "Col", class =...