write.table

write.table() results in permission denied - common solutions don't work [duplicate]

别说谁变了你拦得住时间么 提交于 2021-01-28 18:51:07
问题 This question already has answers here : Permission denied when exporting to CSV in R (2 answers) Closed 2 years ago . Can't seem to get permission to write files in R. Using Windows 10. Only one user account in my computer, have tried running RStudio and Rgui as administrator. getwd() confirms 'C:/Users/name/R' is my working directory. I've gone to properties of the folder and SYSTEM and user have all permissions to write. Have tried changing the directory to no avail. Using write.table

Avoid quotation marks in column and row names when using write.table [duplicate]

只愿长相守 提交于 2020-04-09 18:59:08
问题 This question already has an answer here : Delete “” from csv values and change column names when writing to a CSV (1 answer) Closed 2 years ago . I have the following data in a file called "data.txt": pid 1 2 4 15 18 20 1_at 100 200 89 189 299 788 2_at 8 78 33 89 90 99 3_xt 300 45 53 234 89 34 4_dx 49 34 88 8 9 15 The data is separated by tabs. Now I wanted to extract some columns on that table, based on the information of csv file called "vector.csv", this vector got the following data: 18

R save multiple files with different names

吃可爱长大的小学妹 提交于 2020-01-23 17:05:06
问题 I have a variable named "data" which contains 10 lists, I want to save each list in different files (with different names). I know how to save an individual file but not how to write code for doing it through a loop. My biggest problem is with the name of the files. I would like a folder with files with these names: percentage0.01.bed, percentage0.02.bed...) I'm trying something like this: percentages<-seq(0.01,0.1,0.01) >percentages [1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10

Crashing R when calling `write.table` on particular data set

穿精又带淫゛_ 提交于 2020-01-01 07:36:09
问题 The following consistently crashes my R session. Tested on two machines, Ubuntu and Mac OS X with similar results on both. Brief Description: Calling write.table on a data.frame with factor column of all NA's. The original data set is rather large, and I've managed to isolate the offending column and then create a similar vector, named PROBLEM_DATA below, which causes the same crash. Interestingly, sometimes R crashes outright, othertimes it simply throws the following error: Error in write

Write a dataframe to csv file with value of NA as blank

与世无争的帅哥 提交于 2020-01-01 03:58:16
问题 There is a dataframe named cnbd , for example: cnbd = data.frame(1,2,3,NA,NA,5) Thus the expression: dim(cnbd)[1] give 1. I want to write a dataframe like cnbd to a csv with: write(file = filename, cnbd, append = TRUE) The problem comes: The values of csv file show cnbd with 6 rows not 1 row as 1,2,3,NA,NA,5 . I need output cnbd show as 1,2,3,,,5 in csv file, no NAs. 回答1: Try this: write.table(df, "cnbd.csv", na = "", row.names = FALSE, col.names = FALSE, append = TRUE, sep = ",") 回答2: You

write.table inside a function applied to a list of data frames overwrite outputs

心不动则不痛 提交于 2019-12-29 09:38:10
问题 I almost finish a messy code to apply several statistical methods/test to 11 data frames from different watersheds with physico-chemical parameters as variables. I reach the goal, but I need to do this functional. So to start i made a function to compute correlation, and save the results as .txt tables and .pdf images. It works great when run the function to one dataframe at the time (for that you should import each dataframe separately using read.table , which is not written in the code

write function help in R

孤人 提交于 2019-12-25 02:32:38
问题 > MLest<- arima(X, order = c(1,0,0), method = c("ML")) > MLest Call: arima(x = X, order = c(1, 0, 0), method = c("ML")) >Coefficients: ar1 intercept 0.2657 -0.0824 0.0680 0.1018 sigma^2 estimated as 1.121: log likelihood = -295.23, aic = 596.47 I would like to write the 0.2657 and 1.121 results to an output file. I have defined a path and file name and here is my codes. When I use, write(MLest, file=filename, append=TRUE, sep="\t") I got the following error: Error in cat(list(...), file, sep,

Controlling number of decimal places in write.table while maintaining class “numeric”

若如初见. 提交于 2019-12-22 11:38:06
问题 Generally speaking, controlling the number of digits to display when calling write.table is straightforward. Given the excellent question and answer seen here, we see that format is the means to accomplish this feat. However, this creates a file that when viewed by a text editor, shows quotes around numeric values. This can be turned off by setting quote = FALSE in write.table . Unfortunately, this has the side effect of not putting quotations around character columns. Observe: Normal Case

how to save the output of a foreach loop in R

妖精的绣舞 提交于 2019-12-13 15:19:30
问题 I have a trouble with saving my data output after foreach loop here is the function to read my data and process it readFiles <- function(x){ data <- read.table("filelist", skip=grep('# Begin: Data Text', readLines(filelist)), na.strings=c("NA", "-", "?"), colClasses="numeric") my <- as.matrix(data[1:57600,2]); mesh <- array(my, dim = c(120,60,8)); Ms <- 1350*10^3 # A/m asd2 <- (mesh[70:75,24:36 ,2])/Ms; # in A/m ort_my <- mean(asd2); return(ort_my) } here is the codes for doing parallel

Write to files in R using a loop

旧巷老猫 提交于 2019-12-13 07:04:01
问题 I have several variables as follow: cats <- "some long text with info" dogs <- "some long text with info" fish <- "some long text with info" .... and I manually write the content of these variables into a text file: write.table(cats, "info/cats.txt", sep="\t") write.table(dogs, "info/dogs.txt", sep="\t") .... I read the answer to this question and tried to write a loop to automatically write the files. So I created a list: lst <<- list(cats, dogs,fish, ....) and then iterated through the list