R Frequency Table of Likert Data

I have what I thought was a basic task, but has proven otherwise. I have a series of surveys that I need to convert into frequency tables for each survey. For instance, Survey 1 consists of 6 questions in which participants had 5 response options. ...
more »

2017-05-20 03:05 (3) Answers

calculating simple retention in R

For the dataset test, my objective is to find out how many unique users carried over from one period to the next on a period-by-period basis. > test user_id period 1 1 1 2 5 1 3 1 1 4 3 1 5 ...
more »

2017-05-19 22:05 (3) Answers

Plotly - Shape positions using subplot

I am trying to plot multiple subplots with shapes on each plot. From the following code below, if I display one plot I get the following plot: When I position 4 copies of this plot in a subplot I get the following: As you can see all of the 4 l...
more »

2017-05-19 21:05 (2) Answers

refresh URL link from Google maps using R

there. When using Google maps, we can have the following link: maps.google.com.br/?q=newyork Which will actually be redirected to: https://www.google.com.br/maps/place/Nova+York,+NY,+EUA/@40.7056497,-73.9780035,9z/data=!4m2!3m1!1s0x89c24fa5d33f0...
more »

2017-05-19 18:05 (1) Answers

loop inside a foreach loop using doparallel

I have a function that contains a loop myfun = function(z1.d, r, rs){ x = z1.d[,r] or.d = order(as.vector(x), decreasing=TRUE)[rs] zz1.d = as.vector(x) r.l = zz1.d[or.d] y=vector() for (i in 1:9) { if(i<9) y[i]=mean( x[(x[,r] ...
more »

2017-05-19 18:05 (0) Answers

For loop number path calculation

I have a bidirectional network, that is, a network where flow exists both from i->j and j->i. And I want to calculate the number of simple paths between each [i,j] and report in matrices according to the path length, that is, for each [i,j] pair ther...
more »

2017-05-19 16:05 (0) Answers

Load Global Administrative Areas in R from URL

I tried to load Global Administrative Areas from http://gadm.org/ using a stanford tutorial library(sp) con <- url("http://biogeo.ucdavis.edu/data/gadm2.8/rds/CHE_adm3.rds") print(load(con)) close(con) but I got the following error Error: the...
more »

2017-05-19 14:05 (0) Answers

Write xml-object to disk

I have a big bunch of xml-files, which I need to process. For that matter I want to be able to read the files, and save the resulting list of objects to disk. I tried to save the list with readr::write_rds, but after reading it in again, the object i...
more »

2017-05-19 14:05 (1) Answers

adjust image size to ggplot2 grid

I need to plot over an image. The problem I have is that my PNG image doesn't adjust to grid: library(webshot) library(png) webshot("http://www.doctormetrics.com/","doctor.png") img <- readPNG("doctor.png") dim(img) x11() g <- rasterGrob(img, ...
more »

2017-05-19 11:05 (1) Answers

Exclude rows surpassing threshold value

I have a dataset df field_pointpath assetclass_code value C_THDxL_0154x6KSFS_A03x6KSF_11xaP_ACT 6KSFS_6KSF 50 C_THDxL_0154x6KSFS_A03x6KSF_11xaP_ACT 6KSFS_6KSF 60 C_THDxL_0154x6KSFS_A03x6KSF_11xaP_ACT 6KSFS_...
more »

2017-05-19 08:05 (3) Answers

Error using function in data.table in r

I am using a function in data.table that for some reason does not work when used in data.table but works well when used in the R environment. Will anyone know why this happens? Basically, the function assigns the closest year in an array to a given ...
more »

2017-05-19 01:05 (1) Answers

Defining a date x-axis in a scatter plot (R)

I want to produce a scatterplot of a dataframe which has a date column. The x axis should be monthly divided, or for each 2 months in the last 2 years. The dataframe: code_1000 <- as.data.frame(cbind( c("3", "3", "7", "7", "7", "7", "2", "...
more »

2017-05-19 01:05 (2) Answers

hiding entire pages in an r markdown document

I have the r markdown document below. I would like to hide page 2 if parameter "P" is not equal to A. So the result would be if parameter P != A then only 3 pages are produced. Is this possible somehow? --- title: "Untitled" output: pdf_docume...
more »

2017-05-18 22:05 (1) Answers

R: ordering rows in reshape2

I have a situation where I need to melt the data using the reshape2 package in R. melt(head(faithful), measure.vars = names(faithful)) this gives the output: variable value 1 eruptions 3.600 2 eruptions 1.800 ... 7 waiting 79.000 8 ...
more »

2017-05-18 16:05 (2) Answers

basic loop in R

Trying to create a loop to extract the categorical data from the columns 1:9 of my df: Something like this seems to work, but the problem is that only the las i is returned. Something is missing to keep every output after the loop runs. for (i in ...
more »

2017-05-18 16:05 (3) Answers