r

One slider controlling multiple subplots in R

大兔子大兔子 提交于 2021-02-20 02:45:50
问题 I want to use one slider to control multiple subplots created with plotly. I found answers in Python like these two: Plot.ly. Using slider control with multiple plots https://community.plot.ly/t/using-one-slider-to-control-multiple-subplots-not-multiple-traces/13955/4 Example (second link): import plotly.graph_objs as go from plotly.tools import make_subplots fig = make_subplots(1, 2) fig.add_scatter(y=[1, 3, 2], row=1, col=1, visible=True) fig.add_scatter(y=[3, 1, 1.5], row=1, col=1, visible

Adding Provinces to Canadian Map in R

谁说我不能喝 提交于 2021-02-20 02:45:49
问题 I've been browsing a lot of the topics on mapping in R and would appreciate a little help. I've made it to this code which builds an image of a purchase density then overlays a US State map on top and a Canadian national map as well. It's an ok solution, but Ideally I'd like to show the provinces in Canada as well. library(mapdata); library(maps); library(maptools); library(spatstat); png(filename=file_name, type="cairo-png", bg="transparent", width=10.*960, height=10.*960, pointsize=1);

R pivot_longer combining columns based on the end of column names

时间秒杀一切 提交于 2021-02-20 02:44:39
问题 I have a dataframe with multiple columns with names of various lengths and structures (so not sure how to capture them with a regex). Each column ends either with .t1 or .t3 I want to combine columns based on names without the t1/t3, with an additional column of Time based on that suffix. So, for example, a dataframe such as: df<-data.frame("Subject"= c(1:10), "intercept.freq.acc.t1" = c(1:10), "intercept.freq.acc.t3" = c(1:10), "freq.rt.t1" = c(1:10), "freq.rt.t3" = c(1:10), "vowel.con.acc

R pivot_longer combining columns based on the end of column names

房东的猫 提交于 2021-02-20 02:43:26
问题 I have a dataframe with multiple columns with names of various lengths and structures (so not sure how to capture them with a regex). Each column ends either with .t1 or .t3 I want to combine columns based on names without the t1/t3, with an additional column of Time based on that suffix. So, for example, a dataframe such as: df<-data.frame("Subject"= c(1:10), "intercept.freq.acc.t1" = c(1:10), "intercept.freq.acc.t3" = c(1:10), "freq.rt.t1" = c(1:10), "freq.rt.t3" = c(1:10), "vowel.con.acc

Troubleshooting SPARQL rCurl queries in R

旧城冷巷雨未停 提交于 2021-02-20 02:35:27
问题 I'm doing a sparql query against an authenticated endpoint in R using the SPARQL library. The same query/endpoint/user works using the rrdf package. Unfortuantely, once I get the query working, I need to process the data in R and update the graph with the answers, which rrdf can't do. Setting up a few variables first, the below query works using rrdf: sparql.remote(myEndpoint,myQuery,'rowvar',myUsername,myUserpwd) Using SPARQL, this does not work: SPARQL(myEndpoint,myQuery,curl_args=c(

R package installed in 2 different locations

空扰寡人 提交于 2021-02-20 02:25:12
问题 I have R package ape installed in 2 locations, that are BOTH part of the .libPath() - ape version 3.3 in location1 - ape version 3.4 in location2 in ape version 3.4, there is a new function clustalomega . I have NOT loaded any of the 2 packages (using library ) ape::clustalomega doesn't work on my machine. I suspect it comes from the fact that R is considering first the old version of ape it has found in location1. I have tried to reverse the order of the libPath, with .libPath(rev(.libPath()

How to zoom in on a specific range of values for a categorical variable in ggplot2?

北城以北 提交于 2021-02-20 02:20:55
问题 I just want to zoom in on the x-axis between the values ford and nissan in the mpg dataframe. Package used: tidyverse But I am getting the following error when using the coord_cartesian() function: p<-ggplot(mpg,aes(x=manufacturer,y=class)) p+geom_point()+ + coord_cartesian(xlim = c('ford','nissan')) Error in +coord_cartesian(xlim = c("ford", "nissan")) : invalid argument to unary operator 回答1: You can use a function for contextual zoom from ggforce package ( facet_zoom ) to achieve this: #

How to zoom in on a specific range of values for a categorical variable in ggplot2?

南笙酒味 提交于 2021-02-20 02:16:39
问题 I just want to zoom in on the x-axis between the values ford and nissan in the mpg dataframe. Package used: tidyverse But I am getting the following error when using the coord_cartesian() function: p<-ggplot(mpg,aes(x=manufacturer,y=class)) p+geom_point()+ + coord_cartesian(xlim = c('ford','nissan')) Error in +coord_cartesian(xlim = c("ford", "nissan")) : invalid argument to unary operator 回答1: You can use a function for contextual zoom from ggforce package ( facet_zoom ) to achieve this: #

How to zoom in on a specific range of values for a categorical variable in ggplot2?

最后都变了- 提交于 2021-02-20 02:16:06
问题 I just want to zoom in on the x-axis between the values ford and nissan in the mpg dataframe. Package used: tidyverse But I am getting the following error when using the coord_cartesian() function: p<-ggplot(mpg,aes(x=manufacturer,y=class)) p+geom_point()+ + coord_cartesian(xlim = c('ford','nissan')) Error in +coord_cartesian(xlim = c("ford", "nissan")) : invalid argument to unary operator 回答1: You can use a function for contextual zoom from ggforce package ( facet_zoom ) to achieve this: #

Plot discrete data [closed]

大兔子大兔子 提交于 2021-02-20 02:14:39
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question Hy guys, I just need a suggestion on how to plot in a proper way some data so that they could be self-explanatory. I have a matrix of counts that looks like this: Condition1 Condition2 Condition3 ...... Patient1 30 4 23 ...... Patient2 22 1 2 ......