r

ggsave losing unicode characters from ggplot+gridExtra

血红的双手。 提交于 2021-02-18 05:16:48
问题 More code than you really need, but to set the mood: #Make some data and load packages data<-data.frame(pchange=runif(80,0,1),group=factor(sample(c(1,2,3),80,replace=T))) library(dplyr) library(magrittr) library(gridExtra) library(ggplot2) data%<>%arrange(group,pchange) %>% mutate(num=1:80) #Make plot that includes unicode characters g1<-ggplot(data, aes(factor(num),pchange, fill = group,width=.4)) + geom_bar(stat="identity", position = "dodge") + theme_classic()+ theme(axis.ticks = element

ggsave losing unicode characters from ggplot+gridExtra

£可爱£侵袭症+ 提交于 2021-02-18 05:09:00
问题 More code than you really need, but to set the mood: #Make some data and load packages data<-data.frame(pchange=runif(80,0,1),group=factor(sample(c(1,2,3),80,replace=T))) library(dplyr) library(magrittr) library(gridExtra) library(ggplot2) data%<>%arrange(group,pchange) %>% mutate(num=1:80) #Make plot that includes unicode characters g1<-ggplot(data, aes(factor(num),pchange, fill = group,width=.4)) + geom_bar(stat="identity", position = "dodge") + theme_classic()+ theme(axis.ticks = element

ggsave losing unicode characters from ggplot+gridExtra

爷,独闯天下 提交于 2021-02-18 05:08:42
问题 More code than you really need, but to set the mood: #Make some data and load packages data<-data.frame(pchange=runif(80,0,1),group=factor(sample(c(1,2,3),80,replace=T))) library(dplyr) library(magrittr) library(gridExtra) library(ggplot2) data%<>%arrange(group,pchange) %>% mutate(num=1:80) #Make plot that includes unicode characters g1<-ggplot(data, aes(factor(num),pchange, fill = group,width=.4)) + geom_bar(stat="identity", position = "dodge") + theme_classic()+ theme(axis.ticks = element

R: Recoding variables using recode, mutate and case_when

喜欢而已 提交于 2021-02-18 03:23:17
问题 I want to recode the following values < 4 = -1, 4 = 0, > 4 = 1 for the following variables defined by core.vars in the dataset, and still keep the rest of the variables in the data frame. temp.df <- as.tibble (mtcars) other.vars <- c('hp', 'drat', 'wt') core.vars <- c('mpg', 'cyl', 'disp') temp.df <- rownames_to_column (temp.df, var ="cars_id") temp.df <- temp.df %>% mutate_if (is.integer, as.numeric) I have tried a number of ways to implement this. Using case_when , mutate , recode but with

R: Recoding variables using recode, mutate and case_when

强颜欢笑 提交于 2021-02-18 03:21:40
问题 I want to recode the following values < 4 = -1, 4 = 0, > 4 = 1 for the following variables defined by core.vars in the dataset, and still keep the rest of the variables in the data frame. temp.df <- as.tibble (mtcars) other.vars <- c('hp', 'drat', 'wt') core.vars <- c('mpg', 'cyl', 'disp') temp.df <- rownames_to_column (temp.df, var ="cars_id") temp.df <- temp.df %>% mutate_if (is.integer, as.numeric) I have tried a number of ways to implement this. Using case_when , mutate , recode but with

Using R SOAP (SSOAP) to retrieve data / scrape

我与影子孤独终老i 提交于 2021-02-18 03:20:34
问题 On the B-cycle page(www.bcycle.com/whowantsitmore.aspx) I am trying to scrape locations and values of votes. The URL http://mapservices.bcycle.com/bcycleservice.asmx is a SOAP service. Based on the documentation I believe I am doing it correctly but I get an error due to parsing the input parameters. Even calling a function without parameters also creates errors. # working with SOAP #install.packages("SSOAP", repos="http://www.omegahat.org/R", dependencies = T, type = "source") library(SSOAP)

Using R SOAP (SSOAP) to retrieve data / scrape

邮差的信 提交于 2021-02-18 03:19:23
问题 On the B-cycle page(www.bcycle.com/whowantsitmore.aspx) I am trying to scrape locations and values of votes. The URL http://mapservices.bcycle.com/bcycleservice.asmx is a SOAP service. Based on the documentation I believe I am doing it correctly but I get an error due to parsing the input parameters. Even calling a function without parameters also creates errors. # working with SOAP #install.packages("SSOAP", repos="http://www.omegahat.org/R", dependencies = T, type = "source") library(SSOAP)

merge (opposite of split) pair of rows in r

半腔热情 提交于 2021-02-17 20:34:05
问题 I have the column like the following. Each column has two pairs each with suffix "a" and "b" - for example col1a, col1b, colNa, colNb and so on till end of the file (> 50000). mydataf <- data.frame (Ind = 1:5, col1a = sample (c(1:3), 5, replace = T), col1b = sample (c(1:3), 5, replace = T), colNa = sample (c(1:3), 5, replace = T), colNb = sample (c(1:3),5, replace = T), K_a = sample (c("A", "B"),5, replace = T), K_b = sample (c("A", "B"),5, replace = T)) mydataf Ind col1a col1b colNa colNb K

merge (opposite of split) pair of rows in r

蹲街弑〆低调 提交于 2021-02-17 20:33:09
问题 I have the column like the following. Each column has two pairs each with suffix "a" and "b" - for example col1a, col1b, colNa, colNb and so on till end of the file (> 50000). mydataf <- data.frame (Ind = 1:5, col1a = sample (c(1:3), 5, replace = T), col1b = sample (c(1:3), 5, replace = T), colNa = sample (c(1:3), 5, replace = T), colNb = sample (c(1:3),5, replace = T), K_a = sample (c("A", "B"),5, replace = T), K_b = sample (c("A", "B"),5, replace = T)) mydataf Ind col1a col1b colNa colNb K

Using R to parse out Surveymonkey csv files

青春壹個敷衍的年華 提交于 2021-02-17 19:01:24
问题 I'm trying to analyse a large survey created with surveymonkey which has hundreds of columns in the CSV file and the output format is difficult to use as the headers run over two lines. Has anybody found a simple way of managing the headers in the CSV file so that the analysis is manageable ? How do other people analyse results from Surveymonkey? Thanks! 回答1: You can export it in a convenient form that fits R from Surveymonkey, see download responses in 'Advanced Spreadsheet Format' 回答2: What