Questions tagged [r-faq]

The r-faq tag is created to group a limited number of questions discussing problems that come up regularly on the R tag. It is not the official FAQ on R for SO, but should serve as an interesting source of information on common problems.

The tag is created to group a limited number of questions discussing problems that come up regularly on the tag. It is not the official FAQ on R for SO, but should serve as an interesting source of information on common problems.

The "real" original R-FAQ is reliably found at: https://cran.r-project.org/doc/FAQ/R-FAQ.html and is typically the first google hit for "r-faq".

251 questions
9
votes
4 answers

Where can I find useful R tutorials with various implementations?

I'm using R language and the manuals on the R site are really informative. However, I'd like to see some more examples and implementations with R which can help me develop my knowledge faster. Any suggestions?
Mehper C. Palavuzlar
  • 10,089
  • 23
  • 56
  • 69
9
votes
4 answers

How to order my dataframe lexicographicaly

I have a following data frame a = data.frame(a=c(1,2,3,4,5,6,7),b=c(1,2,3,10,12,21,4),c=c(1,2,10,11,"X","Y",3)) > a a b c 1 1 1 1 2 2 2 2 3 3 3 10 4 4 10 11 5 5 12 X 6 6 21 Y 7 7 4 3 I want to sort whole data frame in lexicographical…
user1631306
  • 4,350
  • 8
  • 39
  • 74
8
votes
1 answer

`lm` summary not display all factor levels

I am running a linear regression on a number of attributes including two categorical attributes, B and F, and I don't get a coefficient value for every factor level I have. B has 9 levels and F has 6 levels. When I initially ran the model (with…
Karen Roberts
  • 83
  • 1
  • 1
  • 4
7
votes
4 answers

Arithmetic operations on R factors

I have an R dataframe and I'm trying to subtract one column from another. I extract the columns using the $ operator but the class of the columns is 'factor' and R won't perform arithmetic operations on factors. Are there special functions to do…
Michael
  • 7,087
  • 21
  • 52
  • 81
6
votes
4 answers

What is the difference between = and == in R?

What is the difference between = and ==? I have found cases where the double equal sign will allow my script to run while one equal sign produces an error message. When should I use == instead of =?
bubbalouie
  • 643
  • 3
  • 10
  • 18
5
votes
2 answers

Remove backslashes from character string

I am reading text in from a txt file and pass the contents to SQL. The SQL text contains double quotes and is causing problems. I would like to remove the "\" in the string below so I can send it to SQL test<- "select case when \"est\" dsaf" …
user3022875
  • 8,598
  • 26
  • 103
  • 167
5
votes
4 answers

as.Date with dates in format m/d/y in R

A client sent me an Excel file with dates formatted as e.g 3/15/2012 for March 15. I saved this as a .csv file and then used camm$Date <- as.Date(camm$Date, "%m/%d/%y") but this gave me values starting in the year 2020! I tried to reformat the…
Peter Flom
  • 2,008
  • 4
  • 22
  • 35
4
votes
2 answers

Display exact value of a variable in R

> x <- 1.00042589212565 > x [1] 1.000426 If I wanted to print the exact value of x, how would I do it? Sorry if this is a dumb question. I tried Googling for "R" and "exact" or "round" but all I get are articles about how to round. Thank you in…
angryavian
  • 334
  • 3
  • 9
4
votes
2 answers

Row-wise count of values that fulfill a condition

I want to generate a new variable which the number of times some columns satisfy a criterion (like ==, <, >). The function needs to handle NA. Sample data with some missing values: x <- seq(10, 20) y <- seq(12, 22) y[4] <- NA z <- seq(14,…
SMM
  • 193
  • 1
  • 3
  • 12
1 2 3
16
17