Menu
  • HOME
  • TAGS

Generating vectors that will result in a HTML file with R results

html,r,write.table

One inefficient way to do this: #get the stock log return based on the close value from each day LogReturnCsan <- data.frame(LogReturnCsan=diff(log(Csan$Close))) DescriptiveStat <- summary(LogReturnCsan) #Makes a histogram with the log returbs Histogram <- hist(LogReturnCsan[,1], breaks=30, col="burlywood3", main="LN Return Csan3 ") #If you want the Hist as table Histogram$counts=c(NA,Histogram$counts) Histogram$density=c(NA,Histogram$density)...

Outputting files in R without overwriting

r,write.table

How about appending Sys.Date() to the filename? write.table(table, file=paste0("C:/DailyReport/data-", Sys.Date(), ".xlsx")) ...

passing in a variable to be used with write.table

r,csv,xts,quantmod,write.table

Found a workaround! We need to turn the auto assign off in the quantmod function. symbols<-getSymbols(px_ticker,from='1990-01-01', auto.assign=F) ...

R use regex to select all fields in data.frame

regex,r,quotes,write.table

You can try paste df1[] <- lapply(df1, function(x) paste0('乃', x, '乃')) df1 # field1 field2 field3 #1 乃valueA乃 乃valueB乃 乃valueC乃 #2 乃valueD乃 乃valueE乃 乃valueF乃 #3 乃valueG乃 乃value"H乃 乃valueI乃 data df1 <- structure(list(field1 = c("valueA", "valueD", "valueG"), field2 = c("valueB", "valueE", "value\"H"), field3 = c("valueC", "valueF", "valueI" )), .Names = c("field1",...

How to prevent write.csv from changing POSIXct, dates and times class back to character/factors?

r,date,time,posixct,write.table

According to ?write.table: Any columns in a data frame which are lists or have a class (e.g. dates) will be converted by the appropriate 'as.character' method: such columns are unquoted by default. Simply put, you can only write text/characters to text files. Use save if you want to preserve the...

R: Trying to format a data.frame created from a JSON object so that I can use write.table

json,r,write.table

You might want to try and adapt this approach: f <- function(x) if(is.list(x)) { unlist(lapply(x, f)) } else { x[which(is.null(x))] <- NA paste(x, collapse = ",") } df <- as.data.frame(do.call(cbind, lapply(friListings, f))) write.table(df, tf <- tempfile(fileext = "csv")) df <- read.table(tf) str(df) # 'data.frame': 4 obs. of 21 variables: #...

Replace all values in a row with 0 if one of the variables has missing data

r,write.table

complete.cases seems appropriate here: dat[!complete.cases(dat),] <- 0 dat # x y z #1 2 3 5 #2 0 0 0 #3 3 2 1 ...

How to make multiple file .txt from spesific column in data frame

r,write.table

I suggest you try the following also instead of using for loops that may confuse you # Create a data frame DOCS <- c(1:5) TEXT <- c("tanaman jagung seumur jagung " , "tanaman jagung kacang ketimun rusak dimakan kelinci" , "ladang diserbu kelinci tanaman jagung kacang ketimun rusak dimakan" ,...

Is there an efficient way to append to an existing csv file without duplicates in R?

r,csv,data.frame,append,write.table

You could read the data.frame from file, rbind it with the new data.frame and check for duplicate values. For writing efficiency, append only the non-duplicate rows. If you came up with this question because you are working with big data sets and read/write time is of concern, take a look...

Keep rows separate with write.table R

r,write.table

Turns out this was a UNIX - Windows encoding issue. So something of a red herring, but perhaps worth recording in case anyone else has this at first perplexing issue. It turns out that Windows notepad sometimes struggles to render files generated in UNIX properly, a quick test to see...