我有一个从 excel 导入的 .csv 文件,其中包含我要删除的公式挂断。数据的简单版本如下。
library(tidyverse)
df <- data.frame(
species = letters[1:5],
param1 = c("Place", "creek", "river", "#VALUE!", "desert"),
param2 = c(-23.8, 43.23, "#NAME?", 45, 0.23),
param3 = c(2.4, 2, 5.7, 0.00003, -2.5),
stringsAsFactors = FALSE
) # This is a simplified version of the excel .csv import
df[df == "#VALUE!"] <- "" # Removes excel cells where the formula left "#VALUE!"
df[df == "#NAME\\?"] <- "" # This does not work
ndf <- df # This is an attempt to reassign the columns to numeric
ndf
class(ndf$param2)
class(ndf$param3)
主要的问题是,Param2
剩下的数据列在需要时分配给character
它numeric
,或者我必须在其上运行的功能不起作用。
我尝试了很多不同的东西,但是我似乎总是什么都认不出这个细胞。如何删除“#NAME”?请穿过df?