Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 206180 articles
Browse latest View live

How do I return the name of an argument in my function as a column value?

I'm generating a reference table from a numerical vector and a vector of start dates. I want one of the columns in my reference table to equal the name of my first argument (it should read "Ekonom" for...

View Article


R interactive stacked area chart using long data.frame or ggplotly

I am recreating the interactive plot from the plotly example code below (found here) but I'm wondering if a long data.frame format can be used to avoid adding an individual add_trace function for each...

View Article


R question. Generate variables followed by number suffix in dataframe...

How do I generate a variables as below by just entering a number into a function (in this case 5)? rank DATE OP 1 1 DATE1 OP1 2 2 DATE2 OP2 3 3 DATE3 OP3 4 4 DATE4 OP4 5 5 DATE5 OP5 > Which is the...

View Article

used on a smartphone, shiny interactive plot doesn't understand finger movements

I have a R-Shiny application with a plot that implements interactive actions: click, hovering (hovering is passing the mouse over the plot, which can be detected by shiny). To give an idea, I post...

View Article

which(is.na()) returning indexed position outside of df

I apologize in advance for the length of my questions, however R is returning output that I cannot make sense of. Therefore, I wanted to some as much of my data as possible. I have the following data...

View Article


Is it possible to add custom aesthetics, in my particular case I'd like to...

It would be nice to use color shading to indicate levels of a discrete value for example.So instead of this:ggplot( mpg ) + geom_boxplot(...

View Article

Error: path for html_dependency not provided R Markdown selectInput

I have a problem with my R Markdown project. I can not add a select input or even a sliderInput. When I click Build Website I get this error message: Error: path for html_dependency not provided...

View Article

Selecting non-consecutive columns in R tables

Let's say I have a some table, T. Assume T has 5 columns. I understand how to select any consecutive subset of columns and store them as a new table. For that I would use brackets and a colon to the...

View Article


Paragraph indentation of a column in a dataframe

I was trying webscraping, and managed to get the headlines and detailed content story of the news. Code for the same is:webpage <- read_html("https://www.rediff.com/sports") headlines.node <-...

View Article


Image may be NSFW.
Clik here to view.

Feature importance plot using xgb and also ranger. Best way to compare

I'm working on a script that trains both a ranger random forest and a xgb regression. Depending on which performs best based on rmse, one or the other is used to test against hold out data.I would also...

View Article

Image may be NSFW.
Clik here to view.

Weighted dataset for complex survey

I have a dataframe with part of the NHANES dataset (which is a complex survey) and a weights to apply on it. A screenshot of part of the dataframe and the weights are shown below:People are represented...

View Article

Global variables in R

I am poking into the manuals, I wanted to ask the community: How can we set global variables inside a function?

View Article

calculate the mean for each column of a matrix in R

I am working on R in R studio. I need to calculate the mean for each column of a data frame. cluster1 // 5 by 4 data frame mean(cluster1) // I got : Warning message: In mean.default(cluster1) :...

View Article


Image may be NSFW.
Clik here to view.

Remove outliers from Raster

I was wondering if it's possible to remove outliers from Raster datasetData> library (raster) > ras <- raster("08_sa.tif") > boxplot(ras) > summary(ras) 08_sa.tif Min. -6.010734e+17 1st...

View Article

in R: how to take value from i+1th row of 1 dataframe and subtract from every...

Note that the actual dataset is 1000s of columns and 100s of rows so I am looking for a way that does not require that i manually name either columns or rows.With a dataset that has similar structure...

View Article


For Loop for Function not appending list / dataframe

I am trying to complete a homework assignment for a class in Analytics. We are using the kknn (K nearest neighbor) function for classification. Anyway, the for loop does not seem to be iterating...

View Article

Update data frame via function doesn't work

I ran into a little problem using R…In the following data frametest <- data.frame(v1=c(rep(1,3),rep(2,3)),v2=0) I want to change values for v2 in the rows where v1 is 1.test[test$v1==1,"v2"] <-...

View Article


How to install many R packages?

I should install many different R packages. I prepared the file requirements.R (example below):install.packages("mongolite", repos="https://cran.rstudio.com") install.packages("xgboost",...

View Article

Transform result of `st_bbox()` to other CRS

Is there a simple way to transform the bounding of a simple feature (sf object) to another CRS?The result of the function st_bbox() is of class bbox. It is not possible to use st_transform() to...

View Article

restoring R environment to condition prior the loading of a package

In a script I need to load packages tydiverse and gdistance.gdistance actually loads several other packages and overall mask some functions of the tydiverse (e.g. select).I tried to rearrange the...

View Article
Browsing all 206180 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>