Handling huge simulations in R

I have written R program that generates a random vector of length 1 million. I need to simulate it 1 million times. Out of the 1 million simulations, I will be using 50K observed vectors (chosen in some random manner) as samples. So, 50K cross 1M is the sample size. Is there way to deal it in R? There are few problems and some not so good solutions. First R cannot store such huge matrix i

在R中处理巨大的模拟

我写了一个R程序,可以生成一个长度为100万的随机向量。 我需要模拟它100万次。 在100万次模拟中,我将使用50K个观察向量(以某种随机方式选择)作为样本。 所以,50K cross 1M是样本大小。 有办法在R中处理它? 有几个问题和一些不太好的解决方案。 First R不能在我的机器中存储如此巨大的矩阵。 它超过RAM内存。 我查看了像bigmemory,ffbase等使用硬盘空间的软件包。 但是如此巨大的数据可能会在TB中占据大小。

Big matrix and memory problems

I am working on a huge dataset and I would like to derive the distribution of a test statistic. Hence I need to do calculations with huge matrices (200000x200000) and as you might predict I have memory issues. More precisely I get the following: Error: cannot allocate vector of size ... Gb. I work on the 64-bit version of R and my RAM is 8Gb. I tried to use the package bigmemory but with not

大矩阵和内存问题

我正在研究一个巨大的数据集,我想推导一个测试统计量的分布。 因此,我需要用巨大的矩阵(200000x200000)进行计算,并且您可能会预测存在内存问题。 更确切地说,我得到以下内容:错误:无法分配大小的向量... Gb。 我在R的64位版本上工作,我的RAM是8Gb。 我试图使用包bigmemory,但没有取得大的成功。 第一个问题出现在我必须计算距离矩阵时。 我在名为Dist的map包中找到了这个很好的函数,它计算并行的数据帧列的距

R distance matrix and clustering for mixed and large dataset?

My intention involves clustering retail data for customer segmentation in r. I need the full dataset for clustering, but will split into training/testing when evaluating the model. The dataset has 133,153 observations of 36 variables with numerical, categorical, and missing values (14.1 MB). How can I cluster in r with a mixed and large dataset? My Machine: sessionInfo() R version 3.1.0

R距离矩阵和聚类的混合和大型数据集?

我的意图涉及将客户细分的零售数据集中在r。 我需要完整的数据集进行聚类,但是在评估模型时会分解为训练/测试。 该数据集有133,153个观测数据,包括数值,分类和缺失值(14.1 MB)。 我如何用r混合大型数据集? 我的机器: sessionInfo()R版本3.1.0(2014-04-10)平台:x86_64-apple-darwin13.1.0(64位) Mac OSX版本10.9.3 4GB RAM 下面是一个线程,建议在使用聚类算法(如k-means:实现Gower距离函数)之前,

Big Data convert to "transactions" from arules package

The arules package in R uses the class 'transactions'. So in order to use the function apriori() I need to convert my existing data. I've got a Matrix with 2 columns and roughly 1.6mm rows and tried to convert the data like this: transaction_data <- as(split(original_data[,"id"], original_data[,"type"]), "transactions") where original_data is my data matrix. Because of the amo

大数据从arules包转换为“交易”

R中的arules包使用类“交易”。 所以为了使用函数apriori()我需要转换我现有的数据。 我有一个有2列和大约1.6毫米行的矩阵,并试图转换数据,如下所示: transaction_data <- as(split(original_data[,"id"], original_data[,"type"]), "transactions") 其中original_data是我的数据矩阵。 由于我使用的是具有64GB RAM的最大AWS亚马逊机器的数据量。 过了一段时间,我得到了 结果向量超出'AnswerType'中的向量

Adding title to plotly legend in R

I'd like to add a legend-title to my plotly graph (made in R). This doesn't seem possible in any straightforward fashion. If nothing else works, I might add an annotation to the graph right above where the legend entries are shown. That said, I'm not sure where to anchor said notation. I'm not sure how to proceed. Thanks. 您可以通过为两者指定相同的y坐标并使用yanchor将每个

在R中为剧情图例添加标题

