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)...
How about appending Sys.Date() to the filename? write.table(table, file=paste0("C:/DailyReport/data-", Sys.Date(), ".xlsx")) ...
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) ...
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",...
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...
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: #...
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 ...
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" ,...
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...
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...