Questions tagged [r]

133482 questions
1

votes
1

answer
161

Views

knitr kable and “*”

I am trying to produce a table with a '*' as a value in a cell: --- title: 'Untitled' author: 'James Durant' date: 'November 7, 2017' output: pdf_document --- ```{r arthmatic, echo=FALSE} library(knitr) dfx
James Thomas Durant
1

votes
2

answer
1.1k

Views

read_html — Error in read_connection_(x, n): Evaluation error: Failure when receiving data from the peer

I'm using rvest and read_html to try and scrape a site. The scraping has worked for me before, but it won't work anymore. Using R version 3.4.2 and rvest 0.3.2 This is my code: library(rvest) read_html('http://hamilton.edu/news/story/the-medias-effect-on-womens-body-image') and my error is: Error in...
Evan O.
0

votes
0

answer
20

Views

Is there a method similar to lag (in R) or shift (in Python) for the javascript framework data-forge?

I have a code like this: const dataForge = require('data-forge'); var df = new dataForge.DataFrame({columns: {col1: [1,2,3,4,5]}}); console.log(df.toString()); with this result: __index__ col1 --------- ---- 0 1 1 2 2 3 3 4 4 5 in R and in Python like n...
EFA
0

votes
0

answer
20

Views

How to specify row and column names when both are categorical

I have two categorical variables and I am trying to create a cross tabulation for them. Since both values are yes and no , I want to specify the row and column names for ease of understanding. T4 % prop.table(margin = 2) *100 T4 no yes no 83.418772 92.217126 yes 16.581228 7.782874 kable(T4...
Ahmad Hasnain
-1

votes
0

answer
16

Views

How to iterate over a loop

I would like to do this automatically instead of typing it out 1500 times. n1
mymymine
2

votes
1

answer
17

Views

R Position of figures in RMarkdown

I want to knit an article in RMarkdown but the figures (tables) don't appear at the correct position in the document (pdf). Here I can show you my problem in the example data. The table should appear after the appendix: Can someone show me how I can solve this problem? And here is y example code: -...
TobKel
1

votes
0

answer
12

Views

Mixed ANOVA (lme) returns error for alphabetic variable

I have a large data set with persons who answered questionnaires at several measurement points. I want to run an ANOVA using the lme function with my 'SERIAL' variable as identifying the persons (which is the serial code of a person in letters and numbers, e.g. YVEDPEPGV9). So person YVEDPEPGV9 answ...
j_brokelm
1

votes
1

answer
252

Views

Scraping a table using the rvest package

I’m totally new to web scraping and I’m exploring the potentialities of the rvest library in R. I’m trying to scrape a table on wellbeing in Italian provinces from the following website, install.packages('rvest') library('rvest') url
Luca De Benedictis
1

votes
1

answer
2.1k

Views

is there a way to avoid having to install packages every time in R?

I looked around and googled everything I could think of but cannot find a solution to what seems to be a basic problem. I am new to R, and I am working on a couple of projects, from various computers. Every time I open a project, I need to reinstall the various packages, and to activate them one by...
Grig
1

votes
1

answer
119

Views

returning command line from windows tasklist

I am searching for a command to get the command line written in the windows task manager. I was using tasklist /fo CSV /v but it doesn't provide the command line I get when I look at the task manager. I attach a picture to show what I mean, it is the right most column. I need this information in a...
drmariod
1

votes
1

answer
1.3k

Views

R merge pdf into one pdf

I have a folder which contains around 400 .pdf files, each .pdf file is 2 pages total. All .pdf file names are under the following format: 148-c16631-27-02-2018.pdf What I would like is to merge under one pdf file, the pdf files that have a certain code in the file name in R. For instance: 148-c166...
KRStam
1

votes
2

answer
42

Views

R- Unsure of what to set y value equal to to create plot with facets

I am trying to create a plot with a facet for each region. I added the region column at the end because I thought I could use that as the parameter for facet_wrap(). Also, what do I set y equal to if I want it to be equal to the values listed in the tibble below? mydata
qq3254
1

votes
2

answer
36

Views

put column name as a value if meets certain conditions in R

Say I have a dataset from four observations, like this: data
imprela
1

votes
2

answer
4.2k

Views

ggplot2 : How to reduce the width AND the space between bars with geom_bar

I understand that one can change the width of a bar in geom_bar using the width argument. That does work, but then it creates a larger gap between the bars. Is there a way to manually push the bars closer to together? Should I be manipulating the axis somehow instead? Here is an example, changing wi...
Alex
1

votes
1

answer
391

Views

how to move tick marks and labels at right/left end of tiles in geom_tile ggplot?

I am unable to move the x-axis labels, including tick marsk, in a geom_tile to the right end of each tile, I would also like to add the zero at the left end. I have tried breaks and labels but with no luck. Also using breaks and labels doesn't really work. I am trying to achieve what is done in this...
1

votes
2

answer
760

Views

ggplot: Plotting timeseries data with missing values

I have been trying to plot a graph between two columns from a data frame which I had created. The data values stored in the first column is daily time data named 'Time'(format- YYYY-MM-DD) and the second column contains precipitation magnitude, which is a numeric value named 'data1'. This data is ta...
Karan Chaudhary
0

votes
0

answer
13

Views

shiny html full page bootstrap carousel

I am begining in styling shiny apps. I want to create a create a full screen slider into a tabpanel of my application for my landing page. According to this snippet https://codepen.io/nikhil/pen/RPOXya , here's my application. The carousel is empty. How can I solve this issues (perhaps the in...
Wilcar
0

votes
0

answer
5

Views

Computing Chebyshev center in R

I'm searching for a way to compute the Chebyshev center of a convex polytope, in R. I would like to have a funcion of the type: x0 = chebycenter(A,b); where x0 is the vector of coordinates of the Chebyshev center and the convex polytope is defined by A*x
Bplanque
0

votes
1

answer
28

Views

Converting text to numbers?

So I am trying to code gender as a dummy variable. However, the data has gender coded as '1.Male' and '2.Female' (rather than 1=Male and 2=Female) I just want to recode it so it comes out as 1's and 2's df$men
Finalsenator
0

votes
0

answer
5

Views

What is the max real number in computer I can get TRUE as a result of is.finite in R?

(reproducible example is added) The maximum positive double (floating point) number in computer in my 64-bit OS and 32-bit R is: .Machine$double.xmax # 1.797693e+308 So, the following is TRUE: is.finite(1.797683e+308) # TRUE; here, as argument I used 1.797683e+308 So, then what is the max real numb...
Erdogan CEVHER
1

votes
4

answer
10.5k

Views

How do I upgrade “keras” from 1.2.0 to 2.0.0?

I am running an image classifier but it keeps producing the error Keras loaded from keras Python module v1.2.0, however version 2.0.0 is required. Please update the keras Python package. Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: init() got an unexpected keyword argumen...
KaRJ XEN
1

votes
1

answer
118

Views

How to customize effect plot in R?

I'm trying to some effects plots to visualize regression results. I'm able to create the plot, but many of the arguments I'm supplying don't seem to affect its appearance. For example, this code produces 3 figures of nearly identical appearance. The multiline and rug settings don't seem to work....
Arthur
1

votes
2

answer
266

Views

Rcrawler scrape does not yield pages

I'm using Rcrawler to extract the infobox of Wikipedia pages. I have a list of musicians and I'd like to extract their name, DOB, date of death, instruments, labels, etc. Then I'd like to create a dataframe of all artists in the list as rows and the data stored as columns/vectors. The code below t...
Ben
1

votes
1

answer
1.7k

Views

RStudio running on 32 bit on a 64 bit OS with 64 bit R installation

The following is the version info for R on my Windows 10 desktop: R version 3.4.1 (2017-06-30) -- 'Single Candle' Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) When I run a script using R studio, it is running on 32 bit. I got this info from...
Sunil Reddy
1

votes
2

answer
305

Views

creating custom annotations in only one facet of a ggplot

Is there a way to specify that a custom_annotation only applies to one facet of a ggplot? For example, if I run the following code library(tidyverse) library(grid) text_grob=grobTree(textGrob('text',x=0.5, y=0.6, rot=90, gp=gpar(col='red'))) ggplot(mtcars, aes(x=mpg, y =drat))+ geom_point() + facet...
Ajjit Narayanan
1

votes
1

answer
39

Views

Check which community a node belongs in louvain community detection

So I have run louvain detection on my dataset and returns a bunch of communities with nodes included. My question is, given a node, how do you find which community it belongs to? Thanks.
Hina
1

votes
2

answer
264

Views

Vertical equivalent of position_dodge for geom_point on categorical scale

I would like to dodge overlapping geom_point's vertically, when I have a categorical y variable. library(tidyverse) # all possible points df %as.tbl # randomly missing and overlapping points # every green point has a pink point underneath, and every blue point # has a green point underneath it. see...
dule arnaux
1

votes
1

answer
231

Views

Using predict function for new data along with tidyverse

I want to use predict function for new data along with tidyverse as in the following example. However, I could not figured out how to use with new data for wt = 4.0 and 4.2. Any hints, please. library(tidyverse) mtcars %>% dplyr::mutate(cyl1 = factor(cyl)) %>% tidyr::nest(-cyl) %>% dplyr::mutate...
MYaseen208
1

votes
1

answer
148

Views

Echarts4r : Create stacked area chart with percentage from total in tooltip

I need to make stacked area chart using the echarts4r. In spite of great examples on javascript I can't find the solution how to make the area chart stacked using R. Ideally it is also necessary to add to the chart the tooltip with percentage from total as in my example using highcharter package....
iomedee
1

votes
1

answer
53

Views

Utilizing Popover (shinybs) within InsertUI function

I'm having issues with using the popover function in my Shiny app when I'm using insertUI. See my code below. library(shinyBS) library(shiny) #ui---- ui = basicPage( actionButton('show', 'Create a New Analysis') ) #server---- server = function(input, output, session) { #Show modal when button is...
M.Yosh
1

votes
2

answer
67

Views

Why isn't my barplot rearranging properly when faceting with ggplot?

So I have made this barplot with this code, bars organised in descending order, great! na.omit(insect_tally_native_ranges)%>% group_by(native_ranges)%>% dplyr::summarise(freq=sum(n))%>% ggplot(aes(x=reorder(native_ranges,freq),y=freq))+ geom_col(color='#CD4F39',fill='#CD4F39',alpha=0.8)+ coord_flip(...
delcast
1

votes
1

answer
108

Views

Fast Wald confidence intervals for a glm with broom in R

I would like to calculate Wald confidence intervals of the coefficients of a glm on a somewhat large data set, and use broom for a tidy output. mydata
bebru
1

votes
2

answer
122

Views

Shiny Modules: Accessing and changing reactiveValues situated inside module`s server function from the outside?

