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

Add column to elements within list of dataframes

I have a list of data frames where some have a need column and others do not. How do I add the need column to the other data frames (with value = NA)? I've tried using Map or lapply test <-...

View Article


How to make a function that calculates newtons quotient for f(x) = exp(x) in R?

I'm working on an assignment for class and I'm a little lost with trying to write a function out which will calculate Newton's quotient. This is what the questions is askingThe derivative of a function...

View Article


Using lapply with multiple function inputs without nesting

I have a data frame with four columns: two columns indicate participation in a sport, while the other two columns indicate whether the player passed each of their two fitness exams. dat <-...

View Article

Extracting nth character till the end of string in R

I'm trying to extract the nth character onwards in a string, using R. Here's my data:StringField example_string1 example_string2 example_string3 example_string4 example_string5 example_string6...

View Article

Independent t-test with an aov-object in R

Is there a simple way to compute independent t-tests with an aov object, similar to how pairwise comparisons can be computed by pairs(emmeans(aov.object,~variable)?

View Article


Modifiy Table with R: Grouping of data 'intellegent'

I have a scenario where even with Excel I am not sure how thsi can be automated rather than doing manually.My Excel chart look like so:Country Customer Device Level DueDate Germany Aldi XYZ 3 12.12.20...

View Article

Avoid for loop when loop has an increment

In R, I try systematically to avoid "for" loops and use lapply() family instead. But how to do so when an iteration contains an increment step ?For example : is it possible to obtain the same result as...

View Article

Stacking multiple columns using pivot longer in R

I am trying to change my data from wide to long on r using pivot_longer. There appear to be a few people having similar issues on here but I have been unable to adapt their solutions to my data. I have...

View Article


Delete everything after second comma from string [duplicate]

I would like to remove anything after the second comma in a string -including the second comma-. Here is an example:x <- 'Day,Bobby,Jean,Gav' gsub("(.*),.*", "\\1", x) and it gives:[1] "Day, Bobby,...

View Article


How to view all k neighbors when performing knn with the mir package?

I'm using the mlr package for knn (both for classification and regression problems), e.g.:knnTask <- makeClassifTask(data = df_train, target = "CLASS") knn <- makeLearner("classif.knn", par.vals...

View Article

How to use sqldf in R to manipulate local dataframes?

I am attempting to analyze some data in RStudio which originates from a MySQL database, so I used dbConnect to connect to said database, and copied the single table I needed for this project. I then...

View Article

Is there a way to combine information from two columns into a single column...

I am working with a data set that has two columns, one of which will have useful information. The one without information will have NA as its value. I would like this information to go into a third...

View Article

Merge the same dates [duplicate]

I have data in this formatdata.frame(id = c(1,1,2), date = c("2008-08-04 05:45:07","2008-08-04 09:45:07","2008-08-04 05:45:07"), text = c("stg","another","final")) # id date text # 1 1 2008-08-04...

View Article


Can I use names from a list/dataframe, to be recognised as list/dataframe...

I'd like to use a loop function to recognise names from a list/dataframe as an actual list/dataframe name in the R script (for data analysis or manipulation). I will create some pseudo data to try to...

View Article

Converting date to numeric but limiting to number of days in year

I want to create date object between 2008-01-01 and 2010-12-31 around 10K of them. I wrote the code for that but I actually want to keep days 1-366 in 2008 because of 2008-02-29 (leap year) I want them...

View Article


Image may be NSFW.
Clik here to view.

Can we replicate only the column names of different datasets with only 1 line...

I have a dataframe dfdf ColA COlB A F B D C E I convert above data to DT. So it looks like (with filters, customised etc). But is it possible to have something like thisdf1 ColA COLB "Message"df <-...

View Article

How to /In which program process a large amount of data(observations)?

I have a project where my data universe is charged in Oracle SQL Developerand it's around 86 millions of rows, of course I want to apply a mothodology in order to reduce the number of observations such...

View Article


comparing multiple columns including NAs in a dataframe R

I have a dataframe include 1,2 and bunch of NAs I would like to compare these columns and save the results in a new column (let's say F) so that: if in each row all values are 1 then the new column get...

View Article

Image may be NSFW.
Clik here to view.

R Markdown - Knitr - Help to Align Table Left in HTML Output

I am experimenting with Knitr/KableExtra in RStudio but cannot make my tables use the full width of the web browser or control the table alignment on the screen.Below is an example of the code where as...

View Article

Image may be NSFW.
Clik here to view.

Putting the legend inside the graph

I am trying to plot a stacked barchart of the global terorrism dataset available at the following link: https://www.kaggle.com/START-UMD/gtd My aim is to put the legend inside the graph, precisely in...

View Article
Browsing all 201839 articles
Browse latest View live