Read dataset.train and dataset.test in r - r

I am doing a project about high dimension data set, the data set is from http://archive.ics.uci.edu/, it can also be found in github (https://github.com/minghust/MaliciousExeDetect/tree/master/TrainData)
The file is called "dataset.train","tst.test". I want to read them in R.
My question is whether there are file format, called .train, and .test file. They are not csv, or txt file. How i can open it and import it in R?

Related

Writing a csv file that is too large R

I currently saved some data as a csv file on my computer. It has 581 rows, but when I try to open the saved file on my mac, the dataframe has been altered and the numbers app from which I am looking at my csv from says some data was deleted. Is there a way to fix this? Or is there a different type of file I can save my data as that would adjust for the number of rows?
This is how I am writing the csv. I'm trying to manually add my file to a github repo after it has been saved to my computer.
write.csv(coords, 'Top_50_Distances.csv', row.names = FALSE)

Loading an existing .RData file into an R program

I have a .RData file. I want to do some operations on the dataframe that this file contains. Can I load this file on my R program and convert it into a dataframe? The only option I know currently is to convert the ..RData file to a csv and convert that csv into a data frame again. I am looking for a neater solution. I got this file from a friend of mine and I cannot produce the dataframe from scratch.

How to import .C3D files into R?

Has anyone ever imported Motion Capture data from a .C3D file containing marker positions, forces, emg, etc. directly into R?
The only way I have found so far is to open the .C3D files first using c3dserver in MatLab, saving the data I want as a .csv file and opening that file in R.
Thanks

How to export a dataset to SPSS?

I want to export a dataset in the MASS package to SPSS for further investigation. I'm looking for the EuStockMarkets data set in the package.
As described in http://www.statmethods.net/input/exportingdata.html, I did:
library(foreign)
write.foreign(EuStockMarkets, "c:/mydata.txt", "c:/mydata.sps", package="SPSS")
I got a text file but the sps file is not a valid SPSS file. I'm really looking for a way to export the dataset to something that a SPSS can open.
As Thomas has mentioned in the comments, write.foreign doesn't generate native SPSS datafiles (.sav). What it does generate is the data in a comma delimited format (the .txt file) and a basic syntax file for reading that data into SPSS (the .sps file). The EuStockMarkets data object class is multivariate time series (mts) so when it's exported the metadata is lost and the resulting .sps file, lacking variable names, throws an error when you try to run it in SPSS. To get around this you can export it as a data frame instead:
write.foreign(as.data.frame(EuStockMarkets), "c:/mydata.txt", "c:/mydata.sps", package="SPSS")
Now you just need to open mydata.sps as a syntax file (NOT as a datafile) in SPSS and run it to read in the datafile.
Rather than exporting it, use the STATS GET R extension command. It will take a specified data frame from an R workspace/dataset and convert it into a Statistics dataset. You need the R Essentials for Statistics and the extension command, which are available via the SPSS Community site (www.ibm.com/developerworks/spssdevcentral)
I'm not trying to answer a question that has been answered. I just think there is something else to complement for other users looking for this.
On your SPSS window, you just need to find the first line of code and edit it. It should be something like this:
"file-name.txt"
You need to find the folder path where you're keeping your file:
"C:\Users\DELL\Google Drive\Folder-With-Your-File"
Then you just need to add this path to your file's name:
"C:\Users\DELL\Google Drive\Folder-With-Your-File\file-name.txt"
Otherwise SPSS will not recognize the .txt file.
Sorry if I'm repeating some information here, I just wanted to make it easier to understand.
I suppose that EuStockMarkets is a (labelled) data frame.
This should work and even keep the variable and value labels:
require(sjlabelled)
write_spss(EuStockMarkets, "mydata.sav")
Or you try rio:
rio::export(EuStockMarkets, "mydata.sav")

R, intercept a csv file to download from a link

i have a link that when open automatically starts a download to a csv file, i need to intercept this csv in R and download it without let the possibility to user to choose where to download the file.
csv is generated on demand and i need to get it
#ntrax, 'download.file' from the 'utils' package will do the trick.
i.e.
download.file(url,destfile)
for the many options that are available check ?download.file.
You can just use read.table to import the csv file as a data frame, for example:
fpe <- read.table("http://data.princeton.edu/wws509/datasets/effort.dat")
Is this what you mean?

Resources