Home / Programs / How to set all the column value by a single TRUE value in the data frame
🚀 Programming Example

How to set all the column value by a single TRUE value in the data frame

👁 418 Views
💻 Practical Program
📘 Step Learning

Here is your data frame. You have to change all the values present in the column PassOrFail to TRUE

Student <- data.frame(RollNo = 1:10,  Marks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100), PassOrFail = c(F, F, F, F, F, T, T, T, T, T))
data frame, r language

💻 Program Code

Student$PassOrFail = TRUE
                        

🖥 Program Output

<img src="/library/images-tutorials/1.student_data_frame3.png" alt="data frame, r language" class="img-responsive">
                            

📘 Explanation

You can also use the above code like below

Student$PassOrFail = FALSE
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.