我想为我的情节图(在R中制作)添加一个传奇标题。 这似乎不可能以任何简单的方式进行。 如果没有其他的工作,我可能会添加一个注释到正上方显示图例条目的图形。 这就是说,我不知道该标注的位置。 我不知道如何继续。 谢谢。 您可以通过为两者指定相同的y坐标并使用yanchor将每个元素放置在正确的一侧来将图例标题固定在图例上: plot_ly( ... ) %>% add_annotations( text="MyTitle", xref="paper", yref="paper"

Saving plots within lapply

I have a list of dataframes: str(subsets.d) List of 22 $ 1 :'data.frame': 358 obs. of 118 variables: ..$ Ac_2017_1 : num [1:358] 0 0 0 0 0 0 0 0 0 0 ... ..$ Ac_9808_1 : num [1:358] 0 0 0 0 0 ... ..$ dates : Ord.factor w/ 6 levels "April"<"May"<..: 1 1 1 1 1 1 1 $ 19 :'data.frame': 358 obs. of 2 variables: ..$ Ac_8598_19: num [1:358] 0.000257 0.000288 0.00017

在lapply中保存地块

我有一个数据框列表: str(subsets.d) List of 22 $ 1 :'data.frame': 358 obs. of 118 variables: ..$ Ac_2017_1 : num [1:358] 0 0 0 0 0 0 0 0 0 0 ... ..$ Ac_9808_1 : num [1:358] 0 0 0 0 0 ... ..$ dates : Ord.factor w/ 6 levels "April"<"May"<..: 1 1 1 1 1 1 1 $ 19 :'data.frame': 358 obs. of 2 variables: ..$ Ac_8598_19: num [1:358] 0.000257 0.000288 0.000171 0 0.00

Colour difference in plot between normal variable and factor variable

I am using plot function on mtcars dataset. I am trying to add colour to the plots based on mtcars$cyl variable The distinct values in cyl variable is 4,6 and 8 First i tried this: plot(x=mtcars$wt, y=mtcars$mpg, col = mtcars$cyl) I got points plotted on blue,purple and grey colour. Then I converted cyl variable into a factor and tried the same plot again, mtcars$fcyl <- as.factor(m

正常变量和因子变量之间的图中的颜色差异

我在mtcars数据集上使用plot函数。 我正在尝试为基于mtcars$cyl变量的图添加颜色 cyl变量中的不同值是4,6和8 首先我试过这个: plot(x=mtcars$wt, y=mtcars$mpg, col = mtcars$cyl) 我用蓝色,紫色和灰色绘制了点。 然后我将cyl变量转换为一个因子并再次尝试相同的绘图, mtcars$fcyl <- as.factor(mtcars$cyl) plot(x=mtcars$wt, y=mtcars$mpg, col = mtcars$fcyl) 但是这次我得到了黑色,红色和绿色 我想了

tidyverse method for reading CSV section

Scenario: You have a CSV file with data in sections, eg [Car data] mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb 21,6,160,110,3.9,2.62,16.46,0,1,4,4 21,6,160,110,3.9,2.875,17.02,0,1,4,4 22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 14.3,8,360,245,3.21,3.57,15.84,0,0,3,4 .

用于阅读CSV部分的翻转方法

情景:您有一个CSV文件,其中包含数据部分,例如 [汽车资料] MPG,CYL,DISP,马力,DRAT,重量,的QseC,VS,上午,齿轮,碳水化合物 21,6,160,110,3.9,2.62,16.46,0,1,4,4 21,6,160,110,3.9,2.875,17.02,0,1,4,4 22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 14.3,8,360,245,3.21,3.57,

Using multiple color scales in stacked bar plots with ggplot

I have a dataset where individual samples belong to a large group and a smaller subgroup. Each group has several subgroups, but each subgroup can only belong to one larger group. Likewise, each sample can only belong to one subgroup, and thus one larger group. I want to make a True/False stacked bar plot with two color meanings: Outline (color) is the larger group Fill is the True/False d

使用ggplot在堆积条形图中使用多个色标

我有一个数据集,其中单个样本属于一个大组和一个较小的子组。 每个组有几个子组,但每个子组只能属于一个较大的组。 同样,每个样本只能属于一个小组,因此属于一个较大的小组。 我想制作一个带有两种颜色含义的True / False堆积条形图: 轮廓(颜色)是较大的组 填充是True / False数据,但是是较大的组轮廓颜色的两个阴影。 这与我想要的很接近,但是我不喜欢浅灰色和深灰色,我喜欢红色水果的浅红色和深红色,绿色

How to add new legends to complicated scatter plot using ggplot2

I built a simple linear regression model, and produced some predicted values using the model. However, I am more interested in visualizing it on the graph, but I do not know how to add a legend to highlight original mpg values as 'black' and new predicted values as "red". Data used in this example is mtcars dataset from datasets package library(ggplot2) library(data

如何使用ggplot2将新的图例添加到复杂的散点图

我建立了一个简单的线性回归模型,并使用该模型产生了一些预测值。 但是,我更感兴趣的是在图形上将其可视化,但我不知道如何添加图例以将原始mpg值突出显示为“黑色”,并将新预测值显示为“红色”。 本例中使用的数据是来自datasets包的mtcars数据集 library(ggplot2) library(datasets) library(broom) # Build a simple linear model between hp and mpg m1<-lm(hp~mpg,data=mtcars) # Predic