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 :: convert all numeric columns to percentages R 
R :: how to throw an error in R 
R :: how to replace values with na in r 
R :: remove column from matrix r 
R :: how to link world bank data into r 
R :: How to extract the row with min or max values? in R 
R :: replace_na 
R :: r rep() 
R :: n list to dataframe r 
R :: r tibble select rows containing string 
R :: count r 
R :: how to interpolate missing data in r with example 
R :: ts object to data frame 
R :: link excel to r 
R :: extract df from lm in r 
R :: How to use group_by inside a function? 
R :: dotted y intercept line in ggplot 
R :: change color theme of fill R 
R :: R view storage size of variable 
Rust :: rust get command line arguments 
Rust :: how to split a string by spaces rust 
Rust :: rust reverse an array 
Rust :: rust•armanriazi•error•cannot be formatted using `{:?}` 
Rust :: armanriazi•rust•error•E0282•type annotations needed 
Rust :: rust get char at index 
Rust :: stringify! in rust 
Rust :: armanriazi•rust•type•wrapper•vs•clone 
Rust :: rust what does the double colon mean? 
Rust :: how to check if a thing is in a vector in rust 
Lua :: luau rainbow part 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =