r

    1热度

    1回答

    我有一个Shiny应用程序,显示硅谷公司员工的种族和员工数量之间的关系。左侧的工具栏是可见的,但情节未显示。我应该如何更改我的代码? 下面是代码: library(shiny) library(ggplot2) library(dplyr) bcl <- read.csv("E:/country/data/reveal.csv") ui <- fluidPage( titlePanel

    1热度

    2回答

    新列有类似的优先级列表:从一个二进制数据帧像下面 Google: High priority Yahoo: medium priority Microsoft: low priority : > df <- data.frame(id = c(1,2,3), Google = c(1,1,0), Yahoo = c(1,1,1), Microsoft = c(0,1,1)) > df

    1热度

    1回答

    这是一个使用Matrix package与常规类比较大型矩阵(稀疏和密集)的行提取的示例。 对于稠密矩阵速度为基类matrix快几乎395倍: library(Matrix) library(microbenchmark) ## row extraction in dense matrices D1<-matrix(rnorm(2000^2), 2000, 2000) D2<-Matri

    0热度

    1回答

    我想做一些类似于以下R代码numpy,其中y是回收利用。 R> x=rbind(c(1,2,3), c(4,5,6)) R> y=c(1,2) R> x/y [,1] [,2] [,3] [1,] 1 2.0 3 [2,] 2 2.5 3 显然,以下代码不适用于numpy。有人知道什么是可用的等效Python代码吗?谢谢。 >>> x=numpy.array([[1,2,3]

    1热度

    1回答

    我试图使用tidyr :: separate()将一些免费(假的)文本分隔为不同的列。 输入: structure(list(PathReportWhole = c("SP-37-2784518\nHospital: Random NHS Foundation Trust\nHospital Number: J6044658\nPatient Name: Jargon, Victoria\nDOB

    1热度

    3回答

    我具有类似于该样品的数据帧:根据在两列我要通过大小和颜色的项进行分类的信息 df <- structure(list(Ball = structure(c(5L, 3L, 2L, 4L, 1L, 3L), .Label = c("blue", "blue is my favourite", "red", "red ", "red ball"), class = "factor"), size =

    1热度

    3回答

    这里是我想要做的事: 创建分配样本秩,以行的多个子集的新列基于有多少行是每个子集。分组变量是“层”列。 我通常使用嵌套ifelse语句随机分配排名,如下所示。有时候这样做足够了,但最近我一直在处理越来越多的分组。 40个嵌套ifelse语句可能开始看起来有点过分。 是否有一个更优雅/更快/最简单的代码方式来使用dplyr或data.table,可能与apply,lapply,sapply等结合使用

    1热度

    2回答

    我想根据预先确定的中心点(my_center_Points)将Long和Lats(my_long_lats)列表分组。 当我运行: - k <- kmeans(as.matrix(my_long_lats), centers = as.matrix(my_center_Points)) k$centers不等于 my_center_Points。 我假设k-means已将我的中心点调整到最佳中

    3热度

    1回答

    我创建了一个清单,1列的值的计数: ataques_tot <- count(t1$attacktype1_txt) ataques_tot x freq 1 Armed Assault 40223 2 Assassination 18402 3 Bombing/Explosion 83073 4 Facility/Infrastructur

    2热度

    2回答

    我遇到devEMF包中的emf()功能问题。 我使用的代码 - library(devEMF) emf(file = "trial.emf") plot(1:10, seq(10, 100, 10), type = "l", xlab = "Time", ylab = "Distance") #sample plot dev.off() 这不会有情节,但确实拥有一切(标签,轴蜱,标题)