Linux内核模块(Linux kernel modules)
我不清楚可以在单片内核中“嵌入”的驱动程序和仅作为外部模块可用的驱动程序之间的区别。
要求将一些驱动程序(仅作为“外部模块”提供)“移植”到单片内核需要付出什么样的努力?
我希望能够运行Vmware Tools,禁用可加载模块支持并摆脱initrd集市。
I've not clear what is the difference between drivers that can be "embedded" inside a monolithic kernel and drivers available only as external modules.
What kind of effort is requested to "port" some driver (provided as "external module" only) to a monolithic kernel?
I would like to be able to run Vmware Tools disabling loadable modules support and getting rid of the initrd bazaar.
原文:https://stackoverflow.com/questions/20313494
最满意答案
你每次都通过循环覆盖文件,这就是为什么你最后只有一行结束。 您可以每次向文件追加一个新行(使用
append=TRUE
)而不是覆盖它,但最好是创建所有r平方值的数据帧并将其写入文件一次。此外,您不需要使用
lm
。 对于两个变量,r平方只是相关系数的平方。corr.data = data.frame(rsq=rep(NA,length(filenames)), file=rep(NA,length(filenames))) for (i in 1:length(filenames)) { y <- read.table(filenames[i], sep ="\t", header=T) corr.data[i,1] <- cor(y[,2],y[,7])^2 corr.data[i,2] <- filenames[i] } write.table(corr.data, "test_out.txt", sep="\t")
您也可以使用
lapply
而不是显式循环:corr.data = lapply(filenames, function(f) { y <- read.table(f, sep ="\t", header=T) data.frame(rsq=cor(y[,2],y[,7])^2, file=f) }) corr.data = do.call(rbind, corr.data) write.table(corr.data, "test_out.txt", sep="\t")
更新:参考您的注释,例如,您可以获得每个文件中每对数字列的r平方,并将它们保存到新文件中。
library(reshape2) corr.data = lapply(filenames, function(f) { y <- read.table(f, sep ="\t", header=T) # Remove non-numeric columns y = y[ , sapply(y, is.numeric)] # Calculate r-squared between every pair of columns y = cor(y)^2 # Keep only upper triangle of r-squared matrix y[!upper.tri(y)] = NA # Melt to long format and remove NA y = na.omit(melt(y)) }) corr.data = do.call(rbind, corr.data) write.table(corr.data, "all_r_squareds.txt", sep="\t")
You're overwriting the file each time through the loop, which is why you're ending up with just one row at the end. You could append a new row to the file each time (using
append=TRUE
) instead of overwriting it, but it's probably better to create a data frame of all the r-squared values and write it to a file once.Also, you don't need to use
lm
. For two variables, the r-squared is just the square of the correlation coefficient.corr.data = data.frame(rsq=rep(NA,length(filenames)), file=rep(NA,length(filenames))) for (i in 1:length(filenames)) { y <- read.table(filenames[i], sep ="\t", header=T) corr.data[i,1] <- cor(y[,2],y[,7])^2 corr.data[i,2] <- filenames[i] } write.table(corr.data, "test_out.txt", sep="\t")
You could also use
lapply
instead of an explicit loop:corr.data = lapply(filenames, function(f) { y <- read.table(f, sep ="\t", header=T) data.frame(rsq=cor(y[,2],y[,7])^2, file=f) }) corr.data = do.call(rbind, corr.data) write.table(corr.data, "test_out.txt", sep="\t")
UPDATE: In reference to your comment, here, for example, is how you'd get the r-squared for every pair of numeric columns in each file and save them to a new file.
library(reshape2) corr.data = lapply(filenames, function(f) { y <- read.table(f, sep ="\t", header=T) # Remove non-numeric columns y = y[ , sapply(y, is.numeric)] # Calculate r-squared between every pair of columns y = cor(y)^2 # Keep only upper triangle of r-squared matrix y[!upper.tri(y)] = NA # Melt to long format and remove NA y = na.omit(melt(y)) }) corr.data = do.call(rbind, corr.data) write.table(corr.data, "all_r_squareds.txt", sep="\t")
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
调整R平方的“调整”与变量的数量和观察次数有关。 如果您不断添加变量(预测因子)到您的模型中,R平方将会改善 - 也就是说,预测变量将会显示解释方差 - 但其中一些改进可能是由于机会而已。 因此,考虑到N = 1的观测值和k =变量数(预测因子)的比率(N-1)/(Nk-1),所以调整的R平方尝试纠正这一点。 你的情况可能不是一个问题,因为你有一个变化。 一些参考: 多高,平方? 适合度统计 多元回归 Re:多重回归中的“调整R ^ 2”是什么 The "adjustment" in adjusted R- ...
-
从numpy.polyfit文档中,它是拟合的线性回归。 具体来说,具有度“d”的numpy.polyfit适合于平均函数的线性回归 E(y | x)= p_d * x ** d + p_ {d-1} * x **(d-1)+ ... + p_1 * x + p_0 所以你只需要计算适合的R平方。 线性回归的维基百科页面提供了全面的细节。 您对R ^ 2感兴趣,您可以通过几种方式计算,最简单的方法 SST = Sum(i=1..n) (y_i - y_bar)^2 SSReg = Sum(i=1..n) ( ...
-
您可以直接从汇总对象summary(fit)$r.squared返回r平方值。 查看names(summary(fit))可以直接提取的所有项目列表。 这篇博客文章概述了一个返回p值的函数: lmp <- function (modelobject) { if (class(modelobject) != "lm") stop("Not an object of class 'lm' ") f <- summary(modelobject)$fstatistic p <- pf(f[ ...
-
你可以使用lapply 。 我假设您的文件已使用save ,因为您使用load来获取它们。 我在我的示例中创建了两个文件,如下所示: TotalData<-list(1:10) save(TotalData,file="DATA3_1") TotalData<-list(11:20) save(TotalData,file="DATA3_2") 然后我读了它们 Filenames <- paste0('DATA3_',as.character(1:2)) Data <- lapply(Filenames, ...
-
你每次都通过循环覆盖文件,这就是为什么你最后只有一行结束。 您可以每次向文件追加一个新行(使用append=TRUE )而不是覆盖它,但最好是创建所有r平方值的数据帧并将其写入文件一次。 此外,您不需要使用lm 。 对于两个变量,r平方只是相关系数的平方。 corr.data = data.frame(rsq=rep(NA,length(filenames)), file=rep(NA,length(filenames))) for (i in 1:length(filenames)) { y <- ...
-
你需要一点统计知识才能看到这一点。 两个向量之间的R平方就是它们相关的平方。 所以你可以定义你的功能为: rsq <- function (x, y) cor(x, y) ^ 2 You need a little statistical knowledge to see this. R squared between two vectors is just the square of their correlation. So you can define you function as: rsq <- ...
-
将多个子目录中的特定文件复制到R中的单个文件夹中(Copying specific files from multiple sub-directories into a single folder in R)[2022-04-27]
parent.folder <- "C:/Desktop/dir" files <- list.files(path = parent.folder, full.names = T, recursive = T, include.dirs = T) 在此之后,您需要选择相关文件: files <- files[grep("wang\\.tax\\.sum", files)] (注意点之前的双重转义: \\. - dot对grep有特殊含义。) 或者你可以用list.files的pattern参数一步完成 ... -
这是一个聚合许多png文件的快速方法: 使用readPNG阅读你的png 将它们转换为栅格,并使用grid.raster绘制它们:非常高效。 像这样的东西: library(png) library(grid) pdf('somefile1.pdf') lapply(ll <- list.files(patt='.*[.]png'),function(x){ img <- as.raster(readPNG(x)) grid.newpage() grid.raster(img, interpol ...