Why can I not load data from beginning.zip file - r

I am trying to load my R file but it keeps reading as errors and
Error in source("C:/Users/masters/OneDrive/Desktop/GCU/Business Analyst/Business Analyst/MIS-650/Beginning.csv") :
C:/Users/masters/OneDrive/Desktop/GCU/Business Analyst/Business Analyst/MIS-650/Beginning.csv:1:3: unexpected input
1: PK
loading through the Rstudio file open file method.
I am using the [Default] [64-bit] C:\Program Files\R\R-3.6.2 version, please help.

Try using read.csv
Something like this:
df <- read.csv('C:/Users/masters/OneDrive/Desktop/GCU/Business Analyst/Business Analyst/MIS-650/Beginning.csv')

Related

Reading .xls-file in R

I am trying to read a .xls-file into a R dataframe. I've tried:
library(readxl)
dfTest <- readxl::read_excel("file_path/file.xls")
Which gives me:
Error:
filepath: file_path/file.xls
libxls error: Unable to open file
Next I tried:
library(xlsx)
dfTest <- xlsx::read.xlsx("file_path/file.xls",1)
Which results in:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.io.IOException: block[ 1462 ] already removed - does your POIFS have circular or duplicate block references?
I tried:
library(openxlsx)
dfTest <- openxlsx::read.xlsx("file_path/file.xls")
Which results in:
Error in read.xlsx.default("file_path/file.xls") :
openxlsx can not read .xls or .xlm files!
Last thing that I tried was:
library(RODBC)
conn <- odbcConnectExcel("file_path/file.xls")
Which gives me:
Error in odbcConnectExcel("file_path/file.xls") :
odbcConnectExcel is only usable with 32-bit Windows
Would anyone have an idea how I can read the Excel file? Saving the file as .csv-file and loading it into R works perfectly fine. However, I have a large amount of files that I ultimately want to read and process in a loop. Saving all by hand as .csv is teadious to say the least.
I'm restricted in changing the software installations on the computer I'm working on.
I believe for .xls files read_delim from the readr package should work.
For example:
readr::read_delim("file_path/file.xls",as.is=TRUE)

error loading csv file for R

when i loading csv file for R, i can see the error
but i don't know why this happening
i wrote following code:
setwd("C:\\Users\\규남\\Desktop\\twitter")
library(KoNLP)
useSejongDic()
txt <- readLines(file("test.csv"))
and, this error appear
txt <- readLines(file("test.csv"))
Error in readLines(file("test.csv")) : cannot open the connection
In addition: Warning message:
In readLines(file("test.csv")) :
cannot open file 'test.csv': No such file or directory
why this happening?
file directory is not wrong, and that file in the folder
[enter image description here][1]
please see this
i restart Rstudio, even notebook power
but error appear again
how to i load that csv file?
and why this happening?
here is result useing getwd() function
[1] "C:/Users/규남/Desktop/twitter"
Warning message:
closing unused connection 3 (test.csv)
[1]: http://i.stack.imgur.com/xkFkt.png
When working through these problems I like to use the file.path() function. Look at the documentation, but it makes certain that the separator characters that are used in the string are what R is expecting.
Try:
path <- file.path("C:", "Users", "규남", "Desktop", "twitter")
setwd(path)
library(KoNLP)
useSejongDic()
txt <- readLines(file("test.csv"))

Unable to read an SBML file in SBMLR

I'm trying to read a SBML file (Test.xml) using the R package SBMLR. Below is the code I executed.
library(SBMLR)
file <- system.file("models","Test.xml",package = "SBMLR")
doc <- readSBML(file)
When I execute the 3rd line I get an error message saying:
Error in xmlEventParse(filename, handlers = sbmlHandler(),
ignoreBlanks = TRUE) : File does not exist
I have tried to read the file using rsbml library as well.. But still I'm getting an error saying
Error: File unreadable.
I'm following this guide at the moment. Any help regarding the issue is highly appreciated!

Cannot read data from an xlsx file in RStudio

I have installed the required packages - gdata and ggplot2 and I have installed perl.
library(gdata)
library(ggplot2)
# Read the data from the excel spreadsheet
df = data.frame(read.xls ("AssignmentData.xlsx", sheet = "Data", header = TRUE, perl = "C:\\Strawberry\\perl\\bin\\perl.exe"))
However when I run this I get the following error:
Error in xls2sep(xls, sheet, verbose = verbose, ..., method = method, :
Intermediate file 'C:\Users\CLAIRE~1\AppData\Local\Temp\RtmpE3UYWA\file8983d8e1efc.csv' missing!
In addition: Warning message:
running command '"C:\STRAWB~1\perl\bin\perl.exe" "C:/Users/Claire1992/Documents/R/win-library/3.1/gdata/perl/xls2csv.pl" "AssignmentData.xlsx" "C:\Users\CLAIRE~1\AppData\Local\Temp\RtmpE3UYWA\file8983d8e1efc.csv" "Data"' had status 2
Error in file.exists(tfn) : invalid 'file' argument
Thanks to #Stibu I realised I had to set my work directory. This is the command you use to run in Rstudio; setwd("C/Documents..."). The file path is where the excel file is located.
I had the issue but I solved it differently.
My problem was because my file was saved as Excel (extension .xls) but it was a txt file.
I corrected the file and I did not meet any other error with the R function.

Open file created by R in an external program

I want R to open a file that is created in my program. My code saves a log file to a variable called logFile using the following code.
logFile <- sprintf("../output/%s_%s_output%sof%s.log", str1, str2, str3, str4);
I tried to access the shell function by calling
shell('%s',logFile);
but I got an error that said
In shell("%s", toFile) : '%s' execution failed with error code 127
How can I get my program to open this file after it is finished writing to it?
How about?
browseURL('view.xlsx')
Are you looking for something like this? It works nicely, at least on my Windows box.
## An example temp file
ff <- paste0(tempfile(), ".txt")
write.table(head(mtcars), file=ff)
## Open the file with the program associated with its file extension
system2("open", ff)
For an solution that naturally extends your attempts, you could use shell.exec.
Documentation
Opens the specified file using the application specified in the Windows file associations.
ff <- paste0(tempfile(), ".txt")
write.table(head(mtcars), file=ff)
shell.exec(ff)
Created on 2020-03-11 by the reprex package (v0.3.0.9001)

Resources