Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Improve this question
Say, if we can save and load an exact same data from .R files, then why came the need for .RData. I tried figuring out some explanation from [R] foo.RData or foo.r?. So, I stumbled upon few queries:
Does .RData saves only final result or complete code just a .R scripts?
What is their exact relevance? Which one to prefer over other and when?
RData saves objects, not scripts — if you load it, you load objects inside your environment. It does not contain the code used to produce these elements.
A .R is a script without any object in it — if you open it, you'll see code and you'll need to source it to get the objects produced by the .R.
I would advice to use them this way
.R : store functions, and scripts used to create an object (for the sake of reproducibility, for example in /data-raw in packages)
use .RData to store objects you'll need later
This is basically how a package works : a /R folder with functions, and a /data folder containing the data objects necessary to the package.
In .R file you can save R code, in .RData file you can save data structures from R, eg vector, matrix, data frame or linear model.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
As I'm dealing with a huge dataset I had to split my data into different buckets. Thus, I want to save some interim results in a csv to recall it later. However, my datafile contains some columns with lists, which according to R can not be exported (see snapshot). Do you guys know a simple way for a R newbie to make this work?
Thank you so much!
I guess the best way to solve your problem is switching to a more apropriate file format. I recomend using write_rds() from the readr package, which creates .rds files. The files you create with readr::write_rds('your_file_path') can be read in with readr::read_rds('your_file_path').
The base R functions are saveRDS() and readRDS() and the functions mentioned earlier form the readr are just wrappers with some convience features.
Just right click, then choose new csv to the folder where you want to save your work. Then set the separator of the csv to a comma.
Input all data in column form. You can later make it a matrix in your R program.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am trying to extract the data in the tables that start on p.52 of this document (a report from FAA).
The problem is that the tables are included as pictures. Any chance I can get some pointers on how to do that without doing it manually?
I have tried converting it to text using Adobe's OCR function, and I have also tried using the extract_tables function in R's tabulized package.
I could of course do this manually, but it would be good to know if there is a more efficient way of doing it.
It's possible, however its accuracy depends on the image. I always use grayscale images. Here an example of available tools. In your case, I'd suggest you take some screenshots of the tables and use the OCRFeeder to compare the results from GOCR and Tesseract.
sudo apt-get install gocr tesseract-ocr ocrfeeder
ocrfeeder -i image.jpg
After some manual checks, you can import this file in LibreOffice Calc, save it as 'csv', and import in R.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm struggling to find the answer to this very basic question and to make the here() function work (from the here package). I'd be glad if someone could help me with that.
What's a file .here mentionned in this github? And how can I create one ?
I've tried adding a text file called '.here.txt' in my workflow (where I want the here() function to "start") but it doesn't work.
You don't need a here file. That's one of the possibilities though. But if you want to use that route then make a file called .here
Not .here.txt or here.txt or any other variant you can think of. Literally just .here
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
i have imported this file into R only problem is there is 380 observations and it only reads first 100 observations. How can i get the rest of it, here it is
BPL16_17 <- read.csv("BPL16:17.csv")
BPL16_17
Thanks
Personally I always recommend using readr::read_csv over read.csv.
While I am unsure why read.csv is limited to 100 columns (This has not been true for many years now, my mistake) read_csv is not and handles data_frames much better especially dates, times and doesn't include factors by default.
https://github.com/tidyverse/readr
Also a great resource is this chapter from the R for data science book which is available online always for free.
http://r4ds.had.co.nz/data-import.html
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Suppose I have VBA macro in Excel which does some calculation. And I would like to do a part of this calculation in R, but in program mode. Say, at some moment Excel macro has a vector and it needs to find its mean by mean function in R. How can I call R from VBA, transmit a vector to R, initiate the calculation in R and get back the result in VBA? Thanks.
There is a plugin RExcel, but I found quite horrible to use it (and you kinda have to pay for it).
The easiest and most general but hacky way to perform your interaction is the following:
1) Save your array/matrix/vector in csv in a folder
2) write your R code in a file that read the csv and write the result in csv
3) Call the R script from VBA with the VBA Shell function (Rscript scriptName.R)
4) Import the result back to excel/VBA.
This method has the advantage that you are separating the computational logic with the formatting from VBA.
You could also call the R code directly within VBA with -e option from R but this is strongly unadvised.
Hope it helps!
BTW: it works with all the other program (Python/LaTeX/Matlab).