I would like to plot heatmap(s) below quantmod::chart_Series(). How to add the below heatmap to chart_Series (or xts::plot.xts): library(quantmod) # Get data fro symbol from Google Finance symbol <- "SPY" src <- "google" from <- "2017-01-01" symbolData <- getSymbols(symbol, src=src, from=from, auto.assign=FALSE) # Calculate simple returns symbolData.ret <- ROC(Cl(symbolData), t
我想绘制下面的热图(s)quantmod :: chart_Series()。 如何将以下热图添加到chart_Series(或xts :: plot.xts): library(quantmod) # Get data fro symbol from Google Finance symbol <- "SPY" src <- "google" from <- "2017-01-01" symbolData <- getSymbols(symbol, src=src, from=from, auto.assign=FALSE) # Calculate simple returns symbolData.ret <- ROC(Cl(symbolData), type="discrete") #
I am trying to reinstall a package that I was previously able to install and use. I was building a package of my own after my computer unexpectedly restarted and then I started to have problems loading the rpgraph package. So I decided to uninstall it and to reinstall it. When I did so I got the following error: library(devtools) library(rJava) install_github("Albluca/rpgraph") Downloading
我正尝试重新安装我以前能够安装和使用的软件包。 在我的电脑意外重新启动后,我正在构建我自己的软件包,然后我开始在加载rpgraph软件包时遇到问题。 所以我决定卸载它并重新安装它。 当我这样做时,我得到了以下错误: library(devtools) library(rJava) install_github("Albluca/rpgraph") Downloading GitHub repo Albluca/rpgraph@master from URL https://api.github.com/repos/Albluca/rpgraph/zipball/master Inst
lm sets model = TRUE by default, meaning the entire dataset used for learning is copied and returned with the fitted object. This is used by predict but creates memory overhead (example below). I am wondering, is the copied dataset used for any reason other than predict ? Not essential to answer, but I'd also like to know of models that store data for reasons other than predict . Examp
默认情况下, lm设置model = TRUE ,这意味着用于学习的整个数据集将被复制并返回给拟合对象。 这被predict使用,但会产生内存开销(下面的例子)。 我想知道,复制的数据集是用于除predict之外的任何其他原因吗? 不是必须回答的,但我也想知道存储数据的模型,而不是predict 。 例 object.size(lm(mpg ~ ., mtcars)) #> 45768 bytes object.size(lm(mpg ~ ., mtcars, model = FALSE)) #> 28152 bytes 更大的数
I have been trying to import the following semi-colon separated file: # word len;freq;mean;sens;npos;u;orthon;freqn;bgp WN000000 fiber "5;8.671;1;5;1;0;5;6.1;0;-1" 10000000 clad "4;6.78;2;2;1;1;8;7.84;2026;-1" 10000000 tucker "6;8.103;2;3;2;0.91829583405449;7;5.5;4547;-1" 10000000 I tried both read.csv and data.table::fread , but with no luck. read.csv recognizes some of headers an
我一直在试图导入下面的分号分隔文件: # word len;freq;mean;sens;npos;u;orthon;freqn;bgp WN000000 fiber "5;8.671;1;5;1;0;5;6.1;0;-1" 10000000 clad "4;6.78;2;2;1;1;8;7.84;2026;-1" 10000000 tucker "6;8.103;2;3;2;0.91829583405449;7;5.5;4547;-1" 10000000 我尝试了read.csv和data.table::fread ,但没有运气。 read.csv识别一些头文件,实际值全部位于第一列: X..word.len freq mean sens npos u
This question already has an answer here: R: Remove multiple empty columns of character variables 6 answers We can use Filter Filter(function(x) !(all(x=="")), df) # Var1 Var3 #1 2R+ 52 #2 2R+ 169 #3 2R+ 83 #4 2R+ 98 #5 2R+ NA #6 2R+ 111 #7 2R+ 94 #8 2R+ 116 #9 2R+ 86 NOTE: It should also work if all the elements are NA for a particular column df$Var3 <- NA Fil
这个问题在这里已经有了答案: R:删除字符变量的多个空列6个答案 我们可以使用Filter Filter(function(x) !(all(x=="")), df) # Var1 Var3 #1 2R+ 52 #2 2R+ 169 #3 2R+ 83 #4 2R+ 98 #5 2R+ NA #6 2R+ 111 #7 2R+ 94 #8 2R+ 116 #9 2R+ 86 注意:如果某个特定列的所有元素都是NA,它也应该可以工作 df$Var3 <- NA Filter(function(x) !(all(x=="")), df) # Var1 #1 2R+ #2 2R+ #3 2R+
I am using the ukcars data set in the expsmooth package. I am trying to execute the following code: decomp <- stl(ukcars, s.window="periodic") lastyear <- rep(decomp$time.series[110:113,"seasonal"],2) fc <- fit$mean + lastyear plot(ukcars,xlim=c(1980,2007)) but I get the error lastyear <- rep(decomp$time.series[110:113,"seasonal"],2) Error in `[.default`(decomp$time.series, 110:11
我正在使用expsmooth包中的ukcars数据集。 我试图执行下面的代码: decomp <- stl(ukcars, s.window="periodic") lastyear <- rep(decomp$time.series[110:113,"seasonal"],2) fc <- fit$mean + lastyear plot(ukcars,xlim=c(1980,2007)) 但我得到的错误 lastyear <- rep(decomp$time.series[110:113,"seasonal"],2) Error in `[.default`(decomp$time.series, 110:113, "seasonal") : subscript out of bounds
I have the following comma-separated data in one of my data.frame's columns called services . > dput(structure(df$services[1:5])) list("Global Expense Management, Company Privacy Policy", "Removal Services, Global Expense Management", "Removal Services, Exception & Cost Admin, Global Cost Estimate, Company Privacy Policy", "Removal Services, Exception & Cost Admi
我在我的data.frame的一个名为services的列中有以下逗号分隔的数据。 > dput(structure(df$services[1:5])) list("Global Expense Management, Company Privacy Policy", "Removal Services, Global Expense Management", "Removal Services, Exception & Cost Admin, Global Cost Estimate, Company Privacy Policy", "Removal Services, Exception & Cost Admin, Ancillary Services, Global Cos
I've written a script that works on a set gene-expression data. I'll try to separate my post in the short question and the rather lengthy explanation (sorry about that long text block). I hope the short question makes sense in itself. The long explanation is simply to clarify if I don't get the point along in the short question. I tried to aquire basic R skills and something that
我写了一个脚本,用于设置基因表达数据。 我会尽量在简短的问题和相当冗长的解释中分开我的文章(对于那个长文本块,抱歉)。 我希望这个简短的问题本身是有意义的。 长时间的解释只是为了澄清我在短题中是否得到了重点。 我试图获得基本的R技能,并且困扰我的事情发生了,我没有通过谷歌找到任何启发。 我真的不明白这一点。 我希望通过澄清在这里发生的事情,我可以更好地理解R.这说我不是程序员,所以请耐心等待我的
I am trying to group row names in a R data frame for typesetting with the Hmisc latex() function. Problem is that latex() adds two tilde characters before each row name, and these show up in my document. How can I either remove these characters or have them not show up? Example: test.df <- data.frame(row.names=letters[1:4], col1=1:4, col2=4:1, col3=4:7) latex(test.df, file="", n.rgroup
我正在尝试在R数据框中对Hmisc latex()函数进行排版来对行名进行分组。 问题是latex()在每个行名称前面添加了两个代字符,并且这些字符显示在我的文档中。 我该如何删除这些角色或让他们不出现? 例: test.df <- data.frame(row.names=letters[1:4], col1=1:4, col2=4:1, col3=4:7) latex(test.df, file="", n.rgroup=c(2,2), rgroup=c("First","Second")) 编辑:乳胶功能发生在针织大块内。 生成的.Rnw文件是通过
I am having trouble using the XGBoost in R. I am reading a CSV file with my data: get_data = function() { #Loading Data path = "dados_eye.csv" data = read.csv(path) #Dividing into two groups train_porcentage = 0.05 train_lines = nrow(data)*train_porcentage train = data[1:train_lines,] test = data[train_lines:nrow(data),] rownames(train) = c(1:nrow(train)) rownames(test) = c(1:nrow(test)) retur
我在使用R中的XGBoost时遇到了问题。我正在用我的数据读取一个CSV文件: get_data = function() { #Loading Data path = "dados_eye.csv" data = read.csv(path) #Dividing into two groups train_porcentage = 0.05 train_lines = nrow(data)*train_porcentage train = data[1:train_lines,] test = data[train_lines:nrow(data),] rownames(train) = c(1:nrow(train)) rownames(test) = c(1:nrow(test)) return (list("test"