I have a shiny-module which uses reactive Values to store its internal state. In the example below this is only used to output the number the input changed, but my real use-cases are more complicated. I now want to create a function which can be used to set one of these modules to the state of the...
Julian
1

votes
2

answer
112

Views

Plotting a ggplot2 graph in a power point slide with a given size - R

I'm trying to plot a ggplot2 graph in a power point slide with the officer package. I can do it actually (printing the ggplot2 directly in the ppt), but as I need to increase the size of the ggplot2 graph (for the ppt slide), and I have understood that ggplot2 graphs are dependent on the size of the...
Chris
1

votes
2

answer
61

Views

How to control the size of the vertex label in textplot_network?

I am able to control the vertex size, but not the vertex label size in textplot_network. Is there a way of doing it? I saw the argument vertex.cex in plot.network but it doesn't work. This is what I have got so far: library(quanteda) toks % tokens(remove_punct = TRUE) %>% tokens_tolower() %>% tokens...
Guilherme Parreira
1

votes
2

answer
115

Views

R, generate pretty plot by dfSummary

I have a problem using summarytools packet. There is tutorial:https://cran.r-project.org/web/packages/summarytools/vignettes/Introduction.html with pretty plots of data: My problem is that my code generate only TEXT GRAPH. This is chunk of code in my markdown to generate plot: ```{r summary, results...
CezarySzulc
-1

votes
1

answer
16

Views

Why does indexing into a list with list[n] instead of list[[n]] in R not do what you would expect?

In an R list, why does indexing with [n] instead of [[n]] not return the nth element as non-R-programmers would expect? lfile
smci
0

votes
1

answer
11

Views

Replacing an if statement's condition character with a variable

This is probably an easy one. In R, can I replace an if condition character (such as >) with a character and execute the if statement with it? For example, if the if statement is: ifelse(1 < 2, 'T', 'F') But I'm getting the > condition character through a variable: cc
dan
0

votes
0

answer
16

Views

How to simplify a for loop that aggregates columns for 130 dataframes

I have 2 csv's with information for 130 cities and a csv of general information for all cities. I need to create a dataframe for each of these cities housing all of their information. I have done this using a loop but I was wondering if there is a simpler way to do this given the information for the...
Yaya
0

votes
1

answer
14

Views

How to compute an index in r?

It is my first time I am asking a question in this great community. I am trying to calculate an index on a data.frame, show them by borough or neighborhood and plot. Which code suited the most? Here is an example of a data set I have. albo, aegy = mosquito species, house = house prospected, The hous...
Armel Tedjou

View additional questions