Search
 
SCRIPT & CODE EXAMPLE
 

R

r - check if a column has non numrical values

df <- data.frame(list(A=c(1, 2, 3, 4, 5, 6, 7, 8, 9), B=c("40g", "< 2", "thx", "about 1", "1-2", "1/2", 3, 2.3, "two")))
df$B <- as.character(df$B)

myscan <- function(x) {
 new <- vector("numeric",length(x))
 for(i in seq_along(x)) {
   new[i] <- readline(sprintf("Non numeric entry '%s' new value to set: ",x[i]))
 }
 as.numeric(new)
}

# get the entries 
notNum <- is.na( as.numeric(df$B) )
# Loop and ask for updates
df$B[notNum] <-  myscan(df$B[notNum])
Comment

PREVIOUS NEXT
Code Example
R :: STR_REPLACE PACKAGE r 
R :: print in r 
R :: r count dataframe 
R :: ggplot box plot without outliers poins 
Rust :: rust allow unused 
Rust :: hello world rust 
Rust :: bevy bundles 
Rust :: convert string to i32 rust 
Rust :: rust count occurrences of a substring 
Rust :: how to make an array in rust 
Rust :: hello world latex 
Rust :: rust file extension 
Rust :: rust array unique 
Rust :: rust cube root 
Rust :: multithreading rust example 
Rust :: rust for loop 
Rust :: rust•armanriazi•trait 
Rust :: rust•armanriazi•lifetime•unsafe•destructor 
Rust :: declare an array with signle value Rust 
Rust :: rmarmanriazi•rust•concept•polymorphism 
Rust :: rust•armanriazi•error•[E0596]: cannot borrow `self.` as mutable, as it is behind a `&` reference 
Rust :: rust•armanriazi•concept•nan 
Lua :: lua 
Lua :: luau kill brick script 
Lua :: how do you find a humanoid in roblox 
Lua :: how do you close the lua program 
Lua :: what does local mean in roblox 
Lua :: lua insert table into table 
Lua :: cmder not taking lua file 
Lua :: Get Nearest Player fivem 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =