I am looking for importing a database into R Studio without having the sentences been compacted in one line, can someone help?
Example:
In a single excel cells I have the following:
She went on holiday
He decided to eat an apple
Whereas in R Studio when I import the database I get:
She went on holiday He decided to eat an apple
The code I am using for importing is:
df <- as.data.frame(read_excel("/mypath.xlsx"))
What I have and would like to keep the format on R:
Related
Currently I am using openxlsx package to read a large excel file (~70Mb and 400,000 columns). I have tried other packages (XLConnect, xlsx, readxl) but they all either give me error or bring my computer to standstill. However, a big problem with openxlsx::read.xlsx is that they do not import all columns in the excel worksheet, as detailed below:
Picture above is the preview of the excel file I need to import. It has 15 columns. However, when I import this file into a R dataframe using openxlsx::read.xlsx, it only import 5 columns, as shown below:
It seems to me that openxlsx in this case only import columns with date and numerical values (Col 8 9 10 11 15) and ignore the rest. Please help me explain the reason for such behavior and is there anyway to remedy the issue (i.e. get openxlsx to import all columns). Thank you very much!
Had a similar issue today, I believe the cause was the way in which the file was created - by SAS. Have you tried opening the file in excel to get it to interpret all the formatting correctly?
My issue was solved by simply opening, saving, and closing the file.
Alternatively if you've since solved this issue another way I would like to hear it.
I can't explain why openxlsx behave like that but the readxl package seems to work in this case.
Our lab gives EDS results as a word file like the one below.
My usual process is to copy the table to an excel sheet like the answer here however I've got more than 50 results and would like to speed things up. There is a macro for getting tables from Word to Excel here. It is faster than copy paste but it doesn't cycle through all files in a folder.
Is there a way to get data off of Word to R?
This article will give you all the idea and code solution
http://www.r-bloggers.com/using-r-to-get-data-out-of-word-docs/
I'm trying to learn R (via this video) and immediately ran into problems. As directed, I created a dataset in Excel with column A being numbers 1 through 10 and column B being random integers. Saved as .xlsx and .csv.
Next I tried to read the data in R with
> data1 <- read.table(file.choose(), header=TRUE, sep="\t")
and that's as far as I got. There's no Workspace like in the video, or an option anywhere to view it. There are many windows in the video, but I only have "R Console".
So, how do I get the workspace?
You may be looking for "R Studio." It's a user-friendly shell that sits on top of R... It shows you your current work space, etc.
http://www.rstudio.com/
Also, you want to use sep="," not sep="\t" if you have a CSV. \t is tab-delimited...
I think you are using the R basic program (not basic in core functionality, just basic in terms of user interface features) that you probably downloaded from http://www.r-project.org/
The video you are watching is running a productive user interface called RStudio. You can download it for free from here: http://www.rstudio.com/ Works the same for all your purposes.
I have a set of SAS data sets and I want to open it using Excel or R. I don't have a SAS software with me so i can't use the export option in it. Is there any converter that converts from SAS7BDAT to excel?
Thanks
I help develop the Colectica for Excel addin, which opens SAS data files in Excel. No SAS software or ODBC configurations are required. The addin directly reads the SAS file and then inserts the data and metadata into your worksheet.
Imports SAS .sas7bdat data and column names
Imports SAS .sas7bcat formats and value labels when avalaible
The Excel addin is downloadable from http://www.colectica.com/software/colecticaforexcel
Documentation is available in the user manual.
You could use SAS add in for Microsoft office to open the SAS dataset in Excel. Not sure if it is free though.
http://support.sas.com/software/products/addin/
As Reese suggested you can use - SAS Universal Viewer , its free!!
Here is the link :-
https://support.sas.com/downloads/browse.htm?fil=&cat=74
Or you can download SAS University Edition, which is also free, it is more than just a viewer, you can write and execute programs in here.
http://www.sas.com/en_us/software/university-edition/download-software.html
Here a quick-and-dirty python five-liner to convert a .xpt file to .csv
import pandas as pd
FILE_PATH = "(directory containing file)"
FILE = "ABC" # filename itself (without suffix)
# Note: might need to substitute the column name of the index (in quotes) for "None" here
df = pd.read_sas(FILE_PATH + FILE + '.XPT', index=None)
df.to_csv(FILE_PATH + FILE + '.csv')
Hopefully this might help someone
I came across the same "need" and after some research here and there, I found a nice and easy way with R and the latest version of RStudio (as per 2020 June date - the FREE one). Using it, you can open various formats of files and RStudio generates for you the R script it ran behind. You can use this as a starting point, in order to have the .sas7bdat file opened, and then do the conversion step.
Steps to follow in order to import the file using the RStudio "visual" way: Evironment tab -> Import Dataset -> From SAS...
It will ask you to import the haven library. After the installation you will have a tab with the preview of the data within the file and also the R script ran behind which will look like this:
library(haven)
aux <- read_sas("//PATH_ON_YOUR_MACHINE_TO_FILE/actual_file.sas7bdat", NULL)
View(aux)
Notice the NULL there, it has the purpose of converting empty strings to NULL.
But wait, we also need to convert it to a .csv file in order to have the final job done. For this you simply add below those lines from above the following:
write.csv(aux, "actual_file.csv")
Which will produce within the same folder with the original SAS file, the desired .CSV one. If you want to have ";" as separator instead on "," use write.csv2(aux, "actual_file.csv"). Anyway Strings are enclosed by " " so it should be fine.
This might be a noob question but I have a problem with exporting and importing a CSV.
I export a CSV with values (i.e. 300425.25). When I open this in Excel it is all comma delimited, as expected. When I hit Data To Columns I everytime changes my values to 300425,25 (I have tried all different combinations of decimal seperator in Advanced). This is excellent to work with in Excel but import this back into R I'm stuck with comma before the decimals, which in turn is unusable with the rest of my R code.
I never had this problem with the export of .CSV until I recently cleaned my computer and had a fresh install. I suspect it might be in R studio settings or Excel.
Can somebody help me out?
Thanks in advance.