Search
 
SCRIPT & CODE EXAMPLE
 

R

make the first row as header in r

dat <- dat[-1,]
Comment

make the first row as header in r

names(dat) <- dat[1,]
Comment

convert first row to header in r

header.true <- function(df) {
  names(df) <- as.character(unlist(df[1,]))
  df[-1,]
}
Comment

make the first row as header in r

names(dat) <- as.matrix(dat[1, ])
dat <- dat[-1, ]
dat[] <- lapply(dat, function(x) type.convert(as.character(x)))
dat
##     Zip CuCurrent PaCurrent PoCurrent      Contact Ext          Fax email Status
## 1 74136         0         1         0 918-491-6998   0 918-491-6659     0      1
## 2 30329         1         0         0 404-321-5711   0            0     0      1
## 3 74136         1         0         0 918-523-2516   0 918-523-2522     0      1
## 4 80203         0         1         0 303-864-1919   0            0     0      1
## 5 80120         1         0         0 345-098-8890 456            0     0      1
Comment

PREVIOUS NEXT
Code Example
R :: how to randomly select R 
R :: r value statistics 
R :: if condition is met skip to next iteration in a for loop in r 
R :: r remove regex from string 
R :: how to filter a vector by location in r 
R :: insert character into string r 
R :: copy list R 
R :: generate pair with one same variable in r 
R :: count equal values in a vector 
R :: R view memory size of variables 
R :: correlation matrix using factors r 
R :: extract df from lm in r 
R :: r max and min functions 
R :: excel date format r 
R :: list variables in dataframe r 
R :: add padding to number r 
R :: mean of a row dataframe in r 
Rust :: return function rust 
Rust :: rust copy trait 
Rust :: add element to vec rust 
Rust :: length of vector rust 
Rust :: rust lang function is never used: rustc(dead_code) 
Rust :: rust comment types 
Rust :: sort reverse rust 
Rust :: armanriazi•rust•thread•spawning•join 
Rust :: Counting bits Kernighan style 
Rust :: how to get public addres from private key solana cli 
Rust :: armanriazi•rust•concept•coherence 
Lua :: lua multiline comment 
Lua :: roblox tween color part 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =