Crash of debugging browser in R/Rstudio when called from inside do.call
In line with this question, the debugger browser does not show me where it has stopped when it is called from within a do.call statement. First it prints all the arguments to the console and then generally the browser is unresponsive leaving no other option than to force quit RStudio. Does anyone have experience with anything equivalent and can point to any fixes?
This also seems to describe a similar issue.
See also questions close to this topic
how can I make a plot with standard deviation
My data looks like below
df<- structure(list(data1 = c(20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L, 20171205L), data2 = c(0.00546273, 0.00552377, 0.00549325, 0.00550851, 0.00556954, 0.00560006, 0.00555428, 0.00560006, 0.0055848, 0.00561532, 0.00555428, 0.0055848, 0.00552377, 0.00549325, 0.00550851, 0.00556954, 0.00560006, 0.00555428, 0.00560006, 0.0055848), data3 = c(0.00546273, 0.00552377, 0.00549325, 0.00550851, 0.00556954, 0.00560006, 0.00555428, 0.00560006, 0.0055848, 0.00561532, 0.00555428, 0.0055848, 0.00552377, 0.00549325, 0.00550851, 0.00556954, 0.00560006, 0.00555428, 0.00560006, 0.0055848), mydf = structure(1:20, .Label = c("B02", "B03", "B04", "B05", "B06", "C02", "C03", "C04", "C05", "C06", "D02", "D03", "D04", "D05", "D06", "E02", "E03", "E04", "E05", "E06"), class = "factor")), .Names = c("data1", "data2", "data3", "mydf"), class = "data.frame", row.names = c(NA, -20L))
I am trying to get the average and standard deviation of certain rows here is what I do
# here is to get the mean library(dplyr) df2 <- df %>% group_by(Group = case_when( grepl("02$|03$", mydf) ~ 1L, grepl("04$|05$|06$", mydf) ~ 2L, TRUE ~ NA_integer_ )) %>% summarise_at(vars(-mydf), funs(mean(.))) # here is to get the standard deviation df3 <- df %>% group_by(Group = case_when( grepl("02$|03$", mydf) ~ 1L, grepl("04$|05$|06$", mydf) ~ 2L, TRUE ~ NA_integer_ )) %>% summarise_at(vars(-mydf), funs(sd(.)))
Then I want to put the mean and their sd but I don't know how to merge these two df together and plot them
the first column is the x- axis (in this case it is 1 and 2)
so data will look like this for the plot (for example):
On 1 for
data1, it will be
20171205with a SD of
On 2 for
data1, it will be
20171205with a SD of
On 1 for
data2, it will be
0.005556190with a SD of
On 2 for
data2, it will be
0.005553013with a SD of
R: change/match data types of common columns between two data frames
Say I have this data frame:
# Original data frame df_1 <- data.frame(a = sample(1:10, 5), b = letters[1:5], c = sample(c(TRUE, FALSE), 5, replace = TRUE), d = 6:10) # a b c d #1 7 a FALSE 6 #2 9 b TRUE 7 #3 3 c TRUE 8 #4 5 d TRUE 9 #5 6 e TRUE 10
I also have a second data frame that has some columns in common with the first:
# Data frame with wonky data types df_2 <- data.frame(a = as.character(sample(1:10, 5)), foo = 1:5, b = letters[1:5], bar = runif(5), c = as.character(sample(c(TRUE, FALSE), 5, replace = TRUE)), stringsAsFactors = FALSE) # a foo b bar c #1 10 1 a 0.1185343 FALSE #2 5 2 b 0.3081978 TRUE #3 6 3 c 0.4409280 TRUE #4 8 4 d 0.5081508 FALSE #5 7 5 e 0.7404537 FALSE
Notice that the columns that
df_2has in common with
c) do not necessarily have the same data type as the corresponding columns in
df_1. For example,
df_1is of type
df_2is of type
What I'd like to do is convert all columns in
df_2that are also present in
df_1to the data type of the
My first hope was that I could bind them and that would automatically do the conversion:
library(dplyr) bind_rows(df_1, df_2)
Error in bind_rows_(x, .id) : Column
acan't be converted from integer to character
So, my next attempt was to figure out which columns are in common:
# Common columns common <- names(df_2)[names(df_2) %in% names(df_1)]
Now, if I wanted to convert them all to
numericI might use,
df_2 %>% mutate_at(common, as.numeric)
but they are all different data types, so I need to use the corresponding data type. I think that somehow I could use
aspassing the corresponding class as derived from
lapply(df_1, class), but the details elude me. I think that there must be a simple, elegant solution and I'm overthinking this, but I've had no luck so far. Any ideas?
Ploting smooth line graph in ggplot in R
I was trying to plot a graph with 3 lines in it. The output looks as follows.
The following code will reproduce it,
library(ggplot2) library(lubridate) Dates <- as.Date(seq(as.Date("2017/05/01"), as.Date("2017/07/31"), "day")) Values <- runif(length(seq(as.Date("2017/05/01"), as.Date("2017/07/31"), "day")), min=-5, max=+5) myData <- data.frame( Dates = Dates, Values = Values ) ggplot(data = myData, aes(x = day(myData$Dates), y = myData$Values)) + geom_line(aes(color = as.factor(months(myData$Dates)))) + geom_point(aes(color = as.factor(months(myData$Dates))))
My goal is to make the lines smooth, but that touche all the points (e.g., Red lines to touch red points)
(I tried with spline. However, that did not give any expected result, also problem was with x-axis labels.
I tried this, plotting smooth line through all data points maybe polynomial interpolation? could to make it work!)
Can someone please put some lights on it? Thank you very much.
Docker with delve debug
I have following
FROM golang ADD . /go/src/github.com/golang/example/outyet ADD . /go/src/github.com/derekparker/delve/cmd/dlv RUN go install github.com/golang/example/outyet RUN go install github.com/derekparker/delve/cmd/dlv ENTRYPOINT /go/bin/outyet RUN dlv debug --headless --listen=:37277 --api-version=2 EXPOSE 8080 EXPOSE 37277
I have helloworld project from this blog and I installed
delveas Goland remote debug asked me to do. After that I exposed my helloworld server port and debug port
I run it like this:
sudo docker run -p 37277:37277 -p 6060:8080 --name test --rm outyet
When I hit my
Goland Go Remoteit looks like it get connection for a second and lost it immediately. What did I do wrong?
Debug where method returns None
I have a big legacy Python method which contains roughly twenty
The method should not return
Nonebut it does so. It is repeatable in a simple test case.
Up to now I used a debugger and stepped through the code line by line to find the matching return statement.
But is there an easier way?
Is there a way to raise an Exception as soon as the method returns None?
and Of course I need to see the line containing the return statement.
def big_method(arg1, some_var): #.... many returns if arg1: return some_var # <------ #... many returns assert not big_method(True, None) is None
Above is a simple code snippet. The result:
Traceback (most recent call last): File "/home/modwork_vums_d/src/manyreturns.py", line 8, in <module> assert not big_method(True, None) is None AssertionError
Above traceback does not help very much, since I want to see the line inside
big_method(). In the example above I want to see which I marked with
I use PyCharm, but a pure python or other solution is welcome.
Unity Debug without the linenumber
I am developing an application for the Hololens using unity,. And sometimes (since still in Debug not Release stage) I print debug statements using
However, everytime I use that, I got my custom message and the following:
(Filename: C:/buildslave/unity/build/artifacts/generated/Metro/runtime/DebugBindings.gen.cpp Line: xx)
I don't know what this means, but it clutters the debug output. Is there any way to use the debug messages of the UnityEngine without these?
- R Markdown - set the markdown file location as current directory
R studio errors on calling packages and Updating packages
When I am trying to call packages like dplyr or swirl , I am getting the following error:
library(swirl) Error: package or namespace load failed for ‘swirl’: .onAttach failed in attachNamespace() for 'swirl', details: call: str_c(..., sep = " ") error: cannot allocate memory block of size 3.8 Gb In addition: Warning message: In str_c(..., sep = " ") : restarting interrupted promise evaluation
library(dplyr) Error: package or namespace load failed for ‘dplyr’ in get(Info[i, 1], envir = env): cannot allocate memory block of size 2.2 Gb
I am using R 3.4.3 in win 7, 32 bit. extreme edition.
Where can I find the official documentation for functions part of tools:rstudio?
I'm talking about all these functions prefixed with
.rs.. I don't know where to look and googling these functions doesn't return anything.