Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

r - Use Print( ) function to only show certain rows of a column in a data frame

I'm trying to print only the first 45 rows of a tibble data frame:

print( data_frame_name, n = 45) 

This will return the first 45 rows of my DF.

However, when I tried to specify a column using the dollar sign operator "$" such that

print( data_frame_name$column_name, n = 45) 

R gave me an error message "invalid 'na.print' specification", is there something I am missing?

I would try a workaround method but the problem asks that I use "$" and print().

question from:https://stackoverflow.com/questions/65909748/use-print-function-to-only-show-certain-rows-of-a-column-in-a-data-frame

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How about

print(data_frame_name$column_name[1:45])

if you're required to use print and $?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...