128 Answered Questions for the topic R

R

06/06/19

How to save a plot as image on the disk?

I plot a simple linear regression using R.I would like to save that image as PNG or JPEG, is it possible to do it automatically? (via code)There are two different questions: First, I am already... more
R

06/06/19

Persistent invalid graphics state error when using ggplot2?

I believe my dataframe is okay and my code is okay. In fact, I have eliminated parts of the dataframe and most of the graphing code to make things as basic as possible. But still, I get: Error... more
R

06/06/19

How do I make a list of data frames?

How do I make a list of data frames and how do I access each of those data frames from the list?For example, how can I put these data frames in a list ? d1 <- data.frame(y1 = c(1, 2, 3), ... more
R

06/03/19

Use of ~ (tilde) in R programming Language?

I saw in a tutorial about regression modeling the following command : myFormula <- Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.WidthWhat exactly does this command do, and... more
R

06/03/19

How to sort a dataframe by multiple column(s)?

I want to sort a data.frame by multiple columns. For example, with the data.frame below I would like to sort by column `z` (descending) then by column `b` (ascending): dd <- data.frame(b =... more
R

06/03/19

Extract every nth element of a vector?

I would like to create a vector in which each element is the `i+6th` element of another vector.For example, in a vector of length 120 I want to create another vector of length 20 in which each... more
R

05/31/19

Split code over multiple lines in an R script?

I want to split a line in an R script over multiple lines (because it is too long). How do I do that?Specifically, I have a line such as ... more
R

05/28/19

What are the differences between "=" and "<-" in R?

What are the differences between the assignment operators `=` and `<-` in R? I know that operators are slightly different, as this example shows x <- y <- 5 x = y = 5 x = y <-... more
R

05/27/19

Add row to dataframe?

In R, how do you add a new row to a dataframe once the dataframe has already been initialized?So far I have this: df<-data.frame("hi","bye") names(df)<-c("hello","goodbye") #I am... more
R

05/26/19

Speed up the loop operation in R?

I have a big performance problem in R. I wrote a function that iterates over a `data.frame` object. It simply adds a new column to a `data.frame` and accumulates something. (simple operation). The... more
R

05/26/19

How do I write a for loop?

R

05/25/19

Changing font size and direction of axes text in ggplot2?

I am plotting a graph with a categorical variable on the x axis and a numerical variable on the y axis.For the x axis, given that there are many data points, the default text formatting causes the... more
R

05/23/19

How do I read data from a CSV file into R?

R

05/20/19

How do I assign variables?

R

05/16/19

Remove NA values from a vector?

I have a huge vector which has a couple of `NA` values, and I'm trying to find the max value in that vector (the vector is all numbers), but I can't do this because of the `NA` values.How can I... more
R

05/11/19

Filtering a data frame by values in a column?

I am working with the dataset `LearnBayes`. For those that want to see the actual data: install.packages('LearnBayes')I am trying to filter out rows based on the value in the columns. For... more
R

04/04/19

Reasons for using the set.seed function?

Many times I have seen the `set.seed` function in R, before starting the program. I know it's basically used for the random number generation. Is there any specific need to set this?
R

03/19/19

How to make execution pause, sleep, wait for X seconds in R?

How do you pause an R script for a specified number of seconds or miliseconds? In many languages, there is a `sleep` function, but `?sleep` references a data set. And `?pause` and `?wait` don't... more
R

03/19/19

Count number of rows within each group?

I have a dataframe and I would like to count the number of rows within each group. I reguarly use the `aggregate` function to sum data as follows: df2

Are statistical programming languages like R/SAS considered functional or procedural?

I still don't understand the difference after reading [this][1] [1]:... more
R

03/18/19

Where does R store packages?

The `install.packages()` function in R is the automatic unzipping utility that gets and install packages in R.1. How do I find out what directory R has chosen to store packages?2. How can I change... more
R

03/18/19

Remove all special characters from a string in R?

How to remove all special characters in a given string in R and replace each special character with space ?
R

03/18/19

How to save a data.frame in R?

I made a data.frame in R that is not very big, but it takes quite some time to build. I would to save it as a file, which I can than again open in R?
R

03/18/19

Using R to list all files with a specified extension?

I'm very new to R and am working on updating an R script to iterate through a series of .dbf tables created using ArcGIS and produce a series of graphs.I have a directory, C:\\Scratch, that will... more
R

03/18/19

What are the different data types in R?

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.