1

I am creating a character vector in which I want to describe information about the columns of my data frame. When I combine text and functions I obtain an empty vector of length 0, for which calling my vector is meaningless.

I am using the cat() function to do this:

columns <- cat("Columns in dataset describe annotations for 28416 genes. Variables:", colnames(DATA)[c(1, 11, 12, 13, 14)], "present descriptive information, variables:", colnames(raw.data), "represent expression data of three experimental conditions.")

When I run this, it works great. I get a paragraph. But when I call my vector, columns, I get: NULL By the way, print and paste are not of use in this example, since they repeat my text for each column name. Which I don't need.

Thanks!

1 Answer 1

1

Paste the colnames as well with collapse

columns <- paste("Columns in dataset describe annotations for 28416 genes. Variables:", paste(colnames(DATA)[c(1, 11, 12, 13, 14)], collapse = " "), "present descriptive information, variables:", paste(colnames(raw.data), collapse = " "), "represent expression data of three experimental conditions.")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.