r Questions
2
Solved
This works as expected:
library(dplyr)
f <- function(x = c(am, vs))
mtcars %>%
select({{x}})
How would I rewrite the function (let's call it f2) such that f2 selects only the first elem...
Upswing asked 6/9, 2024 at 11:57
3
Now I can use JupyterLab with an R kernel in a web browser and use VS Code to edit Jupyter notebook code with a Python kernel. Is it possible to edit R code in VS Code using Jupyter notebook mode? ...
Newark asked 1/5, 2020 at 10:26
1
Solved
I want to create a function that returns another function with a parameter from the former, e.g.
foo1 <- function(y) function(x) x+y
(Edit: I wrote foo1 <- function(y) function(x+y) original...
3
Solved
I had to write a function today like this
data1 %>%
summarise(
ab1 = fn(a1, b1),
ab2 = fn(a2, b2),
ab3 = fn(a3, b3)
)
# imagine if there are 100 of them
If fn was a single argument funct...
1
Solved
This is a follow-up question from my previous question Assign Random Colors in R
(After much trial and error) I wrote this function which randomly colors some nodes on a network and colors 3 of the...
3
Solved
I have this code in R for simulating a country with different neighborhoods:
library(igraph)
width <- 30
height <- 20
num_nodes <- width * height
x <- rep(1:width, each = height)
y &l...
Supinator asked 3/9, 2024 at 23:45
4
Solved
Using R corrplot, I have not found a solution where the correlation coefficients in the boxes are plotted together with their significances, i.e. 0.84***
Here is the code plotting only the signific...
Luker asked 3/8, 2020 at 10:33
6
For a hydrologist, the Rainfall Hyetograph and Streamflow Hydrograph is commonly used. It looks like the figure below.
The X-axis represents Date and left Y-axis which is reversed represents rai...
2
Solved
Short version
What is the simple and elegant way to use renv, venv and jupyterlab with IRkernel together? In particular, how to automatically activate renv from jupyter notebook that is not in the ...
Canalize asked 23/2, 2022 at 18:31
4
Solved
I can add text to a ggplot using geom_text just fine (example using the cars database):
ggplot(cars, aes(speed, dist), color='blue') +
geom_point(size=0.8) +
geom_text(y=25, x=5, aes(label=paste...
4
I've read a .csv file into R, ran some code to edit it and now want to export this data frame as a .csv
This so I can read it into R again for some different editing.
How do I do this the correct ...
Karykaryl asked 25/5, 2020 at 16:5
1
Solved
Here is some code to reproduce a data.frame containing projected coordinates and to add an ID column:
x <- c(611547.6411, 589547.6411, 611447.6411, 609847.6411, 606347.6411, 611447.6411, 613547....
Renitarenitent asked 3/9, 2024 at 7:46
2
A few weeks ago I worked with breakpoints in Rstudio. It worked as I expected: stopping at breakpoints.
However, now I need to use it again, I can't get it to work; more specifically: when I set a...
Brunell asked 27/11, 2018 at 14:57
3
Solved
I have an R script which calls a function written by me. However, when I execute the script, the program doesn't stop at the debug point in the function body.
The only time debug points work is whe...
4
Solved
I have a dataset and I want to perform something like Group By Rollup like we have in SQL for aggregate values.
Below is a reproducible example. I know aggregate works really well as explained her...
Noellanoelle asked 23/3, 2016 at 3:6
4
Solved
I am trying to count the number of mismatches in values between two rows (two samples), going column by column in R. I want to only count mismatches that don't include an NA. Here is some example d...
Thew asked 30/8, 2024 at 20:2
2
Solved
I'm using model.frame() in R (to use within a function) but I can't manage to exclude some of the variables with the formula by using -.
For example, in a data frame (data) with variables "y", "x1"...
Buchanan asked 26/4, 2017 at 21:30
3
I'm trying to create dynamic SQL pulls in R. I'm using dplyr to create the pulls. However, I haven't found a way to properly convert a string to expression with dplyr.
For example, the following co...
Firstly asked 29/8, 2024 at 17:20
5
Solved
I have this dataset
library(dplyr)
# creating a dataframe
data_frame <- data.frame(id = c(1,1,2,2,3,3),
col2 = c("start", "finish", "start", "finish",&q...
3
Solved
My filter_list has a large number of elements. The filtering below works but how would one make the dplyr::filter more concise?
I couldn't make all_of work.
filter_list <- list(
hair_color = c(...
3
Solved
Taking the graph from ggplot2 help pages:
ggplot(mtcars, aes(factor(cyl))) + geom_bar() + facet_grid(. ~ vs)
Is it possible to change the border (colour and/or thickness) of only selected panels...
1
Solved
I have data of a pre and a posttest in two groups: control and treatment. I computed the score and now want to illustrate the differences between groups and tests. As a basis I have a data frame in...
Lucretialucretius asked 26/8, 2024 at 10:54
2
When trying to use the plot function in an R notebook on visual studio, nothing is shown and I obtain the following error:
[Error - 6:53:47 PM] R Tools client: couldn't create connection to server....
Duro asked 27/1, 2023 at 18:7
2
Solved
I have the following character vector in R:
test <- r"(\")"
> print(test)
[1] "\\\""
> cat(test)
\"
As you can see, it consists of two characters,
\&...
Disquiet asked 23/8, 2024 at 12:47
2
Solved
Consider the following:
> n <- 1:4
> n
[1] 1 2 3 4
I would like to transform n so that I get a string which is '1', '2', '3', '4' (which in R, would show as "'1', '2', '3', '4'").
This...
Vi asked 8/7, 2016 at 16:51
© 2022 - 2025 — McMap. All rights reserved.