Hi i have an issue with my files not being written to the location i told them t
ID: 3789703 • Letter: H
Question
Hi i have an issue with my files not being written to the location i told them to write becuase they are not there when i looked. I have provided the R code and R output below. I'm simply tryting to my Analyze function to perform the statistics and graphics to multiple files i have. In addition, i outputed the files in pdf to a location on my computer. I need help getting this code put together. I am doing it mostly for recreation. i dont really have any data but if there is sample data that would work too so i can see an output file for the answer.
#Here we are just stating the type and name of the data set, and that
filenames <- list.files(path = "/Users/johndoe/OneDrive/School/R/R Workspace", pattern = "CodaBrundage", full.names=F, recursive=F)
filenames<-filenames[1:5]
#Function for summary statistics
Analyze<-function(YC){
# attach(YC)
names(YC)
str(YC) #to check breakdown of structure of a data frame
summary(YC) #summary stat
pairs(YC) #basic scatterplot matrix
cor(YC) #determines correlations b/w 2 variables
par(mar=rep(2,4))
boxplot(YC) #indicates if variables differ in magnitiude and that they have different variances
library(MVN)
uniNorm(YC, type="SW", desc=TRUE) #gets the shapiro-wilks test of univariate normality along w/ descriptive stats like skewness and kurtosis
par(mar=rep(2,4))
uniPlot(YC, "histogram") #visulization step
result<-mardiaTest(YC, qqplot=T)#to get all plot within the same frame
result
}
lapply(filenames, function(Analyze) {
t <- read.table(Analyze, header=TRUE, sep=",", row.names="number",na.strings="", fill=T)
out<-function(t)
write.table(out, "/Users/johndoe/Desktop", sep="/t",
quote=F, row.names=F, col.names=T)
})
###OUTPUT R###
#I never got any statistics output from R...but i got this with no error
function (t)
write.table(out, "/Users/johndoe/Desktop", sep = "/t", quote = F,
row.names = F, col.names = T)
[[2]]
function (t)
write.table(out, "/Users/jblamkey/Desktop", sep = "/t", quote = F,
row.names = F, col.names = T)
[[3]]
function (t)
write.table(out, "/Users/jblamkey/Desktop", sep = "/t", quote = F,
row.names = F, col.names = T)
[[4]]
function (t)
write.table(out, "/Users/jblamkey/Desktop", sep = "/t", quote = F,
row.names = F, col.names = T)
[[5]]
function (t)
write.table(out, "/Users/jblamkey/Desktop", sep = "/t", quote = F,
row.names = F, col.names = T)
Explanation / Answer
use setwd("filelocation") to set the path to the directory you want to work in.
Whenever you want to output the file create a variable with destination address and use that this practise helps in overcoming minor errors.
example:
path="c:/users/abc";
write.table(MyData, file =paste(path, "MyData.csv", sep = "/"),row.names=FALSE, na="",col.names=FALSE, sep=",") # it will write MyData to MyData.csv file.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.