r

Searching and using databases

我怕爱的太早我们不能终老 提交于 2021-02-11 13:55:17
问题 df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv') df8 <- read.csv ('https://raw.githubusercontent.com/hirenvadher954/Worldometers-Scraping/master/countries.csv') In the 1st dataset, there are countries divided into continents. In the second data set, there is country and population information. How can I combine population information in data set 2 according to the continental information in data set 1. thank you. The problem

Bubble chart with R

痞子三分冷 提交于 2021-02-11 13:54:15
问题 I have a table with an abundance of species in different months. I want to make a bubble chart wherein the y-axis for abundance species and x-axis for the month while the radius of the bubbles for the abundance of species that I found in the month. My data arrangement is like this I want to end up the bubble chart with like this Please help me. Thank you 回答1: The following is a bubble graph created with a mock data set. I have tried to show how to plot a data set with a structure like the

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : 0 (non-NA) cases but there is NO NA

杀马特。学长 韩版系。学妹 提交于 2021-02-11 13:53:40
问题 I've got a really annoying problem that I tried to solve multiple days but I wasn't able. The code that I want to run is the following: subsample2 <- as.data.frame(subsample) m.extremistvote <- ictreg.joint(formula = resid_model1 ~ stateofeconomy + self_placement_extreme + interaction_resid_1 + age + education + income + electoral_system + election_loser + polity_IV + module1 + module4, J=3, data=extremist2, treat="gender", outcome="extremist_vote", constrained=TRUE, maxIter = 5000) summary(m

Filter a piped df within ggplot

末鹿安然 提交于 2021-02-11 13:53:29
问题 I am using a dplyr pipeline to clean my df then feed directly into a ggplot. However, I want to plot only one group at a time, so I need to filter to just that group. The problem is, I want the scales to remain constant as if all groups are present. Is it possible to further filter a piped df inside the ggplot() commands? Ex below. # create df set.seed(1) df <- data.frame(matrix(nrow=100,ncol=5)) colnames(df) <- c("year","group","var1","var2","var3") df$year <- rep(1:4,each=25) df$group <-

Change the font of all ggplot-outputs once in code instead of with every plot? [duplicate]

与世无争的帅哥 提交于 2021-02-11 13:53:18
问题 This question already has answers here : How to set themes globally for ggplot2? (3 answers) Closed 9 months ago . Working with a quite huge R Markdown document, I was wondering whether it is possible to define the the font of my ggplots once in some kind of global setting? Just like I can use theme_set() to define theme_minimal() for all the plots in the document. I tried adding something like this, but it threw an error: theme_set(text = element_text(size=12, family="Times New Roman")) Is

Change font and color in helpText()

假如想象 提交于 2021-02-11 13:52:47
问题 How can I change the font and the color of helpText() in a shiny app? library(shiny) library(shinydashboard) library(shinydashboardPlus) shinyApp( ui = dashboardPagePlus( header = dashboardHeaderPlus( left_menu = tagList( helpText( a(target="_blank","Login",href="https://www.youtube.com/") ) ) ), sidebar = dashboardSidebar(), body = dashboardBody(), ), server = function(input, output) { } ) 回答1: You could modify the css class of the element. The css selector is .help-block a : ( .NAME is for

Friedman test error, possibly wrong test?

心已入冬 提交于 2021-02-11 13:50:27
问题 I have the following data: df<-structure(list(participant_id = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L,

Replace values in a column with specific row value from same column using loop

落爺英雄遲暮 提交于 2021-02-11 13:50:09
问题 I have data obtained from a survey that lists the recipient's name and whether or not they selected a specific county in the state. The survey structure outputs an off for any county not selected and an for the selected county. The state has about 100 counties so there end up being a lot of columns that really correspond to the same question. What I am looking to do is replace any cells with on with the county name and any cells with off with a blank. From there I can basically unite many

Partial or fuzzy match in R

大憨熊 提交于 2021-02-11 13:49:14
问题 I want to do fuzzy match on 2 dataframes (s1 is data and s2 is reference) based on the 'Answer' column inorder to get corresponding question count and category from s2 . Ex: s1 <- data.frame(Category =c("Stationary","TransferRelocationClaim","IMS"), Question =c( "Where do I get stationary items from?","Process for claiming Transfer relocation allowances.","What is IMS?"),Answer = c("Hey <firstname>, you will find it near helpdesk ","Hey <firstname>, moving to new places can be fun! To claim

Error in nchar(Terms(x), type = “chars”) : invalid multibyte string, element 204, when inspecting document term matrix

ε祈祈猫儿з 提交于 2021-02-11 13:46:34
问题 Here is the source code that I have used: MyData <- Corpus(DirSource("F:/Data/CSV/Data"),readerControl = list(reader=readPlain,language="cn")) SegmentedData <- lapply(MyData, function(x) unlist(segmentCN(x))) temp <- Corpus(DataframeSource(SegmentedData), readerControl = list(reader=readPlain, language="cn")) Preprocessing Data temp <- tm_map(temp, removePunctuation) temp <- tm_map(temp,removeNumbers) removeURL <- function(x)gsub("http[[:alnum:]]*"," ",x) temp <- tm_map(temp, removeURL) temp