r

How to write model file for JAGS binomial using logit function

不打扰是莪最后的温柔 提交于 2021-02-10 10:12:27
问题 I am working on an assignment using JAGS to model a binomial distribution who's p parameter is a function of another variable d . This is what I am trying to do: generate 10000 samples from the posterior for the two parameters alpha/beta produce samples to from the posterior predicted number of success when dist = 25 for 100 attempts calculate 95 credible interval for success rate at 25 feet distance I have written the model but it is giving an error. Below is the code I have already tried #R

R - How to output a partially colored string in R?

混江龙づ霸主 提交于 2021-02-10 09:47:06
问题 I want to output a partially colored string. e.g. something like: print(paste("This is how", style("Red","red", "bold"), "looks.")) [1] "This is how Red looks." The string Red should be colored in red. Any help will be much appreciated!! 回答1: You can hack it using text : plot(1:10,1:10,type='n',frame.plot=F,axes=F,xlab="",ylab="") text(5,1,"This is how") text(5.8,1,"Red",col='red',font=2) text(6.3,1,"looks.") 回答2: Perhaps the crayon package can help you: library(crayon) cat("This is how", red

Using map with a vector of data table names and utils::data

…衆ロ難τιáo~ 提交于 2021-02-10 09:41:33
问题 I would like to load two datasets from the mlbench package into my environment. I know that I am able to do so manually using the data(x) function, but I would like to do this using purrr:map . However, when I try to do this I keep getting the following error: data set ‘.x’ not founddata set ‘.x’ not found[[1]] [1] ".x" [[2]] [1] ".x" Is this possible? ## libraries library("mlbench") library("dplyr") library("purrr") ## load data sets into environment manually data(BostonHousing) data

How to build and test multiple models in R

社会主义新天地 提交于 2021-02-10 09:40:22
问题 Suppose I have a dataset like (forget about the distribution): modData <- data.frame("A" = rnorm(20, 15, 3), "B" = rnorm(20, 20, 3), "C" = rnorm(20, 25, 3), "X" = rnorm(20, 5, 1) ) If I use X as a predictor, A , B and C as responses, respectively: md1 <- lm(A ~ X, data = modData) md2 <- lm(B ~ X, data = modData) md3 <- lm(C ~ X, data = modData) Then do a Shapiro test and a boxcox test to every model, e.g. : shapiro.test(residuals(md1)) boxcox(md1, plotit = T) Is there a convenient way to

R write dataframe to excel without admin rights

南楼画角 提交于 2021-02-10 09:34:51
问题 I am a complete newby to R, so bear with me if the answer is obvious. I work on a laptop that is not owned by me and I thus have no admin rights whatsoever besides the original installation that the administrator had done for me. I assume that the lack of admin rights is the reason for me not to be able to write to an excel file. See an example below. The original dataframe is merged from bibliographic databases. Error codes are the same. Writing the original data file as a text file did work

R Faceted qqplots with column and row

安稳与你 提交于 2021-02-10 09:28:31
问题 I needs to create a qqplot using facets by row and column. I understand how to facet plot with columns and rows, but I am not sure how to set up my data. Ultimately, I want to group my dataset by column and row, then sort the 'Modeled' results and 'Observed' results in ascending order while adding a column with the 'row' group and a column with the 'column' group. I have been trying to modify the solution to this question, Faceted qqplots with ggplot2, , but I am not very familiar with lapply

R write dataframe to excel without admin rights

≯℡__Kan透↙ 提交于 2021-02-10 09:28:11
问题 I am a complete newby to R, so bear with me if the answer is obvious. I work on a laptop that is not owned by me and I thus have no admin rights whatsoever besides the original installation that the administrator had done for me. I assume that the lack of admin rights is the reason for me not to be able to write to an excel file. See an example below. The original dataframe is merged from bibliographic databases. Error codes are the same. Writing the original data file as a text file did work

R Faceted qqplots with column and row

好久不见. 提交于 2021-02-10 09:27:13
问题 I needs to create a qqplot using facets by row and column. I understand how to facet plot with columns and rows, but I am not sure how to set up my data. Ultimately, I want to group my dataset by column and row, then sort the 'Modeled' results and 'Observed' results in ascending order while adding a column with the 'row' group and a column with the 'column' group. I have been trying to modify the solution to this question, Faceted qqplots with ggplot2, , but I am not very familiar with lapply

R Faceted qqplots with column and row

主宰稳场 提交于 2021-02-10 09:25:16
问题 I needs to create a qqplot using facets by row and column. I understand how to facet plot with columns and rows, but I am not sure how to set up my data. Ultimately, I want to group my dataset by column and row, then sort the 'Modeled' results and 'Observed' results in ascending order while adding a column with the 'row' group and a column with the 'column' group. I have been trying to modify the solution to this question, Faceted qqplots with ggplot2, , but I am not very familiar with lapply

ggplot legend: change order of the automatic legend

大憨熊 提交于 2021-02-10 08:40:17
问题 I am struggling with the legend order in ggplot when there are several group of plots. Here is an example: library(ggplot2) library(data.table) data <- data.table(time = rep(1:50,4),dampingtime = rep(c(4,8,12,16),each = 50), excitation = rep(c(rep(0,10),rep(1,10),rep(0,30)),4)) data[,signal := time + .GRP, by = dampingtime] data[,dampingtime := as.factor(dampingtime)] Here I have > levels(data$dampingtime) [1] "4" "8" "12" "16" which I did accordingly to ggplot legends - change labels, order