Search
 
SCRIPT & CODE EXAMPLE
 

R

r set dataframe column names

R> X <- data.frame(bad=1:3, worse=rnorm(3))
R> X
  bad     worse
1   1 -2.440467
2   2  1.320113
3   3 -0.306639
R> colnames(X) <- c("good", "better")
R> X
  good    better
1    1 -2.440467
2    2  1.320113
3    3 -0.306639
Comment

create a dataframe with column names in r

# This works well if you need an empty dataframe with n known columns
df <- data.frame(matrix(ncol = 3, nrow = 0))
x <- c("name", "age", "gender")
colnames(df) <- x
Comment

r set dataframe column names

R> colnames(X)[2] <- "superduper"
Comment

PREVIOUS NEXT
Code Example
R :: r box plots 
R :: how to eliminate duplicates in a column in r 
R :: sort dataframe r 
R :: how to get the mode in r 
R :: R rename singl edf column 
R :: select columns in r 
R :: turn matrix into dataframe r 
R :: r dataframe append row 
R :: r - extracting specific columns from a data frame 
R :: r read excel start from row 
R :: how to label legends in R ggplot 
R :: R remove commas 
R :: how to change the font of the xlab in plot in r 
R :: mutate in r if else 
R :: r remove inf values 
R :: how to tell if a variable is discrete or continuous in r 
R :: r rename column based on variable 
R :: 3d scatter plot in r 
R :: dplyr average columns 
R :: color blind friendly palette r 
R :: check argument of function in r 
R :: how to add in dictionary in R 
R :: change color theme of fill R 
R :: legend in r 
Rust :: bevy bundles 
Rust :: how to open a file rust 
Rust :: read line rust 
Rust :: rust concat 
Rust :: rust modulus 
Rust :: armanriazi•rust•error•the trait `Binary` is not implemented for `f64` 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =