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

R: Export and import a list to .txt file

This post suggests a way to write a list to a file.lapply(mylist, write, "test.txt", append=TRUE, ncolumns=1000) The issue with this technic is that part of the information of the list (the structure...

View Article


FInd max Value by multiple colums as new column [duplicate]

I have a df like this:x = c(1,1,2,2,1 ) y = c(2,2,3,3,1 ) z = c(4,3,2,1,1 ) df<-data.frame(x,y,z) Now I have to find the max value in column z. My Output should looks like this: x y z max 1 2 4 4 1...

View Article


Image may be NSFW.
Clik here to view.

Find point in dataframe where (col_1[ i ], col_2[ i ]) = (col_1[ j ], -col_2[...

There might be an obvious solution to this that I have missed but here goes:Consider the data frame below. I wish to create a column with TRUE/FALSE values, where the value is TRUE whenever the...

View Article

What is the correct/standard way to check if difference is smaller than...

I often end up in situations where it is necessary to check if the obtained difference is above machine precision. Seems like for this purpose R has a handy variable: .Machine$double.eps. However when...

View Article

How to create a function with already written for-loop to automatically...

I have a df with fixed columns and unfixed row number. I created empty vectors and populate R commands to create vectors on its own once I use eval(parse(text = someVector)). What I did with for-loop...

View Article


R - elegant way to select multiple variables in model like rpart or train

I want to use around 50 variable columns of my data as factors for my model and try to figure out an elegant way instead of using a long list of all variables.rpart(output_variable ~ Variable1 +...

View Article

Ifelse function in R doesn't work for dummy variable creation

I'm trying to create a dummy variable in R. Specifically, a variable (post) that takes the value 1 if the date corresponds to any of the listed values and 0 otherwise. I use the ifelse function which...

View Article

Conditional replacing of values ina a variable based on valuse in multiple...

I have a following line of code which replaces a value in a variable (var2) based on a value in other variable (var1) df$var2[df$var1 > 0] <- NA However I would like to extend this and replace...

View Article


upload files within nested folders in AWS S3 using R

I am looking a way where I can upload files with in a nested folder using R ProgrammingI tried below functions which uploads either file or folder from aws.s3 packagelibrary("aws.s3")...

View Article


Each row of the input matrix needs to contain at least one non-zero entry

I have this issue when I run this chunk of codetext_lda <- LDA(text_dtm, k = 2, method = "VEM", control = NULL) I have the next mistake "Each row of the input matrix needs to contain at least one...

View Article

Image may be NSFW.
Clik here to view.

Random effect with gam() with betar family in R

I'm having trouble with my gam() analysis with betar family and the weird thing is that it worked perfectly before. After I restarted R, all kinds of error and warning messages showed up.I'm analysing...

View Article

R Download table from webpage with RCurl

I'm trying to download a table from a html-site by using the RCurl::getURL()-function. The problem is that the following error appears:theurl <-...

View Article

Image may be NSFW.
Clik here to view.

Ggplot2 change the position of y axis values after removing gridlines

I want to create a heatmap in ggplot2 without the gridlines. I removed them using the theme function and panel.grid arguments, but it leaves the space between the y axis values and the plot: I tried to...

View Article


How do I make a binary matrix comparing several columns

I'm new to programming and R.I have a data like this in columns:C1 C2 C3 C4 C5 Apple Apple Banana Banana Banana Orange Orange Orange I want to make a binary matrix comparing all the columns to C1 where...

View Article

R plottinjg polynomial regression line

I try to plot a polynomial regression line but the plotted line does not make sense. I use the iris dataset from the package datasets. This is my code:library(datasets) data2 <- iris[iris$Species !=...

View Article


Speeding up linear model fitting on complete pairwise observations in large...

I have a numeric data.frame df with 134946 rows x 1938 columns. 99.82% of the data are NA. For each pair of (distinct) columns "P1" and "P2", I need to find which rows have non-NA values for both and...

View Article

Calculate the mean of one column from several CSV files

I have over 300 CSV files in a folder (named 001.csv, 002.csv and so on). Each contains a data frame with a header. I am writing a function that will take three arguments: the location of the files,...

View Article


Pattern changes doesn't aggregate rows with same char strings [duplicate]

I generate reports wherein I update/replaces certain details using gsub and %in% operator. Issue is after replacing certain string, the associated numerical values doesn't aggregate, when I use "match"...

View Article

Can we track system logging and system logout time in R shiny

For the purpose of tracking my application, I have incorporated logging events in my application. It is tracking all information. But I need to put app opening time and opp closing time. Is it possible...

View Article

How I can take mean for different subsets of a specific column in a data.table?

Given a sample data frame:dt <- data.table(value=1:10,start=c(1,4,5,8,6,3,2,1,9,4),finish=c(3,7,8,9,10,10,4,10,10,8))I want to add a new column which may be named as mean_column. i'th row of this...

View Article
Browsing all 206102 articles
Browse latest View live


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